Example usage for org.dom4j Node valueOf

List of usage examples for org.dom4j Node valueOf

Introduction

In this page you can find the example usage for org.dom4j Node valueOf.

Prototype

String valueOf(String xpathExpression);

Source Link

Document

valueOf evaluates an XPath expression and returns the textual representation of the results the XPath string-value of this node.

Usage

From source file:org.collectionspace.chain.csp.persistence.services.authorization.AuthorizationStorage.java

License:Educational Community License

/**
 * Returns a list of csid's from a certain type of record
 *//*from   ww  w.j a  v a 2s .c  om*/
@SuppressWarnings("unchecked")
public String[] getPaths(ContextualisedStorage root, CSPRequestCredentials creds, CSPRequestCache cache,
        String rootPath, JSONObject restrictions)
        throws ExistException, UnimplementedException, UnderlyingStorageException {
    try {
        Document list = null;
        List<String> out = new ArrayList<String>();
        String path = getRestrictedPath(r.getServicesURL(), restrictions, "res", "", false, "");

        ReturnedDocument all = conn.getXMLDocument(RequestMethod.GET, path, null, creds, cache);
        if (all.getStatus() != 200) {
            throw new ConnectionException("Bad request in Authorization Storage: status not 200",
                    all.getStatus(), path);
        }
        list = all.getDocument();
        List<Node> objects = list.selectNodes(r.getServicesListPath());

        for (Node object : objects) {
            String csid = object.valueOf("@csid");
            out.add(csid);
            setGleanedValue(cache, r.getServicesURL() + "/" + csid, view_map.get(object.getName()),
                    object.getText());
        }

        return out.toArray(new String[0]);
    } catch (ConnectionException e) {
        throw new UnderlyingStorageException("Service layer exception" + e.getLocalizedMessage(), e.getStatus(),
                e.getUrl(), e);
    } catch (UnsupportedEncodingException e) {
        throw new UnderlyingStorageException("Service layer exception" + e.getLocalizedMessage(), e);
    } catch (JSONException e) {
        throw new UnderlyingStorageException("Service layer exception" + e.getLocalizedMessage(), e);
    }
}

From source file:org.collectionspace.chain.csp.persistence.services.GenericStorage.java

License:Educational Community License

/**
 * return list view of items including hard deleted
 * @param root//from w  ww  .  j a  v a 2  s .c  o m
 * @param creds
 * @param cache
 * @param path
 * @param nodeName
 * @param matchlistitem
 * @param csidfield
 * @param fullcsid
 * @param view_map
 * @return
 * @throws ConnectionException
 * @throws JSONException
 */
