/** * Get a preserved community backup file and respective children from cloud. * * @param context context DSpace * @param ref ID of the community * @param establishConnection true if pretend establish connection to cloud * @return true if file correctly sent to cloud, or false if not */ public Boolean getCommunityAndChilds(Context context, Integer ref, Boolean establishConnection) { // if true make the connection available if (establishConnection == true) { this.makeConnection(); this.filesInCloud.putAll(this.newCloudConnection.getInfoFilesIn(Constants.COMMUNITY)); } // get file community from cloud getCommunity(context, ref, false); Community obj; Community[] subCommunities; Collection[] collections; // get community and the respective sub-communities and childs try { obj = Community.find(context, ref); subCommunities = obj.getSubcommunities(); collections = obj.getCollections(); } catch (Exception ex) { // it means it is the first father in the order, so close connection if (establishConnection == true) this.closeConnection(); Logger.getLogger(ActualContentManagement.class.getName()).log(Level.SEVERE, null, ex); return false; } // get from cloud all the respective files sub-communities and childs if (subCommunities.length != 0) { for (int i = 0; i < subCommunities.length; i++) getCommunityAndChilds(context, subCommunities[i].getID(), false); } // get from cloud all files collections and childs if (collections.length != 0) { for (int i = 0; i < collections.length; i++) getCollectionAndChilds(context, collections[i].getID(), false); } // it means it is the first father in the order if (establishConnection == true) this.closeConnection(); return true; }
/** * Generic find for when the precise type of a DSO is not known, just the a pair of type number * and database ID. * * @param context - the context * @param type - type number * @param id - id within table of type'd objects * @return the object found, or null if it does not exist. * @throws SQLException only upon failure accessing the database. */ public static DSpaceObject find(Context context, int type, int id) throws SQLException { switch (type) { case Constants.BITSTREAM: return Bitstream.find(context, id); case Constants.BUNDLE: return Bundle.find(context, id); case Constants.ITEM: return Item.find(context, id); case Constants.COLLECTION: return Collection.find(context, id); case Constants.COMMUNITY: return Community.find(context, id); case Constants.GROUP: return Group.find(context, id); case Constants.EPERSON: return EPerson.find(context, id); case Constants.SITE: return Site.find(context, id); } return null; }