/** * Internal utitity method to get a description of the handle * * @param item The item to get a description of * @return The handle, or in workflow */ protected String getItemHandle(Item item) { String handle = item.getHandle(); return (handle != null) ? handle : " in workflow"; }
protected String getItemHandle(Item item) { String handle = item.getHandle(); return (handle != null) ? handle : NEW_ITEM_HANDLE; }
protected String getCanonical(Context context, Item item) { String canonical = item.getHandle(); if (canonical.matches(".*/.*\\.\\d+") && canonical.lastIndexOf(DOT) != -1) { canonical = canonical.substring(0, canonical.lastIndexOf(DOT)); } return canonical; }
/** * get the media link URL for the given item * * @param dso target DSpace object * @return media link URL for the given item * @throws DSpaceSWORDException can be thrown by the internals of the DSpace SWORD implementation */ private String getMediaLink(Item dso) throws DSpaceSWORDException { String ml = this.getBaseMediaLinkUrl(); String handle = dso.getHandle(); if (handle != null) { ml = ml + "/" + dso.getHandle(); } return ml; }
/** * get the media link url for the given item * * @param dso * @return * @throws DSpaceSWORDException */ private String getMediaLink(Item dso) throws DSpaceSWORDException { String ml = this.getBaseMediaLinkUrl(); String handle = dso.getHandle(); if (handle != null) { ml = ml + "/" + dso.getHandle(); } return ml; }
protected void init(Item parentItem) { fullTextStreams = new LinkedList<>(); if (parentItem != null) { sourceInfo = parentItem.getHandle(); //extracted full text is always extracted as plain text contentType = "text/plain"; buildFullTextList(parentItem); } }
/** * Obtain the deposit URL for the given item. These URLs * should not be considered persistent, but will remain consistent * unless configuration changes are made to DSpace * * @param item the item to query * @return The Deposit URL * @throws DSpaceSWORDException can be thrown by the internals of the DSpace SWORD implementation */ public String getDepositLocation(Item item) throws DSpaceSWORDException { return this.getBaseDepositUrl() + "/" + item.getHandle(); }
/** * Obtain the deposit URL for the given item. These URLs * should not be considered persistent, but will remain consistent * unless configuration changes are made to DSpace * * @param item * @return The Deposit URL * @throws DSpaceSWORDException */ public String getDepositLocation(Item item) throws DSpaceSWORDException { return this.getBaseDepositUrl() + "/" + item.getHandle(); }
private File getMetadataCache(Item item) { File dir = new File(getBaseDir()); if (!dir.exists()) { dir.mkdirs(); } String name = File.separator + item.getHandle().replace('/', '_'); return new File(getBaseDir() + name); }
@Override public int perform(DSpaceObject dso) throws IOException { if (dso instanceof Item) { Item item = (Item) dso; status = Curator.CURATE_SUCCESS; result = "No operation performed on " + item.getHandle(); setResult(result); report(result); } return status; }
private Item getDSpaceTarget(Context context, String editUrl, SwordConfigurationDSpace config) throws DSpaceSwordException, SwordError { SwordUrlManager urlManager = config.getUrlManager(context, config); // get the target collection Item item = urlManager.getItem(context, editUrl); if (item == null) { throw new SwordError(404); } this.verboseDescription.append( "Performing replace using edit-media URL: " + editUrl); this.verboseDescription.append( "Location resolves to item with handle: " + item.getHandle()); return item; } }
protected void updateItems(AuthorityValue authority) { try { Iterator<Item> itemIterator = itemService .findByMetadataFieldAuthority(context, authority.getField(), authority.getId()); while (itemIterator.hasNext()) { Item next = itemIterator.next(); List<MetadataValue> metadata = itemService.getMetadata(next, authority.getField(), authority.getId()); authority.updateItem(context, next, metadata.get(0)); //should be only one List<MetadataValue> metadataAfter = itemService .getMetadata(next, authority.getField(), authority.getId()); if (!metadata.get(0).getValue().equals(metadataAfter.get(0).getValue())) { print.println("Updated item with handle " + next.getHandle()); } } } catch (Exception e) { log.error("Error updating item", e); print.println("Error updating item. " + Arrays.toString(e.getStackTrace())); } }
@Override public void applyFiltersItem(Context c, Item item) throws Exception { //only apply filters if item not in skip-list if (!inSkipList(item.getHandle())) { //cache this item in MediaFilterManager //so it can be accessed by MediaFilters as necessary currentItem = item; if (filterItem(c, item)) { // increment processed count ++processed; } // clear item objects from context cache and internal cache c.uncacheEntity(currentItem); currentItem = null; } }
private Item getDSpaceTarget(Context context, String editMediaUrl, SwordConfigurationDSpace config) throws DSpaceSwordException, SwordError { SwordUrlManager urlManager = config.getUrlManager(context, config); // get the target collection Item item = urlManager.getItem(context, editMediaUrl); this.verboseDescription .append("Performing replace using edit-media URL: " + editMediaUrl); this.verboseDescription .append("Location resolves to item with handle: " + item.getHandle()); return item; }
@Override public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { // Since 3.0 the lift process for all embargoes is performed through the dates // on the authorization process (see DS-2588) // lifter.liftEmbargo(context, item); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); // set the dc.date.available value to right now itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item " + item.getHandle()); itemService.update(context, item); }
@Override public void addItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException { // Check authorisation authorizeService.authorizeAction(context, collection, Constants.ADD); log.info(LogManager.getHeader(context, "add_item", "collection_id=" + collection.getID() + ",item_id=" + item.getID())); // Create mapping // We do NOT add the item to the collection template since we would have to load in all our items // Instead we add the collection to an item which works in the same way. if (!item.getCollections().contains(collection)) { item.addCollection(collection); } context.addEvent(new Event(Event.ADD, Constants.COLLECTION, collection.getID(), Constants.ITEM, item.getID(), item.getHandle(), getIdentifiers(context, collection))); }
@Override public void removeItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException, IOException { // Check authorisation authorizeService.authorizeAction(context, collection, Constants.REMOVE); //Check if we orphaned our poor item if (item.getCollections().size() == 1) { // Orphan; delete it itemService.delete(context, item); } else { //Remove the item from the collection if we have multiple collections item.removeCollection(collection); } context.addEvent(new Event(Event.REMOVE, Constants.COLLECTION, collection.getID(), Constants.ITEM, item.getID(), item.getHandle(), getIdentifiers(context, collection))); }
/** * Wrap the item, parse all configured fields and generate metadata field * values. * * @param context context * @param item The item being viewed to extract metadata from * @throws SQLException if database error */ public GoogleMetadata(Context context, Item item) throws SQLException { // Hold onto the item in case we need to refresh a stale parse this.item = item; this.itemService = ContentServiceFactory.getInstance().getItemService(); itemURL = HandleServiceFactory.getInstance().getHandleService().resolveToURL(context, item.getHandle()); googleBitstreamComparator = new GoogleBitstreamComparator(context, googleScholarSettings); parseItem(); }