Examples of JCRSiteNode


Examples of org.jahia.services.content.decorator.JCRSiteNode

        try {
            if (request.getParameter("site") == null) {
                return null;
            }
            JCRSiteNode site = (JCRSiteNode) JCRSessionFactory.getInstance().getCurrentUserSession(getWorkspace()).getNodeByUUID(request.getParameter("site"));

            if (site.isMixLanguagesActive()) {
                fallback = LanguageCodeConverters.getLocaleFromCode(site.getDefaultLanguage());
            }
            return fallback;
        } catch (ItemNotFoundException e) {
            return null;
        } catch (RepositoryException e) {
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

     * @param params
     * @param urlGenerator
     */
    public static void addLanguageSwitcherLinks(RenderContext renderContext, Map<String, String> params, URLGenerator urlGenerator) {
        try {
            final JCRSiteNode currentSite = renderContext.getSite();
            if (currentSite != null) {
                final Set<String> languageSettings = currentSite.getLanguages();
                if (languageSettings != null && languageSettings.size() > 0) {
                    for (String lang : languageSettings) {
                        params.put(lang, urlGenerator.getLanguages().get(lang));
                    }
                }
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

        }
        n.setThumbnailsMap(new HashMap<String, String>());
        n.setVersioned(node.isVersioned());
        n.setLanguageCode(node.getLanguage());
        try {
            JCRSiteNode site = node.getResolveSite();
            if (site != null) {
                n.setSiteUUID(site.getUUID());
                n.setAclContext("site:" + site.getName());
                n.setSiteKey(site.getSiteKey());
            } else {
                n.setAclContext("sharedOnly");
            }
        } catch (RepositoryException e) {
            logger.error("Error when getting sitekey", e);
        }
        if (node.isFile()) {
            n.setSize(node.getFileContent().getContentLength());

        }
        n.setFile(node.isFile());

        n.setIsShared(false);
        try {
            if (node.isNodeType("mix:shareable") && node.getSharedSet().getSize() > 1) {
                n.setIsShared(true);
            }
        } catch (RepositoryException e) {
            logger.error("Error when getting shares", e);
        }

        try {
            n.setReference(node.isNodeType("jmix:nodeReference"));
        } catch (RepositoryException e1) {
            logger.error("Error checking node type", e1);
        }

        if (fields.contains(GWTJahiaNode.CHILDREN_INFO)) {
            boolean hasChildren = false;
            if (node instanceof JCRMountPointNode) {
                hasChildren = true;
            } else if (!node.isFile()) {
                try {
                    final NodeIterator nodesIterator = node.getNodes();
                    if (nodesIterator.hasNext()) {
                        hasChildren = true;
                    }
                } catch (RepositoryException e) {
                    logger.error(e.getMessage(), e);
                }
            }
            n.setHasChildren(hasChildren);
        }

        if (fields.contains(GWTJahiaNode.TAGS)) {
            try {
                if (node.hasProperty("j:tags")) {
                    StringBuilder b = new StringBuilder();
                    Value[] values = node.getProperty("j:tags").getValues();
                    for (Value value : values) {
                        Node tag = ((JCRValueWrapper) value).getNode();
                        if (tag != null) {
                            b.append(", ");
                            b.append(tag.getName());
                        }
                    }
                    if (b.length() > 0) {
                        n.setTags(b.substring(2));
                    }
                }
            } catch (RepositoryException e) {
                logger.error("Error when getting tags", e);
            }
        }

        if (node.isPortlet()) {
            n.setPortlet(true);
        }

        // icons
        if (fields.contains(GWTJahiaNode.ICON)) {
            try {
                n.setIcon(JCRContentUtils.getIcon(node));
            } catch (RepositoryException e) {
                logger.error(e.getMessage(), e);
            }
        }

        // thumbnails
        List<String> names = node.getThumbnails();
        if (names.contains("thumbnail")) {
            n.setPreview(node.getThumbnailUrl("thumbnail"));
            n.setDisplayable(true);
        }
        for (String name : names) {
            n.getThumbnailsMap().put(name, node.getThumbnailUrl(name));
        }

        //count
        if (fields.contains(GWTJahiaNode.COUNT)) {
            try {
                n.set("count", JCRContentUtils.size(node.getWeakReferences()));
            } catch (RepositoryException e) {
                logger.warn("Unable to count node references for node");
            }
        }

        if (fields.contains(GWTJahiaNode.PUBLICATION_INFO)) {
            try {
                n.setAggregatedPublicationInfos(publication.getAggregatedPublicationInfosByLanguage(node.getIdentifier(),
                        Collections.singleton(node.getSession().getLocale().toString()), node.getSession()));
            } catch (UnsupportedRepositoryOperationException e) {
                // do nothing
                logger.debug(e.getMessage());
            } catch (RepositoryException e) {
                logger.error(e.getMessage(), e);
            } catch (GWTJahiaServiceException e) {
                logger.error(e.getMessage(), e);
            }
        }

        if (fields.contains(GWTJahiaNode.PUBLICATION_INFOS)) {
            try {
                JCRSiteNode siteNode = node.getResolveSite();
                if (siteNode != null) {
                    JCRSessionWrapper session = node.getSession();

                    n.setAggregatedPublicationInfos(publication.getAggregatedPublicationInfosByLanguage(node.getIdentifier(),
                            siteNode.getLanguages(), session));
                    n.setFullPublicationInfos(publication.getFullPublicationInfosByLanguage(Arrays.asList(node.getIdentifier()), siteNode.getLanguages(),
                                        session, false));
                }
            } catch (UnsupportedRepositoryOperationException e) {
                // do nothing
                logger.debug(e.getMessage());
            } catch (RepositoryException e) {
                logger.error(e.getMessage(), e);
            } catch (GWTJahiaServiceException e) {
                logger.error(e.getMessage(), e);
            }
        }

        if (fields.contains(GWTJahiaNode.WORKFLOW_INFO) || fields.contains(GWTJahiaNode.PUBLICATION_INFO)) {
            try {
                n.setWorkflowInfo(
                        workflow.getWorkflowInfo(n.getPath(), node.getSession(), node.getSession().getLocale()));
            } catch (UnsupportedRepositoryOperationException e) {
//                 do nothing
                logger.debug(e.getMessage());
            } catch (RepositoryException e) {
                logger.error(e.getMessage(), e);
            } catch (GWTJahiaServiceException e) {
                logger.error(e.getMessage(), e);
            }
        }

        if (fields.contains(GWTJahiaNode.WORKFLOW_INFOS)) {
            try {
                JCRSiteNode node1 = node.getResolveSite();
                if (node1 != null) {
                    Map<String, GWTJahiaWorkflowInfo> infoMap = new HashMap<String, GWTJahiaWorkflowInfo>();
                    JCRSessionWrapper session = node.getSession();
                    for (String code : node1.getLanguages()) {
                        Locale locale = LanguageCodeConverters.languageCodeToLocale(code);
                        JCRSessionWrapper localeSession =
                                sessionFactory.getCurrentUserSession(session.getWorkspace().getName(), locale);
                        GWTJahiaWorkflowInfo info = workflow.getWorkflowInfo(n.getPath(), localeSession, locale);
                        infoMap.put(code, info);
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

            JCRTemplate.getInstance().doExecuteWithSystemSession(null,
                    Constants.LIVE_WORKSPACE,curLocale,new JCRCallback<Object>() {
                public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                    try {
                        if(site!=null) {
                            JCRSiteNode nodeByIdentifier = (JCRSiteNode) session.getNodeByIdentifier(site.getIdentifier());
                            JCRNodeWrapper home = nodeByIdentifier.getHome();
                            if (home!=null && !newLocaleList.contains(curLocale)) {
                                newLocaleList.add(curLocale);
                            }
                        }
                    } catch (RepositoryException e) {
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

    }

    protected void userRedirect(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws Exception {
        JahiaUser user = (JahiaUser) request.getSession().getAttribute(ProcessingContext.SESSION_USER);
        if (!JahiaUserManagerService.isGuest(user)) {
            JCRSiteNode site = (JCRSiteNode) JCRStoreService.getInstance().getSessionFactory().getCurrentUserSession("live").getNode(JCRContentUtils.getSystemSitePath());
            String language = resolveLanguage(request, site, user);
            redirect(request.getContextPath() + "/cms/render/live/"+language + user.getLocalPath() + ".user-home.html", response);
        } else {
            throw new AccessDeniedException();
        }
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

    }

    protected void defaultRedirect(HttpServletRequest request, HttpServletResponse response,
            ServletContext context) throws Exception {
        request.getSession(true);
        final JCRSiteNode site = resolveSite(request, Constants.LIVE_WORKSPACE);
        String redirect = null;
        if (site == null) {
            userRedirect(request, response, context);
            return;
        } else {
            JahiaUser user = (JahiaUser) request.getSession().getAttribute(ProcessingContext.SESSION_USER);
            String language = resolveLanguage(request, site, user);
            String base;

            String pathInfo = request.getPathInfo();
            JCRNodeWrapper home = site.getHome();
            if (pathInfo != null && "/edit".equals(pathInfo) && !SettingsBean.getInstance().isDistantPublicationServerMode()) {
                // edit mode was requested
                if(home!=null) {
                    base = request.getContextPath() + Edit.getEditServletPath() + "/"
                        + Constants.EDIT_WORKSPACE + "/" + language + home.getPath();
                } else {
                    base = request.getContextPath() + Edit.getEditServletPath() + "/"
                        + Constants.EDIT_WORKSPACE + "/" + language + resolveSite(request, Constants.EDIT_WORKSPACE).getHome().getPath();
                }
            } else {
                if (home != null) {
                    base = request.getContextPath() + Render.getRenderServletPath() + "/"
                            + Constants.LIVE_WORKSPACE + "/" + language + home.getPath();
                } else if (!SettingsBean.getInstance().isDistantPublicationServerMode()) {
                    JCRSiteNode defSite = null;
                    try {
                        defSite = (JCRSiteNode) JCRStoreService.getInstance().getSessionFactory()
                                .getCurrentUserSession().getNode(site.getPath());
                    } catch (PathNotFoundException e) {
                        redirect(request.getContextPath()+"/start", response);
                        return;
                    }
                    if (defSite.getHome() != null) {
                        base = request.getContextPath() + Edit.getEditServletPath() + "/"
                                + Constants.EDIT_WORKSPACE + "/" + language
                                + defSite.getHome().getPath();
                    } else {
                        redirect(request.getContextPath()+"/start", response);
                        return;
                    }
                } else {
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

            JCRTemplate.getInstance().doExecuteWithSystemSession(null,
                    Constants.LIVE_WORKSPACE,curLocale,new JCRCallback<Object>() {
                public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
                    try {
                        if(site!=null) {
                            JCRSiteNode nodeByIdentifier = (JCRSiteNode) session.getNodeByIdentifier(site.getIdentifier());
                            JCRNodeWrapper home = nodeByIdentifier.getHome();
                            if (home!=null && !newLocaleList.contains(curLocale)) {
                                newLocaleList.add(curLocale);
                            }
                        }
                    } catch (RepositoryException e) {
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

            String nodetype = null;
            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;
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

                for (Map.Entry<String, List<String>> entry : contextParams.entrySet()) {
                    r.getModuleParams().put(entry.getKey(), entry.getValue().get(0));
                }
            }

            JCRSiteNode site = node.getResolveSite();
            renderContext.setSite(site);
            String res = renderService.render(r, renderContext);
            Map<String, Set<String>> map = (Map<String, Set<String>>) renderContext.getRequest().getAttribute("staticAssets");
            String constraints = ConstraintsHelper.getConstraints(node);
            if (constraints == null) {
View Full Code Here

Examples of org.jahia.services.content.decorator.JCRSiteNode

                        item.setMandatory(mandatoryLanguages.contains(langCode));
                        items.add(item);
                    }
                }
            } else {
                JCRSiteNode siteByKey = (JCRSiteNode) ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(
                        JahiaSitesBaseService.SYSTEM_SITE_KEY).getNode();
                final Set<String>languages  = siteByKey.getLanguages();
                final Set<String> activeLanguages = siteByKey.getActiveLanguages();
                final Set<String> mandatoryLanguages = site.getMandatoryLanguages();
                final TreeSet<String> orderedLangs = new TreeSet<String>();
                orderedLangs.addAll(languages);
                for (String langCode : orderedLangs) {
                    GWTJahiaLanguage item = new GWTJahiaLanguage();
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.