Tobias Jeger pushed to branch bugfix/HCM-187 at cms-community / hippo-configuration-management
Commits: 876ff1d2 by Tobias Jeger at 2017-08-09T14:28:51+02:00 HCM-187 Reduce duplicated logic - - - - - 1 changed file: - model/src/main/java/org/onehippo/cm/model/serializer/AutoExportModuleWriter.java Changes: ===================================== model/src/main/java/org/onehippo/cm/model/serializer/AutoExportModuleWriter.java ===================================== --- a/model/src/main/java/org/onehippo/cm/model/serializer/AutoExportModuleWriter.java +++ b/model/src/main/java/org/onehippo/cm/model/serializer/AutoExportModuleWriter.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Set; import org.onehippo.cm.model.Module; import org.onehippo.cm.model.impl.ModuleImpl; @@ -47,15 +48,14 @@ public class AutoExportModuleWriter extends ModuleWriter { private void removeDeletedResources(final ModuleContext moduleContext) throws IOException { final ModuleImpl module = moduleContext.getModule(); - log.debug("removing config resources: \n\t{}", String.join("\n\t", module.getRemovedConfigResources())); - log.debug("removing content resources: \n\t{}", String.join("\n\t", module.getRemovedContentResources())); - for (final String removed : module.getRemovedConfigResources()) { - final Path removedPath = moduleContext.getConfigOutputProvider().getResourcePath(null, removed); - boolean wasDeleted = Files.deleteIfExists(removedPath); - log.debug("File to be deleted: {}, was deleted: {}", removedPath, wasDeleted); - } - for (final String removed : module.getRemovedContentResources()) { - final Path removedPath = moduleContext.getContentOutputProvider().getResourcePath(null, removed); + removeResources(module.getRemovedConfigResources(), moduleContext.getConfigOutputProvider()); + removeResources(module.getRemovedContentResources(), moduleContext.getContentOutputProvider()); + } + + private void removeResources(final Set<String> removedResources, final ResourceOutputProvider resourceOutputProvider) + throws IOException { + for (final String removed : removedResources) { + final Path removedPath = resourceOutputProvider.getResourcePath(null, removed); boolean wasDeleted = Files.deleteIfExists(removedPath); log.debug("File to be deleted: {}, was deleted: {}", removedPath, wasDeleted); } View it on GitLab: https://code.onehippo.org/cms-community/hippo-configuration-management/commit/876ff1d2a26d87b1acf4f1e9825f17f240f42f55 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-configuration-management/commit/876ff1d2a26d87b1acf4f1e9825f17f240f42f55 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn