@Test @Override public void testGetAdminObject() throws SQLException { assertThat("testGetAdminObject 0", (Item)it.getAdminObject(Constants.REMOVE), equalTo(it)); assertThat("testGetAdminObject 1", (Item)it.getAdminObject(Constants.ADD), equalTo(it)); assertThat("testGetAdminObject 2", it.getAdminObject(Constants.DELETE), nullValue()); assertThat("testGetAdminObject 3", (Item)it.getAdminObject(Constants.ADMIN), equalTo(it)); }
public DSpaceObject getAdminObject(int action) throws SQLException { DSpaceObject adminObject = null; Collection collection = getOwningCollection(); Community community = null; if (collection != null) { Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } else { TableRow qResult = DatabaseManager.querySingle(ourContext, "SELECT collection_id FROM collection " + "WHERE template_item_id = ?",getID()); if (qResult != null) { collection = Collection.find(ourContext, qResult.getIntColumn("collection_id")); Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } } switch (action) { case Constants.ADD: if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamCreation()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamCreation()) { adminObject = community; } break; case Constants.REMOVE: if (AuthorizeConfiguration.canItemAdminPerformBitstreamDeletion()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamDeletion()) { adminObject = community; } break; case Constants.DELETE: if (getOwningCollection() != null) { if (AuthorizeConfiguration.canCollectionAdminPerformItemDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformItemDeletion()) { adminObject = community; } } else { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } break; case Constants.WRITE: if (getOwningCollection() == null) { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } else { adminObject = this; } break; default: adminObject = this; break; } return adminObject; }
Item extends DSpaceObject { public DSpaceObject getAdminObject(int action) throws SQLException { DSpaceObject adminObject = null; Collection collection = getOwningCollection(); Community community = null; if (collection != null) { Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } else { TableRow qResult = DatabaseManager.querySingle(ourContext, "SELECT collection_id FROM collection " + "WHERE template_item_id = ?",getID()); if (qResult != null) { collection = Collection.find(ourContext, qResult.getIntColumn("collection_id")); Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } } switch (action) { case Constants.ADD: if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamCreation()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamCreation()) { adminObject = community; } break; case Constants.REMOVE: if (AuthorizeConfiguration.canItemAdminPerformBitstreamDeletion()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamDeletion()) { adminObject = community; } break; case Constants.DELETE: if (getOwningCollection() != null) { if (AuthorizeConfiguration.canCollectionAdminPerformItemDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformItemDeletion()) { adminObject = community; } } else { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } break; case Constants.WRITE: if (getOwningCollection() == null) { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } else { adminObject = this; } break; default: adminObject = this; break; } return adminObject; } }
Item extends DSpaceObject { public DSpaceObject getAdminObject(int action) throws SQLException { DSpaceObject adminObject = null; Collection collection = getOwningCollection(); Community community = null; if (collection != null) { Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } else { TableRow qResult = DatabaseManager.querySingle(ourContext, "SELECT collection_id FROM collection " + "WHERE template_item_id = ?",getID()); if (qResult != null) { collection = Collection.find(ourContext, qResult.getIntColumn("collection_id")); Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } } switch (action) { case Constants.ADD: if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamCreation()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamCreation()) { adminObject = community; } break; case Constants.REMOVE: if (AuthorizeConfiguration.canItemAdminPerformBitstreamDeletion()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamDeletion()) { adminObject = community; } break; case Constants.DELETE: if (getOwningCollection() != null) { if (AuthorizeConfiguration.canCollectionAdminPerformItemDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformItemDeletion()) { adminObject = community; } } else { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } break; case Constants.WRITE: if (getOwningCollection() == null) { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } else { adminObject = this; } break; default: adminObject = this; break; } return adminObject; } Item(Context context, TableRow row); }
Item extends DSpaceObject { public DSpaceObject getAdminObject(int action) throws SQLException { DSpaceObject adminObject = null; Collection collection = getOwningCollection(); Community community = null; if (collection != null) { Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } else { TableRow qResult = DatabaseManager.querySingle(ourContext, "SELECT collection_id FROM collection " + "WHERE template_item_id = ?",getID()); if (qResult != null) { collection = Collection.find(ourContext, qResult.getIntColumn("collection_id")); Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } } switch (action) { case Constants.ADD: if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamCreation()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamCreation()) { adminObject = community; } break; case Constants.REMOVE: if (AuthorizeConfiguration.canItemAdminPerformBitstreamDeletion()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamDeletion()) { adminObject = community; } break; case Constants.DELETE: if (getOwningCollection() != null) { if (AuthorizeConfiguration.canCollectionAdminPerformItemDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformItemDeletion()) { adminObject = community; } } else { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } break; case Constants.WRITE: if (getOwningCollection() == null) { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } else { adminObject = this; } break; default: adminObject = this; break; } return adminObject; } Item(Context context, TableRow row); static Item find(Context context, int id); static ItemIterator findAll(Context context); static ItemIterator findBySubmitter(Context context, EPerson eperson); int getID(); String getHandle(); boolean isArchived(); boolean isWithdrawn(); Date getLastModified(); void setArchived(boolean isArchived); void setOwningCollection(Collection c); Collection getOwningCollection(); @Deprecated DCValue[] getDC(String element, String qualifier, String lang); DCValue[] getMetadata(String schema, String element, String qualifier,
            String lang); DCValue[] getMetadata(String mdString); @Deprecated void addDC(String element, String qualifier, String lang,
            String[] values); @Deprecated void addDC(String element, String qualifier, String lang,
            String value); void addMetadata(String schema, String element, String qualifier, String lang,
            String[] values); void addMetadata(String schema, String element, String qualifier, String lang,
            String[] values, String authorities[], int confidences[]); void addMetadata(String schema, String element, String qualifier,
            String lang, String value); void addMetadata(String schema, String element, String qualifier,
            String lang, String value, String authority, int confidence); @Deprecated void clearDC(String element, String qualifier, String lang); void clearMetadata(String schema, String element, String qualifier,
            String lang); EPerson getSubmitter(); void setSubmitter(EPerson sub); boolean isIn(Collection collection); Collection[] getCollections(); Community[] getCommunities(); Bundle[] getBundles(); Bundle[] getBundles(String name); Bundle createBundle(String name); void addBundle(Bundle b); void removeBundle(Bundle b); Bitstream createSingleBitstream(InputStream is, String name); Bitstream createSingleBitstream(InputStream is); Bitstream[] getNonInternalBitstreams(); void removeDSpaceLicense(); void removeLicenses(); void update(); void withdraw(); void reinstate(); void decache(); @Override boolean equals(Object obj); @Override int hashCode(); boolean isOwningCollection(Collection c); int getType(); void replaceAllItemPolicies(List<ResourcePolicy> newpolicies); void replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies); void removeGroupPolicies(Group g); void inheritCollectionDefaultPolicies(Collection c); void move(Collection from, Collection to); void move(Collection from, Collection to, boolean inheritDefaultPolicies); boolean hasUploadedFiles(); Collection[] getCollectionsNotLinked(); boolean canEdit(); String getName(); static ItemIterator findByMetadataField(Context context,
               String schema, String element, String qualifier, String value); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject(); static ItemIterator findByAuthorityValue(Context context,
            String schema, String element, String qualifier, String value); }
Item extends DSpaceObject { public DSpaceObject getAdminObject(int action) throws SQLException { DSpaceObject adminObject = null; Collection collection = getOwningCollection(); Community community = null; if (collection != null) { Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } else { TableRow qResult = DatabaseManager.querySingle(ourContext, "SELECT collection_id FROM collection " + "WHERE template_item_id = ?",getID()); if (qResult != null) { collection = Collection.find(ourContext, qResult.getIntColumn("collection_id")); Community[] communities = collection.getCommunities(); if (communities != null && communities.length > 0) { community = communities[0]; } } } switch (action) { case Constants.ADD: if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamCreation()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamCreation()) { adminObject = community; } break; case Constants.REMOVE: if (AuthorizeConfiguration.canItemAdminPerformBitstreamDeletion()) { adminObject = this; } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformBitstreamDeletion()) { adminObject = community; } break; case Constants.DELETE: if (getOwningCollection() != null) { if (AuthorizeConfiguration.canCollectionAdminPerformItemDeletion()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminPerformItemDeletion()) { adminObject = community; } } else { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } break; case Constants.WRITE: if (getOwningCollection() == null) { if (AuthorizeConfiguration.canCollectionAdminManageTemplateItem()) { adminObject = collection; } else if (AuthorizeConfiguration.canCommunityAdminManageCollectionTemplateItem()) { adminObject = community; } } else { adminObject = this; } break; default: adminObject = this; break; } return adminObject; } Item(Context context, TableRow row); static Item find(Context context, int id); static ItemIterator findAll(Context context); static ItemIterator findBySubmitter(Context context, EPerson eperson); int getID(); String getHandle(); boolean isArchived(); boolean isWithdrawn(); Date getLastModified(); void setArchived(boolean isArchived); void setOwningCollection(Collection c); Collection getOwningCollection(); @Deprecated DCValue[] getDC(String element, String qualifier, String lang); DCValue[] getMetadata(String schema, String element, String qualifier,
            String lang); DCValue[] getMetadata(String mdString); @Deprecated void addDC(String element, String qualifier, String lang,
            String[] values); @Deprecated void addDC(String element, String qualifier, String lang,
            String value); void addMetadata(String schema, String element, String qualifier, String lang,
            String[] values); void addMetadata(String schema, String element, String qualifier, String lang,
            String[] values, String authorities[], int confidences[]); void addMetadata(String schema, String element, String qualifier,
            String lang, String value); void addMetadata(String schema, String element, String qualifier,
            String lang, String value, String authority, int confidence); @Deprecated void clearDC(String element, String qualifier, String lang); void clearMetadata(String schema, String element, String qualifier,
            String lang); EPerson getSubmitter(); void setSubmitter(EPerson sub); boolean isIn(Collection collection); Collection[] getCollections(); Community[] getCommunities(); Bundle[] getBundles(); Bundle[] getBundles(String name); Bundle createBundle(String name); void addBundle(Bundle b); void removeBundle(Bundle b); Bitstream createSingleBitstream(InputStream is, String name); Bitstream createSingleBitstream(InputStream is); Bitstream[] getNonInternalBitstreams(); void removeDSpaceLicense(); void removeLicenses(); void update(); void withdraw(); void reinstate(); void decache(); @Override boolean equals(Object obj); @Override int hashCode(); boolean isOwningCollection(Collection c); int getType(); void replaceAllItemPolicies(List<ResourcePolicy> newpolicies); void replaceAllBitstreamPolicies(List<ResourcePolicy> newpolicies); void removeGroupPolicies(Group g); void inheritCollectionDefaultPolicies(Collection c); void move(Collection from, Collection to); void move(Collection from, Collection to, boolean inheritDefaultPolicies); boolean hasUploadedFiles(); Collection[] getCollectionsNotLinked(); boolean canEdit(); String getName(); static ItemIterator findByMetadataField(Context context,
               String schema, String element, String qualifier, String value); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject(); static ItemIterator findByAuthorityValue(Context context,
            String schema, String element, String qualifier, String value); static final String ANY; }