diff --git a/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java b/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java index f41438756a94c95a4f34cb0e84260d4d43de7b9b..0cfd33606891b420be662cc88e039c168c03b2f6 100644 --- a/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java +++ b/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java @@ -22,6 +22,8 @@ public class AggregationEntry { protected final Optional<Aggregation> parent; + private String baseName; + protected AggregationEntry(final ObjectType metadata) { this(metadata, null); } @@ -32,9 +34,6 @@ protected AggregationEntry(final ObjectType metadata, this.parent = Optional.fromNullable(parent); if (this.parent.isPresent()) { parent.add(this); - logger.info(MessageFormat.format("{0} has parent {1}", this, parent)); - } else { - logger.info(MessageFormat.format("{0} has no parent", this)); } } @@ -53,13 +52,14 @@ public ObjectType getMetadata() { * whether to append a content type specific extension. */ protected String getSimpleFileName(final boolean withExtension) { - final String baseName = - FilenamePolicy.getTransliterator().transliterate( - getMetadata().getGeneric().getProvided().getTitle().get(0)) - .concat(".") - .concat(URI.create( - getMetadata().getGeneric().getGenerated().getTextgridUri() - .getValue()).getSchemeSpecificPart()); + if (baseName == null) { + baseName = FilenamePolicy.getTransliterator().transliterate( + getMetadata().getGeneric().getProvided().getTitle().get(0)) + .concat(".") + .concat(URI.create( + getMetadata().getGeneric().getGenerated().getTextgridUri() + .getValue()).getSchemeSpecificPart()); + } if (withExtension) return FileExtensionMap.getInstance().addExtension(baseName, getFormat()); @@ -72,9 +72,9 @@ public String getFormat() { } public Optional<URI> getBase() { - if (getParent().isPresent()) { + if (getParent().isPresent()) return Optional.of(URI.create(getParent().get().getFileName(false).concat("/"))); - } else + else return Optional.absent(); } @@ -87,7 +87,7 @@ public Optional<URI> getBase() { * component of the path. */ protected File getFile(final boolean withExtension) { - Optional<Aggregation> parent = getParent(); + final Optional<Aggregation> parent = getParent(); if (parent.isPresent()) return new File(parent.get().getFile(false), getSimpleFileName(withExtension)); @@ -101,7 +101,7 @@ protected File getFile(final boolean withExtension) { * {@code {@linkplain #getFile(boolean) getFileName(true)}}. * @param withExtension TODO */ - public String getFileName(boolean withExtension) { + public String getFileName(final boolean withExtension) { return baseURI.relativize(getFile(withExtension).toURI()).toString(); }