forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged dspace-cris-7 into DSC-1124-inline-group-fields-should-be-indexed
- Loading branch information
Showing
218 changed files
with
9,241 additions
and
804 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
* | ||
* @author Jason Sherman [email protected] | ||
*/ | ||
public class BrandedPreviewJPEGFilter extends MediaFilter { | ||
public class BrandedPreviewJPEGFilter extends JPEGFilter { | ||
@Override | ||
public String getFilteredName(String oldFilename) { | ||
return oldFilename + ".preview.jpg"; | ||
|
@@ -36,14 +36,6 @@ public String getBundleName() { | |
return "BRANDED_PREVIEW"; | ||
} | ||
|
||
/** | ||
* @return String bitstreamformat | ||
*/ | ||
@Override | ||
public String getFormatString() { | ||
return "JPEG"; | ||
} | ||
|
||
/** | ||
* @return String description | ||
*/ | ||
|
@@ -81,9 +73,7 @@ public InputStream getDestinationStream(Item currentItem, InputStream source, bo | |
String brandFont = configurationService.getProperty("webui.preview.brand.font"); | ||
int brandFontPoint = configurationService.getIntProperty("webui.preview.brand.fontpoint"); | ||
|
||
JPEGFilter jpegFilter = new JPEGFilter(); | ||
return jpegFilter | ||
.getThumbDim(currentItem, buf, verbose, xmax, ymax, blurring, hqscaling, brandHeight, brandFontPoint, | ||
return getThumbDim(currentItem, buf, verbose, xmax, ymax, blurring, hqscaling, brandHeight, brandFontPoint, | ||
brandFont); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...api/src/main/java/org/dspace/app/metadata/export/DspaceExportMetadataSchemaException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* 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.app.metadata.export; | ||
|
||
/** | ||
* @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com) | ||
**/ | ||
public class DspaceExportMetadataSchemaException extends Exception { | ||
|
||
public DspaceExportMetadataSchemaException(Exception e) { | ||
super(e); | ||
} | ||
|
||
public DspaceExportMetadataSchemaException(String message, Exception e) { | ||
super(message, e); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
dspace-api/src/main/java/org/dspace/app/metadata/export/MetadataSchemaExportCliScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* 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.app.metadata.export; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.commons.cli.ParseException; | ||
import org.dspace.core.Context; | ||
|
||
/** | ||
* This script can be use to export a given {@code MetadataSchema} into its | ||
* registry file, that respects the standard DTD / XSD DSpace xml registry. | ||
* <p/> | ||
* This script is supposed to work with the CLI (command-line-interface), | ||
* it accepts only two parameters {@code -i <schema-id> -f <file-path>} | ||
* respectively representing: | ||
* <ul> | ||
* <li><b>{@code schema-id}</b>: id of the schema to export</li> | ||
* <li><b>{@code file-path}</b>:full file path of the file that will contain the export</li> | ||
* <ul> | ||
* | ||
* @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com) | ||
* | ||
*/ | ||
public class MetadataSchemaExportCliScript extends MetadataSchemaExportScript { | ||
|
||
protected String filename; | ||
|
||
@Override | ||
public void setup() throws ParseException { | ||
super.setup(); | ||
filename = commandLine.getOptionValue('f'); | ||
} | ||
|
||
@Override | ||
protected File getExportedFile(Context context) throws DspaceExportMetadataSchemaException { | ||
try { | ||
File file = new File(filename); | ||
return metadataSchemaExportService.exportMetadataSchemaToFile(context, metadataSchema, file); | ||
} catch (DspaceExportMetadataSchemaException e) { | ||
handler.logError("Problem occured while exporting the schema to file: " + filename, e); | ||
throw e; | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
.../main/java/org/dspace/app/metadata/export/MetadataSchemaExportCliScriptConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* 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.app.metadata.export; | ||
|
||
import org.apache.commons.cli.Option; | ||
import org.apache.commons.cli.Options; | ||
|
||
/** | ||
* @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com) | ||
* | ||
*/ | ||
public class MetadataSchemaExportCliScriptConfiguration | ||
extends MetadataSchemaExportScriptConfiguration<MetadataSchemaExportCliScript> { | ||
|
||
@Override | ||
public Options getOptions() { | ||
Options options = super.getOptions(); | ||
|
||
options.addOption( | ||
Option.builder("f").longOpt("file") | ||
.desc("The temporary file-name to use") | ||
.hasArg() | ||
.build() | ||
); | ||
|
||
return options; | ||
} | ||
|
||
} |
126 changes: 126 additions & 0 deletions
126
dspace-api/src/main/java/org/dspace/app/metadata/export/MetadataSchemaExportScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* 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.app.metadata.export; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.sql.SQLException; | ||
import java.text.MessageFormat; | ||
|
||
import org.apache.commons.cli.ParseException; | ||
import org.dspace.app.metadata.export.service.MetadataExportServiceFactory; | ||
import org.dspace.app.metadata.export.service.MetadataSchemaExportService; | ||
import org.dspace.content.MetadataSchema; | ||
import org.dspace.content.factory.ContentServiceFactory; | ||
import org.dspace.content.service.MetadataSchemaService; | ||
import org.dspace.core.Context; | ||
import org.dspace.scripts.DSpaceRunnable; | ||
import org.dspace.services.factory.DSpaceServicesFactory; | ||
|
||
/** | ||
* This script can be use to export a given {@code MetadataSchema} into its | ||
* registry file, that respects the standard DTD / XSD DSpace xml registry. | ||
* <p/> | ||
* This script is supposed to work with the webapp, it accepts only one | ||
* parameter {@code -i <schema-id>} representing the id of the schema that | ||
* will be exported. | ||
* | ||
* @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com) | ||
**/ | ||
public class MetadataSchemaExportScript | ||
extends DSpaceRunnable<MetadataSchemaExportScriptConfiguration<MetadataSchemaExportScript>> { | ||
|
||
protected static String REGISTRY_FILENAME_TEMPLATE = "{0}-types.xml"; | ||
|
||
protected MetadataSchemaService metadataSchemaService = | ||
ContentServiceFactory.getInstance().getMetadataSchemaService(); | ||
|
||
protected MetadataSchemaExportService metadataSchemaExportService = | ||
MetadataExportServiceFactory.getInstance().getMetadataSchemaExportService(); | ||
|
||
protected boolean help; | ||
protected int id; | ||
|
||
protected MetadataSchema metadataSchema; | ||
|
||
@Override | ||
public MetadataSchemaExportScriptConfiguration getScriptConfiguration() { | ||
return DSpaceServicesFactory | ||
.getInstance().getServiceManager() | ||
.getServiceByName("export-schema", MetadataSchemaExportScriptConfiguration.class); | ||
} | ||
|
||
@Override | ||
public void setup() throws ParseException { | ||
help = commandLine.hasOption('h'); | ||
try { | ||
id = Integer.parseInt(commandLine.getOptionValue('i')); | ||
} catch (Exception e) { | ||
handler.logError("Cannot parse the id argument ( " + id + " )! You should provide an integer!"); | ||
throw new ParseException("Cannot parse the id argument ( " + id + " )! You should provide an integer!"); | ||
} | ||
} | ||
|
||
@Override | ||
public void internalRun() throws Exception { | ||
if (help) { | ||
printHelp(); | ||
return; | ||
} | ||
|
||
Context context = new Context(); | ||
try { | ||
validate(context); | ||
exportMetadataSchema(context); | ||
} catch (Exception e) { | ||
context.abort(); | ||
throw e; | ||
} | ||
} | ||
|
||
private void validate(Context context) throws SQLException, ParseException { | ||
metadataSchema = this.metadataSchemaService.find(context, id); | ||
if (metadataSchema == null) { | ||
handler.logError("Cannot find the metadata-schema with id: " + id); | ||
throw new ParseException("Cannot find the metadata-schema with id: " + id); | ||
} | ||
} | ||
|
||
private void exportMetadataSchema(Context context) throws Exception { | ||
handler.logInfo( | ||
"Exporting the metadata-schema file for the schema " + metadataSchema.getName() | ||
); | ||
try { | ||
File tempFile = getExportedFile(context); | ||
|
||
handler.logInfo( | ||
"Exported to file: " + tempFile.getAbsolutePath() | ||
); | ||
|
||
try (FileInputStream fis = new FileInputStream(tempFile)) { | ||
handler.logInfo("Summarizing export ..."); | ||
context.turnOffAuthorisationSystem(); | ||
handler.writeFilestream( | ||
context, getFilename(metadataSchema), fis, "application/xml", false | ||
); | ||
context.restoreAuthSystemState(); | ||
} | ||
} catch (Exception e) { | ||
handler.logError("Problem occured while exporting the schema!", e); | ||
throw e; | ||
} | ||
} | ||
|
||
protected String getFilename(MetadataSchema ms) { | ||
return MessageFormat.format(REGISTRY_FILENAME_TEMPLATE, ms.getName()); | ||
} | ||
|
||
protected File getExportedFile(Context context) throws DspaceExportMetadataSchemaException { | ||
return this.metadataSchemaExportService.exportMetadataSchemaToFile(context, metadataSchema); | ||
} | ||
} |
Oops, something went wrong.