@Override public String getOwningCollection(Item item) { return item.getOwningCollection().getName(); }
@Override public DSpaceObject getParentObject(Context context, Item item) throws SQLException { Collection ownCollection = item.getOwningCollection(); if (ownCollection != null) { return ownCollection; } else { // is a template item? return item.getTemplateItemOf(); } }
@Override public boolean isOwningCollection(Item item, Collection collection) { Collection owningCollection = item.getOwningCollection(); return owningCollection != null && collection.getID().equals(owningCollection.getID()); }
@Override public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) { try { WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(), false); Item itemNew = workspaceItem.getItem(); itemService.update(context, itemNew); return itemNew; } catch (SQLException | AuthorizeException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public boolean canEdit(Context context, Item item) throws SQLException { // can this person write to the item? if (authorizeService.authorizeActionBoolean(context, item, Constants.WRITE)) { return true; } // is this collection not yet created, and an item template is created if (item.getOwningCollection() == null) { if (!isInProgressSubmission(context, item)) { return true; } else { return false; } } return collectionService.canEditBoolean(context, item.getOwningCollection(), false); }
/** * Get the style using the owning collection handle */ public String getStyleForItem(Item item) throws SQLException { Collection c = item.getOwningCollection(); if(c!=null) { // Style specified & exists return getFromMap(c.getHandle()); } else { return "default"; //no specific style - item is an in progress Submission } }
/** * Enforce lifting of embargo by turning read access to bitstreams in * this Item back on. * * @param context the DSpace context * @param item the item to embargo */ @Override public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { // remove the item's policies and replace them with // the defaults from the collection ContentServiceFactory.getInstance().getItemService() .inheritCollectionDefaultPolicies(context, item, item.getOwningCollection()); } }
if (AuthorizeConfiguration.canCollectionAdminPerformItemWithdrawn()) { authorized = authorizeService.authorizeActionBoolean(context, item .getOwningCollection(), Constants.ADMIN); } else if (AuthorizeConfiguration.canCommunityAdminPerformItemWithdrawn()) { authorized = authorizeService .authorizeActionBoolean(context, item.getOwningCollection() .getCommunities().get(0), Constants.ADMIN); .getOwningCollection(), Constants.REMOVE, false);
for (String req : getReqList(item.getOwningCollection().getHandle())) { List<MetadataValue> vals = itemService.getMetadataByMetadataString(item, req); if (vals.size() == 0) {
/** * Enforce embargo by turning off all read access to bitstreams in * this Item. * * @param context the DSpace context * @param item the item to embargo */ @Override public void setEmbargo(Context context, Item item) throws SQLException, AuthorizeException { DCDate liftDate = EmbargoServiceFactory.getInstance().getEmbargoService().getEmbargoTermsAsDate(context, item); for (Bundle bn : item.getBundles()) { // Skip the LICENSE and METADATA bundles, they stay world-readable String bnn = bn.getName(); if (!(bnn.equals(Constants.LICENSE_BUNDLE_NAME) || bnn.equals(Constants.METADATA_BUNDLE_NAME) || bnn .equals(CreativeCommonsServiceImpl.CC_BUNDLE_NAME))) { //AuthorizeManager.removePoliciesActionFilter(context, bn, Constants.READ); generatePolicies(context, liftDate.toDate(), null, bn, item.getOwningCollection()); for (Bitstream bs : bn.getBitstreams()) { //AuthorizeManager.removePoliciesActionFilter(context, bs, Constants.READ); generatePolicies(context, liftDate.toDate(), null, bs, item.getOwningCollection()); } } } }
/** * Is allowed manage (create, remove, edit) item's policies in the * current context? * * @param context the DSpace Context Object * @param item the item that the policy refer to * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the item's policies * @throws SQLException if database error * if a db error occur */ public static void authorizeManageItemPolicy(Context context, Item item) throws AuthorizeException, SQLException { if (AuthorizeConfiguration.canItemAdminManagePolicies()) { authorizeService.authorizeAction(context, item, Constants.ADMIN); } else if (AuthorizeConfiguration.canCollectionAdminManageItemPolicies()) { authorizeService.authorizeAction(context, item .getOwningCollection(), Constants.ADMIN); } else if (AuthorizeConfiguration.canCommunityAdminManageItemPolicies()) { authorizeService .authorizeAction(context, item.getOwningCollection() .getCommunities().get(0), Constants.ADMIN); } else if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only system admin are allowed to manage item policies"); } }
@Override public void addMetadata(Context context, T dso, MetadataField metadataField, String language, List<String> values) throws SQLException { if (metadataField != null) { String fieldKey = metadataAuthorityService .makeFieldKey(metadataField.getMetadataSchema().getName(), metadataField.getElement(), metadataField.getQualifier()); if (metadataAuthorityService.isAuthorityControlled(fieldKey)) { List<String> authorities = new ArrayList<String>(); List<Integer> confidences = new ArrayList<Integer>(); for (int i = 0; i < values.size(); ++i) { if (dso instanceof Item) { getAuthoritiesAndConfidences(fieldKey, ((Item) dso).getOwningCollection(), values, authorities, confidences, i); } else { getAuthoritiesAndConfidences(fieldKey, null, values, authorities, confidences, i); } } addMetadata(context, dso, metadataField, language, values, authorities, confidences); } else { addMetadata(context, dso, metadataField, language, values, null, null); } } }
adjustItemPolicies(context, item, item.getOwningCollection());
current = ((Item) current).getOwningCollection();
current = ((Item) current).getOwningCollection();
public void addPageMeta(PageMeta pageMeta) throws WingException, SQLException { Item item = Item.find(context, parameters.getParameterAsInteger("itemID",-1)); Collection owner = item.getOwningCollection(); int collectionID = (owner == null) ? -1 : owner.getID(); pageMeta.addMetadata("choice", "collection").addContent(String.valueOf(collectionID)); pageMeta.addMetadata("title").addContent(T_title); pageMeta.addTrailLink(contextPath + "/", T_dspace_home); pageMeta.addTrailLink(contextPath + "/admin/item", T_item_trail); pageMeta.addTrail().addContent(T_trail); }
Community community = null; if (item != null) { collection = item.getOwningCollection(); if (collection != null) { community = collection.getCommunities().get(0);
if (i.getOwningCollection() == null) { return; String owningCollectionHandle = i.getOwningCollection().getHandle(); line.add("collection", owningCollectionHandle);
select.setHelp(T_collection_help); Collection owningCollection = item.getOwningCollection(); if (owningCollection == null) { select.addOption("",T_collection_default);
dso = ((Item) dso).getOwningCollection();