Exemplo n.º 1
0
  /**
   * See which items are possible to get the backup file from cloud.
   *
   * @param context DSpace context
   * @param item iterator of items
   * @return integer set with all the IDs Items that are possible to get the backup file from cloud
   */
  public Set<Integer> checkPossibleItemsGet(Context context, ItemIterator items) {
    // This will contain all the Items IDs that backup files could be get from cloud
    Set<Integer> setInfo = new HashSet<Integer>();

    try {
      // if exist some item to evaluate make the connection and
      // get items backups files in cloud
      if (items.hasNext() == true) {
        this.makeConnection();
        this.filesInCloud.putAll(this.newCloudConnection.getInfoFilesIn(Constants.ITEM));
      }

      // do the operation for all items
      while (items.hasNext() == true) {
        Item objItem = items.next();
        // check if it is possible and necessary to get a backup file from cloud
        Boolean checkCorrect = this.couldGetFileFromCloud(context, objItem.getID(), Constants.ITEM);
        // add the ID collection to set if correct
        if (checkCorrect == true) setInfo.add(objItem.getID());
      }

      // close the connection to cloud
      this.closeConnection();

    } catch (SQLException ex) {
      Logger.getLogger(ActualContentManagement.class.getName()).log(Level.SEVERE, null, ex);
    }

    return setInfo;
  }
Exemplo n.º 2
0
  /**
   * See if the Collection have the updated backup file in cloud.
   *
   * @param context DSpace context
   * @param col array of Collections
   * @return integer set with all the IDs Collection that have the updated backup in cloud
   */
  public Set<Integer> checkCollectionsInCloud(Context context, Collection[] col) {
    // This will contain all the CollectionsIDs with backup file in cloud
    Set<Integer> setInfo = new HashSet<Integer>();

    // if exist some collection to evaluate make the connection and
    // get collections backups files in cloud
    if (col.length != 0) {
      this.makeConnection();
      this.filesInCloud.putAll(this.newCloudConnection.getInfoFilesIn(Constants.COLLECTION));
    }

    // do the operation for all communities
    for (int i = 0; i < col.length; i++) {
      // check the backup file has been sent to cloud
      Boolean checkCorrect = this.sendDone(context, col[i].getID(), Constants.COLLECTION);

      // add the ID collection to set if correct
      if (checkCorrect == true) setInfo.add(col[i].getID());
    }

    // close the connection to cloud
    this.closeConnection();

    return setInfo;
  }
Exemplo n.º 3
0
  /**
   * See which collections are possible to get the backup file from cloud.
   *
   * @param context DSpace context
   * @param com array of Collections
   * @return integer set with all the IDs Collections that are possible to get the backup file from
   *     cloud
   */
  public Set<Integer> checkPossibleCollectionsGet(Context context, Collection[] col) {
    // This will contain all the Communities IDs that backup files could be get from cloud
    Set<Integer> setInfo = new HashSet<Integer>();

    // if exist some community to evaluate make the connection and
    // get communities backups files in cloud
    if (col.length != 0) {
      this.makeConnection();
      ;
      this.filesInCloud.putAll(this.newCloudConnection.getInfoFilesIn(Constants.COLLECTION));
    } else return setInfo;

    // do the operation for all communities
    for (int i = 0; i < col.length; i++) {
      // check if it is possible and necessary to get a backup file from cloud
      Boolean checkCorrect =
          this.couldGetFileFromCloud(context, col[i].getID(), Constants.COLLECTION);

      // add the ID community to set if correct
      if (checkCorrect == true) setInfo.add(col[i].getID());
    }

    // close the connection to cloud
    this.closeConnection();

    return setInfo;
  }
Exemplo n.º 4
0
  /** Sherpa romeo submission support */
  public void make_sherpaRomeo_submission(Item item, Division divIn) throws WingException {

    if (ConfigurationManager.getBooleanProperty(
        "webui.submission.sherparomeo-policy-enabled", true)) {

      SHERPASubmitService sherpaSubmitService =
          new DSpace().getSingletonService(SHERPASubmitService.class);

      if (sherpaSubmitService.hasISSNs(context, item)) {
        List div = divIn.addList("submit-upload-new", List.TYPE_FORM);
        div.setHead(T_sherpa_title);

        // Since sherpa web service doesn't work reliable with more than 1 issn, perform the service
        // for each issn
        Set<String> issns = sherpaSubmitService.getISSNs(context, item);
        Iterator<String> issnsIterator = issns.iterator();

        int i = 0;
        while (issnsIterator.hasNext()) {
          SHERPAResponse shresp =
              sherpaSubmitService.searchRelatedJournalsByISSN(issnsIterator.next());
          java.util.List<SHERPAJournal> journals = shresp.getJournals();
          java.util.List<SHERPAPublisher> publishers = shresp.getPublishers();

          if (CollectionUtils.isNotEmpty(journals)) {
            for (SHERPAJournal journ : journals) {
              SHERPAPublisher pub = publishers.get(0);

              List sherpaList = div.addList("sherpaList" + (i + 1), "simple", "sherpaList");
              sherpaList
                  .addItem()
                  .addFigure(
                      contextPath + "/static/images/" + (i == 0 ? "romeosmall" : "clear") + ".gif",
                      "http://www.sherpa.ac.uk/romeo/",
                      "sherpaLogo");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_journal);
              sherpaList.addItem(journ.getTitle() + " (" + journ.getIssn() + ")");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_publisher);
              sherpaList.addItemXref(pub.getHomeurl(), pub.getName());

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_colour);
              sherpaList
                  .addItem()
                  .addHighlight("sherpaStyle " + pub.getRomeocolour())
                  .addContent(message("xmlui.aspect.sherpa.submission." + pub.getRomeocolour()));
              sherpaList
                  .addItem()
                  .addXref(
                      "http://www.sherpa.ac.uk/romeo/search.php?issn=" + journ.getIssn(),
                      T_sherpa_more,
                      "sherpaMoreInfo");

              i = i + 1;
            }
          }
        }

        List sherpaList = div.addList("sherpaListEnd", "simple", "sherpaList");
        sherpaList.addItem(T_sherpa_consult);
      }
    }
  }