Code cleaning
authorBruno Sinou <bsinou@argeo.org>
Wed, 30 Nov 2016 08:44:34 +0000 (08:44 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 30 Nov 2016 08:44:34 +0000 (08:44 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@9336 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.cms.ui.workbench/plugin.xml
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/commands/OpenFile.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/GenericNodeDoubleClickListener.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/SingleNodeAsTreeContentProvider.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/ImportFileSystem.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/UploadFiles.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ImportFileSystemWizard.java

index 691e893f39460aa7151a009dffc3163728d46629..f012695b81942af54674096104b79f1cf66621c3 100644 (file)
                        name="Delete nodes">
                </command>
                <command
-               defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.ImportFileSystem"
-               id="org.argeo.cms.ui.workbench.importFileSystem"
-               name="Import files...">
+               defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.UploadFiles"
+               id="org.argeo.cms.ui.workbench.uploadFiles"
+               name="Upload files">
                </command>
                <!-- <command
                defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                                </visibleWhen>
                        </command>
                        <command
-                               commandId="org.argeo.cms.ui.workbench.importFileSystem"
+                               commandId="org.argeo.cms.ui.workbench.uploadFiles"
                                icon="icons/import_fs.png"
                                style="push"
-                               tooltip="Import files from the files sytem">
+                               tooltip="Upload files from the local file sytem">
                                <visibleWhen>
                                        <iterate>
                                                <and>
index f7ffef15056a074cd1789d07332e293ef0e2fd6d..2b88c9d2a53bc98134d0a8d170fe70b0d64c3be8 100644 (file)
@@ -28,7 +28,7 @@ import org.eclipse.core.commands.ExecutionException;
  * 
  * <p>
  * The parameter "URI" is used to determine the correct file service, the path
- * and the file name. An optional file name can be precized to present a
+ * and the file name. An optional file name can be precised to present a
  * different file name as the one used to retrieve it to the end user.
  * </p>
  * 
@@ -44,13 +44,12 @@ import org.eclipse.core.commands.ExecutionException;
  */
 public class OpenFile extends AbstractHandler {
        // private final static Log log = LogFactory.getLog(OpenFile.class);
-
-       /* DEPENDENCY INJECTION */
-       private String openFileServiceId;
-
        public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".openFile";
+
        public final static String PARAM_FILE_NAME = OpenFileService.PARAM_FILE_NAME;
        public final static String PARAM_FILE_URI = OpenFileService.PARAM_FILE_URI; // "param.fileURI";
+       /* DEPENDENCY INJECTION */
+       private String openFileServiceId;
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
 
index d9fdb9b166d67fd87c019285edaa0e38c5ef3199..3cacd5da99f2b5c06ee42d3e54897a358fa73ff8 100644 (file)
  */
 package org.argeo.cms.ui.workbench.internal.jcr;
 
+import static javax.jcr.Node.JCR_CONTENT;
+import static javax.jcr.Property.JCR_DATA;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Binary;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 
+import org.apache.commons.io.IOUtils;
 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
+import org.argeo.cms.ui.workbench.commands.OpenFile;
 import org.argeo.cms.ui.workbench.internal.jcr.model.RepositoryElem;
 import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
 import org.argeo.cms.ui.workbench.internal.jcr.model.WorkspaceElem;
 import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericNodeEditorInput;
 import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
+import org.argeo.cms.ui.workbench.util.CommandUtils;
 import org.argeo.eclipse.ui.EclipseUiException;
+import org.argeo.eclipse.ui.specific.SingleSourcingException;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -53,8 +71,7 @@ public class GenericNodeDoubleClickListener implements IDoubleClickListener {
        public void doubleClick(DoubleClickEvent event) {
                if (event.getSelection() == null || event.getSelection().isEmpty())
                        return;
-               Object obj = ((IStructuredSelection) event.getSelection())
-                               .getFirstElement();
+               Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
                if (obj instanceof RepositoryElem) {
                        RepositoryElem rpNode = (RepositoryElem) obj;
                        if (!rpNode.isConnected()) {
@@ -73,41 +90,57 @@ public class GenericNodeDoubleClickListener implements IDoubleClickListener {
                        Node node = sjn.getNode();
                        try {
                                if (node.isNodeType(NodeType.NT_FILE)) {
-                                       // double click on a file node triggers its opening
-                                       // String name = node.getName();
-                                       // String id = node.getIdentifier();
+                                       // Also open it
+
+                                       String name = node.getName();
+                                       Map<String, String> params = new HashMap<String, String>();
+                                       params.put(OpenFile.PARAM_FILE_NAME, name);
 
-                                       // TODO add integration of direct retrieval of the binary in
-                                       // a JCR repo.
-                                       // Map<String, String> params = new HashMap<String,
-                                       // String>();
-                                       // params.put(OpenFile.PARAM_FILE_NAME, name);
-                                       // params.put(OpenFile.PARAM_FILE_URI, "jcr://" + id);
-                                       // CommandUtils
-                                       // .callCommand("org.argeo.security.ui.specific.openFile",
-                                       // params);
+                                       // TODO rather directly transmit the path to the node, once
+                                       // we have defined convention to provide an Absolute URI to
+                                       // a node in a multi repo / workspace / user context
+                                       // params.put(OpenFile.PARAM_FILE_URI,
+                                       // OpenFileService.JCR_SCHEME + node.getPath());
 
-                                       // For the file provider to be able to browse the
-                                       // various
-                                       // repository.
-                                       // TODO : enhanced that.
-                                       // ITreeContentProvider itcp = (ITreeContentProvider)
-                                       // nodeViewer
-                                       // .getContentProvider();
-                                       // jfp.setReferenceNode(node);
-                                       // if (fileHandler != null)
-                                       // fileHandler.openFile(name, id);
+                                       // we copy the node to a tmp file to be opened as a dirty
+                                       // workaround
+                                       File tmpFile = null;
+                                       OutputStream os = null;
+                                       InputStream is = null;
+                                       int i = name.lastIndexOf('.');
+                                       String prefix, suffix;
+                                       if (i == -1) {
+                                               prefix = name;
+                                               suffix = null;
+                                       } else {
+                                               prefix = name.substring(0, i);
+                                               suffix = name.substring(i);
+                                       }
+                                       try {
+                                               tmpFile = File.createTempFile(prefix, suffix);
+                                               tmpFile.deleteOnExit();
+                                               os = new FileOutputStream(tmpFile);
+                                               Binary binary = node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary();
+                                               is = binary.getStream();
+                                               IOUtils.copy(is, os);
+                                       } catch (IOException e) {
+                                               throw new SingleSourcingException("Cannot open file " + prefix + "." + suffix, e);
+                                       } finally {
+                                               IOUtils.closeQuietly(is);
+                                               IOUtils.closeQuietly(os);
+                                       }
+                                       Path path = Paths.get(tmpFile.getAbsolutePath());
+                                       String uri = path.toUri().toString();
+                                       params.put(OpenFile.PARAM_FILE_URI, uri);
+                                       CommandUtils.callCommand(OpenFile.ID, params);
                                }
                                GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
-                               WorkbenchUiPlugin.getDefault().getWorkbench()
-                                               .getActiveWorkbenchWindow().getActivePage()
+                               WorkbenchUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
                                                .openEditor(gnei, DefaultNodeEditor.ID);
                        } catch (RepositoryException re) {
-                               throw new EclipseUiException(
-                                               "Repository error while getting node info", re);
+                               throw new EclipseUiException("Repository error while getting node info", re);
                        } catch (PartInitException pie) {
-                               throw new EclipseUiException(
-                                               "Unexepected exception while opening node editor", pie);
+                               throw new EclipseUiException("Unexepected exception while opening node editor", pie);
                        }
                }
        }
index 558e35f4041cf19a047050ce10babe30ee447ec4..83ada24aafd6d3364831ed087a6a8a5eee7794ec 100644 (file)
@@ -46,15 +46,11 @@ public class SingleNodeAsTreeContentProvider implements ITreeContentProvider {
                        Node rootNode = (Node) inputElement;
                        List<Node> result = new ArrayList<Node>();
                        NodeIterator ni = rootNode.getNodes();
-                       while (ni.hasNext()) {
+                       while (ni.hasNext())
                                result.add(ni.nextNode());
-                       }
-
                        return result.toArray();
                } catch (RepositoryException re) {
-                       throw new EclipseUiException(
-                                       "Unexpected error while getting child nodes for children editor page ",
-                                       re);
+                       throw new EclipseUiException("Unable to retrieve elements for " + inputElement, re);
                }
        }
 
@@ -78,29 +74,27 @@ public class SingleNodeAsTreeContentProvider implements ITreeContentProvider {
                try {
                        return ((Node) element).hasNodes();
                } catch (RepositoryException e) {
-                       throw new EclipseUiException("Cannot check children of " + element, e);
+                       throw new EclipseUiException("Cannot check children existence on " + element, e);
                }
        }
 
-       public void dispose() {
-       }
-
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-       }
-
        protected Object[] childrenNodes(Node parentNode) {
                try {
                        List<Node> children = new ArrayList<Node>();
                        NodeIterator nit = parentNode.getNodes();
-                       while (nit.hasNext()) {
-                               Node node = nit.nextNode();
-                               children.add(node);
-                       }
-                       Node[] arr = children.toArray(new Node[children.size()]);
+                       while (nit.hasNext())
+                               children.add(nit.nextNode());
+                       Node[] arr = children.toArray(new Node[0]);
                        Arrays.sort(arr, itemComparator);
                        return arr;
                } catch (RepositoryException e) {
                        throw new EclipseUiException("Cannot list children of " + parentNode, e);
                }
        }
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
 }
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/ImportFileSystem.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/ImportFileSystem.java
deleted file mode 100644 (file)
index 0493ffe..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import javax.jcr.Node;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.workbench.internal.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.ImportFileSystemWizard;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Import a local file system directory tree. */
-public class ImportFileSystem extends AbstractHandler {
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
-                               .getActivePage().getSelection();
-               JcrBrowserView view = (JcrBrowserView) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage()
-                               .findView(HandlerUtil.getActivePartId(event));
-               if (selection != null && !selection.isEmpty()
-                               && selection instanceof IStructuredSelection) {
-                       Object obj = ((IStructuredSelection) selection).getFirstElement();
-                       try {
-                               Node folder = null;
-                               if (obj instanceof SingleJcrNodeElem) {
-                                       folder = ((SingleJcrNodeElem) obj).getNode();
-                               } else if (obj instanceof WorkspaceElem) {
-                                       folder = ((WorkspaceElem) obj).getRootNode();
-                               } else {
-                                       ErrorFeedback.show(WorkbenchUiPlugin
-                                                       .getMessage("warningInvalidNodeToImport"));
-                               }
-                               if (folder != null) {
-                                       ImportFileSystemWizard wizard = new ImportFileSystemWizard(
-                                                       folder);
-                                       WizardDialog dialog = new WizardDialog(
-                                                       HandlerUtil.getActiveShell(event), wizard);
-                                       dialog.open();
-                                       view.nodeAdded((TreeParent) obj);
-                               }
-                       } catch (Exception e) {
-                               ErrorFeedback.show("Cannot import files to " + obj, e);
-                       }
-               }
-               return null;
-       }
-}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/UploadFiles.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/UploadFiles.java
new file mode 100644 (file)
index 0000000..3470c8a
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.cms.ui.workbench.internal.jcr.commands;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
+import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
+import org.argeo.cms.ui.workbench.internal.jcr.model.WorkspaceElem;
+import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Upload local file(s) under the currently selected node */
+public class UploadFiles extends AbstractHandler {
+       // private final static Log log = LogFactory.getLog(ImportFileSystem.class);
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
+               JcrBrowserView view = (JcrBrowserView) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
+                               .findView(HandlerUtil.getActivePartId(event));
+               if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+                       Object obj = ((IStructuredSelection) selection).getFirstElement();
+                       try {
+                               Node folder = null;
+                               if (obj instanceof SingleJcrNodeElem) {
+                                       folder = ((SingleJcrNodeElem) obj).getNode();
+                               } else if (obj instanceof WorkspaceElem) {
+                                       folder = ((WorkspaceElem) obj).getRootNode();
+                               } else {
+                                       ErrorFeedback.show(WorkbenchUiPlugin.getMessage("warningInvalidNodeToImport"));
+                               }
+                               if (folder != null) {
+                                       FileDialog dialog = new FileDialog(HandlerUtil.getActiveShell(event), SWT.MULTI);
+                                       dialog.setText("Choose one or more files to upload");
+
+                                       if (EclipseUiUtils.notEmpty(dialog.open())) {
+                                               String[] names = dialog.getFileNames();
+                                               // Workaround small differences between RAP and RCP
+                                               // 1. returned names are absolute path on RAP and
+                                               // relative in RCP
+                                               // 2. in RCP we must use getFilterPath that does not
+                                               // exists on RAP
+                                               Method filterMethod = null;
+                                               Path parPath = null;
+
+                                               try {
+                                                       filterMethod = dialog.getClass().getDeclaredMethod("getFilterPath");
+                                                       String filterPath = (String) filterMethod.invoke(dialog);
+                                                       parPath = Paths.get(filterPath);
+                                               } catch (NoSuchMethodException nsme) { // RAP
+                                               }
+                                               if (names.length == 0)
+                                                       return null;
+                                               else {
+                                                       loop: for (String name : names) {
+                                                               Path path = Paths.get(name);
+                                                               if (parPath != null)
+                                                                       path = parPath.resolve(path);
+                                                               if (Files.exists(path)) {
+                                                                       URI uri = path.toUri();
+                                                                       String uriStr = uri.toString();
+                                                                       System.out.println(uriStr);
+
+                                                                       if (Files.isDirectory(path)) {
+                                                                               MessageDialog.openError(HandlerUtil.getActiveShell(event),
+                                                                                               "Unimplemented directory import",
+                                                                                               "Upload of directories in the system is not yet implemented");
+                                                                               continue loop;
+                                                                       }
+                                                                       Node fileNode = folder.addNode(path.getFileName().toString(), NodeType.NT_FILE);
+                                                                       Node resNode = fileNode.addNode(Property.JCR_CONTENT, NodeType.NT_RESOURCE);
+                                                                       Binary binary = null;
+                                                                       try (InputStream is = Files.newInputStream(path)) {
+                                                                               binary = folder.getSession().getValueFactory().createBinary(is);
+                                                                               resNode.setProperty(Property.JCR_DATA, binary);
+                                                                       }
+                                                                       folder.getSession().save();
+                                                               } else {
+                                                                       String msg = "Cannot upload file at " + path.toString();
+                                                                       if (parPath != null)
+                                                                               msg += "\nPlease remember that file upload fails when choosing files from the \"Recently Used\" bookmarks on some OS";
+                                                                       MessageDialog.openError(HandlerUtil.getActiveShell(event), "Missing file", msg);
+                                                                       continue loop;
+                                                               }
+                                                       }
+                                                       view.nodeAdded((TreeParent) obj);
+                                                       return true;
+                                               }
+                                       }
+                               }
+                       } catch (Exception e) {
+                               ErrorFeedback.show("Cannot import files to " + obj, e);
+                       }
+               }
+               return null;
+       }
+}
index 21857075e99e907ef0c03e331c0d7d3f8c18b1f7..b9acf6146b0f2ed680c290a7ffb2cd7d64de4e4a 100644 (file)
@@ -17,7 +17,6 @@ package org.argeo.cms.ui.workbench.internal.jcr.parts;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.InputStream;
 
 import javax.jcr.Binary;
 import javax.jcr.Node;
