Commit ce001fde authored by Ricco Førgaard's avatar Ricco Førgaard

Refactored how the program is organised, collected classes that in reality are...

Refactored how the program is organised, collected classes that in reality are "controllers" in one place.
parent 9de14187
......@@ -8,9 +8,9 @@
</properties>
<repositories>
<repository>
<id>internal</id>
<name>Internal Mirror of Central Repository</name>
<url>http://nesstar-dev.nsd.uib.no/internal/</url>
<id>Nesstar</id>
<name>Nesstar Maven Repository</name>
<url>http://nesstar-dev.nsd.uib.no/nexus/content/groups/public/</url>
</repository>
</repositories>
<modelVersion>4.0.0</modelVersion>
......@@ -18,7 +18,7 @@
<artifactId>oai-pmh</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>oai-pmh web wevice</name>
<name>oai-pmh web service</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.ArrayList;
import java.util.List;
......@@ -15,10 +15,10 @@ import com.nesstar.oaipmh.exceptions.BadArgumentException;
import com.nesstar.oaipmh.exceptions.CannotDisseminateFormatException;
import com.nesstar.oaipmh.exceptions.OAIException;
public class GetRecordRequest extends OAIRequest {
private static Logger logger = Logger.getLogger(GetRecordRequest.class);
public class GetRecordController extends OAIRequest {
private static Logger logger = Logger.getLogger(GetRecordController.class);
public GetRecordRequest(Map<String, String[]> arguments) throws OAIException {
public GetRecordController(Map<String, String[]> arguments) throws OAIException {
super(arguments);
}
......@@ -28,7 +28,9 @@ public class GetRecordRequest extends OAIRequest {
}
public OAIXmlBuilder performRequest() throws Exception {
GetRecordResult result = new GetRecordResult(this);
GetRecordResult result = new GetRecordResult(getIdentifier());
setRequestValues(result);
verifyCorrectMetadataPrefixForEGMS(result);
GetRecordXmlBuilder xmlBuilder = null;
if (isDublinCoreRequest()) {
......@@ -44,11 +46,11 @@ public class GetRecordRequest extends OAIRequest {
}
protected boolean isDublinCoreRequest() {
return OAIRequestParser.DUBLIN_CORE_FORMAT.equalsIgnoreCase(getMetadataPrefix());
return RequestParser.DUBLIN_CORE_FORMAT.equalsIgnoreCase(getMetadataPrefix());
}
protected boolean isDDIRequest() {
return OAIRequestParser.DDI_FORMAT.equalsIgnoreCase(getMetadataPrefix());
return RequestParser.DDI_FORMAT.equalsIgnoreCase(getMetadataPrefix());
}
protected void verifyCorrectMetadataPrefixForEGMS(GetRecordResult result) throws CannotDisseminateFormatException {
......@@ -58,20 +60,20 @@ public class GetRecordRequest extends OAIRequest {
}
public String getIdentifier() {
return getArgumentValue(OAIRequestParser.IDENTIFIER);
return getArgumentValue(RequestParser.IDENTIFIER);
}
public String getMetadataPrefix() {
return getArgumentValue(OAIRequestParser.METADATA_PREFIX);
return getArgumentValue(RequestParser.METADATA_PREFIX);
}
private void checkPresenceOfValidArguments() throws BadArgumentException {
final List<String> badArguments = new ArrayList<String>(2);
if (!arguments.containsKey(OAIRequestParser.IDENTIFIER)) {
badArguments.add(OAIRequestParser.IDENTIFIER);
if (!arguments.containsKey(RequestParser.IDENTIFIER)) {
badArguments.add(RequestParser.IDENTIFIER);
}
if (!arguments.containsKey(OAIRequestParser.METADATA_PREFIX)) {
badArguments.add(OAIRequestParser.METADATA_PREFIX);
if (!arguments.containsKey(RequestParser.METADATA_PREFIX)) {
badArguments.add(RequestParser.METADATA_PREFIX);
}
if (badArguments.size() > 0) {
throw new BadArgumentException(badArguments);
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Map;
......@@ -9,10 +9,10 @@ import com.nesstar.oaipmh.xml.IdentifyXmlBuilder;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
import com.nesstar.oaipmh.exceptions.OAIException;
public class IdentifyRequest extends OAIRequest {
private static Logger logger = Logger.getLogger(IdentifyRequest.class);
public class IdentifyController extends OAIRequest {
private static Logger logger = Logger.getLogger(IdentifyController.class);
public IdentifyRequest(Map<String, String[]> arguments) throws OAIException {
public IdentifyController(Map<String, String[]> arguments) throws OAIException {
super(arguments);
}
......@@ -22,7 +22,8 @@ public class IdentifyRequest extends OAIRequest {
public OAIXmlBuilder performRequest() throws Exception {
logger.debug("Performing Identify request");
IdentifyResult oaiResult = new IdentifyResult(this);
IdentifyResult oaiResult = new IdentifyResult();
setRequestValues(oaiResult);
OAIXmlBuilder xmlBuilder = new IdentifyXmlBuilder(oaiResult);
xmlBuilder.buildXML();
return xmlBuilder;
......
package com.nesstar.oaipmh.servlet;
package com.nesstar.oaipmh.controller;
import java.io.File;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Map;
......@@ -7,8 +7,8 @@ import com.nesstar.oaipmh.xml.ListIdentifiersXmlBuilder;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
import com.nesstar.oaipmh.exceptions.OAIException;
public class ListIdentifiersRequest extends OAIRequest {
public ListIdentifiersRequest(Map<String, String[]> arguments) throws OAIException {
public class ListIdentifiersController extends OAIRequest {
public ListIdentifiersController(Map<String, String[]> arguments) throws OAIException {
super(arguments);
}
......@@ -17,7 +17,8 @@ public class ListIdentifiersRequest extends OAIRequest {
}
public OAIXmlBuilder performRequest() throws Exception {
ListIdentifiersResult result = new ListIdentifiersResult(this);
ListIdentifiersResult result = new ListIdentifiersResult(getVerb(), getMetadataPrefix());
ListIdentifiersXmlBuilder xmlBuilder = new ListIdentifiersXmlBuilder(result);
xmlBuilder.buildXML();
return xmlBuilder;
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Map;
......@@ -7,8 +7,8 @@ import com.nesstar.oaipmh.xml.ListMetadataFormatsXmlBuilder;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
import com.nesstar.oaipmh.exceptions.OAIException;
public class ListMetadataFormatsRequest extends OAIRequest {
public ListMetadataFormatsRequest(Map<String, String[]> arguments) throws OAIException {
public class ListMetadataFormatsController extends OAIRequest {
public ListMetadataFormatsController(Map<String, String[]> arguments) throws OAIException {
super(arguments);
}
......@@ -17,7 +17,8 @@ public class ListMetadataFormatsRequest extends OAIRequest {
}
public OAIXmlBuilder performRequest() throws Exception {
ListMetadataFormatsResult result = new ListMetadataFormatsResult(this);
ListMetadataFormatsResult result = new ListMetadataFormatsResult();
setRequestValues(result);
OAIXmlBuilder xmlBuilder = new ListMetadataFormatsXmlBuilder(result);
xmlBuilder.buildXML();
return xmlBuilder;
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Map;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
import com.nesstar.oaipmh.exceptions.OAIException;
public class ListSetsRequest extends OAIRequest {
public ListSetsRequest(Map<String, String[]> arguments) throws OAIException {
public class ListRecordsController extends OAIRequest {
public ListRecordsController(Map<String, String[]> arguments) throws OAIException {
super(arguments);
}
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Map;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
import com.nesstar.oaipmh.exceptions.OAIException;
public class ListRecordsRequest extends OAIRequest {
public ListRecordsRequest(Map<String, String[]> arguments) throws OAIException {
public class ListSetsController extends OAIRequest {
public ListSetsController(Map<String, String[]> arguments) throws OAIException {
super(arguments);
}
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Hashtable;
import java.util.Map;
import com.nesstar.oaipmh.result.OAIResult;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
import com.nesstar.oaipmh.request.OAIRequestParser;
import com.nesstar.oaipmh.controller.RequestParser;
import com.nesstar.oaipmh.exceptions.BadArgumentException;
import com.nesstar.oaipmh.exceptions.CannotDisseminateFormatException;
import com.nesstar.oaipmh.exceptions.OAIException;
......@@ -24,27 +25,36 @@ public abstract class OAIRequest {
protected abstract void identifyInvalidArguments() throws OAIException;
public String getVerb() {
return getArgumentValue(OAIRequestParser.VERB);
return getArgumentValue(RequestParser.VERB);
}
public String getIdentifier() {
return getArgumentValue(OAIRequestParser.IDENTIFIER);
return getArgumentValue(RequestParser.IDENTIFIER);
}
public String getMetadataPrefix() {
return getArgumentValue(OAIRequestParser.METADATA_PREFIX);
return getArgumentValue(RequestParser.METADATA_PREFIX);
}
public String getFrom() {
return getArgumentValue(OAIRequestParser.FROM);
return getArgumentValue(RequestParser.FROM);
}
public String getUntil() {
return getArgumentValue(OAIRequestParser.UNTIL);
return getArgumentValue(RequestParser.UNTIL);
}
public String getSet() {
return getArgumentValue(OAIRequestParser.SET);
return getArgumentValue(RequestParser.SET);
}
protected void setRequestValues(OAIResult someResult) {
someResult.setVerb(getVerb());
someResult.setIdentifier(getIdentifier());
someResult.setMetadataPrefix(getMetadataPrefix());
someResult.setDateRangeFrom(getFrom());
someResult.setDateRangeTo(getUntil());
someResult.setSetName(getSet());
}
protected String getArgumentValue(String argument) {
......@@ -59,8 +69,8 @@ public abstract class OAIRequest {
protected void checkValidMetadataPrefix() throws CannotDisseminateFormatException, BadArgumentException {
final String prefix = getMetadataPrefix();
if ("".equals(prefix)) {
throw new BadArgumentException(OAIRequestParser.METADATA_PREFIX);
} else if (!OAIRequestParser.KNOWN_METADATA_PREFIXES.contains(prefix)) {
throw new BadArgumentException(RequestParser.METADATA_PREFIX);
} else if (!RequestParser.KNOWN_METADATA_PREFIXES.contains(prefix)) {
throw new CannotDisseminateFormatException(prefix);
}
}
......
package com.nesstar.oaipmh.servlet;
package com.nesstar.oaipmh.controller;
import java.io.File;
import java.io.IOException;
......@@ -13,8 +13,8 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.nesstar.oaipmh.exceptions.OAIException;
import com.nesstar.oaipmh.request.OAIRequest;
import com.nesstar.oaipmh.request.OAIRequestParser;
import com.nesstar.oaipmh.controller.OAIRequest;
import com.nesstar.oaipmh.controller.RequestParser;
import com.nesstar.oaipmh.xml.ExceptionXmlBuilder;
import com.nesstar.oaipmh.xml.OAIXmlBuilder;
......@@ -49,7 +49,7 @@ public class OaiPmhServlet extends HttpServlet {
protected void handleOAIRequest(HttpServletRequest request) throws Exception {
logger.debug("Handling request");
OAIRequestParser parser = new OAIRequestParser(request);
RequestParser parser = new RequestParser(request);
OAIRequest oaiRequest = parser.getOAIRequest();
OAIXmlBuilder oaiXML = oaiRequest.performRequest();
......
package com.nesstar.oaipmh.request;
package com.nesstar.oaipmh.controller;
import java.util.Arrays;
import java.util.List;
......@@ -11,8 +11,8 @@ import org.apache.log4j.Logger;
import com.nesstar.oaipmh.exceptions.BadVerbException;
import com.nesstar.oaipmh.exceptions.OAIException;
public class OAIRequestParser {
private static Logger logger = Logger.getLogger(OAIRequestParser.class);
public class RequestParser {
private static Logger logger = Logger.getLogger(RequestParser.class);
private HttpServletRequest request;
public final static String VERB = "verb";
public final static String IDENTIFIER = "identifier";
......@@ -31,7 +31,7 @@ public class OAIRequestParser {
public static final List<String> KNOWN_METADATA_PREFIXES = Arrays.asList(new String[] { "oai_dc", "oai_ddi" } );
public OAIRequestParser(HttpServletRequest request) {
public RequestParser(HttpServletRequest request) {
this.request = request;
}
......@@ -48,17 +48,17 @@ public class OAIRequestParser {
OAIRequest oaiRequest = null;
if (GET_RECORD.equalsIgnoreCase(verb)) {
oaiRequest = new GetRecordRequest(arguments);
oaiRequest = new GetRecordController(arguments);
} else if (IDENTIFY.equalsIgnoreCase(verb)) {
oaiRequest = new IdentifyRequest(arguments);
oaiRequest = new IdentifyController(arguments);
} else if (LIST_IDENTIFIERS.equalsIgnoreCase(verb)) {
oaiRequest = new ListIdentifiersRequest(arguments);
oaiRequest = new ListIdentifiersController(arguments);
} else if (LIST_METADATA_FORMATS.equalsIgnoreCase(verb)) {
oaiRequest = new ListMetadataFormatsRequest(arguments);
oaiRequest = new ListMetadataFormatsController(arguments);
} else if (LIST_RECORDS.equalsIgnoreCase(verb)) {
oaiRequest = new ListRecordsRequest(arguments);
oaiRequest = new ListRecordsController(arguments);
} else if (LIST_SETS.equalsIgnoreCase(verb)) {
oaiRequest = new ListSetsRequest(arguments);
oaiRequest = new ListSetsController(arguments);
} else {
throw new BadVerbException(verb);
}
......
......@@ -4,13 +4,15 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.Map;
import nesstar.api.common.EGMSResource;
import org.apache.log4j.Logger;
import com.nesstar.oaipmh.NesstarServer;
import com.nesstar.oaipmh.request.GetRecordRequest;
import com.nesstar.oaipmh.controller.OAIRequest;
import com.nesstar.oaipmh.controller.RequestParser;
import com.nesstar.oaipmh.exceptions.IdDoesNotExistException;
import com.nesstar.api.NesstarObject;
......@@ -21,31 +23,33 @@ public class GetRecordResult extends OAIResult {
protected String identifier;
protected Date timestamp;
public GetRecordResult(GetRecordRequest request) throws Exception {
public GetRecordResult(String identifier) throws Exception {
super();
this.oaiRequest = request;
this.identifier = identifier;
fetchResource();
}
private void fetchResource() throws Exception {
String address = oaiRequest.getIdentifier();
try {
URL url = new URL(address);
URL url = new URL(identifier);
payload = NesstarServer.getNesstarDB().lookup(url);
if (payload == null) {
logger.fatal("Resource does not exist: " + address);
throw new IdDoesNotExistException(address);
logger.fatal("Resource does not exist: " + identifier);
throw new IdDoesNotExistException(identifier);
}
identifier = url.toString();
timestamp = payload.timeStamp();
} catch (MalformedURLException malformedURLexception) {
logger.fatal("Malformed URL: " + address, malformedURLexception);
throw new IdDoesNotExistException(address);
logger.fatal("Malformed URL: " + identifier, malformedURLexception);
throw new IdDoesNotExistException(identifier);
} catch (IOException ioException) {
logger.fatal("Could not retrieve resource from Nesstar.", ioException);
throw ioException;
}
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public Date getTimestamp() {
return timestamp;
......
......@@ -8,7 +8,6 @@ import org.apache.log4j.Logger;
import com.nesstar.api.*;
import com.nesstar.oaipmh.NesstarServer;
import com.nesstar.oaipmh.request.OAIRequest;
import com.nesstar.oaipmh.util.Properties;
public class IdentifyResult extends OAIResult {
......@@ -22,9 +21,8 @@ public class IdentifyResult extends OAIResult {
private String granularity = "YYYY-MM-DDThh:mm:ssZ";
private String compression = "deflate";
public IdentifyResult(OAIRequest oaiRequest) {
public IdentifyResult() {
super();
this.oaiRequest = oaiRequest;
administratorEmails = Properties.getInstance().getAdministratorEmails();
logger.debug("New IdentifyResult");
}
......
......@@ -6,17 +6,16 @@ import java.util.List;
import java.util.Map;
import com.nesstar.oaipmh.NesstarServer;
import com.nesstar.oaipmh.request.GetRecordRequest;
import com.nesstar.oaipmh.request.ListIdentifiersRequest;
import com.nesstar.oaipmh.request.OAIRequestParser;
import com.nesstar.oaipmh.controller.RequestParser;
import com.nesstar.api.Study;
public class ListIdentifiersResult extends OAIResult {
protected List<GetRecordResult> records;
public ListIdentifiersResult(ListIdentifiersRequest request) throws Exception {
this.oaiRequest = request;
public ListIdentifiersResult(String verb, String metadataPrefix) throws Exception {
this.metadataPrefix = metadataPrefix;
this.verb = verb;
records = new ArrayList<GetRecordResult>();
fetchResult();
}
......@@ -34,19 +33,27 @@ public class ListIdentifiersResult extends OAIResult {
private void createXMLBuilderForStudy(Study study) throws Exception {
Map<String, String[]> arguments = getArgumentsForStudy(study);
GetRecordRequest request = new GetRecordRequest(arguments);
GetRecordResult result = new GetRecordResult(request);
GetRecordResult result = new GetRecordResult(getIdentifierArgument(arguments));
result.setVerb("GetRecord");
records.add(result);
}
private Map<String, String[]> getArgumentsForStudy(Study study) {
Map<String, String[]> arguments = new Hashtable<String, String[]>();
arguments.put(OAIRequestParser.IDENTIFIER, new String[] { study.toURL().toString() });
arguments.put(OAIRequestParser.METADATA_PREFIX, new String[] { oaiRequest.getMetadataPrefix() });
arguments.put(RequestParser.IDENTIFIER, new String[] { study.toURL().toString() });
arguments.put(RequestParser.METADATA_PREFIX, new String[] { metadataPrefix });
return arguments;
}
private String getIdentifierArgument(Map<String, String[]> arguments) {
return arguments.get(RequestParser.IDENTIFIER)[0];
}
public List<GetRecordResult> getRecords() {
return records;
}
public void setMetadataPrefix(String prefix) {
metadataPrefix = prefix;
}
}
......@@ -4,14 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import com.nesstar.oaipmh.dataformats.MetadataFormat;
import com.nesstar.oaipmh.request.ListMetadataFormatsRequest;
public class ListMetadataFormatsResult extends OAIResult {
protected List<MetadataFormat> metadataFormats;
public ListMetadataFormatsResult(ListMetadataFormatsRequest request) {
public ListMetadataFormatsResult() {
super();
this.oaiRequest = request;
metadataFormats = new ArrayList<MetadataFormat>(2);
MetadataFormat dublinCore = new MetadataFormat("oai_dc",
"http://www.openarchives.org/OAI/2.0/oai_dc.xsd",
......
......@@ -4,11 +4,14 @@ import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import com.nesstar.oaipmh.request.OAIRequest;
public abstract class OAIResult {
protected OAIRequest oaiRequest;
protected Date responseDate;
protected String verb;
protected String identifier;
protected String metadataPrefix;
protected String dateRangeFrom;
protected String dateRangeTo;
protected String setName;
public OAIResult() {
responseDate = Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime();
......@@ -17,8 +20,52 @@ public abstract class OAIResult {
public Date getResponseDate() {
return responseDate;
}
public String getVerb() {
return verb;
}
public void setVerb(String verb) {
this.verb = verb;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getMetadataPrefix() {
return metadataPrefix;
}
public void setMetadataPrefix(String metadataPrefix) {
this.metadataPrefix = metadataPrefix;
}
public String getDateRangeFrom() {
return dateRangeFrom;
}
public void setDateRangeFrom(String dateRangeFrom) {
this.dateRangeFrom = dateRangeFrom;
}
public String getDateRangeTo() {
return dateRangeTo;
}
public void setDateRangeTo(String dateRangeTo) {
this.dateRangeTo = dateRangeTo;
}
public String getSet() {
return setName;
}
public OAIRequest getRequest() {
return oaiRequest;
public void setSetName(String setName) {
this.setName = setName;
}
}
......@@ -21,7 +21,9 @@ import com.nesstar.oaipmh.xml.oaipmh.MetadataType;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import com.nesstar.api.ComplexDdiElement;
import com.nesstar.api.DdiElement;
import com.nesstar.api.DdiList;
import com.nesstar.api.NesstarObject;
import com.nesstar.api.Study;
......@@ -71,13 +73,14 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
createRelationElement(study);
createCoverageElement(study);
createRightsElement(study);
createLanguageElement(study);
JAXBElement<OaiDcType> root = dcObjectFactory.createDc(oaiDCType);
return root;
}
protected void createTitleElement(Study study) {
String content = getContentFromDDI(study, "./docDscr/citation/titlStmt/titl");
String content = getStringContentFromDDI(study, "./docDscr/citation/titlStmt/titl");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createTitle(elementType);
......@@ -86,7 +89,7 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createCreatorElement(Study study) {
String content = getContentFromDDI(study, "./docDscr/citation/rspStmt/AuthEnty");
String content = getStringContentFromDDI(study, "./stdyDscr/citation/rspStmt/AuthEnty");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createCreator(elementType);
......@@ -95,7 +98,7 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createSubjectElement(Study study) {
String content = getContentFromDDI(study, "./stdyDscr/stdyInfo/subject/keyword");
String content = getStringContentFromDDI(study, "./stdyDscr/stdyInfo/subject/keyword");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createSubject(elementType);
......@@ -104,7 +107,7 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createDescriptionElement(Study study) {
String content = getContentFromDDI(study, "./stdyDscr/stdyInfo/abstract");
String content = getStringContentFromDDI(study, "./stdyDscr/stdyInfo/abstract");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createDescription(elementType);
......@@ -113,7 +116,7 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createPublisherElement(Study study) {
String content = getContentFromDDI(study, "./stdyDscr/citation/prodStmt/producer");
String content = getStringContentFromDDI(study, "./stdyDscr/citation/prodStmt/producer");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createPublisher(elementType);
......@@ -122,7 +125,7 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createContributorElement(Study study) {
String content = getContentFromDDI(study, "./stdyDscr/citation/rspStmt/othId");
String content = getStringContentFromDDI(study, "./stdyDscr/citation/rspStmt/othId");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createContributor(elementType);
......@@ -131,7 +134,7 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createDateElement(Study study) {
String content = getContentFromDDI(study, "./stdyDscr/citation/prodStmt/prodDate");
String content = getStringContentFromDDI(study, "./stdyDscr/citation/prodStmt/prodDate");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createDate(elementType);
......@@ -139,11 +142,8 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
}
/*
* This element isn't available in Nesstar.
*/
protected void createTypeElement(Study study) {
String content = getContentFromDDI(study, "./stdyDscr/citation/stdyInfo/sumDscr/dataKind");
String content = getStringContentFromDDI(study, "./stdyDscr/citation/stdyInfo/sumDscr/dataKind");
if (contentIsNotEmpty(content)) {
ElementType elementType = getNewElementType(content);
JAXBElement<ElementType> element = dcObjectFactory.createType(elementType);
......@@ -152,16 +152,32 @@ public class DublinCoreRecordBuilder extends GetRecordXmlBuilder {
}
protected void createFormatElement(Study study) {