// CSPACE-5988: Allow view_map to be passed as a parameter, instead of using the instance variable.
protected JSONObject getRepeatableHardListView(ContextualisedStorage root, CSPRequestCredentials creds,
        CSPRequestCache cache, String path, String nodeName, String matchlistitem, String csidfield,
        Boolean fullcsid, Map<String, String> view_map) throws ConnectionException, JSONException {
    JSONObject out = new JSONObject();
    JSONObject pagination = new JSONObject();
    Document list = null;
    List<JSONObject> listitems = new ArrayList<JSONObject>();
    ReturnedDocument all = conn.getXMLDocument(RequestMethod.GET, path, null, creds, cache);
    if (all.getStatus() != 200) {
        //throw new StatusException(all.getStatus(),path,"Bad request during identifier cache map update: status not 200");
        throw new ConnectionException("Bad request during identifier cache map update: status not 200 is "
                + Integer.toString(all.getStatus()), all.getStatus(), path);
    }
    list = all.getDocument();

    List<Node> nodes = list.selectNodes(nodeName);
    if (matchlistitem.equals("roles_list/*") || matchlistitem.equals("permissions_list/*")) {
        //XXX hack to deal with roles being inconsistent
        //XXX CSPACE-1887 workaround
        for (Node node : nodes) {
            if (node.matches(matchlistitem)) {
                String csid = node.valueOf("@csid");
                JSONObject test = new JSONObject();
                test.put("csid", csid);
                listitems.add(test);
            } else {
                pagination.put(node.getName(), node.getText());
            }
        }
    } else {
        String[] allfields = null;
        String fieldsReturnedName = r.getServicesFieldsPath();
        for (Node node : nodes) {
            if (node.matches(matchlistitem)) {
                List<Node> fields = node.selectNodes("*");
                String csid = "";
                String urlPlusCSID = null;
                if (node.selectSingleNode(csidfield) != null) {
                    csid = node.selectSingleNode(csidfield).getText();
                    urlPlusCSID = r.getServicesURL() + "/" + csid;
                }
                JSONObject test = new JSONObject();
                for (Node field : fields) {
                    if (csidfield.equals(field.getName())) {
                        if (!fullcsid) {
                            int idx = csid.lastIndexOf("/");
                            if (idx != -1) {
                                csid = csid.substring(idx + 1);
                                urlPlusCSID = r.getServicesURL() + "/" + csid;
                            }
                        }
                        test.put("csid", csid);
                    } else {
                        String json_name = view_map.get(field.getName());
                        if (json_name != null) {
                            String value = field.getText();
                            // XXX hack to cope with multi values      
                            if (value == null || "".equals(value)) {
                                List<Node> inners = field.selectNodes("*");
                                for (Node n : inners) {
                                    value += n.getText();
                                }
                            }
                            String gleanname = urlPlusCSID;
                            if (csidfield.equals("uri")) {
                                gleanname = csid;
                            }
                            setGleanedValue(cache, gleanname, json_name, value);
                            test.put(json_name, value);
                        }
                    }
                }
                listitems.add(test);
                if (allfields == null || allfields.length == 0) {
                    if (log.isWarnEnabled()) {
                        log.warn(
                                "getRepeatableHardListView(): Missing fieldsReturned value - may cause fan-out!\nRecord:"
                                        + r.getID() + " request to: " + path);
                    }
                } else {
                    // Mark all the fields not yet found as gleaned - 
                    String gleanname = urlPlusCSID;
                    if (csidfield.equals("uri")) {
                        gleanname = csid;
                    }
                    for (String s : allfields) {
                        String gleaned = getGleanedValue(cache, gleanname, s);
                        if (gleaned == null) {
                            setGleanedValue(cache, gleanname, s, "");
                        }
                    }
                }
            } else if (fieldsReturnedName.equals(node.getName())) {
                String myfields = node.getText();
                allfields = myfields.split("\\|");
            } else {
                pagination.put(node.getName(), node.getText());
            }
        }
    }
    out.put("pagination", pagination);
    out.put("listItems", listitems);
    return out;
}

From source file:org.collectionspace.chain.csp.persistence.services.GenericStorage.java

License:Educational Community License

/**
 * return list view of items//from w  ww .j a  v a2s .  c  o  m
 * TODO make getHardListView and getRepeatableHardListView to share more code as they aren't different enough to warrant the level of code repeat
 * @param creds
 * @param cache
 * @param path
 * @param nodeName
 * @param matchlistitem
 * @param csidfield
 * @param fullcsid
 * @return
 * @throws ConnectionException
 * @throws JSONException
 */
