APM-57-Dry-run-summary
Changing way of creating name for dry run history entry
@@ -27,16 +27,18 @@ import com.google.common.collect.ImmutableMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
public class DryRunHistoryEntryNamingStrategy implements HistoryEntryNamingStrategy {
@Override
public Resource getHistoryEntryResource(ResourceResolver resolver, Resource historyFolder, String fileName)
throws PersistenceException {
- Resource historyLogResource = resolver.getResource(historyFolder, "dryRun-" + fileName);
+ String uniqueName = ResourceUtil.createUniqueChildName(historyFolder, "dryRun-" + fileName);
+ Resource historyLogResource = resolver.getResource(historyFolder, uniqueName);
if (historyLogResource == null) {
historyLogResource = resolver
- .create(historyFolder, "dryRun-" + fileName, ImmutableMap.of(JCR_PRIMARYTYPE, NT_UNSTRUCTURED));
+ .create(historyFolder, uniqueName, ImmutableMap.of(JCR_PRIMARYTYPE, NT_UNSTRUCTURED));
}
return historyLogResource;
}
