@Test public void testUpdateAuth() throws Exception { new NonStrictExpectations() { AuthorizeManager authManager; { AuthorizeManager.authorizeAction((Context) any, (Item) any, Constants.WRITE); result = null; } }; it.update(); }
public void update() throws SQLException, AuthorizeException { if (!canEdit()) { AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); } log.info(LogManager.getHeader(ourContext, "update_item", "item_id=" + getID())); int sequence = 0; Bundle[] bunds = getBundles(); for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() > sequence) { sequence = streams[k].getSequenceID(); } } } sequence++; for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() < 0) { streams[k].setSequenceID(sequence); sequence++; streams[k].update(); modified = true; } } } Map<String,Integer> elementCount = new HashMap<String,Integer>(); if (dublinCoreChanged) { dublinCoreChanged = false; int[] placeNum = new int[getMetadata().size()]; boolean[] storedDC = new boolean[getMetadata().size()]; MetadataField[] dcFields = new MetadataField[getMetadata().size()]; for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { DCValue dcv = getMetadata().get(dcIdx); int current = 0; String key = dcv.element + ((dcv.qualifier == null) ? "" : ("." + dcv.qualifier)); Integer currentInteger = elementCount.get(key); if (currentInteger != null) { current = currentInteger.intValue(); } current++; elementCount.put(key, Integer.valueOf(current)); placeNum[dcIdx] = current; storedDC[dcIdx] = false; dcFields[dcIdx] = getMetadataField(dcv); if (dcFields[dcIdx] == null) { log.warn(LogManager .getHeader(ourContext, "bad_dc", "Bad DC field. schema="+dcv.schema + ", element: \"" + ((dcv.element == null) ? "null" : dcv.element) + "\" qualifier: \"" + ((dcv.qualifier == null) ? "null" : dcv.qualifier) + "\" value: \"" + ((dcv.value == null) ? "null" : dcv.value) + "\"")); throw new SQLException("bad_dublin_core " + "schema="+dcv.schema+", " + dcv.element + " " + dcv.qualifier); } } TableRowIterator tri = retrieveMetadata(); if (tri != null) { try { while (tri.hasNext()) { TableRow tr = tri.next(); boolean removeRow = true; for (int dcIdx = 0; dcIdx < getMetadata().size() && removeRow; dcIdx++) { if (!storedDC[dcIdx]) { boolean matched = true; DCValue dcv = getMetadata().get(dcIdx); if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id")) { matched = false; } if (matched && placeNum[dcIdx] != tr.getIntColumn("place")) { matched = false; } if (matched) { String text = tr.getStringColumn("text_value"); if (dcv.value == null && text == null) { matched = true; } else if (dcv.value != null && dcv.value.equals(text)) { matched = true; } else { matched = false; } } if (matched) { String lang = tr.getStringColumn("text_lang"); if (dcv.language == null && lang == null) { matched = true; } else if (dcv.language != null && dcv.language.equals(lang)) { matched = true; } else { matched = false; } } if (matched) { String auth = tr.getStringColumn("authority"); int conf = tr.getIntColumn("confidence"); if (!((dcv.authority == null && auth == null) || (dcv.authority != null && auth != null && dcv.authority.equals(auth)) && dcv.confidence == conf)) { matched = false; } } if (matched) { storedDC[dcIdx] = true; removeRow = false; } } } if (removeRow) { DatabaseManager.delete(ourContext, tr); dublinCoreChanged = true; modified = true; } } } finally { tri.close(); } } for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { if (!storedDC[dcIdx]) { DCValue dcv = getMetadata().get(dcIdx); MetadataValue metadata = new MetadataValue(); metadata.setItemId(getID()); metadata.setFieldId(dcFields[dcIdx].getFieldID()); metadata.setValue(dcv.value); metadata.setLanguage(dcv.language); metadata.setPlace(placeNum[dcIdx]); metadata.setAuthority(dcv.authority); metadata.setConfidence(dcv.confidence); metadata.create(ourContext); dublinCoreChanged = true; modified = true; } } } if (dublinCoreChanged || modified) { itemRow.setColumn("last_modified", new Date()); if (itemRow.isColumnNull("in_archive")) { itemRow.setColumn("in_archive", false); } if (itemRow.isColumnNull("withdrawn")) { itemRow.setColumn("withdrawn", false); } DatabaseManager.update(ourContext, itemRow); if (dublinCoreChanged) { ourContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.ITEM, getID(), getDetails())); clearDetails(); dublinCoreChanged = false; } ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(), null)); modified = false; } }
Item extends DSpaceObject { public void update() throws SQLException, AuthorizeException { if (!canEdit()) { AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); } log.info(LogManager.getHeader(ourContext, "update_item", "item_id=" + getID())); int sequence = 0; Bundle[] bunds = getBundles(); for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() > sequence) { sequence = streams[k].getSequenceID(); } } } sequence++; for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() < 0) { streams[k].setSequenceID(sequence); sequence++; streams[k].update(); modified = true; } } } Map<String,Integer> elementCount = new HashMap<String,Integer>(); if (dublinCoreChanged) { dublinCoreChanged = false; int[] placeNum = new int[getMetadata().size()]; boolean[] storedDC = new boolean[getMetadata().size()]; MetadataField[] dcFields = new MetadataField[getMetadata().size()]; for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { DCValue dcv = getMetadata().get(dcIdx); int current = 0; String key = dcv.element + ((dcv.qualifier == null) ? "" : ("." + dcv.qualifier)); Integer currentInteger = elementCount.get(key); if (currentInteger != null) { current = currentInteger.intValue(); } current++; elementCount.put(key, Integer.valueOf(current)); placeNum[dcIdx] = current; storedDC[dcIdx] = false; dcFields[dcIdx] = getMetadataField(dcv); if (dcFields[dcIdx] == null) { log.warn(LogManager .getHeader(ourContext, "bad_dc", "Bad DC field. schema="+dcv.schema + ", element: \"" + ((dcv.element == null) ? "null" : dcv.element) + "\" qualifier: \"" + ((dcv.qualifier == null) ? "null" : dcv.qualifier) + "\" value: \"" + ((dcv.value == null) ? "null" : dcv.value) + "\"")); throw new SQLException("bad_dublin_core " + "schema="+dcv.schema+", " + dcv.element + " " + dcv.qualifier); } } TableRowIterator tri = retrieveMetadata(); if (tri != null) { try { while (tri.hasNext()) { TableRow tr = tri.next(); boolean removeRow = true; for (int dcIdx = 0; dcIdx < getMetadata().size() && removeRow; dcIdx++) { if (!storedDC[dcIdx]) { boolean matched = true; DCValue dcv = getMetadata().get(dcIdx); if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id")) { matched = false; } if (matched && placeNum[dcIdx] != tr.getIntColumn("place")) { matched = false; } if (matched) { String text = tr.getStringColumn("text_value"); if (dcv.value == null && text == null) { matched = true; } else if (dcv.value != null && dcv.value.equals(text)) { matched = true; } else { matched = false; } } if (matched) { String lang = tr.getStringColumn("text_lang"); if (dcv.language == null && lang == null) { matched = true; } else if (dcv.language != null && dcv.language.equals(lang)) { matched = true; } else { matched = false; } } if (matched) { String auth = tr.getStringColumn("authority"); int conf = tr.getIntColumn("confidence"); if (!((dcv.authority == null && auth == null) || (dcv.authority != null && auth != null && dcv.authority.equals(auth)) && dcv.confidence == conf)) { matched = false; } } if (matched) { storedDC[dcIdx] = true; removeRow = false; } } } if (removeRow) { DatabaseManager.delete(ourContext, tr); dublinCoreChanged = true; modified = true; } } } finally { tri.close(); } } for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { if (!storedDC[dcIdx]) { DCValue dcv = getMetadata().get(dcIdx); MetadataValue metadata = new MetadataValue(); metadata.setItemId(getID()); metadata.setFieldId(dcFields[dcIdx].getFieldID()); metadata.setValue(dcv.value); metadata.setLanguage(dcv.language); metadata.setPlace(placeNum[dcIdx]); metadata.setAuthority(dcv.authority); metadata.setConfidence(dcv.confidence); metadata.create(ourContext); dublinCoreChanged = true; modified = true; } } } if (dublinCoreChanged || modified) { itemRow.setColumn("last_modified", new Date()); if (itemRow.isColumnNull("in_archive")) { itemRow.setColumn("in_archive", false); } if (itemRow.isColumnNull("withdrawn")) { itemRow.setColumn("withdrawn", false); } DatabaseManager.update(ourContext, itemRow); if (dublinCoreChanged) { ourContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.ITEM, getID(), getDetails())); clearDetails(); dublinCoreChanged = false; } ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(), null)); modified = false; } } }
Item extends DSpaceObject { public void update() throws SQLException, AuthorizeException { if (!canEdit()) { AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); } log.info(LogManager.getHeader(ourContext, "update_item", "item_id=" + getID())); int sequence = 0; Bundle[] bunds = getBundles(); for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() > sequence) { sequence = streams[k].getSequenceID(); } } } sequence++; for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() < 0) { streams[k].setSequenceID(sequence); sequence++; streams[k].update(); modified = true; } } } Map<String,Integer> elementCount = new HashMap<String,Integer>(); if (dublinCoreChanged) { dublinCoreChanged = false; int[] placeNum = new int[getMetadata().size()]; boolean[] storedDC = new boolean[getMetadata().size()]; MetadataField[] dcFields = new MetadataField[getMetadata().size()]; for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { DCValue dcv = getMetadata().get(dcIdx); int current = 0; String key = dcv.element + ((dcv.qualifier == null) ? "" : ("." + dcv.qualifier)); Integer currentInteger = elementCount.get(key); if (currentInteger != null) { current = currentInteger.intValue(); } current++; elementCount.put(key, Integer.valueOf(current)); placeNum[dcIdx] = current; storedDC[dcIdx] = false; dcFields[dcIdx] = getMetadataField(dcv); if (dcFields[dcIdx] == null) { log.warn(LogManager .getHeader(ourContext, "bad_dc", "Bad DC field. schema="+dcv.schema + ", element: \"" + ((dcv.element == null) ? "null" : dcv.element) + "\" qualifier: \"" + ((dcv.qualifier == null) ? "null" : dcv.qualifier) + "\" value: \"" + ((dcv.value == null) ? "null" : dcv.value) + "\"")); throw new SQLException("bad_dublin_core " + "schema="+dcv.schema+", " + dcv.element + " " + dcv.qualifier); } } TableRowIterator tri = retrieveMetadata(); if (tri != null) { try { while (tri.hasNext()) { TableRow tr = tri.next(); boolean removeRow = true; for (int dcIdx = 0; dcIdx < getMetadata().size() && removeRow; dcIdx++) { if (!storedDC[dcIdx]) { boolean matched = true; DCValue dcv = getMetadata().get(dcIdx); if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id")) { matched = false; } if (matched && placeNum[dcIdx] != tr.getIntColumn("place")) { matched = false; } if (matched) { String text = tr.getStringColumn("text_value"); if (dcv.value == null && text == null) { matched = true; } else if (dcv.value != null && dcv.value.equals(text)) { matched = true; } else { matched = false; } } if (matched) { String lang = tr.getStringColumn("text_lang"); if (dcv.language == null && lang == null) { matched = true; } else if (dcv.language != null && dcv.language.equals(lang)) { matched = true; } else { matched = false; } } if (matched) { String auth = tr.getStringColumn("authority"); int conf = tr.getIntColumn("confidence"); if (!((dcv.authority == null && auth == null) || (dcv.authority != null && auth != null && dcv.authority.equals(auth)) && dcv.confidence == conf)) { matched = false; } } if (matched) { storedDC[dcIdx] = true; removeRow = false; } } } if (removeRow) { DatabaseManager.delete(ourContext, tr); dublinCoreChanged = true; modified = true; } } } finally { tri.close(); } } for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { if (!storedDC[dcIdx]) { DCValue dcv = getMetadata().get(dcIdx); MetadataValue metadata = new MetadataValue(); metadata.setItemId(getID()); metadata.setFieldId(dcFields[dcIdx].getFieldID()); metadata.setValue(dcv.value); metadata.setLanguage(dcv.language); metadata.setPlace(placeNum[dcIdx]); metadata.setAuthority(dcv.authority); metadata.setConfidence(dcv.confidence); metadata.create(ourContext); dublinCoreChanged = true; modified = true; } } } if (dublinCoreChanged || modified) { itemRow.setColumn("last_modified", new Date()); if (itemRow.isColumnNull("in_archive")) { itemRow.setColumn("in_archive", false); } if (itemRow.isColumnNull("withdrawn")) { itemRow.setColumn("withdrawn", false); } DatabaseManager.update(ourContext, itemRow); if (dublinCoreChanged) { ourContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.ITEM, getID(), getDetails())); clearDetails(); dublinCoreChanged = false; } ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(), null)); modified = false; } } Item(Context context, TableRow row); }
Item extends DSpaceObject { public void update() throws SQLException, AuthorizeException { if (!canEdit()) { AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); } log.info(LogManager.getHeader(ourContext, "update_item", "item_id=" + getID())); int sequence = 0; Bundle[] bunds = getBundles(); for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() > sequence) { sequence = streams[k].getSequenceID(); } } } sequence++; for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() < 0) { streams[k].setSequenceID(sequence); sequence++; streams[k].update(); modified = true; } } } Map<String,Integer> elementCount = new HashMap<String,Integer>(); if (dublinCoreChanged) { dublinCoreChanged = false; int[] placeNum = new int[getMetadata().size()]; boolean[] storedDC = new boolean[getMetadata().size()]; MetadataField[] dcFields = new MetadataField[getMetadata().size()]; for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { DCValue dcv = getMetadata().get(dcIdx); int current = 0; String key = dcv.element + ((dcv.qualifier == null) ? "" : ("." + dcv.qualifier)); Integer currentInteger = elementCount.get(key); if (currentInteger != null) { current = currentInteger.intValue(); } current++; elementCount.put(key, Integer.valueOf(current)); placeNum[dcIdx] = current; storedDC[dcIdx] = false; dcFields[dcIdx] = getMetadataField(dcv); if (dcFields[dcIdx] == null) { log.warn(LogManager .getHeader(ourContext, "bad_dc", "Bad DC field. schema="+dcv.schema + ", element: \"" + ((dcv.element == null) ? "null" : dcv.element) + "\" qualifier: \"" + ((dcv.qualifier == null) ? "null" : dcv.qualifier) + "\" value: \"" + ((dcv.value == null) ? "null" : dcv.value) + "\"")); throw new SQLException("bad_dublin_core " + "schema="+dcv.schema+", " + dcv.element + " " + dcv.qualifier); } } TableRowIterator tri = retrieveMetadata(); if (tri != null) { try { while (tri.hasNext()) { TableRow tr = tri.next(); boolean removeRow = true; for (int dcIdx = 0; dcIdx < getMetadata().size() && removeRow; dcIdx++) { if (!storedDC[dcIdx]) { boolean matched = true; DCValue dcv = getMetadata().get(dcIdx); if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id")) { matched = false; } if (matched && placeNum[dcIdx] != tr.getIntColumn("place")) { matched = false; } if (matched) { String text = tr.getStringColumn("text_value"); if (dcv.value == null && text == null) { matched = true; } else if (dcv.value != null && dcv.value.equals(text)) { matched = true; } else { matched = false; } } if (matched) { String lang = tr.getStringColumn("text_lang"); if (dcv.language == null && lang == null) { matched = true; } else if (dcv.language != null && dcv.language.equals(lang)) { matched = true; } else { matched = false; } } if (matched) { String auth = tr.getStringColumn("authority"); int conf = tr.getIntColumn("confidence"); if (!((dcv.authority == null && auth == null) || (dcv.authority != null && auth != null && dcv.authority.equals(auth)) && dcv.confidence == conf)) { matched = false; } } if (matched) { storedDC[dcIdx] = true; removeRow = false; } } } if (removeRow) { DatabaseManager.delete(ourContext, tr); dublinCoreChanged = true; modified = true; } } } finally { tri.close(); } } for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { if (!storedDC[dcIdx]) { DCValue dcv = getMetadata().get(dcIdx); MetadataValue metadata = new MetadataValue(); metadata.setItemId(getID()); metadata.setFieldId(dcFields[dcIdx].getFieldID()); metadata.setValue(dcv.value); metadata.setLanguage(dcv.language); metadata.setPlace(placeNum[dcIdx]); metadata.setAuthority(dcv.authority); metadata.setConfidence(dcv.confidence); metadata.create(ourContext); dublinCoreChanged = true; modified = true; } } } if (dublinCoreChanged || modified) { itemRow.setColumn("last_modified", new Date()); if (itemRow.isColumnNull("in_archive")) { itemRow.setColumn("in_archive", false); } if (itemRow.isColumnNull("withdrawn")) { itemRow.setColumn("withdrawn", false); } DatabaseManager.update(ourContext, itemRow); if (dublinCoreChanged) { ourContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.ITEM, getID(), getDetails())); clearDetails(); dublinCoreChanged = false; } ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(), null)); modified = false; } } 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 void update() throws SQLException, AuthorizeException { if (!canEdit()) { AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); } log.info(LogManager.getHeader(ourContext, "update_item", "item_id=" + getID())); int sequence = 0; Bundle[] bunds = getBundles(); for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() > sequence) { sequence = streams[k].getSequenceID(); } } } sequence++; for (int i = 0; i < bunds.length; i++) { Bitstream[] streams = bunds[i].getBitstreams(); for (int k = 0; k < streams.length; k++) { if (streams[k].getSequenceID() < 0) { streams[k].setSequenceID(sequence); sequence++; streams[k].update(); modified = true; } } } Map<String,Integer> elementCount = new HashMap<String,Integer>(); if (dublinCoreChanged) { dublinCoreChanged = false; int[] placeNum = new int[getMetadata().size()]; boolean[] storedDC = new boolean[getMetadata().size()]; MetadataField[] dcFields = new MetadataField[getMetadata().size()]; for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { DCValue dcv = getMetadata().get(dcIdx); int current = 0; String key = dcv.element + ((dcv.qualifier == null) ? "" : ("." + dcv.qualifier)); Integer currentInteger = elementCount.get(key); if (currentInteger != null) { current = currentInteger.intValue(); } current++; elementCount.put(key, Integer.valueOf(current)); placeNum[dcIdx] = current; storedDC[dcIdx] = false; dcFields[dcIdx] = getMetadataField(dcv); if (dcFields[dcIdx] == null) { log.warn(LogManager .getHeader(ourContext, "bad_dc", "Bad DC field. schema="+dcv.schema + ", element: \"" + ((dcv.element == null) ? "null" : dcv.element) + "\" qualifier: \"" + ((dcv.qualifier == null) ? "null" : dcv.qualifier) + "\" value: \"" + ((dcv.value == null) ? "null" : dcv.value) + "\"")); throw new SQLException("bad_dublin_core " + "schema="+dcv.schema+", " + dcv.element + " " + dcv.qualifier); } } TableRowIterator tri = retrieveMetadata(); if (tri != null) { try { while (tri.hasNext()) { TableRow tr = tri.next(); boolean removeRow = true; for (int dcIdx = 0; dcIdx < getMetadata().size() && removeRow; dcIdx++) { if (!storedDC[dcIdx]) { boolean matched = true; DCValue dcv = getMetadata().get(dcIdx); if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id")) { matched = false; } if (matched && placeNum[dcIdx] != tr.getIntColumn("place")) { matched = false; } if (matched) { String text = tr.getStringColumn("text_value"); if (dcv.value == null && text == null) { matched = true; } else if (dcv.value != null && dcv.value.equals(text)) { matched = true; } else { matched = false; } } if (matched) { String lang = tr.getStringColumn("text_lang"); if (dcv.language == null && lang == null) { matched = true; } else if (dcv.language != null && dcv.language.equals(lang)) { matched = true; } else { matched = false; } } if (matched) { String auth = tr.getStringColumn("authority"); int conf = tr.getIntColumn("confidence"); if (!((dcv.authority == null && auth == null) || (dcv.authority != null && auth != null && dcv.authority.equals(auth)) && dcv.confidence == conf)) { matched = false; } } if (matched) { storedDC[dcIdx] = true; removeRow = false; } } } if (removeRow) { DatabaseManager.delete(ourContext, tr); dublinCoreChanged = true; modified = true; } } } finally { tri.close(); } } for (int dcIdx = 0; dcIdx < getMetadata().size(); dcIdx++) { if (!storedDC[dcIdx]) { DCValue dcv = getMetadata().get(dcIdx); MetadataValue metadata = new MetadataValue(); metadata.setItemId(getID()); metadata.setFieldId(dcFields[dcIdx].getFieldID()); metadata.setValue(dcv.value); metadata.setLanguage(dcv.language); metadata.setPlace(placeNum[dcIdx]); metadata.setAuthority(dcv.authority); metadata.setConfidence(dcv.confidence); metadata.create(ourContext); dublinCoreChanged = true; modified = true; } } } if (dublinCoreChanged || modified) { itemRow.setColumn("last_modified", new Date()); if (itemRow.isColumnNull("in_archive")) { itemRow.setColumn("in_archive", false); } if (itemRow.isColumnNull("withdrawn")) { itemRow.setColumn("withdrawn", false); } DatabaseManager.update(ourContext, itemRow); if (dublinCoreChanged) { ourContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.ITEM, getID(), getDetails())); clearDetails(); dublinCoreChanged = false; } ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(), null)); modified = false; } } 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; }