protected JSONObject getHardListView(CSPRequestCredentials creds, CSPRequestCache cache, String path,
        String nodeName, String matchlistitem, String csidfield, Boolean fullcsid)
        throws ConnectionException, JSONException {
    JSONObject out = new JSONObject();
    JSONObject pagination = new JSONObject();
    Document list = null;
    List<String> listitems = new ArrayList<String>();
    ReturnedDocument all = conn.getXMLDocument(RequestMethod.GET, path, null, creds, cache);
    if (all.getStatus() != 200) {
        //throw new StatusException(all.getStatus(),path,"Bad request during identifier cache map update: status not 200");
        throw new ConnectionException("Bad request during identifier cache map update: status not 200 is "
                + Integer.toString(all.getStatus()), all.getStatus(), path);
    }
    list = all.getDocument();

    List<Node> nodes = list.selectNodes(nodeName);
    if (matchlistitem.equals("roles_list/*") || matchlistitem.equals("permissions_list/*")) {
        //XXX hack to deal with roles being inconsistent
        //XXX CSPACE-1887 workaround
        for (Node node : nodes) {
            if (node.matches(matchlistitem)) {
                String csid = node.valueOf("@csid");
                listitems.add(csid);
            } else {
                pagination.put(node.getName(), node.getText());
            }
        }
    } else {
        String[] allfields = null;
        String fieldsReturnedName = r.getServicesFieldsPath();
        for (Node node : nodes) {
            if (node.matches(matchlistitem)) {
                List<Node> fields = node.selectNodes("*");
                String csid = "";
                String urlPlusCSID = null;
                if (node.selectSingleNode(csidfield) != null) {
                    csid = node.selectSingleNode(csidfield).getText();
                    urlPlusCSID = r.getServicesURL() + "/" + csid;
                    setGleanedValue(cache, urlPlusCSID, "csid", csid);
                }
                for (Node field : fields) {
                    if (csidfield.equals(field.getName())) {
                        if (!fullcsid) {
                            int idx = csid.lastIndexOf("/");
                            if (idx != -1) {
                                csid = csid.substring(idx + 1);
                                urlPlusCSID = r.getServicesURL() + "/" + csid;
                            }
                        }
                        listitems.add(csid);
                    } else {
                        String json_name = view_map.get(field.getName());
                        if (json_name != null) {
                            String value = field.getText();
                            // XXX hack to cope with multi values      
                            if (value == null || "".equals(value)) {
                                List<Node> inners = field.selectNodes("*");
                                for (Node n : inners) {
                                    value += n.getText();
                                }
                            }
                            setGleanedValue(cache, urlPlusCSID, json_name, value);
                        }
                    }
                }
                if (allfields == null || allfields.length == 0) {
                    if (log.isWarnEnabled()) {
                        log.warn("getHardListView(): Missing fieldsReturned value - may cause fan-out!\nRecord:"
                                + r.getID() + " request to: " + path);
                    }
                } else {
                    // Mark all the fields not yet found as gleaned - 
                    for (String s : allfields) {
                        String gleaned = getGleanedValue(cache, urlPlusCSID, s);
                        if (gleaned == null) {
                            setGleanedValue(cache, urlPlusCSID, s, "");
                        }
                    }
                }
            } else if (fieldsReturnedName.equals(node.getName())) {
                String myfields = node.getText();
                allfields = myfields.split("\\|");
            } else {
                pagination.put(node.getName(), node.getText());
            }
        }
    }
    out.put("pagination", pagination);
    out.put("listItems", listitems.toArray(new String[0]));
    return out;

}

From source file:org.collectionspace.chain.csp.persistence.services.RecordStorage.java

License:Educational Community License

/**
 * Gets a list of csids of a certain type of record
 * /* ww  w.  j  a va  2s  .c o  m*/
 * XXX should not be used...
 */
