Examples of JCRNodeWrapper


Examples of org.jahia.services.content.JCRNodeWrapper

        }
    }

    private TreeMap<String, JCRNodeWrapper> getTemplatesSets() throws RepositoryException {
        TreeMap<String, JCRNodeWrapper> orderedTemplateSets = new TreeMap<String, JCRNodeWrapper>();
        final JCRNodeWrapper templatesSet =
                JCRStoreService.getInstance().getSessionFactory().getCurrentUserSession().getNode("/templateSets");
        NodeIterator templates = templatesSet.getNodes();
        while (templates.hasNext()) {
            JCRNodeWrapper node = (JCRNodeWrapper) templates.next();
            if (!node.getName().equals("templates-system") && node.hasProperty("j:siteType") &&
                    node.getProperty("j:siteType").getString().equals("templatesSet")) {
                orderedTemplateSets.put(node.getName(), node);
            }
        }
        return orderedTemplateSets;
    }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

        if (jahiaPreference == null) {
            logger.warn("Can't set a null jahia preference");
            return;
        }
        try {
            JCRNodeWrapper node = jahiaPreference.getNode();
            node.getParent().save();
            if (logger.isDebugEnabled()) {
                logger.debug("Jahia preference [" + jahiaPreference + "] saved.");
                logger.debug("[" + node.getPath() + JahiaPreferencesQueryHelper.convertToSQLPureStringProperties(node.getPropertiesAsString()) + "] saved.");
            }
        } catch (RepositoryException re) {
            logger.error("Error while setting preference " + jahiaPreference, re);
        }
    }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

     *
     * @param principal
     */
    public void deleteAllPreferencesByPrincipal(Principal principal) {
        try {
            JCRNodeWrapper preferencesNode = getPreferencesNode(principal);
            if (preferencesNode != null) {
                Node ppNode = getPreferencesNode(principal).getNode(getType());
                if (ppNode != null) {
                    ppNode.remove();
                }
                preferencesNode.save();
            }
        } catch (RepositoryException e) {
            logger.error(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

        return null;
    }

    private Node getProviderPreferencesNode(Principal principal) {
        try {
            JCRNodeWrapper preferences = getPreferencesNode(principal);
            if (!preferences.hasNode(getType())) {
                if(!preferences.isCheckedOut()) {
                    preferences.checkout();
                }
                Node p = preferences.addNode(getType(), "jnt:preferenceProvider");
                preferences.save();
                return p;
            }
            return preferences.getNode(getType());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }

        return null;
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

        this.imageService = imageService;
    }

    public void crop(String path, String target, int top, int left, int width, int height, boolean forceReplace, JCRSessionWrapper session) throws GWTJahiaServiceException {
        try {
            JCRNodeWrapper node = session.getNode(path);
            if (contentManager
                    .checkExistence(node.getPath().replace(node.getName(), target), session) &&
                    !forceReplace) {
                throw new ExistingFileException("The file " + target + " already exists.");
            }
            Image image = imageService.getImage(node);
            File f = File.createTempFile("image", null);
            imageService.cropImage(image, f, top, left, width, height);

            InputStream fis = new BufferedInputStream(new FileInputStream(f));
            try {
                node.getParent().uploadFile(target, fis, node.getFileContent().getContentType());
                session.save();
            } finally {
                IOUtils.closeQuietly(fis);
                f.delete();
            }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

        }
    }

    public void resizeImage(String path, String target, int width, int height, boolean forceReplace, JCRSessionWrapper session) throws GWTJahiaServiceException {
        try {
            JCRNodeWrapper node = session.getNode(path);
            if (contentManager
                    .checkExistence(node.getPath().replace(node.getName(), target), session) &&
                    !forceReplace) {
                throw new ExistingFileException("The file " + target + " already exists.");
            }
            Image image = imageService.getImage(node);
            File f = File.createTempFile("image", null);
            imageService.resizeImage(image, f, width, height);

            InputStream fis = new BufferedInputStream(new FileInputStream(f));
            try {
                node.getParent().uploadFile(target, fis, node.getFileContent().getContentType());
                session.save();
            } finally {
                IOUtils.closeQuietly(fis);
                f.delete();
            }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

        }
    }

    public void rotateImage(String path, String target, boolean clockwise, boolean forceReplace, JCRSessionWrapper session) throws GWTJahiaServiceException {
        try {
            JCRNodeWrapper node = session.getNode(path);
            if (contentManager
                    .checkExistence(node.getPath().replace(node.getName(), target), session) &&
                    !forceReplace) {
                throw new ExistingFileException("The file " + target + " already exists.");
            }
            Image image = imageService.getImage(node);
            File f = File.createTempFile("image", null);
            imageService.rotateImage(image, f, clockwise);

            InputStream fis = new BufferedInputStream(new FileInputStream(f));
            try {
                node.getParent().uploadFile(target, fis, node.getFileContent().getContentType());
                session.save();
            } finally {
                IOUtils.closeQuietly(fis);
                f.delete();
            }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

            QueryManager qm = JCRSessionFactory.getInstance().getCurrentUserSession().getWorkspace().getQueryManager();
            Query q = qm.createQuery("select * from [jnt:user] as user order by user.name", Query.JCR_SQL2);
            QueryResult qr = q.execute();
            NodeIterator ni = qr.getNodes();
            while (ni.hasNext()) {
                JCRNodeWrapper node = (JCRNodeWrapper) ni.nextNode();
                if (node.getName().equals("guest")) {
                    continue;
                }

                String name = "";
                if (node.hasProperty("j:firstName")) {
                    name += node.getProperty("j:firstName").getString() + " ";
                }
                if (node.hasProperty("j:lastName")) {
                    name += node.getProperty("j:lastName").getString();
                }
                name = name.trim();
                if (name.equals("")) {
                    name = node.getName();
                }
                vs.add(new ChoiceListValue(name, new HashMap<String,Object>(), new ValueImpl(node.getUUID(), PropertyType.WEAKREFERENCE, false)));
            }
        } catch (RepositoryException e) {
            e.printStackTrace();
        }
        return vs;
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

            if (s.length > 1) {
                nodetype = s[1];
            }
            try {
                JCRSiteNode site = null;
                JCRNodeWrapper contextNode = (JCRNodeWrapper) context.get("contextParent");
                if (contextNode == null) {
                    contextNode = (JCRNodeWrapper) context.get("contextNode");
                }
                if (contextNode != null) {
                    site = contextNode.getResolveSite();
                } else {
                    final JahiaSite defaultSite = JahiaSitesBaseService.getInstance().getDefaultSite();
                    if (defaultSite != null) {
                        site = (JCRSiteNode) sessionFactory.getCurrentUserSession().getNode("/sites/"+ defaultSite.getSiteKey());
                    } else {
                        site = (JCRSiteNode) sessionFactory.getCurrentUserSession().getNode(JCRContentUtils.getSystemSitePath());
                    }
                }
                String path = s[0];
                Locale fallbackLocale = null;
                if (site != null) {
                    fallbackLocale = site.isMixLanguagesActive() ? LanguageCodeConverters.languageCodeToLocale(
                            site.getDefaultLanguage()) : null;
                    path = path.replace("$currentSite", site.getPath());
                }
                boolean subTree = false;
                if (path.endsWith("//*")) {
                    path = StringUtils.substringBeforeLast(path, "//*");
                    subTree = true;
                }
                final JCRSessionWrapper jcrSessionWrapper = sessionFactory.getCurrentUserSession(null, locale, fallbackLocale);
                final JCRNodeWrapper node = jcrSessionWrapper.getNode(path);
                addSubnodes(listValues, nodetype, node, subTree);
            } catch (PathNotFoundException e) {
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
View Full Code Here

Examples of org.jahia.services.content.JCRNodeWrapper

    }

    private void addSubnodes(ArrayList<ChoiceListValue> listValues, String nodetype, JCRNodeWrapper node, boolean subTree) throws RepositoryException {
        final NodeIterator nodeIterator = node.getNodes();
        while (nodeIterator.hasNext()) {
            JCRNodeWrapper nodeWrapper = (JCRNodeWrapper) nodeIterator.next();
            if (nodeWrapper.isNodeType(nodetype)) {
                String displayName = nodeWrapper.getDisplayableName();
                listValues.add(new ChoiceListValue(displayName, new HashMap<String, Object>(), new ValueImpl(
                        nodeWrapper.getIdentifier(), PropertyType.STRING, false)));
                if (subTree) {
                    addSubnodes(listValues, nodetype, nodeWrapper, subTree);
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.