@@ -25,20 +24,16 @@ import javax.jcr.Property;
 import javax.jcr.nodetype.NodeType;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.CmsException;
 import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.eclipse.ui.specific.UploadFileWizardPage;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.wizard.Wizard;
 
 public class ImportFileSystemWizard extends Wizard {
-       private final static Log log = LogFactory
-                       .getLog(ImportFileSystemWizard.class);
+       private final static Log log = LogFactory.getLog(ImportFileSystemWizard.class);
 
        private UploadFileWizardPage importPage;
        private final Node folder;
@@ -46,13 +41,14 @@ public class ImportFileSystemWizard extends Wizard {
        public ImportFileSystemWizard(Node folder) {
                this.folder = folder;
                setWindowTitle("Import from file system");
+               throw new CmsException("Deprecated wizard, cannot be used");
        }
 
        @Override
        public void addPages() {
-               importPage = new UploadFileWizardPage();
-               addPage(importPage);
-               setNeedsProgressMonitor(importPage.getNeedsProgressMonitor());
+               // importPage = new UploadFileWizardPage();
+               // addPage(importPage);
+               // setNeedsProgressMonitor(importPage.getNeedsProgressMonitor());
        }
 
        /**
@@ -62,93 +58,94 @@ public class ImportFileSystemWizard extends Wizard {
        @Override
        public boolean performFinish() {
 
-               // Initialization
-               final String objectType = importPage.getObjectType();
-               final String objectPath = importPage.getObjectPath();
-
-               // We do not display a progress bar for one file only
-               if (UploadFileWizardPage.FILE_ITEM_TYPE.equals(objectType)) {
-                       // In Rap we must force the "real" upload of the file
-                       // importPage.performFinish();
-                       try {
-                               Node fileNode = folder.addNode(importPage.getObjectName(),
-                                               NodeType.NT_FILE);
-                               Node resNode = fileNode.addNode(Property.JCR_CONTENT,
-                                               NodeType.NT_RESOURCE);
-                               Binary binary = null;
-                               InputStream is = null;
-                               try {
-                                       is = importPage.getFileInputStream();
-                                       binary = folder.getSession().getValueFactory()
-                                                       .createBinary(is);
-                                       resNode.setProperty(Property.JCR_DATA, binary);
-                               } finally {
-                                       if (binary != null)
-                                               binary.dispose();
-                                       IOUtils.closeQuietly(is);
-                               }
-                               folder.getSession().save();
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               return false;
-                       }
-                       return true;
-               } else if (UploadFileWizardPage.FOLDER_ITEM_TYPE.equals(objectType)) {
-                       if (objectPath == null || !new File(objectPath).exists()) {
-                               ErrorFeedback.show("Directory " + objectPath
-                                               + " does not exist");
-                               return false;
-                       }
-
-                       Boolean failed = false;
-                       final File dir = new File(objectPath).getAbsoluteFile();
-                       final Long sizeB = directorySize(dir, 0l);
-                       final Stats stats = new Stats();
-                       Long begin = System.currentTimeMillis();
-                       try {
-                               getContainer().run(true, true, new IRunnableWithProgress() {
-                                       public void run(IProgressMonitor monitor) {
-                                               try {
-                                                       Integer sizeKB = (int) (sizeB / FileUtils.ONE_KB);
-                                                       monitor.beginTask("", sizeKB);
-                                                       importDirectory(folder, dir, monitor, stats);
-                                                       monitor.done();
-                                               } catch (Exception e) {
-                                                       if (e instanceof RuntimeException)
-                                                               throw (RuntimeException) e;
-                                                       else
-                                                               throw new EclipseUiException("Cannot import "
-                                                                               + objectPath, e);
-                                               }
-                                       }
-                               });
-                       } catch (Exception e) {
-                               ErrorFeedback.show("Cannot import " + objectPath, e);
-                               failed = true;
-                       }
-
-                       Long duration = System.currentTimeMillis() - begin;
-                       Long durationS = duration / 1000l;
-                       String durationStr = (durationS / 60) + " min " + (durationS % 60)
-                                       + " s";
-                       StringBuffer message = new StringBuffer("Imported\n");
-                       message.append(stats.fileCount).append(" files\n");
-                       message.append(stats.dirCount).append(" directories\n");
-                       message.append(FileUtils.byteCountToDisplaySize(stats.sizeB));
-                       if (failed)
-                               message.append(" of planned ").append(
-                                               FileUtils.byteCountToDisplaySize(sizeB));
-                       message.append("\n");
-                       message.append("in ").append(durationStr).append("\n");
-                       if (failed)
-                               MessageDialog.openError(getShell(), "Import failed",
-                                               message.toString());
-                       else
-                               MessageDialog.openInformation(getShell(), "Import successful",
-                                               message.toString());
-
-                       return true;
-               }
+               // // Initialization
+               // final String objectType = importPage.getObjectType();
+               // final String objectPath = importPage.getObjectPath();
+               //
+               // // We do not display a progress bar for one file only
+               // if (UploadFileWizardPage.FILE_ITEM_TYPE.equals(objectType)) {
+               // // In Rap we must force the "real" upload of the file
+               // // importPage.performFinish();
+               // try {
+               // Node fileNode = folder.addNode(importPage.getObjectName(),
+               // NodeType.NT_FILE);
+               // Node resNode = fileNode.addNode(Property.JCR_CONTENT,
+               // NodeType.NT_RESOURCE);
+               // Binary binary = null;
+               // InputStream is = null;
+               // try {
+               // is = importPage.getFileInputStream();
+               // binary = folder.getSession().getValueFactory()
+               // .createBinary(is);
+               // resNode.setProperty(Property.JCR_DATA, binary);
+               // } finally {
+               // if (binary != null)
+               // binary.dispose();
+               // IOUtils.closeQuietly(is);
+               // }
+               // folder.getSession().save();
+               // } catch (Exception e) {
+               // e.printStackTrace();
+               // return false;
+               // }
+               // return true;
+               // } else if (UploadFileWizardPage.FOLDER_ITEM_TYPE.equals(objectType))
+               // {
+               // if (objectPath == null || !new File(objectPath).exists()) {
+               // ErrorFeedback.show("Directory " + objectPath
+               // + " does not exist");
+               // return false;
+               // }
+               //
+               // Boolean failed = false;
+               // final File dir = new File(objectPath).getAbsoluteFile();
+               // final Long sizeB = directorySize(dir, 0l);
+               // final Stats stats = new Stats();
+               // Long begin = System.currentTimeMillis();
+               // try {
+               // getContainer().run(true, true, new IRunnableWithProgress() {
+               // public void run(IProgressMonitor monitor) {
+               // try {
+               // Integer sizeKB = (int) (sizeB / FileUtils.ONE_KB);
+               // monitor.beginTask("", sizeKB);
+               // importDirectory(folder, dir, monitor, stats);
+               // monitor.done();
+               // } catch (Exception e) {
+               // if (e instanceof RuntimeException)
+               // throw (RuntimeException) e;
+               // else
+               // throw new EclipseUiException("Cannot import "
+               // + objectPath, e);
+               // }
+               // }
+               // });
+               // } catch (Exception e) {
+               // ErrorFeedback.show("Cannot import " + objectPath, e);
+               // failed = true;
+               // }
+               //
+               // Long duration = System.currentTimeMillis() - begin;
+               // Long durationS = duration / 1000l;
+               // String durationStr = (durationS / 60) + " min " + (durationS % 60)
+               // + " s";
+               // StringBuffer message = new StringBuffer("Imported\n");
+               // message.append(stats.fileCount).append(" files\n");
+               // message.append(stats.dirCount).append(" directories\n");
+               // message.append(FileUtils.byteCountToDisplaySize(stats.sizeB));
+               // if (failed)
+               // message.append(" of planned ").append(
+               // FileUtils.byteCountToDisplaySize(sizeB));
+               // message.append("\n");
+               // message.append("in ").append(durationStr).append("\n");
+               // if (failed)
+               // MessageDialog.openError(getShell(), "Import failed",
+               // message.toString());
+               // else
+               // MessageDialog.openInformation(getShell(), "Import successful",
+               // message.toString());
+               //
+               // return true;
+               // }
                return false;
 
        }
@@ -170,14 +167,12 @@ public class ImportFileSystemWizard extends Wizard {
        /**
         * Import recursively a directory and its content to the repository.
         */
-       protected void importDirectory(Node folder, File dir,
-                       IProgressMonitor monitor, Stats stats) {
+       protected void importDirectory(Node folder, File dir, IProgressMonitor monitor, Stats stats) {
                try {
                        File[] files = dir.listFiles();
                        for (File file : files) {
                                if (file.isDirectory()) {
-                                       Node childFolder = folder.addNode(file.getName(),
-                                                       NodeType.NT_FOLDER);
+                                       Node childFolder = folder.addNode(file.getName(), NodeType.NT_FOLDER);
                                        importDirectory(childFolder, file, monitor, stats);
                                        folder.getSession().save();
                                        stats.dirCount++;
@@ -186,23 +181,16 @@ public class ImportFileSystemWizard extends Wizard {
                                        // we skip temporary files that are created by apps when a
                                        // file is being edited.
                                        // TODO : make this configurable.
-                                       if (file.getName().lastIndexOf('~') != file.getName()
-                                                       .length() - 1) {
+                                       if (file.getName().lastIndexOf('~') != file.getName().length() - 1) {
 
-                                               monitor.subTask(file.getName() + " ("
-                                                               + FileUtils.byteCountToDisplaySize(fileSize)
-                                                               + ") " + file.getCanonicalPath());
+                                               monitor.subTask(file.getName() + " (" + FileUtils.byteCountToDisplaySize(fileSize) + ") "
+                                                               + file.getCanonicalPath());
                                                try {
-                                                       Node fileNode = folder.addNode(file.getName(),
-                                                                       NodeType.NT_FILE);
-                                                       Node resNode = fileNode.addNode(
-                                                                       Property.JCR_CONTENT, NodeType.NT_RESOURCE);
+                                                       Node fileNode = folder.addNode(file.getName(), NodeType.NT_FILE);
+                                                       Node resNode = fileNode.addNode(Property.JCR_CONTENT, NodeType.NT_RESOURCE);
                                                        Binary binary = null;
                                                        try {
-                                                               binary = folder
-                                                                               .getSession()
-                                                                               .getValueFactory()
-                                                                               .createBinary(new FileInputStream(file));
+                                                               binary = folder.getSession().getValueFactory().createBinary(new FileInputStream(file));
                                                                resNode.setProperty(Property.JCR_DATA, binary);
                                                        } finally {
                                                                if (binary != null)
@@ -212,11 +200,7 @@ public class ImportFileSystemWizard extends Wizard {
                                                        stats.fileCount++;
                                                        stats.sizeB = stats.sizeB + fileSize;
                                                } catch (Exception e) {
-                                                       log.warn("Import of "
-                                                                       + file
-                                                                       + " ("
-                                                                       + FileUtils
-                                                                                       .byteCountToDisplaySize(fileSize)
+                                                       log.warn("Import of " + file + " (" + FileUtils.byteCountToDisplaySize(fileSize)
                                                                        + ") failed: " + e);
                                                        folder.getSession().refresh(false);
                                                }
@@ -225,8 +209,7 @@ public class ImportFileSystemWizard extends Wizard {
                                }
                        }
                } catch (Exception e) {
-                       throw new EclipseUiException("Cannot import " + dir + " to " + folder,
-                                       e);
+                       throw new EclipseUiException("Cannot import " + dir + " to " + folder, e);
                }
        }