diff --git a/ccm-core/src/com/arsdigita/portation/AbstractConversion.java b/ccm-core/src/com/arsdigita/portation/AbstractConversion.java new file mode 100644 index 000000000..27db4bfa4 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/AbstractConversion.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.portation; + +/** + * Abstract class for converting all trunk objects of a certain class into + * objects of their corresponding ng classes. + * + * @author exportList) { - File file = new File(filename); FileWriter fileWriter = null; - try { + final Path filePath = Paths.get(pathName, fileName); + Files.createFile(filePath); + + final File file = new File(filePath.toString()); fileWriter = new FileWriter(file); - } catch (IOException e) { - log.error(String.format("Unable to open a fileWriter for the file" + - " with the name %s.", file.getName())); + } catch (FileAlreadyExistsException e) { + // destination file already exists + } catch (IOException ex) { + System.err.printf("ERROR Unable to open a fileWriter for the file" + + " with the name %s.\n %s\n", fileName, ex); } - if (fileWriter != null) { + + if (objectMapper != null && fileWriter != null) { + if (indentation) { + objectMapper.enable(SerializationFeature.INDENT_OUTPUT); + } + objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); + + String line = null; for (P object : exportList) { - String line = null; - - switch (format) { - case XML: - try { - line = xmlMapper.writeValueAsString(object); - //log.info(line); - } catch (IOException e) { - log.error(String.format( - "Unable to write objetct of %s as XML " + - "string with name %s in file %s.", - object.getClass(), - object.toString(), - file.getName()), e); - } - break; - - default: - break; + try { + line = objectMapper.writeValueAsString(object); + } catch (JsonProcessingException ex) { + System.err.printf("ERROR Unable to write object of class " + + "%s as XML string with name %s " + + "in file %s.\n %s\n", object.getClass(), + object.toString(), fileName, ex); } - if (line != null) { try { fileWriter.write(line); fileWriter.write(System.getProperty("line.separator")); - } catch (IOException e) { - log.error(String.format( - "Unable to write to file with the name %s.", - file.getName())); + } catch (IOException ex) { + System.err.printf("ERROR Unable to write to file with" + + " the name %s.\n %s\n", fileName, ex); } } } try { fileWriter.close(); - } catch (IOException e) { - log.error(String.format("Unable to close a fileWriter for the" + - " file with the name %s.", file.getName())); + } catch (IOException ex) { + System.err.printf("ERROR Unable to close a fileWriter for" + + " a file with the name %s.\n %s\n", fileName, ex); } - } } } diff --git a/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java b/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java index c2149ad1e..45f8e0627 100644 --- a/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java +++ b/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java @@ -18,13 +18,10 @@ */ package com.arsdigita.portation.cmd; -import com.arsdigita.portation.conversion.CoreConverter; -import com.arsdigita.portation.modules.CoreExporter; +import com.arsdigita.portation.AbstractExporter; +import com.arsdigita.portation.Format; import com.arsdigita.util.cmd.Program; import org.apache.commons.cli.CommandLine; -import org.apache.log4j.Logger; - -import java.lang.reflect.Method; /** * A Commandline tool for exporting all the objects of specified classes to @@ -34,9 +31,6 @@ import java.lang.reflect.Method; * @version created on 25.05.16 */ public class ExportCliTool extends Program { - - private final static Logger logger = Logger.getLogger(ExportCliTool.class); - /** * Constructor for the command line tool. */ @@ -104,30 +98,16 @@ public class ExportCliTool extends Program { /** * Method for converting all trunk objects into ng objects at once. */ - @SuppressWarnings("unchecked") private void convert() { try { - System.err.println("Started conversions of systems objects to " + + System.out.println("Started conversions of systems objects to " + "ng-objects:"); - - // Core conversions - CoreConverter.getInstance().startConversionToNg(); - - // Lnd-Terms conversions - Class cls = Class - .forName("com.arsdigita.london.terms.portation" + - ".conversion.LdnTermsConverter"); - if (cls != null) { - Method startConversionToNg = cls - .getDeclaredMethod("startConversionToNg"); - startConversionToNg.invoke(cls.newInstance()); - } - - System.err.println("Finished conversions."); - System.out.printf("\n"); + RootConverter.rootConversionExecution(); + System.out.println("Finished conversions."); + System.out.print("\n"); } catch (Exception e) { - logger.error("ERROR while converting trunk-objects to " + - "ng-objects", e); + System.err.printf("ERROR while converting trunk-objects to " + + "ng-objects: %s\n", e); e.printStackTrace(); } } @@ -138,41 +118,30 @@ public class ExportCliTool extends Program { * * @param args The secondary command line arguments */ - @SuppressWarnings("unchecked") private void export(String[] args) { if (args.length != 2) { printUsage(); System.exit(-1); } - //final String moduleClass = args[1]; - //System.err.printf("module-class: %s\n", moduleClass); + final Format format = Format.XML; final String pathName = args[1]; - System.err.printf("path for export: %s\n", pathName); - CoreExporter.setPath(pathName); - System.err.printf("\n"); - + final boolean ind = false; + System.out.printf("format to export to: %s\n", format.toString()); + System.out.printf("path to export to: %s\n", pathName); + System.out.printf("indentations in files: %b\n", ind); + AbstractExporter.setFormat(format); + AbstractExporter.setPath(pathName); + AbstractExporter.setIndentation(ind); + System.out.print("\n"); try { System.out.println("Started exporting all ng-objects:"); - - // Core - CoreExporter.startExport(); - - // Ldn-Terms - Class cls = Class - .forName("com.arsdigita.london.terms.portation.modules" + - ".LdnTermsExporter"); - if (cls != null) { - Method startExport = cls - .getDeclaredMethod("startExport"); - startExport.invoke(cls.newInstance()); - } - + RootExporter.rootExportExecution(); System.out.println("Finished exports."); - System.out.printf("\n"); + System.out.print("\n"); } catch (Exception ex) { - logger.error("ERROR while exporting", ex); + System.err.printf("ERROR while exporting: %s\n", ex); } } @@ -180,25 +149,25 @@ public class ExportCliTool extends Program { * Prints the usage of this command line tool. */ private void printUsage() { - System.err.printf( + System.out.print( "\n" + - "\t\t\t --- ExportCliTool ---\n" + + "\t\t\t\t --- ExportCliTool ---\n" + "\n" + - "usage:\t \n" + + "Usage:\t\n" + "\n" + "Available commands:\n" + "\thelp" + "\t\t\t\t\t Shows information on how to use this tool.\n" + "\tconvert" + "\t\t\t\t\t Converts all trunk objects to ng objects.\n" + - "\texport " + - "\t\t Exports the chosen module class to a file\n" + + "\texport " + + "\t\t\t\t Exports the chosen module class to a file\n" + "\t\t\t\t" + "\t\t at the location specified by the given path." + "\n" + "\n" + "Available module-classes for export:\n" + - " \t\t categories \t\t all categories of the system\n" + + /*" \t\t categories \t\t all categories of the system\n" + " \t\t categorizations \t\t all categorizations of the system\n" + " \t\t users \t\t all users of the system\n" + " \t\t groups \t\t all groups of the system\n" + @@ -212,9 +181,8 @@ public class ExportCliTool extends Program { " \t\t permissions \t\t all permissions of the system\n" + " \n" + " \t\t default: \t\t all objects of the entire core module" + + */"\n" + "\n" + - "\n" + - "" + "Do use for exporting java objects of a specified class.\n" + "\n" ); diff --git a/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java b/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java new file mode 100644 index 000000000..202be4537 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.portation.cmd; + +import com.arsdigita.portation.conversion.CoreConverter; + +import java.lang.reflect.Method; + +/** + * Helper class to bundle all conversion calls. + * + * @author trunkCategories = com .arsdigita.categorization.Category.getAllObjectCategories(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting categories and categorizations...\n"); + System.out.print("\tConverting categories and categorizations...\n"); createCategoryAndCategorizations(trunkCategories); setRingAssociations(trunkCategories); - System.err.printf("\tSorting categories...\n"); + System.out.print("\tSorting categories...\n"); sortCategoryMap(); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -68,7 +75,7 @@ public class CategoryConversion { * {@link com.arsdigita.categorization.Category}s * from this old trunk-system. */ - private static void createCategoryAndCategorizations( + private void createCategoryAndCategorizations( List trunkCategories) { int processedCategories = 0, processedCategorizations = 0; @@ -88,7 +95,7 @@ public class CategoryConversion { processedCategories++; } - System.err.printf("\t\tCreated %d categories and\n" + + System.out.printf("\t\tCreated %d categories and\n" + "\t\tcreated %d categorizations.\n", processedCategories, processedCategorizations); } @@ -104,7 +111,7 @@ public class CategoryConversion { * * @return Number of how many {@link Categorization}s have been processed. */ - private static long createCategorizations(Category category, + private long createCategorizations(Category category, CategorizedCollection categorizedObjects) { int processed = 0; @@ -140,7 +147,7 @@ public class CategoryConversion { * {@link com.arsdigita.categorization.Category}s * from this old trunk-system. */ - private static void setRingAssociations( + private void setRingAssociations( List trunkCategories) { for (com.arsdigita.categorization.Category trunkCategory : trunkCategories) { @@ -176,7 +183,7 @@ public class CategoryConversion { * Runs once over the unsorted map and iterates over each their parents * to add them to the sorted list. */ - private static void sortCategoryMap() { + private void sortCategoryMap() { ArrayList sortedList = new ArrayList<>(); int runs = 0; @@ -190,7 +197,7 @@ public class CategoryConversion { } NgCoreCollection.sortedCategories = sortedList; - System.err.printf("\t\tSorted categories in %d runs.\n", runs); + System.out.printf("\t\tSorted categories in %d runs.\n", runs); } /** @@ -200,7 +207,7 @@ public class CategoryConversion { * @param sortedList Map of already sorted categories * @param category Current category */ - private static void addParent(ArrayList sortedList, Category + private void addParent(ArrayList sortedList, Category category) { Category parent = category.getParentCategory(); @@ -211,4 +218,13 @@ public class CategoryConversion { sortedList.add(parent); } } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static CategoryConversion getInstance() { + return instance; + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java index 86bd9744c..8a9652912 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java @@ -19,6 +19,7 @@ package com.arsdigita.portation.conversion.core.security; import com.arsdigita.kernel.UserCollection; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.Group; import com.arsdigita.portation.modules.core.security.GroupMembership; @@ -34,7 +35,12 @@ import java.util.List; * @author trunkGroups = com.arsdigita.kernel .Group.getAllObjectGroups(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting groups and group memberships...\n"); + System.out.print("\tConverting groups and group memberships...\n"); createGroupsAndSetAssociations(trunkGroups); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -61,7 +68,7 @@ public class GroupConversion { * @param trunkGroups List of all {@link com.arsdigita.kernel.Group}s * from this old trunk-system. */ - private static void createGroupsAndSetAssociations( + private void createGroupsAndSetAssociations( List trunkGroups) { int pGroups = 0, pMemberships = 0; @@ -75,7 +82,7 @@ public class GroupConversion { pGroups++; } - System.err.printf("\t\tCreated %d groups and\n" + + System.out.printf("\t\tCreated %d groups and\n" + "\t\tcreated %d group memberships.\n", pGroups, pMemberships); } @@ -90,7 +97,7 @@ public class GroupConversion { * {@link com.arsdigita.kernel.User}s belonging to * the given group */ - private static long createGroupMemberships(Group group, UserCollection + private long createGroupMemberships(Group group, UserCollection userCollection) { int processed = 0; @@ -115,4 +122,12 @@ public class GroupConversion { return processed; } + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static GroupConversion getInstance() { + return instance; + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java index cda63046b..badfa646a 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java @@ -19,6 +19,7 @@ package com.arsdigita.portation.conversion.core.security; import com.arsdigita.kernel.RoleCollection; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.security.*; @@ -39,8 +40,13 @@ import java.util.stream.Collectors; * @author trunkPermissions = com.arsdigita.kernel.permissions.Permission .getAllObjectPermissions(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting permissions...\n"); + System.out.print("\tConverting permissions...\n"); createPermissionsAndSetAssociations(trunkPermissions); try { @@ -68,7 +75,7 @@ public class PermissionConversion { System.exit(-1); } - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -79,7 +86,7 @@ public class PermissionConversion { * {@link com.arsdigita.kernel.permissions.Permission}s * from the old trunk-system */ - private static void createPermissionsAndSetAssociations(final List trunkPermissions) { int processed = 0, skipped = 0; @@ -95,7 +102,7 @@ public class PermissionConversion { .get("id")).longValue() || -200 == ((BigDecimal) trunkPermission.getPartyOID() .get("id")).longValue()) { - /*System.err.println( + /*System.out.println( "Skiping because it is a internal permission");*/ skipped++; continue; @@ -125,7 +132,7 @@ public class PermissionConversion { processed++; } - System.err.printf("\t\tCreated %d permissions and skipped: %d.\n", + System.out.printf("\t\tCreated %d permissions and skipped: %d.\n", processed, skipped); } @@ -148,7 +155,7 @@ public class PermissionConversion { * {@link com.arsdigita.kernel.permissions.Permission}s * from the old trunk-system */ - private static void setGranteeDependency(final List trunkPermissions) { int duplicates = 0; @@ -248,7 +255,7 @@ public class PermissionConversion { trunkPermission.getACSObject().get("id")).longValue()); } } - System.err.printf("\t\t(Created %d duplicates and created %d new " + + System.out.printf("\t\t(Created %d duplicates and created %d new " + "roles.)\n", duplicates, rolesCreated); } @@ -259,7 +266,7 @@ public class PermissionConversion { * * @return A role for the specified member */ - private static Role getRoleIfExists(Party member) { + private Role getRoleIfExists(Party member) { // might cause problems cause the // task assignments are missing String roleName = member.getName() + "_role"; @@ -280,4 +287,13 @@ public class PermissionConversion { return granteeRole; } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static PermissionConversion getInstance() { + return instance; + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java index cab181c0f..881c318ee 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java @@ -20,6 +20,7 @@ package com.arsdigita.portation.conversion.core.security; import com.arsdigita.kernel.PartyCollection; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.Party; import com.arsdigita.portation.modules.core.security.Role; @@ -35,7 +36,12 @@ import java.util.List; * @author trunkRoles = com.arsdigita.kernel .Role.getAllObjectRoles(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tCreating roles and role memberships...\n"); + System.out.print("\tCreating roles and role memberships...\n"); createRolesAndSetAssociations(trunkRoles); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -61,7 +68,7 @@ public class RoleConversion { * @param trunkRoles List of all {@link com.arsdigita.kernel.Role}s from * this old trunk-system. */ - private static void createRolesAndSetAssociations( + private void createRolesAndSetAssociations( List trunkRoles) { int pRoles = 0, pMemberships = 0; @@ -90,7 +97,7 @@ public class RoleConversion { * {@link com.arsdigita.kernel.Party}s belonging to * the given group */ - private static long createRoleMemberships(Role role, PartyCollection + private long createRoleMemberships(Role role, PartyCollection partyCollection) { int processed = 0; @@ -112,4 +119,13 @@ public class RoleConversion { return processed; } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static RoleConversion getInstance() { + return instance; + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/UserConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/UserConversion.java index d9f3b80fb..2af6daed3 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/UserConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/UserConversion.java @@ -18,6 +18,7 @@ */ package com.arsdigita.portation.conversion.core.security; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.modules.core.security.User; import java.util.List; @@ -30,20 +31,26 @@ import java.util.List; * @author trunkUsers = com.arsdigita.kernel .User.getAllObjectUsers(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting users...\n"); + System.out.print("\tConverting users...\n"); // create users int processed = 0; for (com.arsdigita.kernel.User trunkUser : trunkUsers) { @@ -51,6 +58,15 @@ public class UserConversion { processed++; } System.out.printf("\t\tCreated %d users.\n", processed); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); + } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static UserConversion getInstance() { + return instance; } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java index 128bbdac8..2b3b1293d 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java @@ -21,11 +21,11 @@ package com.arsdigita.portation.conversion.core.workflow; import com.arsdigita.kernel.GroupCollection; import com.arsdigita.kernel.RoleCollection; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.Role; import com.arsdigita.portation.modules.core.security.User; import com.arsdigita.portation.modules.core.workflow.AssignableTask; -import com.arsdigita.portation.modules.core.workflow.Task; import com.arsdigita.portation.modules.core.workflow.TaskAssignment; import com.arsdigita.portation.modules.core.workflow.TaskComment; import com.arsdigita.portation.modules.core.workflow.TaskDependency; @@ -44,8 +44,12 @@ import java.util.List; * @author trunkUserTasks = com .arsdigita.workflow.simple.UserTask.getAllObjectUserTasks(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting assignable tasks, task dependencies " + + System.out.print("\tConverting assignable tasks, task dependencies " + "and task assignments...\n"); createAssignableTasksAndSetAssociations(trunkUserTasks); - System.err.printf("\tSorting task assignments...\n"); + System.out.print("\tSorting task assignments...\n"); sortAssignableTaskMap(); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } @@ -77,7 +82,7 @@ public class AssignableTaskConversion { * {@link com.arsdigita.workflow.simple.UserTask}s * from this old trunk-system. */ - private static void createAssignableTasksAndSetAssociations(List trunkUserTasks) { int pTasks = 0, pAssignments = 0, pDependencies = 0; @@ -148,13 +153,13 @@ public class AssignableTaskConversion { pTasks++; - /*System.err.printf("\t\tTasks: %d, " + + /*System.out.printf("\t\tTasks: %d, " + "Dependencies: %d, " + "Assignments: %d\n", pTasks, pDependencies, pAssignments);*/ } - System.err.printf("\t\tCreated %d assignable tasks and\n" + + System.out.printf("\t\tCreated %d assignable tasks and\n" + "\t\tCreated %d task dependencies and\n" + "\t\tcreated %d task assignments.\n", pTasks, pDependencies, pAssignments); @@ -172,7 +177,7 @@ public class AssignableTaskConversion { * @param dependencyIt An iterator representing all dependencies of the * given assignableTask */ - private static long createTaskDependencies(AssignableTask assignableTask, + private long createTaskDependencies(AssignableTask assignableTask, Iterator dependencyIt) { int processed = 0; @@ -211,7 +216,7 @@ public class AssignableTaskConversion { * {@link com.arsdigita.kernel.Role}s belonging to * the assignableTask */ - private static long createTaskAssignments(AssignableTask assignableTask, + private long createTaskAssignments(AssignableTask assignableTask, GroupCollection groupCollection) { int processed = 0; @@ -245,7 +250,7 @@ public class AssignableTaskConversion { * Runs once over the unsorted map and iterates over each their dependencies * to add them to the sorted list. */ - private static void sortAssignableTaskMap() { + private void sortAssignableTaskMap() { ArrayList sortedList = new ArrayList<>(); int runs = 0; @@ -262,7 +267,7 @@ public class AssignableTaskConversion { } NgCoreCollection.sortedAssignableTasks = sortedList; - System.err.printf("\t\tSorted assignable tasks in %d runs.\n", runs); + System.out.printf("\t\tSorted assignable tasks in %d runs.\n", runs); } /** @@ -273,7 +278,7 @@ public class AssignableTaskConversion { * @param sortedList List of already sorted tasks * @param assignableTask Current assignable task */ - private static void addDependencies(ArrayList sortedList, + private void addDependencies(ArrayList sortedList, AssignableTask assignableTask) { List dependencies = assignableTask.getBlockingTasks(); @@ -290,4 +295,13 @@ public class AssignableTaskConversion { } } } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static AssignableTaskConversion getInstance() { + return instance; + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskCommentConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskCommentConversion.java index 38898d219..2d810199e 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskCommentConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskCommentConversion.java @@ -18,6 +18,7 @@ */ package com.arsdigita.portation.conversion.core.workflow; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.User; import com.arsdigita.portation.modules.core.workflow.TaskComment; @@ -33,7 +34,12 @@ import java.util.List; * @author trunkTaskComments = com .arsdigita.workflow.simple.TaskComment.getAllTaskComments(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting task comments...\n"); + System.out.print("\tConverting task comments...\n"); createTaskCommentsAndSetAssociations(trunkTaskComments); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } @@ -61,7 +68,7 @@ public class TaskCommentConversion { * {@link com.arsdigita.workflow.simple.TaskComment}s * from this old trunk-system. */ - private static void createTaskCommentsAndSetAssociations( + private void createTaskCommentsAndSetAssociations( List trunkTaskComments) { int processed = 0; @@ -82,6 +89,15 @@ public class TaskCommentConversion { processed++; } - System.err.printf("\t\tCreated %d task comments.\n", processed); + System.out.printf("\t\tCreated %d task comments.\n", processed); + } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static TaskCommentConversion getInstance() { + return instance; } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java index 77ac5af26..6abc990ea 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java @@ -19,6 +19,7 @@ package com.arsdigita.portation.conversion.core.workflow; import com.arsdigita.kernel.ACSObject; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.categorization.Category; import com.arsdigita.portation.modules.core.core.CcmObject; @@ -39,26 +40,32 @@ import java.util.Map; * @author trunkWorkflows = com.arsdigita.workflow.simple.Workflow.getAllObjectWorkflows(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting workflows...\n"); + System.out.print("\tConverting workflows...\n"); createWorkflowAndSetAssociations(trunkWorkflows); setTemplateAssociations(trunkWorkflows); - System.err.printf("\tSorting workflows...\n"); + System.out.print("\tSorting workflows...\n"); sortWorkflowMap(); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -69,7 +76,7 @@ public class WorkflowConversion { * {@link com.arsdigita.workflow.simple.Workflow}s * from this old trunk-system. */ - private static void createWorkflowAndSetAssociations( + private void createWorkflowAndSetAssociations( List trunkWorkflows) { int processed = 0; @@ -90,7 +97,7 @@ public class WorkflowConversion { processed++; } - System.err.printf("\t\tCreated %d workflows.\n", processed); + System.out.printf("\t\tCreated %d workflows.\n", processed); } /** @@ -101,7 +108,7 @@ public class WorkflowConversion { * {@link com.arsdigita.workflow.simple.Workflow}s * from this old trunk-system. */ - private static void setTemplateAssociations( + private void setTemplateAssociations( List trunkWorkflows) { int processed = 0; @@ -123,7 +130,7 @@ public class WorkflowConversion { } else processed++; } - System.err.printf("\t\tFound %d templates.\n", processed); + System.out.printf("\t\tFound %d templates.\n", processed); } /** @@ -134,7 +141,7 @@ public class WorkflowConversion { * Runs once over the unsorted list and iterates over each their templates * to add them to the sorted list. */ - private static void sortWorkflowMap() { + private void sortWorkflowMap() { ArrayList sortedList = new ArrayList<>(); int runs = 0; @@ -150,7 +157,7 @@ public class WorkflowConversion { } NgCoreCollection.sortedWorkflows = sortedList; - System.err.printf("\t\tSorted workflows in %d runs.\n", runs); + System.out.printf("\t\tSorted workflows in %d runs.\n", runs); } /** @@ -160,7 +167,7 @@ public class WorkflowConversion { * @param sortedList List of already sorted workflows * @param workflow Current workflow */ - private static void addTemplate(ArrayList sortedList, Workflow + private void addTemplate(ArrayList sortedList, Workflow workflow) { Workflow template = workflow.getTemplate(); @@ -171,4 +178,13 @@ public class WorkflowConversion { sortedList.add(template); } } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static WorkflowConversion getInstance() { + return instance; + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java b/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java index 0a3e0173d..8fa517e7e 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java +++ b/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java @@ -36,161 +36,52 @@ import java.util.ArrayList; * @version created on 25.07.2016 */ public class CoreExporter extends AbstractExporter { - public static void startExport() { - exportUsers(); - exportGroups(); - exportGroupMemberships(); - exportRoles(); - exportRoleMemberships(); - exportCategories(); - exportCategorizations(); + private static CoreExporter instance; - exportPermissions(); - - exportWorkflows(); - exportTaskComments(); - exportAssignableTasks(); - exportTaskDependencies(); - exportTaskAssignments(); + static { + instance = new CoreExporter(); } - - private static void exportUsers() { - System.out.printf("\tExporting users..."); - UserMarshaller userMarshaller = new UserMarshaller(); - userMarshaller.prepare( - Format.XML, pathName, "users", indentation); - userMarshaller.exportList( - new ArrayList<>(NgCoreCollection.users.values())); - System.out.printf("\t\tdone.\n"); + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static CoreExporter getInstance() { + return instance; } - private static void exportGroups() { - System.out.printf("\tExporting groups..."); - GroupMarshaller groupMarshaller = new GroupMarshaller(); - groupMarshaller.prepare( - Format.XML, pathName, "groups", indentation); - groupMarshaller.exportList( - new ArrayList<>(NgCoreCollection.groups.values())); - System.out.printf("\t\tdone.\n"); - } + @Override + public void startMarshaller() { + UserMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + GroupMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + GroupMembershipMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + RoleMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + RoleMembershipMarshaller.getInstance(). + marshallAll(format, pathName, indentation); - private static void exportGroupMemberships() { - System.out.printf("\tExporting group memberships..."); - GroupMembershipMarshaller groupMembershipMarshaller = new - GroupMembershipMarshaller(); - groupMembershipMarshaller.prepare( - Format.XML, pathName, "groupMemberships", indentation); - groupMembershipMarshaller.exportList( - new ArrayList<>(NgCoreCollection.groupMemberships.values())); - System.out.printf("\tdone.\n"); - } + CategoryMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + CategorizationMarshaller.getInstance(). + marshallAll(format, pathName, indentation); - private static void exportRoles() { - System.out.printf("\tExporting roles..."); - RoleMarshaller roleMarshaller = new RoleMarshaller(); - roleMarshaller.prepare( - Format.XML, pathName, "roles", indentation); - roleMarshaller.exportList( - new ArrayList<>(NgCoreCollection.roles.values())); - System.out.printf("\t\tdone.\n"); - } + PermissionMarshaller.getInstance(). + marshallAll(format, pathName, indentation); - private static void exportRoleMemberships() { - System.out.printf("\tExporting role memberships..."); - RoleMembershipMarshaller roleMembershipMarshaller = new - RoleMembershipMarshaller(); - roleMembershipMarshaller.prepare( - Format.XML, pathName, "roleMemberships", indentation); - roleMembershipMarshaller.exportList( - new ArrayList<>(NgCoreCollection.roleMemberships.values())); - System.out.printf("\tdone.\n"); - } - - private static void exportCategories() { - System.out.printf("\tExporting categories..."); - CategoryMarshaller categoryMarshaller = new CategoryMarshaller(); - categoryMarshaller.prepare( - Format.XML, pathName, "categories", indentation); - categoryMarshaller.exportList( - NgCoreCollection.sortedCategories); - System.out.printf("\t\tdone.\n"); - } - - private static void exportCategorizations() { - System.out.printf("\tExporting categorizations..."); - CategorizationMarshaller categorizationMarshaller = new - CategorizationMarshaller(); - categorizationMarshaller.prepare( - Format.XML, pathName, "categorizations", indentation); - categorizationMarshaller.exportList( - new ArrayList<>(NgCoreCollection.categorizations.values())); - System.out.printf("\tdone.\n"); - } - - private static void exportPermissions() { - System.out.printf("\tExporting permissions..."); - PermissionMarshaller permissionMarshaller = new - PermissionMarshaller(); - permissionMarshaller.prepare( - Format.XML, pathName, "permissions", indentation); - permissionMarshaller.exportList( - new ArrayList<>(NgCoreCollection.permissions.values())); - System.out.printf("\tdone.\n"); - } - - private static void exportWorkflows() { - System.out.printf("\tExporting workflows..."); - WorkflowMarshaller workflowMarshaller = new WorkflowMarshaller(); - workflowMarshaller.prepare( - Format.XML, pathName, "workflows", indentation); - workflowMarshaller.exportList( - NgCoreCollection.sortedWorkflows); - System.out.printf("\t\tdone.\n"); - } - - private static void exportTaskComments() { - System.out.printf("\tExporting task comments..."); - TaskCommentMarshaller taskCommentMarshaller = new - TaskCommentMarshaller(); - taskCommentMarshaller.prepare( - Format.XML, pathName, "taskComments", indentation); - taskCommentMarshaller.exportList( - new ArrayList<>(NgCoreCollection.taskComments.values())); - System.out.printf("\tdone.\n"); - } - - private static void exportAssignableTasks() { - System.out.printf("\tExporting assignable tasks..."); - AssignableTaskMarshaller assignableTaskMarshaller = new - AssignableTaskMarshaller(); - assignableTaskMarshaller.prepare( - Format.XML, pathName, "assignableTasks", indentation); - assignableTaskMarshaller.exportList( - NgCoreCollection.sortedAssignableTasks); - System.out.printf("\tdone.\n"); - } - - private static void exportTaskDependencies() { - System.out.printf("\tExporting task dependencies..."); - TaskDependencyMarshaller taskDependencyMarshaller = new - TaskDependencyMarshaller(); - taskDependencyMarshaller.prepare( - Format.XML, pathName, "taskDependencies", indentation); - taskDependencyMarshaller.exportList( - new ArrayList<>(NgCoreCollection.taskDependencies.values())); - System.out.printf("\tdone.\n"); - } - - private static void exportTaskAssignments() { - System.out.printf("\tExporting task assignments..."); - TaskAssignmentMarshaller taskAssignmentMarshaller = new - TaskAssignmentMarshaller(); - taskAssignmentMarshaller.prepare( - Format.XML, pathName, "taskAssignments", indentation); - taskAssignmentMarshaller.exportList( - new ArrayList<>(NgCoreCollection.taskAssignments.values())); - System.out.printf("\tdone.\n"); + WorkflowMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + TaskCommentMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + AssignableTaskMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + TaskDependencyMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + TaskAssignmentMarshaller.getInstance(). + marshallAll(format, pathName, indentation); } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationMarshaller.java index e73b9f69e..25bfa9039 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationMarshaller.java @@ -7,7 +7,7 @@ * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of + * but WITHerr ANY WARRANTY; witherr even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * @@ -19,10 +19,49 @@ package com.arsdigita.portation.modules.core.categorization; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.categorizations.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategoryMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategoryMarshaller.java index cf0436624..c5a2db698 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategoryMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategoryMarshaller.java @@ -19,10 +19,47 @@ package com.arsdigita.portation.modules.core.categorization; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; /** * @author (NgCoreCollection.groups.values())); + System.out.print("\t\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembershipMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembershipMarshaller.java index e8b5df47a..db7301cdf 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembershipMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembershipMarshaller.java @@ -19,10 +19,49 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.groupMemberships.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionMarshaller.java index 2ec3b7606..e6db0c74f 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionMarshaller.java @@ -19,10 +19,49 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.permissions.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMarshaller.java index a28f28ac5..6f899bff0 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMarshaller.java @@ -19,10 +19,49 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.roles.values())); + System.out.print("\t\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipMarshaller.java index c30545067..0308e7939 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipMarshaller.java @@ -19,10 +19,49 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.roleMemberships.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/UserMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/UserMarshaller.java index 67863b4cc..e8ef9c147 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/UserMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/UserMarshaller.java @@ -19,10 +19,48 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.users.values())); + System.out.print("\t\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTaskMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTaskMarshaller.java index aee1caf97..8acf7c276 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTaskMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTaskMarshaller.java @@ -19,10 +19,47 @@ package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; /** * @author (NgCoreCollection.taskAssignments.values())); + System.out.print("\tdone.\n"); + + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskCommentMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskCommentMarshaller.java index 40d986d51..c5bfe6eb3 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskCommentMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskCommentMarshaller.java @@ -19,10 +19,49 @@ package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.taskComments.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskDependencyMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskDependencyMarshaller.java index 4ddaf7958..f052ada87 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskDependencyMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskDependencyMarshaller.java @@ -7,7 +7,7 @@ * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of + * but WITHerr ANY WARRANTY; witherr even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * @@ -19,6 +19,10 @@ package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; + +import java.util.ArrayList; /** * @author (NgCoreCollection.taskDependencies.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowMarshaller.java index a9bbf1ce2..dbcf9f400 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowMarshaller.java @@ -19,10 +19,47 @@ package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; /** * @author trunkDomains = com .arsdigita.london.terms.Domain.getAllObjectDomains(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting domains and domain ownerships...\n"); + System.out.print("\tConverting domains and domain ownerships...\n"); createDomainsAndSetAssociations(trunkDomains); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -65,7 +72,7 @@ public class DomainConversion { * @param trunkDomains List of all {@link com.arsdigita.london.terms.Domain}s * from this old trunk-system. */ - private static void createDomainsAndSetAssociations( + private void createDomainsAndSetAssociations( List trunkDomains) { int processedDomains = 0, processedDomainOwnerships = 0; @@ -91,7 +98,7 @@ public class DomainConversion { processedDomains++; } - System.err.printf("\t\tCreated %d domains and\n" + + System.out.printf("\t\tCreated %d domains and\n" + "\t\tcreated %d domain ownerships.\n", processedDomains, processedDomainOwnerships); } @@ -107,7 +114,7 @@ public class DomainConversion { * * @return Number of how many {@link DomainOwnership}s have been processed. */ - private static long createDomainOwnerships(Domain domain, + private long createDomainOwnerships(Domain domain, DomainCollection useContexts) { int processed = 0; @@ -142,5 +149,12 @@ public class DomainConversion { return processed; } - + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static DomainConversion getInstance() { + return instance; + } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/core/ResourceTypeConversion.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/core/ResourceTypeConversion.java index 50de219d7..7e456fc2b 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/core/ResourceTypeConversion.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/core/ResourceTypeConversion.java @@ -19,6 +19,7 @@ package com.arsdigita.london.terms.portation.conversion.core.core; import com.arsdigita.london.terms.portation.modules.core.core.ResourceType; +import com.arsdigita.portation.AbstractConversion; import java.util.List; @@ -30,20 +31,27 @@ import java.util.List; * @author trunkResourceTypes = com .arsdigita.kernel.ResourceType.getAllObjectResourceTypes(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting domains...\n"); + System.out.print("\tConverting domains...\n"); // create resource types int processed = 0; for (com.arsdigita.kernel.ResourceType trunkResourceType : @@ -52,6 +60,15 @@ public class ResourceTypeConversion { processed++; } System.out.printf("\t\tCreated %d resource types.\n", processed); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); + } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static ResourceTypeConversion getInstance() { + return instance; } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/web/CcmApplicationConversion.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/web/CcmApplicationConversion.java index 095f33a48..265bf97b2 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/web/CcmApplicationConversion.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/web/CcmApplicationConversion.java @@ -23,6 +23,7 @@ import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; import com.arsdigita.london.terms.portation.modules.core.core.Resource; import com.arsdigita.london.terms.portation.modules.core.core.ResourceType; import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication; +import com.arsdigita.portation.AbstractConversion; import com.arsdigita.web.Application; import java.util.ArrayList; @@ -36,28 +37,35 @@ import java.util.List; * @author trunkApplications = Application .getAllApplicationObjects(); - System.err.println("done."); + System.out.println("done."); - System.err.printf("\tConverting ccm applications...\n"); + System.out.print("\tConverting ccm applications...\n"); // create ccm applications createCcmApplicationsAndSetAssociations(trunkApplications); setRingAssociations(trunkApplications); - System.err.printf("\tSorting ccm applications...\n"); + System.out.print("\tSorting ccm applications...\n"); sortCcmApplications(); - System.err.println("\tdone.\n"); + System.out.println("\tdone.\n"); } /** @@ -67,7 +75,7 @@ public class CcmApplicationConversion { * @param trunkApplications List of all {@link Application}s * from this old trunk-system. */ - private static void createCcmApplicationsAndSetAssociations( + private void createCcmApplicationsAndSetAssociations( List trunkApplications) { int processed = 0; @@ -86,11 +94,9 @@ public class CcmApplicationConversion { ccmApplication.setResourceType(resourceType); } - //System.err.println(String.format( - // "ccm application id: %d", ccmApplication.getObjectId())); processed++; } - System.err.printf("\t\tCreated %d ccm applications.\n", processed); + System.out.printf("\t\tCreated %d ccm applications.\n", processed); } /** @@ -101,14 +107,14 @@ public class CcmApplicationConversion { * @param trunkApplications List of all {@link Application} from the old * trunk-system. */ - private static void setRingAssociations(List trunkApplications) { + private void setRingAssociations(List trunkApplications) { for (Application trunkApplication : trunkApplications) { CcmApplication ccmApplication = NgCoreCollection .ccmApplications .get(trunkApplication.getID().longValue()); // set parent Resource and opposed association - CcmApplication parentResource = null; + CcmApplication parentResource; Application trunkParent = trunkApplication .getParentApplication(); @@ -130,7 +136,7 @@ public class CcmApplicationConversion { * Runs once over the unsorted list and iterates over each their parents * to add them to the sorted list. */ - private static void sortCcmApplications() { + private void sortCcmApplications() { ArrayList sortedList = new ArrayList<>(); int runs = 0; @@ -145,7 +151,7 @@ public class CcmApplicationConversion { } NgCoreCollection.sortedCcmApplications = sortedList; - System.err.printf("\t\tSorted ccm applications in %d runs.\n", runs); + System.out.printf("\t\tSorted ccm applications in %d runs.\n", runs); } /** @@ -155,7 +161,7 @@ public class CcmApplicationConversion { * @param sortedList List of already sorted assignable tasks * @param ccmApplication Current assignable task */ - private static void addResourceParent(ArrayList sortedList, + private void addResourceParent(ArrayList sortedList, CcmApplication ccmApplication) { CcmApplication resourceParent = (CcmApplication) ccmApplication .getParent(); @@ -167,4 +173,13 @@ public class CcmApplicationConversion { sortedList.add(resourceParent); } } + + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static CcmApplicationConversion getInstance() { + return instance; + } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java index 533b5e69b..5008245de 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java @@ -25,6 +25,7 @@ import com.arsdigita.london.terms.portation.modules.core.categorization.DomainMa import com.arsdigita.london.terms.portation.modules.core.web.CcmApplicationMarshaller; import com.arsdigita.portation.AbstractExporter; import com.arsdigita.portation.Format; +import com.arsdigita.portation.modules.CoreExporter; import java.util.ArrayList; @@ -40,53 +41,30 @@ import java.util.ArrayList; */ public class LdnTermsExporter extends AbstractExporter { - public static void startExport() { - exportResourceTypes(); - exportCcmApplications(); - exportDomains(); - exportDomainOwnerships(); + private static LdnTermsExporter instance; + + static { + instance = new LdnTermsExporter(); } - private static void exportResourceTypes() { - System.out.printf("\tExporting resource types..."); - ResourceTypeMarshaller resourceTypeMarshaller = new - ResourceTypeMarshaller(); - resourceTypeMarshaller.prepare( - Format.XML, pathName, "resourceTypes", indentation); - resourceTypeMarshaller.exportList( - new ArrayList<>(NgCoreCollection.resourceTypes.values())); - System.out.printf("\tdone.\n"); + /** + * Getter for the instance of the singleton. + * + * @return instance of this singleton + */ + public static LdnTermsExporter getInstance() { + return instance; } - private static void exportCcmApplications() { - System.out.printf("\tExporting ccm applications..."); - CcmApplicationMarshaller ccmApplicationMarshaller = new - CcmApplicationMarshaller(); - ccmApplicationMarshaller.prepare( - Format.XML, pathName, "ccmApplications", indentation); - ccmApplicationMarshaller.exportList( - NgCoreCollection.sortedCcmApplications); - System.out.printf("\tdone.\n"); - } - - private static void exportDomains() { - System.out.printf("\tExporting domains..."); - DomainMarshaller domainMarshaller = new DomainMarshaller(); - domainMarshaller.prepare( - Format.XML, pathName, "domains", indentation); - domainMarshaller.exportList( - new ArrayList<>(NgCoreCollection.domains.values())); - System.out.printf("\t\tdone.\n"); - } - - private static void exportDomainOwnerships() { - System.out.printf("\tExporting domain ownerships..."); - DomainOwnershipMarshaller domainOwnershipMarshaller = new - DomainOwnershipMarshaller(); - domainOwnershipMarshaller.prepare( - Format.XML, pathName, "domainOwnerships", indentation); - domainOwnershipMarshaller.exportList( - new ArrayList<>(NgCoreCollection.domainOwnerships.values())); - System.out.printf("\tdone.\n"); + @Override + public void startMarshaller() { + ResourceTypeMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + CcmApplicationMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + DomainMarshaller.getInstance(). + marshallAll(format, pathName, indentation); + DomainOwnershipMarshaller.getInstance(). + marshallAll(format, pathName, indentation); } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainMarshaller.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainMarshaller.java index b5d7a5e17..995b33535 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainMarshaller.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainMarshaller.java @@ -18,11 +18,50 @@ */ package com.arsdigita.london.terms.portation.modules.core.categorization; +import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; + +import java.util.ArrayList; /** * @author (NgCoreCollection.domains.values())); + System.out.print("\t\tdone.\n"); + } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainOwnershipMarshaller.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainOwnershipMarshaller.java index c7b6d9b6b..fa4f87844 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainOwnershipMarshaller.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainOwnershipMarshaller.java @@ -18,11 +18,50 @@ */ package com.arsdigita.london.terms.portation.modules.core.categorization; +import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; + +import java.util.ArrayList; /** * @author (NgCoreCollection.domainOwnerships.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceType.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceType.java index 6566c78c5..4e5db1504 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceType.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceType.java @@ -29,7 +29,7 @@ import java.util.Locale; /** * This class is a port of the old {@code ResourceType} entity. * - * @deprecated The real purpose of this class is not clear. Also the + * /@deprecated The real purpose of this class is not clear. Also the * informations provided by the entities of this class are all quite static or * can be interfered from the classes itself. In modern Java most if not all the * informations provided by the entities of this class would be expressed as diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceTypeMarshaller.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceTypeMarshaller.java index 44473b338..0ff31ef0b 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceTypeMarshaller.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceTypeMarshaller.java @@ -18,12 +18,50 @@ */ package com.arsdigita.london.terms.portation.modules.core.core; -import com.arsdigita.london.terms.portation.modules.core.core.ResourceType; +import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; + +import java.util.ArrayList; /** * @author (NgCoreCollection.resourceTypes.values())); + System.out.print("\tdone.\n"); + } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplicationMarshaller.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplicationMarshaller.java index 363ef20f3..d2f8c29c6 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplicationMarshaller.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplicationMarshaller.java @@ -18,11 +18,48 @@ */ package com.arsdigita.london.terms.portation.modules.core.web; +import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; import com.arsdigita.portation.AbstractMarshaller; +import com.arsdigita.portation.Format; /** * @author