Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-477

import mode can be selected from servlet

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 2.1 Final
    • None
    • admininterface
    • None
    • Any (OSX 10.4.2, Jetty , Java 1.4)

      Would like to be able to select the import mode when using the Import/Export servlet.

      int importMode = ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW;

      is no more static but is actually a parameter in the post request.

      It is possible to have the fix included in SVN ?
      Also, at the same time, if the html in both the import and export could be CSSized, that would be great.

      Patch (without CSS) is here:
      Index: /Users/niko/Documents/workspace/Magnolia/src/main/info/magnolia/cms/servlets/ImportExportServlet.java
      ===================================================================
      — /Users/niko/Documents/workspace/Magnolia/src/main/info/magnolia/cms/servlets/ImportExportServlet.java (revision 1128)
      +++ /Users/niko/Documents/workspace/Magnolia/src/main/info/magnolia/cms/servlets/ImportExportServlet.java (working copy)
      @@ -61,6 +61,11 @@

      • request parameter: keep versions.
        */
        private static final String PARAM_KEEPVERSIONS = "mgnlKeepVersions"; //$NON-NLS-1$
        +
        + /**
        + * request parameter: override
        + */
        + private static final String PARAM_OVERRIDE = "mgnlOverride"; //$NON-NLS-1$

      /**

      • request parameter: imported file.
        @@ -172,6 +177,7 @@
        writeRepositoryField(request, out, repository);
        writeBasePathField(request, out, basepath);
        writeKeepVersionField(request, out);
        + writeOverwriteField(request,out);
        out.println(MessagesManager.get(request, "importexport.file") //$NON-NLS-1$
        + " <input type=\"file\" name=\"" + PARAM_FILE + "\" /><br/>"); //$NON-NLS-1$//$NON-NLS-2$

      @@ -202,6 +208,15 @@
      + " <input name=\"" //$NON-NLS-1$
      + PARAM_KEEPVERSIONS + "\" value=\"true\" type=\"checkbox\"/><br/>"); //$NON-NLS-1$
      }
      +
      + /**
      + * @param out
      + */
      + private void writeOverrideField(HttpServletRequest request, PrintWriter out)

      { + out.println(MessagesManager.get(request, "importexport.override") //$NON-NLS-1$ + + " <input name=\"" //$NON-NLS-1$ + + PARAM_OVERRIDE + "\" value=\"true\" type=\"checkbox\"/><br/>"); //$NON-NLS-1$ + }

      /**

      • @param out
        @@ -244,6 +259,8 @@
        }

      boolean keepVersionHistory = BooleanUtils.toBoolean(form.getParameter(PARAM_KEEPVERSIONS));
      +
      + boolean override = BooleanUtils.toBoolean(form.getParameter(PARAM_OVERRIDE));

      String repository = form.getParameter(PARAM_REPOSITORY);
      Document xmlFile = form.getDocument(PARAM_FILE);
      @@ -251,7 +268,7 @@
      throw new RuntimeException("Wrong parameters"); //$NON-NLS-1$
      }

      • executeImport(basepath, repository, xmlFile, keepVersionHistory);
        + executeImport(basepath, repository, xmlFile, keepVersionHistory,override);

      String redirectPage = form.getParameter(PARAM_REDIRECT);
      if (StringUtils.isNotBlank(redirectPage)) {
      @@ -346,8 +363,9 @@

      • @param basepath base path in repository
      • @param xmlFile uploaded file
      • @param keepVersionHistory if <code>false</code> version info will be stripped before importing the document
        + * @param override if <code>true</code> set import mode to <code>ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW</code>
        */
      • private void executeImport(String basepath, String repository, Document xmlFile, boolean keepVersionHistory) {
        + private void executeImport(String basepath, String repository, Document xmlFile, boolean keepVersionHistory,boolean override) {
        HierarchyManager hr = ContentRepository.getHierarchyManager(repository);
        Workspace ws = hr.getWorkspace();

      @@ -365,6 +383,9 @@
      if ("website".equals(repository))

      { //$NON-NLS-1$ importMode = ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING; }

      +
      + if(override)
      + importMode = ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING;

      try {
      if (keepVersionHistory) {

        Acceptance criteria

              fgiust Fabrizio Giustina
              modrzyk Nicolas Modrzyk
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD