Exemplo n.º 1
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.º 2
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.º 3
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;
  }