Commit 05732352 authored by bourgesl's avatar bourgesl
Browse files

javadoc + datacite sync: show all DOIs

parent 0a50c0af
......@@ -148,9 +148,8 @@ public class DOIApplication {
final boolean saveCSV = aa.containsOption("csv");
try {
final ProjectConfig projectConfig = new ProjectConfig(doiConfig.getPathConfig(), project);
final AbstractPipeline<?> pipeline = doiConfig.getProcessPipeline(saveCSV, projectConfig);
// Staging only
final AbstractPipeline<?> pipeline = doiConfig.getProcessPipeline(saveCSV, getProjectConfig(project));
pipeline.execute();
} catch (IOException ioe) {
......@@ -163,9 +162,8 @@ public class DOIApplication {
final String project = getRequiredValue("project", aa);
try {
final ProjectConfig projectConfig = new ProjectConfig(doiConfig.getPathConfig(), project);
final AbstractPipeline<?> pipeline = doiConfig.getProcessUrlPipeline(projectConfig, null);
// Staging only
final AbstractPipeline<?> pipeline = doiConfig.getProcessUrlPipeline(getProjectConfig(project), null);
pipeline.execute();
} catch (IOException ioe) {
......@@ -185,9 +183,8 @@ public class DOIApplication {
final char ch = (char) in.readByte();
if (Character.toLowerCase(ch) == 'y') {
final ProjectConfig projectConfig = new ProjectConfig(doiConfig.getPathConfig(), project);
final AbstractPipeline<?> pipeline = doiConfig.getPublishPipeline(projectConfig, doiPattern);
// Public only
final AbstractPipeline<?> pipeline = doiConfig.getPublishPipeline(getProjectConfig(project), doiPattern);
pipeline.execute();
} else {
logger.info("Action cancelled ({})", ch);
......@@ -210,9 +207,8 @@ public class DOIApplication {
final char ch = (char) in.readByte();
if (Character.toLowerCase(ch) == 'y') {
final ProjectConfig projectConfig = new ProjectConfig(doiConfig.getPathConfig(), project);
final AbstractPipeline<?> pipeline = doiConfig.getRemovePipeline(projectConfig, doiPattern);
// Staging only
final AbstractPipeline<?> pipeline = doiConfig.getRemovePipeline(getProjectConfig(project), doiPattern);
pipeline.execute();
} else {
logger.info("Action cancelled ({})", ch);
......@@ -241,6 +237,10 @@ public class DOIApplication {
}
}
private ProjectConfig getProjectConfig(final String project) throws IOException {
return new ProjectConfig(doiConfig.getPathConfig(), project);
}
/** Show command arguments help. */
public static void showArgumentsHelp() {
System.out.println("---------------------------------- Arguments help ------------------------------");
......
......@@ -84,6 +84,12 @@ public class DOIConfig {
logger.info("Enable Datacite Client: {}", isDataciteClientEnabled());
}
/**
* (CLI) Get the Process pipeline (Staging only)
* @param saveCSV save CSV (intermediate results)
* @param projectConfig project config to use
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public ProcessPipeline getProcessPipeline(final boolean saveCSV,
......@@ -96,6 +102,12 @@ public class DOIConfig {
);
}
/**
* (CLI) Get the Process URL pipeline (Staging only)
* @param projectConfig project config to use
* @param pipeData optional pipeline data
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public ProcessUrlPipeline getProcessUrlPipeline(final ProjectConfig projectConfig,
......@@ -108,11 +120,17 @@ public class DOIConfig {
);
}
/**
* (CLI) Get the Publish pipeline (Public only)
* @param projectConfig project config to use
* @param doiPattern pattern to match DOI suffix
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public PublishPipeline getPublishPipeline(final ProjectConfig projectConfig,
final String doiPattern) {
final PipelineCommonData pipelineData = new PipelineCommonData(pathConfig);
final PipelineCommonData pipelineData = createPipelineData(null);
pipelineData.addProjectConfig(projectConfig);
pipelineData.setDoiPattern(doiPattern);
......@@ -121,11 +139,17 @@ public class DOIConfig {
);
}
/**
* (CLI) Get the Remove pipeline (Staging only)
* @param projectConfig project config to use
* @param doiPattern pattern to match DOI suffix
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public RemovePipeline getRemovePipeline(final ProjectConfig projectConfig,
final String doiPattern) {
final PipelineCommonData pipelineData = new PipelineCommonData(pathConfig);
final PipelineCommonData pipelineData = createPipelineData(null);
pipelineData.addProjectConfig(projectConfig);
pipelineData.setDoiPattern(doiPattern);
......@@ -134,6 +158,13 @@ public class DOIConfig {
);
}
/**
* (CLI) Get the Generate pipeline (Public / Staging)
* @param doStaging true to process Staging: web pages & datacite sync
* @param doPublic true to process Public: web pages & datacite sync
* @param pipeData optional pipeline data
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public GeneratePipeline getGeneratePipeline(final boolean doStaging, final boolean doPublic,
......@@ -144,6 +175,13 @@ public class DOIConfig {
);
}
/**
* Get the Generate Redirect pipeline (Public / Staging)
* @param doStaging true to process Staging: datacite sync
* @param doPublic true to process Public: datacite sync
* @param pipeData optional pipeline data
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public GenerateRedirectPipeline getGenerateRedirectPipeline(final boolean doStaging, final boolean doPublic,
......@@ -154,6 +192,13 @@ public class DOIConfig {
);
}
/**
* Get the Datacite Sync pipeline (Public / Staging)
* @param doStaging true to process Staging: datacite sync
* @param doPublic true to process Public: datacite sync
* @param pipeData optional pipeline data
* @return new pipeline instance
*/
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public DataciteSyncPipeline getDataciteSyncPipeline(final boolean doStaging, final boolean doPublic,
......
......@@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
public class DataciteSyncPipeline extends AbstractPipeline<PipelineCommonData> {
public final class DataciteSyncPipeline extends AbstractPipeline<PipelineCommonData> {
private final static Logger logger = LoggerFactory.getLogger(DataciteSyncPipeline.class.getName());
......@@ -38,10 +38,6 @@ public class DataciteSyncPipeline extends AbstractPipeline<PipelineCommonData> {
@Override
public void doExecute() throws IOException {
if (!doiConfig.isDataciteClientEnabled()) {
logger.warn("publishDatacite: skipping - datacite client disabled.");
return;
}
logger.info("doStaging: {}", doStaging);
logger.info("doPublic: {}", doPublic);
......@@ -108,37 +104,41 @@ public class DataciteSyncPipeline extends AbstractPipeline<PipelineCommonData> {
logger.warn("Ignoring {} - missing xml at {}", doiSuffix, doiFile);
}
} else {
// only skip staging DOI:
// TODO: consider for public once it is tested:
final boolean exist = (isStaging && publishedDois != null) ? publishedDois.contains(doi.toUpperCase()) : false;
if (!doiConfig.isDataciteClientEnabled()) {
logger.warn("skipping DOI [{}] - datacite client disabled", doi);
} else {
// only skip staging DOI:
// TODO: consider for public once it is tested:
final boolean exist = (isStaging && publishedDois != null) ? publishedDois.contains(doi.toUpperCase()) : false;
boolean push = true;
boolean push = true;
if (exist) {
// verify that URL and metadata (MD5) are equivalent:
if (url.equals(d.getDataciteUrl()) && d.getMetadataMd5().equals(d.getDataciteMetadataMd5())) {
push = false;
if (exist) {
// verify that URL and metadata (MD5) are equivalent:
if (url.equals(d.getDataciteUrl()) && d.getMetadataMd5().equals(d.getDataciteMetadataMd5())) {
push = false;
}
}
}
if (push) {
logger.info("publish DOI [{}]", doi);
if (push) {
logger.info("publish DOI [{}]", doi);
// Push DOI in staging phase:
final String metadata = FileUtils.readFile(doiFile);
// Push DOI in staging phase:
final String metadata = FileUtils.readFile(doiFile);
if (dc.publishDoi(doi, url, metadata)) {
// update database:
if (isStaging) {
doiService.updateStagingDoiDatacite(doiSuffix, d.getMetadataMd5(), url, now);
if (dc.publishDoi(doi, url, metadata)) {
// update database:
if (isStaging) {
doiService.updateStagingDoiDatacite(doiSuffix, d.getMetadataMd5(), url, now);
} else {
doiService.updatePublicDoiDatacite(doiSuffix, d.getMetadataMd5(), url, now);
}
} else {
doiService.updatePublicDoiDatacite(doiSuffix, d.getMetadataMd5(), url, now);
logger.error("Failed to push DOI[{}] to datacite", doi);
}
} else {
logger.error("Failed to push DOI[{}] to datacite", doi);
logger.info("skipping DOI [{}] - datacite is up-to-date", doi);
}
} else {
logger.info("skipping DOI [{}] - datacite is up-to-date", doi);
}
}
}
......
......@@ -30,7 +30,7 @@ import java.util.Date;
/**
*
*/
public class GeneratePipeline extends AbstractPipeline<PipelineCommonData> {
public final class GeneratePipeline extends AbstractPipeline<PipelineCommonData> {
private final static Logger logger = LoggerFactory.getLogger(GeneratePipeline.class.getName());
......
......@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
public class GenerateRedirectPipeline extends AbstractPipeline<PipelineCommonData> {
public final class GenerateRedirectPipeline extends AbstractPipeline<PipelineCommonData> {
private final static Logger logger = LoggerFactory.getLogger(GenerateRedirectPipeline.class.getName());
......
......@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
public class ProcessPipeline extends AbstractPipeline<ProcessPipelineData> {
public final class ProcessPipeline extends AbstractPipeline<ProcessPipelineData> {
private final static Logger logger = LoggerFactory.getLogger(ProcessPipeline.class.getName());
......
......@@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
public class ProcessUrlPipeline extends AbstractPipeline<PipelineCommonData> {
public final class ProcessUrlPipeline extends AbstractPipeline<PipelineCommonData> {
private final static Logger logger = LoggerFactory.getLogger(ProcessUrlPipeline.class.getName());
......
......@@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
public class RemovePipeline extends AbstractPipeline<PipelineCommonData> {
public final class RemovePipeline extends AbstractPipeline<PipelineCommonData> {
private final static Logger logger = LoggerFactory.getLogger(RemovePipeline.class.getName());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment