mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Remove deprecated getMetadata(Context, String) from CommunityService, CollectionService.
This commit is contained in:
@@ -496,7 +496,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -650,30 +650,41 @@ public class StructBuilder {
|
||||
element.setAttribute("identifier", community.getHandle());
|
||||
|
||||
Element nameElement = new Element("name");
|
||||
nameElement.setText(communityService.getMetadata(community, "name"));
|
||||
nameElement.setText(communityService.getMetadataFirstValue(
|
||||
community, CommunityService.MD_NAME, Item.ANY));
|
||||
element.addContent(nameElement);
|
||||
|
||||
if (communityService.getMetadata(community, "short_description") != null) {
|
||||
String fieldValue;
|
||||
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element descriptionElement = new Element("description");
|
||||
descriptionElement.setText(communityService.getMetadata(community, "short_description"));
|
||||
descriptionElement.setText(fieldValue);
|
||||
element.addContent(descriptionElement);
|
||||
}
|
||||
|
||||
if (communityService.getMetadata(community, "introductory_text") != null) {
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element introElement = new Element("intro");
|
||||
introElement.setText(communityService.getMetadata(community, "introductory_text"));
|
||||
introElement.setText(fieldValue);
|
||||
element.addContent(introElement);
|
||||
}
|
||||
|
||||
if (communityService.getMetadata(community, "copyright_text") != null) {
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element copyrightElement = new Element("copyright");
|
||||
copyrightElement.setText(communityService.getMetadata(community, "copyright_text"));
|
||||
copyrightElement.setText(fieldValue);
|
||||
element.addContent(copyrightElement);
|
||||
}
|
||||
|
||||
if (communityService.getMetadata(community, "side_bar_text") != null) {
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("sidebar");
|
||||
sidebarElement.setText(communityService.getMetadata(community, "side_bar_text"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
@@ -733,42 +744,57 @@ public class StructBuilder {
|
||||
element.setAttribute("identifier", collection.getHandle());
|
||||
|
||||
Element nameElement = new Element("name");
|
||||
nameElement.setText(collectionService.getMetadata(collection, "name"));
|
||||
nameElement.setText(collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY));
|
||||
element.addContent(nameElement);
|
||||
|
||||
if (collectionService.getMetadata(collection, "short_description") != null) {
|
||||
String fieldValue;
|
||||
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element descriptionElement = new Element("description");
|
||||
descriptionElement.setText(collectionService.getMetadata(collection, "short_description"));
|
||||
descriptionElement.setText(fieldValue);
|
||||
element.addContent(descriptionElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "introductory_text") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element introElement = new Element("intro");
|
||||
introElement.setText(collectionService.getMetadata(collection, "introductory_text"));
|
||||
introElement.setText(fieldValue);
|
||||
element.addContent(introElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "copyright_text") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element copyrightElement = new Element("copyright");
|
||||
copyrightElement.setText(collectionService.getMetadata(collection, "copyright_text"));
|
||||
copyrightElement.setText(fieldValue);
|
||||
element.addContent(copyrightElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "side_bar_text") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("sidebar");
|
||||
sidebarElement.setText(collectionService.getMetadata(collection, "side_bar_text"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "license") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("license");
|
||||
sidebarElement.setText(collectionService.getMetadata(collection, "license"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "provenance_description") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("provenance");
|
||||
sidebarElement.setText(collectionService.getMetadata(collection, "provenance_description"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
|
@@ -205,7 +205,8 @@ public class SyndicationFeed {
|
||||
if (dso instanceof IndexableCollection) {
|
||||
Collection col = ((IndexableCollection) dso).getIndexedObject();
|
||||
defaultTitle = col.getName();
|
||||
feed.setDescription(collectionService.getMetadata(col, "short_description"));
|
||||
feed.setDescription(collectionService.getMetadataFirstValue(col,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY));
|
||||
logo = col.getLogo();
|
||||
String cols = configurationService.getProperty("webui.feed.podcast.collections");
|
||||
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
||||
@@ -215,7 +216,8 @@ public class SyndicationFeed {
|
||||
} else if (dso instanceof IndexableCommunity) {
|
||||
Community comm = ((IndexableCommunity) dso).getIndexedObject();
|
||||
defaultTitle = comm.getName();
|
||||
feed.setDescription(communityService.getMetadata(comm, "short_description"));
|
||||
feed.setDescription(communityService.getMetadataFirstValue(comm,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY));
|
||||
logo = comm.getLogo();
|
||||
String comms = configurationService.getProperty("webui.feed.podcast.communities");
|
||||
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
||||
|
@@ -12,6 +12,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@@ -207,10 +208,17 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
||||
* Get the license that users must grant before submitting to this
|
||||
* collection.
|
||||
*
|
||||
* @return the license for this collection
|
||||
* @return the license for this collection. Never null.
|
||||
*/
|
||||
@Nonnull
|
||||
public String getLicenseCollection() {
|
||||
return getCollectionService().getMetadata(this, "license");
|
||||
String license = getCollectionService()
|
||||
.getMetadataFirstValue(this, CollectionService.MD_LICENSE, Item.ANY);
|
||||
if (null == license) {
|
||||
return "";
|
||||
} else {
|
||||
return license;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -457,22 +457,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a metadata field
|
||||
*
|
||||
* @param collection which collection to operate on
|
||||
* @param field the name of the metadata field to get
|
||||
* @return the value of the metadata field
|
||||
* @throws IllegalArgumentException if the requested metadata field doesn't exist
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMetadata(Collection collection, String field) {
|
||||
String[] MDValue = getMDValueByLegacyField(field);
|
||||
String value = getMetadataFirstValue(collection, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Group createSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException {
|
||||
// Check authorisation - Must be an Admin to create Submitters Group
|
||||
@@ -553,7 +537,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
@Override
|
||||
public String getLicense(Collection collection) {
|
||||
String license = getMetadata(collection, "license");
|
||||
String license = getMetadataFirstValue(collection, CollectionService.MD_LICENSE, Item.ANY);
|
||||
|
||||
if (license == null || license.trim().equals("")) {
|
||||
// Fallback to site-wide default
|
||||
|
@@ -51,7 +51,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(CommunityServiceImpl.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CommunityServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected CommunityDAO communityDAO;
|
||||
@@ -174,13 +174,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
return communityDAO.findAllNoParent(context, sortField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMetadata(Community community, String field) {
|
||||
String[] MDValue = getMDValueByLegacyField(field);
|
||||
String value = getMetadataFirstValue(community, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(Context context, Community community, String field, String value)
|
||||
throws MissingResourceException, SQLException {
|
||||
@@ -310,7 +303,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
|
||||
@Override
|
||||
public List<Community> getAllParents(Context context, Community community) throws SQLException {
|
||||
List<Community> parentList = new ArrayList<Community>();
|
||||
List<Community> parentList = new ArrayList<>();
|
||||
Community parent = (Community) getParentObject(context, community);
|
||||
while (parent != null) {
|
||||
parentList.add(parent);
|
||||
@@ -332,7 +325,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
|
||||
@Override
|
||||
public List<Collection> getAllCollections(Context context, Community community) throws SQLException {
|
||||
List<Collection> collectionList = new ArrayList<Collection>();
|
||||
List<Collection> collectionList = new ArrayList<>();
|
||||
List<Community> subCommunities = community.getSubcommunities();
|
||||
for (Community subCommunity : subCommunities) {
|
||||
addCollectionList(subCommunity, collectionList);
|
||||
|
@@ -410,6 +410,24 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve first metadata field value
|
||||
*
|
||||
* @param dso The DSpaceObject which we ask for metadata.
|
||||
* @param field {schema, element, qualifier} for the desired field.
|
||||
* @param language the language to match, or <code>Item.ANY</code>
|
||||
* @return the first metadata field value
|
||||
*/
|
||||
@Override
|
||||
public String getMetadataFirstValue(T dso, MetadataFieldName field, String language) {
|
||||
List<MetadataValue> metadataValues
|
||||
= getMetadata(dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER, language);
|
||||
if (CollectionUtils.isNotEmpty(metadataValues)) {
|
||||
return metadataValues.get(0).getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set first metadata field value
|
||||
*
|
||||
|
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Simple immutable holder for the name of a metadata field.
|
||||
*
|
||||
* @author mwood
|
||||
*/
|
||||
public class MetadataFieldName {
|
||||
/** Name of the metadata schema which defines this field. Never null. */
|
||||
public final String SCHEMA;
|
||||
|
||||
/** Element name of this field. Never null. */
|
||||
public final String ELEMENT;
|
||||
|
||||
/** Qualifier name of this field. May be {@code null}. */
|
||||
public final String QUALIFIER;
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
* @param qualifier qualifier name of the field.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull String schema, @Nonnull String element, String qualifier) {
|
||||
if (null == schema) {
|
||||
throw new IllegalArgumentException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema;
|
||||
ELEMENT = element;
|
||||
QUALIFIER = qualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier=null) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull String schema, @Nonnull String element) {
|
||||
if (null == schema) {
|
||||
throw new IllegalArgumentException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema;
|
||||
ELEMENT = element;
|
||||
QUALIFIER = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
* @param qualifier qualifier name of the field.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull MetadataSchemaEnum schema, @Nonnull String element, String qualifier) {
|
||||
if (null == schema) {
|
||||
throw new IllegalArgumentException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema.getName();
|
||||
ELEMENT = element;
|
||||
QUALIFIER = qualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier=null) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull MetadataSchemaEnum schema, @Nonnull String element) {
|
||||
if (null == schema) {
|
||||
throw new IllegalArgumentException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema.getName();
|
||||
ELEMENT = element;
|
||||
QUALIFIER = null;
|
||||
}
|
||||
}
|
@@ -451,13 +451,18 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
protected List<MetadataValueDTO> community2Metadata(Community community) {
|
||||
List<MetadataValueDTO> metadata = new ArrayList<>();
|
||||
|
||||
String description = communityService.getMetadata(community, "introductory_text");
|
||||
String description_abstract = communityService.getMetadata(community, "short_description");
|
||||
String description_table = communityService.getMetadata(community, "side_bar_text");
|
||||
String description = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = handleService.getCanonicalPrefix()
|
||||
+ community.getHandle();
|
||||
String rights = communityService.getMetadata(community, "copyright_text");
|
||||
String title = communityService.getMetadata(community, "name");
|
||||
String rights = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String title = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_NAME, Item.ANY);
|
||||
|
||||
metadata.add(createDCValue("description", null, description));
|
||||
|
||||
@@ -494,15 +499,22 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
protected List<MetadataValueDTO> collection2Metadata(Collection collection) {
|
||||
List<MetadataValueDTO> metadata = new ArrayList<>();
|
||||
|
||||
String description = collectionService.getMetadata(collection, "introductory_text");
|
||||
String description_abstract = collectionService.getMetadata(collection, "short_description");
|
||||
String description_table = collectionService.getMetadata(collection, "side_bar_text");
|
||||
String description = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = handleService.getCanonicalPrefix()
|
||||
+ collection.getHandle();
|
||||
String provenance = collectionService.getMetadata(collection, "provenance_description");
|
||||
String rights = collectionService.getMetadata(collection, "copyright_text");
|
||||
String rights_license = collectionService.getMetadata(collection, "license");
|
||||
String title = collectionService.getMetadata(collection, "name");
|
||||
String provenance = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
String rights = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String rights_license = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
String title = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY);
|
||||
|
||||
if (description != null) {
|
||||
metadata.add(createDCValue("description", null, description));
|
||||
|
@@ -343,14 +343,21 @@ public class XSLTDisseminationCrosswalk
|
||||
if (dso.getType() == Constants.COLLECTION) {
|
||||
Collection collection = (Collection) dso;
|
||||
|
||||
String description = collectionService.getMetadata(collection, "introductory_text");
|
||||
String description_abstract = collectionService.getMetadata(collection, "short_description");
|
||||
String description_table = collectionService.getMetadata(collection, "side_bar_text");
|
||||
String description = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = "hdl:" + collection.getHandle();
|
||||
String provenance = collectionService.getMetadata(collection, "provenance_description");
|
||||
String rights = collectionService.getMetadata(collection, "copyright_text");
|
||||
String rights_license = collectionService.getMetadata(collection, "license");
|
||||
String title = collectionService.getMetadata(collection, "name");
|
||||
String provenance = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
String rights = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String rights_license = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
String title = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY);
|
||||
|
||||
dim.addContent(createField("dc", "description", null, null, description));
|
||||
dim.addContent(createField("dc", "description", "abstract", null, description_abstract));
|
||||
@@ -363,12 +370,17 @@ public class XSLTDisseminationCrosswalk
|
||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||
Community community = (Community) dso;
|
||||
|
||||
String description = communityService.getMetadata(community, "introductory_text");
|
||||
String description_abstract = communityService.getMetadata(community, "short_description");
|
||||
String description_table = communityService.getMetadata(community, "side_bar_text");
|
||||
String description = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = "hdl:" + community.getHandle();
|
||||
String rights = communityService.getMetadata(community, "copyright_text");
|
||||
String title = communityService.getMetadata(community, "name");
|
||||
String rights = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String title = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_NAME, Item.ANY);
|
||||
|
||||
dim.addContent(createField("dc", "description", null, null, description));
|
||||
dim.addContent(createField("dc", "description", "abstract", null, description_abstract));
|
||||
|
@@ -29,7 +29,6 @@ import org.dspace.eperson.Group;
|
||||
*/
|
||||
public interface CommunityService extends DSpaceObjectService<Community>, DSpaceObjectLegacySupportService<Community> {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new top-level community, with a new ID.
|
||||
*
|
||||
@@ -88,20 +87,6 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
|
||||
*/
|
||||
public List<Community> findAllTop(Context context) throws SQLException;
|
||||
|
||||
/**
|
||||
* Get the value of a metadata field
|
||||
*
|
||||
* @param community community
|
||||
* @param field the name of the metadata field to get
|
||||
* @return the value of the metadata field
|
||||
* @throws IllegalArgumentException if the requested metadata field doesn't exist
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMetadata(Community community, String field);
|
||||
|
||||
|
||||
/**
|
||||
* Set a metadata value
|
||||
*
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.content.service;
|
||||
|
||||
import static org.dspace.content.MetadataSchemaEnum.DC;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -16,25 +18,46 @@ import java.util.UUID;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
/**
|
||||
* Service interface class for the DSpaceObject.
|
||||
* All DSpaceObject service classes should implement this class since it offers some basic methods which all
|
||||
* DSpaceObjects
|
||||
* are required to have.
|
||||
* All DSpaceObject service classes should implement this class since it offers
|
||||
* some basic methods which all {@code DSpaceObject}s are required to have.
|
||||
*
|
||||
* @param <T> class type
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
|
||||
// Some common metadata fields which must be defined.
|
||||
|
||||
public static final MetadataFieldName MD_INTRODUCTORY_TEXT
|
||||
= new MetadataFieldName(DC, "description");
|
||||
public static final MetadataFieldName MD_SHORT_DESCRIPTION
|
||||
= new MetadataFieldName(DC, "description", "abstract");
|
||||
public static final MetadataFieldName MD_SIDEBAR_TEXT
|
||||
= new MetadataFieldName(DC, "description", "tableofcontents");
|
||||
public static final MetadataFieldName MD_COPYRIGHT_TEXT
|
||||
= new MetadataFieldName(DC, "rights");
|
||||
public static final MetadataFieldName MD_NAME
|
||||
= new MetadataFieldName(DC, "title");
|
||||
public static final MetadataFieldName MD_PROVENANCE_DESCRIPTION
|
||||
= new MetadataFieldName(DC, "provenance");
|
||||
public static final MetadataFieldName MD_LICENSE
|
||||
= new MetadataFieldName(DC, "rights", "license");
|
||||
public static final MetadataFieldName MD_USER_FORMAT_DESCRIPTION
|
||||
= new MetadataFieldName(DC, "format");
|
||||
public static final MetadataFieldName MD_SOURCE
|
||||
= new MetadataFieldName(DC, "source");
|
||||
|
||||
/**
|
||||
* Generic find for when the precise type of an Entity is not known
|
||||
*
|
||||
* @param context - the context
|
||||
* @param uuid - uuid within table of type'd dspace objects
|
||||
* @param uuid - uuid within table of typed dspace objects
|
||||
* @return the dspace object found, or null if it does not exist.
|
||||
* @throws SQLException only upon failure accessing the database.
|
||||
*/
|
||||
@@ -175,10 +198,29 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
public String getMetadata(T dSpaceObject, String value);
|
||||
|
||||
|
||||
/**
|
||||
* Get the value(s) of a metadata field.
|
||||
* @param dSpaceObject the object whose metadata are sought.
|
||||
* @param mdString the name of the field: {@code schema.element.qualifier}.
|
||||
* @param authority name of the authority which controls these values, or null.
|
||||
* @return all matching metadata values, or null if none.
|
||||
*/
|
||||
public List<MetadataValue> getMetadata(T dSpaceObject, String mdString, String authority);
|
||||
|
||||
public List<MetadataValue> getMetadata(T dSpaceObject, String schema, String element, String qualifier, String lang,
|
||||
String authority);
|
||||
/**
|
||||
* Get the value(s) of a metadata field.
|
||||
* @param dSpaceObject the object whose metadata are sought.
|
||||
* @param schema name of the schema which defines the field.
|
||||
* @param element the field's element name.
|
||||
* @param qualifier the field's qualifier name, or null.
|
||||
* @param lang the language of the requested field value(s),
|
||||
* null if explicitly no language,
|
||||
* or {@link org.dspace.content.Item.ANY} to match all languages.
|
||||
* @param authority name of the authority which controls these values, or null.
|
||||
* @return value(s) of the indicated field for the given DSO, or null.
|
||||
*/
|
||||
public List<MetadataValue> getMetadata(T dSpaceObject, String schema,
|
||||
String element, String qualifier, String lang, String authority);
|
||||
|
||||
/**
|
||||
* Add metadata fields. These are appended to existing values.
|
||||
@@ -376,8 +418,26 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
|
||||
public void removeMetadataValues(Context context, T dso, List<MetadataValue> values) throws SQLException;
|
||||
|
||||
/**
|
||||
* Get the first value of a metadata field.
|
||||
* @param dso the object whose metadata are sought.
|
||||
* @param schema name of the schema which defines the field.
|
||||
* @param element element name of the field.
|
||||
* @param qualifier qualifier name of the field, or null.
|
||||
* @param language select only values in this language.
|
||||
* @return first value of the field, or null if none.
|
||||
*/
|
||||
public String getMetadataFirstValue(T dso, String schema, String element, String qualifier, String language);
|
||||
|
||||
/**
|
||||
* Get the first value of a metadata field.
|
||||
* @param dso the object whose metadata are sought.
|
||||
* @param field {schema, element, qualifier} for the desired field.
|
||||
* @param language select only values in this language.
|
||||
* @return first value of the field, or null if none.
|
||||
*/
|
||||
public String getMetadataFirstValue(T dso, MetadataFieldName field, String language);
|
||||
|
||||
/**
|
||||
* Set first metadata field value
|
||||
*
|
||||
|
@@ -19,6 +19,7 @@ import java.util.UUID;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
@@ -96,13 +97,20 @@ public class CollectionIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<Ind
|
||||
|
||||
|
||||
// Add collection metadata
|
||||
String description = collectionService.getMetadata(collection, "introductory_text");
|
||||
String description_abstract = collectionService.getMetadata(collection, "short_description");
|
||||
String description_table = collectionService.getMetadata(collection, "side_bar_text");
|
||||
String provenance = collectionService.getMetadata(collection, "provenance_description");
|
||||
String rights = collectionService.getMetadata(collection, "copyright_text");
|
||||
String rights_license = collectionService.getMetadata(collection, "license");
|
||||
String title = collectionService.getMetadata(collection, "name");
|
||||
String description = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String provenance = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
String rights = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String rights_license = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
String title = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY);
|
||||
|
||||
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(collection.getType());
|
||||
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description",
|
||||
|
@@ -18,6 +18,7 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.SearchUtils;
|
||||
@@ -71,7 +72,7 @@ public class CommunityIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<Inde
|
||||
DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(community);
|
||||
DiscoveryHitHighlightingConfiguration highlightingConfiguration = discoveryConfiguration
|
||||
.getHitHighlightingConfiguration();
|
||||
List<String> highlightedMetadataFields = new ArrayList<String>();
|
||||
List<String> highlightedMetadataFields = new ArrayList<>();
|
||||
if (highlightingConfiguration != null) {
|
||||
for (DiscoveryHitHighlightFieldConfiguration configuration : highlightingConfiguration
|
||||
.getMetadataFields()) {
|
||||
@@ -80,11 +81,16 @@ public class CommunityIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<Inde
|
||||
}
|
||||
|
||||
// Add community metadata
|
||||
String description = communityService.getMetadata(community, "introductory_text");
|
||||
String description_abstract = communityService.getMetadata(community, "short_description");
|
||||
String description_table = communityService.getMetadata(community, "side_bar_text");
|
||||
String rights = communityService.getMetadata(community, "copyright_text");
|
||||
String title = communityService.getMetadata(community, "name");
|
||||
String description = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String rights = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String title = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_NAME, Item.ANY);
|
||||
|
||||
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(community.getType());
|
||||
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description",
|
||||
|
@@ -7,12 +7,15 @@
|
||||
*/
|
||||
package org.dspace.eperson.service;
|
||||
|
||||
import static org.dspace.content.MetadataSchemaEnum.DC;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||
import org.dspace.content.service.DSpaceObjectService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -22,9 +25,10 @@ import org.dspace.eperson.PasswordHash;
|
||||
|
||||
/**
|
||||
* Service interface class for the EPerson object.
|
||||
* The implementation of this class is responsible for all business logic calls for the EPerson object and is
|
||||
* autowired by spring
|
||||
* The implementation of this class is responsible for all business logic calls
|
||||
* for the EPerson object and is autowired by Spring.
|
||||
*
|
||||
* <p>
|
||||
* Methods for handling registration by email and forgotten passwords. When
|
||||
* someone registers as a user, or forgets their password, the
|
||||
* sendRegistrationInfo or sendForgotPasswordInfo methods can be used to send an
|
||||
@@ -33,14 +37,25 @@ import org.dspace.eperson.PasswordHash;
|
||||
* back to the system, the AccountManager can use the token to determine the
|
||||
* identity of the eperson.
|
||||
*
|
||||
* *NEW* now ignores expiration dates so that tokens never expire
|
||||
* <p>
|
||||
* *NEW* now ignores expiration dates so that tokens never expire.
|
||||
*
|
||||
* @author Peter Breton
|
||||
* @author kevinvandevelde at atmire.com
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface EPersonService extends DSpaceObjectService<EPerson>, DSpaceObjectLegacySupportService<EPerson> {
|
||||
|
||||
// Common metadata fields which must be defined.
|
||||
|
||||
public static final MetadataFieldName MD_FIRSTNAME
|
||||
= new MetadataFieldName(DC, "firstname");
|
||||
public static final MetadataFieldName MD_LASTNAME
|
||||
= new MetadataFieldName(DC, "lastname");
|
||||
public static final MetadataFieldName MD_PHONE
|
||||
= new MetadataFieldName(DC, "phone");
|
||||
public static final MetadataFieldName MD_LANGUAGE
|
||||
= new MetadataFieldName(DC, "language");
|
||||
|
||||
/**
|
||||
* Find the eperson by their email address.
|
||||
*
|
||||
@@ -119,7 +134,8 @@ public interface EPersonService extends DSpaceObjectService<EPerson>, DSpaceObje
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
* Find all the epeople in a specific order
|
||||
* Find all the {@code EPerson}s in a specific order by field.
|
||||
* The sortable fields are:
|
||||
* <ul>
|
||||
* <li><code>ID</code></li>
|
||||
* <li><code>LASTNAME</code></li>
|
||||
|
@@ -99,18 +99,34 @@ public class StructBuilderIT
|
||||
"<import_structure>\n" +
|
||||
" <community>\n" +
|
||||
" <name>Top Community 0</name>\n" +
|
||||
" <description/><intro/><copyright/><sidebar/>" +
|
||||
" <description>A top level community</description>\n" +
|
||||
" <intro>Testing 1 2 3</intro>\n" +
|
||||
" <copyright>1969</copyright>\n" +
|
||||
" <sidebar>A sidebar</sidebar>\n" +
|
||||
" <community>\n" +
|
||||
" <name>Sub Community 0.0</name>\n" +
|
||||
" <description/><intro/><copyright/><sidebar/>" +
|
||||
" <description>A sub community</description>\n" +
|
||||
" <intro>Live from New York....</intro>\n" +
|
||||
" <copyright>1957</copyright>\n" +
|
||||
" <sidebar>Another sidebar</sidebar>\n" +
|
||||
" <collection>\n" +
|
||||
" <name>Collection 0.0.0</name>\n" +
|
||||
" <description/><intro/><copyright/><sidebar/><license/><provenance/>" +
|
||||
" <description>A collection</description>\n" +
|
||||
" <intro>Our next guest needs no introduction</intro>\n" +
|
||||
" <copyright>1776</copyright>\n" +
|
||||
" <sidebar>Yet another sidebar</sidebar>\n" +
|
||||
" <license>MIT</license>\n" +
|
||||
" <provenance>Testing</provenance>\n" +
|
||||
" </collection>\n" +
|
||||
" </community>\n" +
|
||||
" <collection>\n" +
|
||||
" <name>Collection 0.1</name>\n" +
|
||||
" <description/><intro/><copyright/><sidebar/><license/><provenance/>" +
|
||||
" <description>Another collection</description>\n" +
|
||||
" <intro>Fourscore and seven years ago</intro>\n" +
|
||||
" <copyright>1863</copyright>\n" +
|
||||
" <sidebar>No sidebar</sidebar>\n" +
|
||||
" <license>Public domain</license>\n" +
|
||||
" <provenance>Testing again</provenance>\n" +
|
||||
" </collection>\n" +
|
||||
" </community>\n" +
|
||||
"</import_structure>\n";
|
||||
@@ -119,30 +135,15 @@ public class StructBuilderIT
|
||||
"<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||
"<import_structure>\n" +
|
||||
" <community>\n" +
|
||||
" <name>Top Community 0</name>" +
|
||||
" <description/><intro/><copyright/><sidebar/>" +
|
||||
" <name>Top Community 0</name>\n" +
|
||||
" <description/><intro/><copyright/><sidebar/>\n" +
|
||||
" <collection>\n" +
|
||||
" <name>Collection 0.0</name>" +
|
||||
" <description/><intro/><copyright/><sidebar/><license/>" +
|
||||
" <name>Collection 0.0</name>\n" +
|
||||
" <description/><intro/><copyright/><sidebar/><license/>\n" +
|
||||
" </collection>\n" +
|
||||
" </community>\n" +
|
||||
"</import_structure>\n";
|
||||
|
||||
/**
|
||||
* Test of main method, of class StructBuilder.
|
||||
* @throws java.lang.Exception
|
||||
/*
|
||||
@Test
|
||||
public void testMain()
|
||||
throws Exception {
|
||||
System.out.println("main");
|
||||
String[] argv = null;
|
||||
StructBuilder.main(argv);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test of importStructure method, of class StructBuilder.
|
||||
*
|
||||
|
@@ -11,6 +11,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -32,6 +33,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
@@ -55,7 +57,7 @@ public class CollectionTest extends AbstractDSpaceObjectTest {
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CollectionTest.class);
|
||||
|
||||
private LicenseService licenseService = CoreServiceFactory.getInstance().getLicenseService();
|
||||
private final LicenseService licenseService = CoreServiceFactory.getInstance().getLicenseService();
|
||||
|
||||
/**
|
||||
* Collection instance for the tests
|
||||
@@ -265,22 +267,6 @@ public class CollectionTest extends AbstractDSpaceObjectTest {
|
||||
assertTrue("testGetHandle 0", collection.getHandle().contains("123456789/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getMetadata method, of class Collection.
|
||||
*/
|
||||
@Test
|
||||
public void testGetMetadata() {
|
||||
//by default all empty values will return ""
|
||||
assertThat("testGetMetadata 0", collectionService.getMetadata(collection, "name"), equalTo(""));
|
||||
assertThat("testGetMetadata 1", collectionService.getMetadata(collection, "short_description"), equalTo(""));
|
||||
assertThat("testGetMetadata 2", collectionService.getMetadata(collection, "introductory_text"), equalTo(""));
|
||||
assertThat("testGetMetadata 4", collectionService.getMetadata(collection, "copyright_text"), equalTo(""));
|
||||
assertThat("testGetMetadata 6", collectionService.getMetadata(collection, "provenance_description"),
|
||||
equalTo(""));
|
||||
assertThat("testGetMetadata 7", collectionService.getMetadata(collection, "side_bar_text"), equalTo(""));
|
||||
assertThat("testGetMetadata 8", collectionService.getMetadata(collection, "license"), equalTo(""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of setMetadata method, of class Collection.
|
||||
*/
|
||||
@@ -302,14 +288,27 @@ public class CollectionTest extends AbstractDSpaceObjectTest {
|
||||
collectionService.setMetadata(context, collection, "provenance_description", provDesc);
|
||||
collectionService.setMetadata(context, collection, "license", license);
|
||||
|
||||
assertThat("testSetMetadata 0", collectionService.getMetadata(collection, "name"), equalTo(name));
|
||||
assertThat("testSetMetadata 1", collectionService.getMetadata(collection, "short_description"), equalTo(sdesc));
|
||||
assertThat("testSetMetadata 2", collectionService.getMetadata(collection, "introductory_text"), equalTo(itext));
|
||||
assertThat("testSetMetadata 4", collectionService.getMetadata(collection, "copyright_text"), equalTo(copy));
|
||||
assertThat("testSetMetadata 5", collectionService.getMetadata(collection, "side_bar_text"), equalTo(sidebar));
|
||||
assertThat("testGetMetadata 7", collectionService.getMetadata(collection, "provenance_description"),
|
||||
equalTo(provDesc));
|
||||
assertThat("testGetMetadata 8", collectionService.getMetadata(collection, "license"), equalTo(license));
|
||||
assertEquals("Name was not set properly.", name,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY));
|
||||
assertEquals("Short description was not set properly.", sdesc,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY));
|
||||
assertEquals("Introductory text was not set properly.", itext,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY));
|
||||
assertEquals("Copyright text was not set properly.", copy,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY));
|
||||
assertEquals("Sidebar text was not set properly.", sidebar,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY));
|
||||
assertEquals("Provenance was not set properly.", provDesc,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY));
|
||||
assertEquals("License text was not set properly.", license,
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -12,6 +12,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -33,6 +34,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.Group;
|
||||
@@ -297,19 +299,6 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
|
||||
assertTrue("testGetHandle 0", c.getHandle().contains("123456789/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getMetadata method, of class Community.
|
||||
*/
|
||||
@Test
|
||||
public void testGetMetadata() {
|
||||
//by default all empty values will return ""
|
||||
assertThat("testGetMetadata 0", communityService.getMetadata(c, "name"), equalTo(""));
|
||||
assertThat("testGetMetadata 1", communityService.getMetadata(c, "short_description"), equalTo(""));
|
||||
assertThat("testGetMetadata 2", communityService.getMetadata(c, "introductory_text"), equalTo(""));
|
||||
assertThat("testGetMetadata 4", communityService.getMetadata(c, "copyright_text"), equalTo(""));
|
||||
assertThat("testGetMetadata 5", communityService.getMetadata(c, "side_bar_text"), equalTo(""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of setMetadata method, of class Community.
|
||||
*/
|
||||
@@ -327,11 +316,16 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
|
||||
communityService.setMetadata(context, c, "copyright_text", copy);
|
||||
communityService.setMetadata(context, c, "side_bar_text", sidebar);
|
||||
|
||||
assertThat("testSetMetadata 0", communityService.getMetadata(c, "name"), equalTo(name));
|
||||
assertThat("testSetMetadata 1", communityService.getMetadata(c, "short_description"), equalTo(sdesc));
|
||||
assertThat("testSetMetadata 2", communityService.getMetadata(c, "introductory_text"), equalTo(itext));
|
||||
assertThat("testSetMetadata 4", communityService.getMetadata(c, "copyright_text"), equalTo(copy));
|
||||
assertThat("testSetMetadata 5", communityService.getMetadata(c, "side_bar_text"), equalTo(sidebar));
|
||||
assertEquals("Name not set properly.", name,
|
||||
communityService.getMetadataFirstValue(c, CommunityService.MD_NAME, Item.ANY));
|
||||
assertEquals("Short description not set properly.", sdesc,
|
||||
communityService.getMetadataFirstValue(c, CommunityService.MD_SHORT_DESCRIPTION, Item.ANY));
|
||||
assertEquals("Introductory text not set properly.", itext,
|
||||
communityService.getMetadataFirstValue(c, CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY));
|
||||
assertEquals("Copyright text not set properly.", copy,
|
||||
communityService.getMetadataFirstValue(c, CommunityService.MD_COPYRIGHT_TEXT, Item.ANY));
|
||||
assertEquals("Sidebar text not set properly.", sidebar,
|
||||
communityService.getMetadataFirstValue(c, CommunityService.MD_SIDEBAR_TEXT, Item.ANY));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -580,7 +574,7 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
|
||||
public void testGetAllCollections() throws Exception {
|
||||
//empty by default
|
||||
assertThat("testGetAllCollections 0", communityService.getAllCollections(context, c), notNullValue());
|
||||
assertTrue("testGetAllCollections 1", communityService.getAllCollections(context, c).size() == 0);
|
||||
assertTrue("testGetAllCollections 1", communityService.getAllCollections(context, c).isEmpty());
|
||||
|
||||
//community has a collection and a subcommunity, subcommunity has a collection
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
@@ -13,6 +13,7 @@ import java.util.Map;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
@@ -75,7 +76,8 @@ public class CollectionCollectionGenerator extends ATOMCollectionGenerator {
|
||||
String location = urlManager.getDepositLocation(col);
|
||||
|
||||
// collection title is just its name
|
||||
String title = collectionService.getMetadata(col, "name");
|
||||
String title = collectionService.getMetadataFirstValue(col,
|
||||
CollectionService.MD_NAME, Item.ANY);
|
||||
|
||||
// the collection policy is the licence to which the collection adheres
|
||||
String collectionPolicy = collectionService.getLicense(col);
|
||||
@@ -84,8 +86,8 @@ public class CollectionCollectionGenerator extends ATOMCollectionGenerator {
|
||||
// String treatment = " ";
|
||||
|
||||
// abstract is the short description of the collection
|
||||
String dcAbstract = collectionService
|
||||
.getMetadata(col, "short_description");
|
||||
String dcAbstract = collectionService.getMetadataFirstValue(col,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
|
||||
// we just do support mediation
|
||||
boolean mediation = swordConfig.isMediated();
|
||||
|
@@ -136,7 +136,8 @@ public class ServiceDocumentManager {
|
||||
Collection collection = (Collection) dso;
|
||||
Workspace workspace = new Workspace();
|
||||
workspace.setTitle(
|
||||
collectionService.getMetadata(collection, "name"));
|
||||
collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY));
|
||||
|
||||
List<Item> items = swordAuth
|
||||
.getAllowedItems(swordContext, collection);
|
||||
@@ -151,7 +152,8 @@ public class ServiceDocumentManager {
|
||||
Community community = (Community) dso;
|
||||
Workspace workspace = new Workspace();
|
||||
workspace.setTitle(
|
||||
communityService.getMetadata(community, "name"));
|
||||
communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_NAME, null));
|
||||
|
||||
List<Collection> collections = swordAuth
|
||||
.getAllowedCollections(swordContext, community);
|
||||
|
Reference in New Issue
Block a user