@SuppressWarnings("unchecked")
public String[] getPaths(ContextualisedStorage root, CSPRequestCredentials creds, CSPRequestCache cache,
        String rootPath, JSONObject restrictions)
        throws ExistException, UnimplementedException, UnderlyingStorageException {
    try {
        Document list = null;
        List<String> out = new ArrayList<String>();

        String path = getRestrictedPath(r.getServicesURL(), restrictions, r.getServicesSearchKeyword(), "",
                false, "");

        ReturnedDocument all = conn.getXMLDocument(RequestMethod.GET, path, null, creds, cache);
        if (all.getStatus() != 200) {
            throw new ConnectionException("Bad request during identifier cache map update: status not 200");
        }
        list = all.getDocument();
        List<Node> objects = list.selectNodes(r.getServicesListPath());
        if (r.getServicesListPath().equals("roles_list/*")) {
            //XXX hack to deal with roles being inconsistent
            // XXX CSPACE-1887 workaround
            for (Node object : objects) {
                String csid = object.valueOf("@csid");
                out.add(csid);
            }

        } else {
            for (Node object : objects) {
                List<Node> fields = object.selectNodes("*");
                String csid = object.selectSingleNode("csid").getText();
                for (Node field : fields) {
                    if ("csid".equals(field.getName())) {
                        int idx = csid.lastIndexOf("/");
                        if (idx != -1)
                            csid = csid.substring(idx + 1);
                        out.add(csid);
                    } else if ("uri".equals(field.getName())) {
                        // Skip!
                    } else {
                        String json_name = view_map.get(field.getName());
                        if (json_name != null) {
                            String value = field.getText();
                            // XXX hack to cope with multi values      
                            if (value == null || "".equals(value)) {
                                List<Node> inners = field.selectNodes("*");
                                for (Node n : inners) {
                                    value += n.getText();
                                }
                            }
                            setGleanedValue(cache, r.getServicesURL() + "/" + csid, json_name, value);
                        }
                    }
                }
            }
        }
        return out.toArray(new String[0]);
    } catch (ConnectionException e) {
        throw new UnderlyingStorageException("Service layer exception" + e.getLocalizedMessage(), e.getStatus(),
                e.getUrl(), e);
    } catch (UnsupportedEncodingException e) {
        throw new UnderlyingStorageException("Service layer exception:UnsupportedEncodingException", e);
    } catch (JSONException e) {
        throw new UnderlyingStorageException("Service layer exception:JSONException", e);
    }
}

From source file:org.craftercms.cstudio.alfresco.action.GenericImportActionExecutor.java

License:Open Source License

/**
 * load configuration/*from   w  w w .  j av a  2s  . c  o m*/
 */
@SuppressWarnings("unchecked")
protected synchronized void loadConfiguration() {
    LOGGER.debug("Start loadConfiguration");
    if (_configRef == null) {
        _configRef = _searchService.findNodeFromPath(CStudioConstants.STORE_REF, _configPath, _configFileName,
                true);
    }
    Document document = loadXml(_configRef);
    LOGGER.debug("Loaded Configuration document: " + document.asXML());

    _configTimeStamp = new Date();

    Element root = document.getRootElement();
    _site = root.valueOf("//site");
    _namespace = root.valueOf("//namespace");
    _contentPath = root.valueOf("//content-path");
    String publish = root.valueOf("//publish-to-cstudio");
    _publishToCStudio = (!StringUtils.isEmpty(publish) && publish.equalsIgnoreCase("true")) ? true : false;

    // get processed paths
    Map<String, NodeRef> paths = new HashMap<String, NodeRef>();
    List<Node> pathNodes = document.selectNodes("//paths/path");
    if (pathNodes != null) {
        for (Node node : pathNodes) {
            String name = node.valueOf("@name");
            String path = node.getText();
            NodeRef pathRef = _searchService.findNode(CStudioConstants.STORE_REF, "PATH:\"" + path + "\"");
            paths.put(name, pathRef);
        }
    }
    this._paths = paths;
}

From source file:org.craftercms.cstudio.alfresco.dm.script.DmDependencyServiceScript.java

License:Open Source License

/**
 * get components and assets that must be submitted with the items listed in
 * the request//from   www  .  j  a  va2s .c o m
 *
 * @param site
 * @param content
 * @param deleteDependencies
 * @return a list of dependencies for each item in json string
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
public String getDependencies(String site, Content content, Boolean deleteDependencies)
        throws ServiceException {

    if (deleteDependencies == null)
        deleteDependencies = false;

    InputStream in = content.getInputStream();
    try {

        Document document = ContentUtils.convertStreamToXml(in);
        Element root = document.getRootElement();
        List<Node> nodes = root.selectNodes(
                "/" + CStudioXmlConstants.DOCUMENT_ELM_ITEMS + "/" + CStudioXmlConstants.DOCUMENT_ELM_ITEM);
        List<DmContentItemTO> items = null;
        if (nodes != null && nodes.size() > 0) {
            List<String> submittedItems = new FastList<String>(nodes.size());
            for (Node node : nodes) {
                String uri = node.valueOf("@" + CStudioXmlConstants.DOCUMENT_ATTR_URI);
                submittedItems.add(uri);
            }
            DmContentItemComparator comparator = new DmContentItemComparator(
                    DmContentItemComparator.SORT_BROWSER_URI, true, true, true);
            items = _servicesManager.getService(DmDependencyService.class).getDependencies(site, submittedItems,
                    comparator, false, deleteDependencies);
        } else {
            items = new FastList<DmContentItemTO>(0);
        }
        StringBuilder sb = new StringBuilder();
        for (DmContentItemTO item : items) {
            String comment = item.getSubmissionComment();
            if (StringUtils.isNotEmpty(comment)) {
                sb.append(comment).append("\n");
            }
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(JSON_KEY_ITEMS, items);
        jsonObject.put(JSON_KEY_SUBMISSION_COMMENT, sb.toString());
        return jsonObject.toString();
    } catch (DocumentException e) {
        logger.error("Error getting dependecies", e);
        throw new ServiceException("Error in parsing the submitted content.", e);

    } catch (RuntimeException e) {
        logger.error("Error getting dependecies", e);
        throw e;
    } catch (ServiceException e) {
        logger.error("Error getting dependecies", e);
        throw e;
    } finally {
        ContentUtils.release(in);
    }
}

From source file:org.craftercms.cstudio.alfresco.dm.script.DmImportScript.java

License:Open Source License

/**
 * import site contents//  ww  w. j a  v a2  s.  c  o m
 * 
 * @param configLocation
 */
@SuppressWarnings("unchecked")
public void importSite(String configLocation) {
    Document document = loadConfiguration(configLocation);
    if (document != null) {
        Element root = document.getRootElement();
        List<Node> siteNodes = root.selectNodes("site");
        if (siteNodes != null) {
            for (Node siteNode : siteNodes) {
                String name = siteNode.valueOf("name");
                String buildDataLocation = siteNode.valueOf("build-data-location");
                String publishingChannelGroup = siteNode.valueOf("publish-channel-group");
                String publish = siteNode.valueOf("publish");
                String publishSize = siteNode.valueOf("publish-chunk-size");
                int chunkSize = (!StringUtils.isEmpty(publishSize) && StringUtils.isNumeric(publishSize))
                        ? Integer.valueOf(publishSize)
                        : -1;
                Node foldersNode = siteNode.selectSingleNode("folders");
                String targetRoot = this.getServicesConfig().getRepositoryRootPath(name);
                NodeRef targetRef = this.findContent(targetRoot);
                String sourceLocation = buildDataLocation + "/" + name;
                String delayIntervalStr = siteNode.valueOf("delay-interval");
                int delayInterval = (!StringUtils.isEmpty(delayIntervalStr)
                        && StringUtils.isNumeric(delayIntervalStr)) ? Integer.valueOf(delayIntervalStr) : -1;
                String delayLengthStr = siteNode.valueOf("delay-length");
                int delayLength = (!StringUtils.isEmpty(delayLengthStr)
                        && StringUtils.isNumeric(delayLengthStr)) ? Integer.valueOf(delayLengthStr) : -1;

                // trigger an action
                Map<String, Serializable> args = new FastMap<String, Serializable>();
                args.put(DmImportActionExecutor.PARAM_SITE, name);
                args.put(DmImportActionExecutor.PARAM_SOURCE_LOCATION, sourceLocation);
                args.put(DmImportActionExecutor.PARAM_TARGET_LOCATION, targetRoot);
                args.put(DmImportActionExecutor.PARAM_PUBLISH, publish);
                args.put(DmImportActionExecutor.PARAM_CHUNK_SIZE, chunkSize);
                args.put(DmImportActionExecutor.PARAM_DELAY_INTERVAL, delayInterval);
                args.put(DmImportActionExecutor.PARAM_DELAY_LENGTH, delayLength);
                args.put(DmImportActionExecutor.PARAM_PUBLISH_CHANNEL_GROUP, publishingChannelGroup);
                args.put(DmImportActionExecutor.PARAM_CONFIG_NODE, (Serializable) foldersNode);
                Action action = _actionService.createAction(DmImportActionExecutor.NAME, args);
                _actionService.executeAction(action, targetRef, false, true);
            }
        }
    }
}

