Skip to content
Snippets Groups Projects
Commit cbadb7e2 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

Support for leaving out meta and aggregation files

parent 993cd116
No related branches found
No related tags found
No related merge requests found
...@@ -162,7 +162,7 @@ public Response getZIP( ...@@ -162,7 +162,7 @@ public Response getZIP(
@Context final Request request) throws MetadataParseFault, ObjectNotFoundFault, IoFault, AuthFault, ProtocolNotImplementedFault, IOException, SaxonApiException { @Context final Request request) throws MetadataParseFault, ObjectNotFoundFault, IoFault, AuthFault, ProtocolNotImplementedFault, IOException, SaxonApiException {
final ZipResult zipResult = new ZipResult(repository, request, uriList, filenames, metanames, dirnames, only); final ZipResult zipResult = new ZipResult(repository, request, uriList, filenames, metanames, dirnames, only, meta);
if (title != null) if (title != null)
zipResult.setTitle(title); zipResult.setTitle(title);
if (sid != null) if (sid != null)
......
...@@ -60,6 +60,7 @@ public class ZipResult extends AbstractExporter implements StreamingOutput { ...@@ -60,6 +60,7 @@ public class ZipResult extends AbstractExporter implements StreamingOutput {
private final Set<URI> written = Sets.newHashSet(); private final Set<URI> written = Sets.newHashSet();
private boolean onlySomeFormats; private boolean onlySomeFormats;
private List<MediaType> onlyFormats; private List<MediaType> onlyFormats;
private boolean includeMeta;
private static final Function<ObjectType, String> GetURI = new Function<ObjectType, String>() { private static final Function<ObjectType, String> GetURI = new Function<ObjectType, String>() {
...@@ -74,7 +75,7 @@ public String apply(final ObjectType input) { ...@@ -74,7 +75,7 @@ public String apply(final ObjectType input) {
public ZipResult(final ITextGridRep repository, final Request request, public ZipResult(final ITextGridRep repository, final Request request,
final String uriList, final String filenames, final String uriList, final String filenames,
final String metanames, final String dirnames, final String metanames, final String dirnames,
final List<String> only) { final List<String> only, final boolean includeMeta) {
super(repository, request, uriList); super(repository, request, uriList);
final ConfigurableFilenamePolicy parentPolicy = ConfigurableFilenamePolicy final ConfigurableFilenamePolicy parentPolicy = ConfigurableFilenamePolicy
.builder(dirnames) .builder(dirnames)
...@@ -104,6 +105,7 @@ public MediaType apply(final String input) { ...@@ -104,6 +105,7 @@ public MediaType apply(final String input) {
setFileExtension("zip"); setFileExtension("zip");
setMediaType("application/zip"); setMediaType("application/zip");
this.includeMeta = includeMeta;
} }
@Override @Override
...@@ -245,7 +247,8 @@ private void writeAggregation(final ZipOutputStream zip, ...@@ -245,7 +247,8 @@ private void writeAggregation(final ZipOutputStream zip,
logger.log(Level.WARNING, "Skipping duplicate aggregation {0}", uri); logger.log(Level.WARNING, "Skipping duplicate aggregation {0}", uri);
return; return;
} }
writeFile(zip, root); if (includeMeta)
writeFile(zip, root);
// final ZipEntry zipEntry = new ZipEntry(policy.getFilename(root, true) // final ZipEntry zipEntry = new ZipEntry(policy.getFilename(root, true)
// .toString()); // .toString());
// zip.putNextEntry(zipEntry); // zip.putNextEntry(zipEntry);
...@@ -323,6 +326,10 @@ private void writeFile(final ZipOutputStream zip, ...@@ -323,6 +326,10 @@ private void writeFile(final ZipOutputStream zip,
private void writeMetadata(final ZipOutputStream zip, private void writeMetadata(final ZipOutputStream zip,
final IAggregationEntry child) throws IOException { final IAggregationEntry child) throws IOException {
if (!includeMeta)
return;
final ZipEntry zipEntry = new ZipEntry(metaPolicy.getFilename(child).toString()); final ZipEntry zipEntry = new ZipEntry(metaPolicy.getFilename(child).toString());
zipEntry.setTime(child.getMetadata().getGeneric().getGenerated() zipEntry.setTime(child.getMetadata().getGeneric().getGenerated()
.getLastModified().toGregorianCalendar().getTimeInMillis()); .getLastModified().toGregorianCalendar().getTimeInMillis());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment