Skip to content

Commit

Permalink
#24 various messaging/logging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Mar 3, 2016
1 parent ebeb2e3 commit 0b64d1e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ public String createIdentifier(String identifier, HashMap<String, String> metada
metadataTemplate.setTitle(metadata.get("datacite.title"));
metadataTemplate.setPublisher(metadata.get("datacite.publisher"));
metadataTemplate.setPublisherYear(metadata.get("datacite.publicationyear"));
logger.log(Level.INFO, "identifier={0}, creators={1}, title={2}, publisher={3}, publicationyear={4}",
new Object[]{identifier, metadata.get("datacite.creator"),
metadata.get("datacite.title"), metadata.get("datacite.publisher"),
metadata.get("datacite.publicationyear")});

String xmlMetadata = metadataTemplate.generateXML();
logger.log(Level.INFO, "xmlMetadata 70 " + xmlMetadata.toString() );

String status = metadata.get("_status").trim();
String target = metadata.get("_target");
String retString = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,31 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
String authority = theDataset.getAuthority();
if (theDataset.getGlobalIdCreateTime() == null) {
if (protocol.equals("doi")
&& doiProvider.equals("EZID")) {
String doiRetString = ctxt.doiEZId().createIdentifier(theDataset);
&& (doiProvider.equals("EZID") || doiProvider.equals("DataCite"))) {
String doiRetString = "";
if (doiProvider.equals("EZID")) {
doiRetString = ctxt.doiEZId().createIdentifier(theDataset);
} else {
doiRetString = ctxt.doiDataCite().createIdentifier(theDataset);
}

if (doiRetString.contains(theDataset.getIdentifier())) {
theDataset.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
} else {
if (doiRetString.contains("identifier already exists")){
theDataset.setIdentifier(ctxt.datasets().generateIdentifierSequence(protocol, authority, theDataset.getDoiSeparator()));
} else if (doiRetString.contains("identifier already exists")) {
theDataset.setIdentifier(ctxt.datasets().generateIdentifierSequence(protocol, authority, theDataset.getDoiSeparator()));
if (doiProvider.equals("EZID")) {
doiRetString = ctxt.doiEZId().createIdentifier(theDataset);
if(!doiRetString.contains(theDataset.getIdentifier())){
throw new IllegalCommandException("This dataset may not be published because its identifier is already in use by another dataset. Please contact Dataverse Support for assistance.", this);
} else{
theDataset.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
}
} else {
throw new IllegalCommandException("This dataset may not be published because it has not been registered. Please contact Dataverse Support for assistance.", this);
doiRetString = ctxt.doiDataCite().createIdentifier(theDataset);
}

if (!doiRetString.contains(theDataset.getIdentifier())) {
throw new IllegalCommandException("This dataset may not be published because its identifier is already in use by another dataset. Please contact Dataverse Support for assistance.", this);
} else {
theDataset.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
}
} else {
throw new IllegalCommandException("This dataset may not be published because it has not been registered. Please contact Dataverse Support for assistance.", this);
}
} else {
throw new IllegalCommandException("This dataset may not be published because its DOI provider is not supported. Please contact Dataverse Support for assistance.", this);
Expand Down Expand Up @@ -158,15 +167,6 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
theDataset.setFileAccessRequest(theDataset.getLatestVersion().getTermsOfUseAndAccess().isFileAccessRequest());
Dataset savedDataset = ctxt.em().merge(theDataset);

boolean doNormalSolrDocCleanUp = true;
ctxt.index().indexDataset(savedDataset, doNormalSolrDocCleanUp);
/**
* @todo consider also ctxt.solrIndex().indexPermissionsOnSelfAndChildren(theDataset);
*/
/**
* @todo what should we do with the indexRespose?
*/
IndexResponse indexResponse = ctxt.solrIndex().indexPermissionsForOneDvObject(savedDataset);

// set the subject of the parent (all the way up) Dataverses
DatasetField subject = null;
Expand Down Expand Up @@ -212,11 +212,29 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
try{
ctxt.doiDataCite().publicizeIdentifier(savedDataset);
} catch (Exception e){


if(e.toString().contains("EJB")){
throw new IllegalCommandException("This dataset may not be published because the DataCite Service is inaccessible. Please try again. If the issue persists, please contact Dataverse Support for assistance.", this);
}
throw new IllegalCommandException("This dataset may not be published because the DOI update failed. Please contact Dataverse Support for assistance.", this);
}

}

/*
MoveIndexing to after DOI update so that if command exception is thrown the re-index will not
*/

boolean doNormalSolrDocCleanUp = true;
ctxt.index().indexDataset(savedDataset, doNormalSolrDocCleanUp);
/**
* @todo consider also ctxt.solrIndex().indexPermissionsOnSelfAndChildren(theDataset);
*/
/**
* @todo what should we do with the indexRespose?
*/
IndexResponse indexResponse = ctxt.solrIndex().indexPermissionsForOneDvObject(savedDataset);

return savedDataset;
}
Expand Down

0 comments on commit 0b64d1e

Please sign in to comment.