From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmContentTypeServiceImpl.java

License:Open Source License

/**
 * copy the given element to the target node
 *
 * @param site//w  w w  . ja v a  2  s  .c  o m
 * @param parentPath
 * @param element
 * @param targetNode
 */
protected void copyContent(String site, String parentPath, Element element, Node targetNode) {
    if (targetNode != null) {
        String name = element.getName();
        String currentPath = parentPath + name;
        boolean noCopyOnConvert = DmUtils.getBooleanValue(targetNode.valueOf("@no-copy"), false);
        if (!this.getExcludedPaths(site).contains(currentPath) && !noCopyOnConvert) {
            Element targetElement = (Element) targetNode;
            boolean multiValued = DmUtils.getBooleanValue(targetNode.valueOf("@copy-children"), false);
            List<Element> childElements = element.elements();
            if (childElements != null && childElements.size() > 0) {
                for (Element childElement : childElements) {
                    Node targetChildNode = null;
                    if (this.getMultiValuedPaths(site).contains(currentPath) || multiValued) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.debug("[CHANGE-TEMPLATE] " + currentPath + " is multi-valued.");
                        }
                        targetChildNode = (Node) targetElement.addElement(childElement.getName());
                    } else {
                        String uniquePath = childElement.getUniquePath(element);
                        targetChildNode = targetElement.selectSingleNode(uniquePath);
                    }
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("[CHANGE-TEMPLATE] copying child node of " + currentPath + " : "
                                + childElement.getUniquePath(element));
                    }
                    copyContent(site, currentPath + "/", childElement, targetChildNode);
                }
            }
            targetElement.setText(element.getText());
            targetElement.setAttributes(element.attributes());
        } else {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("[CHANGE-TEMPLATE] " + currentPath
                        + " is not being copied since it is in exlcudedPaths or no copy on convert node.");
            }
        }
    } else {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(
                    "[CHANGE-TEMPLATE] " + element.getUniquePath() + " does not exist in target location.");
        }
    }

}

From source file:org.craftercms.cstudio.alfresco.dm.util.impl.DmImportServiceImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
public void importFromConfigNode(final String site, String publishChannelGroup, final Node node,
        final String fileRoot, final String targetRoot, final NodeRef targetRef, boolean publish, int chunkSize,
        int delayInterval, int delayLength) {
    if (!inProgress) {
        inProgress = true;// w w w  .ja v  a2 s .c o  m
        if (delayInterval > 0)
            pauseEanbeld = true;
        this.currentDelayInterval = delayInterval * 1000;
        this.currentDelayLength = delayLength * 1000;
        final Set<String> importedPaths = new FastSet<String>();
        final List<String> importedFullPaths = new FastList<String>();
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("[IMPORT] started importing in " + site + ", pause enabled: " + pauseEanbeld
                    + ", delay interval: " + this.currentDelayInterval + ", delay length: "
                    + this.currentDelayLength);
        }
        boolean overWrite = ContentFormatUtils.getBooleanValue(node.valueOf("@over-write"));
        final List<Node> folderNodes = node.selectNodes("folder");
        if (publish) {
            SiteService siteService = getService(SiteService.class);
            PublishingChannelGroupConfigTO configTO = siteService.getPublishingChannelGroupConfigs(site)
                    .get(publishChannelGroup);
            String user = _authenticationService.getCurrentUserName();
            List<PublishingChannel> channels = getChannels(site, configTO);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("[IMPORT] publishing user: " + user + ", publishing channel config: "
                        + configTO.getName());
            }
            this.nextStop = System.currentTimeMillis() + this.currentDelayInterval;
            createFolders(site, importedPaths, importedFullPaths, folderNodes, fileRoot, targetRef, targetRoot,
                    "", overWrite, channels, user);
            LOGGER.info("Starting Publish of Imported Files (Total " + importedFullPaths.size()
                    + " On chunkSize of " + chunkSize + " )");
            publish(site, publishChannelGroup, targetRoot, importedFullPaths, chunkSize);
        } else {
            this.nextStop = System.currentTimeMillis() + this.currentDelayInterval;
            createFolders(site, importedPaths, importedFullPaths, folderNodes, fileRoot, targetRef, targetRoot,
                    "", overWrite, null, null);
        }
        inProgress = false;
    } else {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("[IMPORT] an import process is currently running.");
        }
    }
}

From source file:org.craftercms.cstudio.alfresco.dm.util.impl.DmImportServiceImpl.java

License:Open Source License

/**
 * create folders//from www  . ja  va 2  s.com
 * 
 * @param name
 *            site name
 * @param importedFiles
 *            a list of imported files
 * @param importedFullPaths
 * @param nodes
 *            nodes representing folders
 * @param fileRoot
 *            the root location of files/folders being imported
 * @param parentRef
 *            the parent nodeRef
 * @param targetRoot
 *            the target location root
 * @param parentPath
 *            the target location to import to
 * @param overWrite
 *            overwrite contents?
 * @param channels
 * @param user
 * 
 */
@SuppressWarnings("unchecked")
private void createFolders(String site, Set<String> importedPaths, List<String> importedFullPaths,
        List<Node> nodes, String fileRoot, NodeRef parentRef, String targetRoot, String parentPath,
        boolean overWrite, List<PublishingChannel> channels, String user) {
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info(
                "[IMPORT] createFolders : site[" + site + "] " + "] fileRoot [" + fileRoot + "] targetRoot [ "
                        + targetRoot + "] parentPath [" + parentPath + "] overwrite[" + overWrite + "]");
    }
    if (nodes != null) {
        for (Node node : nodes) {
            String name = node.valueOf("@name");
            String value = node.valueOf("@over-write");
            boolean folderOverWrite = (StringUtils.isEmpty(value)) ? overWrite
                    : ContentFormatUtils.getBooleanValue(value);
            if (!StringUtils.isEmpty(name)) {
                String currentFilePath = fileRoot + "/" + name;
                String currentPath = parentPath + "/" + name;
                // check if the parent node exists and create the folder if
                // not
                NodeRef currentRef = findChildByName(parentRef, name);
                if (currentRef == null) {
                    currentRef = createDirectory(parentRef, name);
                }
                boolean importAll = ContentFormatUtils.getBooleanValue(node.valueOf("@import-all"));
                if (importAll) {
                    importRootFileList(site, importedPaths, importedFullPaths, fileRoot + "/" + name,
                            currentRef, targetRoot, currentPath, folderOverWrite, channels, user);

                } else {
                    // create child folders
                    List<Node> childFolders = node.selectNodes("folder");
                    createFolders(site, importedPaths, importedFullPaths, childFolders, currentFilePath,
                            currentRef, targetRoot, currentPath, folderOverWrite, channels, user);
                    // create child fiimportedPathsles
                    List<Node> childFiles = node.selectNodes("file");
                    createFiles(site, importedPaths, importedFullPaths, childFiles, currentFilePath, currentRef,
                            targetRoot, currentPath, folderOverWrite, channels, user);
                }
            }
        }
    }
}