Examples of JCRSiteNode


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

            } else {
                Node ref = targetNode.addNode(name, "jnt:contentReference");
                ref.setProperty("j:node", node.getUUID());
            }
        } else {
            JCRSiteNode sourceSite = node.getResolveSite();
            JCRSiteNode targetSite = targetNode.getResolveSite();
            if (!sourceSite.equals(targetSite)) {
                JCRSessionWrapper session = node.getSession();
                Query q = session.getWorkspace().getQueryManager().createQuery("select * from [jnt:template] as t where isdescendantnode(t, ['"+sourceSite.getPath() + "/templates'])", Query.JCR_SQL2);
                NodeIterator ni = q.execute().getNodes();
                while (ni.hasNext()) {
                    JCRNodeWrapper next = (JCRNodeWrapper) ni.next();
                    try {
                        session.getUuidMapping().put(next.getIdentifier(), session.getNode(targetSite.getPath() + StringUtils.substringAfter(next.getPath(), sourceSite.getPath())).getIdentifier());
                    } catch (RepositoryException e) {
                        logger.debug("No matching template for copy",e);
                    }
                }
            }
View Full Code Here

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

                List<JahiaPrincipal> principals = new ArrayList<JahiaPrincipal>();
                JahiaUserManagerService userService = ServicesRegistry.getInstance().getJahiaUserManagerService();
                JahiaGroupManagerService groupService = ServicesRegistry.getInstance().getJahiaGroupManagerService();

                JCRSiteNode site = node.getResolveSite();

                Map<String, List<String[]>> m = node.getAclEntries();

                Collection<WorkflowRule> rules = getWorkflowRules(node, null);
                for (WorkflowRule rule : rules) {
                    if (rule.getProviderKey().equals(definition.getProvider()) &&
                        rule.getWorkflowDefinitionKey().equals(definition.getKey())) {
                        Map<String, String> perms = workflowPermissions.get(rule.getWorkflowDefinitionKey());
                        if (perms != null) {
                            String permName = perms.get(activityName);
                            if (permName != null) {
                                if (permName.indexOf("$") > -1) {
                                    Workflow w = getWorkflow(definition.getProvider(), processId, null);
                                    if (w != null) {
                                        for (Map.Entry<String, Object> entry : w.getVariables().entrySet()) {
                                            if (entry.getValue() instanceof List) {
                                                @SuppressWarnings("unchecked")
                                                List<Object> variable = (List<Object>) entry.getValue();
                                                for (Object workflowVariable : variable) {
                                                    if (workflowVariable instanceof WorkflowVariable) {
                                                        String v = ((WorkflowVariable) workflowVariable).getValue();
                                                        permName = permName.replace("$" + entry.getKey(), v);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                try {
                                    Set<String> s = new HashSet<String>();

                                    try {
                                        String path = "/permissions" + permName;
                                        while (path.length() >= "/permissions".length()) {
                                            JCRNodeWrapper permissionNode = session.getNode(path);
                                            for (PropertyIterator iterator = permissionNode.getWeakReferences(
                                                    "j:permissions"); iterator.hasNext();) {
                                                Property prop = iterator.nextProperty();
                                                Node roleNode = prop.getParent();
                                                s.add(roleNode.getName());
                                            }
                                            path = StringUtils.substringBeforeLast(path, "/");
                                        }
                                    } catch (PathNotFoundException e) {
                                        logger.warn("Unable to find the node for the permission " + permName);
                                    }

                                    for (Map.Entry<String, List<String[]>> entry : m.entrySet()) {
                                        for (String[] strings : entry.getValue()) {
                                            if (strings[1].equals("GRANT")) {
                                                if (s.contains(strings[2])) {
                                                    String principal = entry.getKey();
                                                    final String principalName = principal.substring(2);
                                                    if (principal.charAt(0) == 'u') {
                                                        JahiaUser jahiaUser = userService.lookupUser(principalName);
                                                        principals.add(jahiaUser);
                                                    } else if (principal.charAt(0) == 'g') {
                                                        JahiaGroup group = groupService.lookupGroup(site.getID(),
                                                                principalName);
                                                        principals.add(group);
                                                    }
                                                }
                                            }
View Full Code Here

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

    private Collection<WorkflowRule> getWorkflowRulesForAction(JCRNodeWrapper objectNode, JahiaUser user, String action, Locale locale) throws RepositoryException {

        Collection<WorkflowRule> results = new HashSet<WorkflowRule>();
        Collection<WorkflowRule> rules = getWorkflowRules(objectNode, locale);

        JCRSiteNode site = objectNode.getResolveSite();

        for (WorkflowRule rule : rules) {
            if (action == null || workflowTypeByDefinition.get(rule.getWorkflowDefinitionKey()).equals(action)) {
                Map<String,String> perms = workflowPermissions.get(rule.getWorkflowDefinitionKey());
                if (perms != null) {
View Full Code Here

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

                            } catch (PathNotFoundException ex) {
                                // ignore it
                            }
                        }

                        JCRSiteNode site = node.getResolveSite();
                        JCRSessionWrapper userSession;

                        if (site != null) {
                            String defaultLanguage = site.getDefaultLanguage();
                            boolean mixLanguagesActive = site
                                    .isMixLanguagesActive();

                            if (defaultLanguage != null && mixLanguagesActive) {
                                userSession = JCRSessionFactory
                                        .getInstance()
View Full Code Here

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

    public BasePagingLoadResult<GWTJahiaUser> searchUsersInContext(String match, int offset, int limit, String context) {
        if (context != null) {
            List<Integer> list = new ArrayList<Integer>();;

            if (context.equals("currentSite")) {
                JCRSiteNode site = getSite();
                if (site != null) {
                    list.add(site.getID());
                }
            } else if (context.startsWith("site:")) {
                String sitekey = context.substring(5);
                try {
                    JahiaSite site = sitesService.getSiteByKey(sitekey);
                    if (site != null) {
                        list.add(site.getID());
                    }
                } catch (JahiaException e) {
                    logger.error(e.getMessage(), e);
                }
            } else if (context.startsWith("sharedOnly")) {
View Full Code Here

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

    public BasePagingLoadResult<GWTJahiaGroup> searchGroupsInContext(String match, int offset, int limit, String context) {
        if (context != null) {
            List<Integer> list = new ArrayList<Integer>();;

            if (context.equals("currentSite")) {
                JCRSiteNode site = getSite();
                if (site != null) {
                    list.add(site.getID());
                }
            } else if (context.startsWith("site:")) {
                String sitekey = context.substring(5);
                try {
                    JahiaSite site = sitesService.getSiteByKey(sitekey);
                    if (site != null ) {
                        list.add(site.getID());
                    }
                } catch (JahiaException e) {
                    logger.error(e.getMessage(), e);
                }
            } else if (context.startsWith("sharedOnly")) {
View Full Code Here

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

    public boolean checkLanguageValidity(Set<String> languages) {
        final JCRSessionWrapper jcrSessionWrapper = getSession();
        try {
            Locale locale = jcrSessionWrapper.getLocale();
            if (locale != null) {
                JCRSiteNode siteNode = getResolveSite();
                if (siteNode != null) {
                    Set<String> mandatoryLanguages = siteNode.getMandatoryLanguages();
                    List<Locale> locales = jcrSessionWrapper.isLive() ? siteNode.getActiveLanguagesAsLocales() : siteNode.getLanguagesAsLocales();
                    if (locales.size() == 0) {
                        return true;
                    }
                    if (!locales.contains(locale)) {
                        return false;
                    }
                    for (String mandatoryLanguage : mandatoryLanguages) {
                        if (!checkI18nAndMandatoryPropertiesForLocale(LanguageCodeConverters.getLocaleFromCode(mandatoryLanguage))) {
                            return false;
                        }
                    }
                }
                boolean b = checkI18nAndMandatoryPropertiesForLocale(locale);
                if(!b && siteNode != null && siteNode.isMixLanguagesActive()) {
                    b = checkI18nAndMandatoryPropertiesForLocale(LanguageCodeConverters.getLocaleFromCode(siteNode.getDefaultLanguage()));
                }
                return b;
            } else if (languages != null) {
                for (String language : languages) {
                    if (checkI18nAndMandatoryPropertiesForLocale(LanguageCodeConverters.getLocaleFromCode(language))) {
                        JCRSiteNode siteNode = getResolveSite();
                        if (siteNode != null) {
                            Set<String> mandatoryLanguages = siteNode.getMandatoryLanguages();
                            if (mandatoryLanguages == null || mandatoryLanguages.isEmpty()) {
                                return true;
                            }
                            for (String mandatoryLanguage : mandatoryLanguages) {
                                if (!checkI18nAndMandatoryPropertiesForLocale(LanguageCodeConverters.getLocaleFromCode(mandatoryLanguage))) {
View Full Code Here

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

    protected void doPost(HttpServletRequest req, HttpServletResponse resp, RenderContext renderContext,
                          URLResolver urlResolver) throws Exception {
        if (req.getParameter(JahiaPortalURLParserImpl.PORTLET_INFO) != null) {
            Resource resource = urlResolver.getResource();
            renderContext.setMainResource(resource);
            JCRSiteNode site = resource.getNode().getResolveSite();
            renderContext.setSite(site);
            doGet(req, resp, renderContext, resource, System.currentTimeMillis());
            return;
        }
        Map<String, List<String>> parameters = new HashMap<String, List<String>>();
        if (checkForUploadedFiles(req, resp, urlResolver.getWorkspace(), urlResolver.getLocale(), parameters, urlResolver)) {
            if (parameters.isEmpty()) {
                return;
            }
        }
        if (parameters.isEmpty()) {
            parameters = toParameterMapOfListOfString(req);
        }

        req.getSession().removeAttribute("formDatas");
        req.getSession().removeAttribute("formError");

        Action action;
        Resource resource = null;
        if (urlResolver.getPath().endsWith(".do")) {
            resource = urlResolver.getResource();
            renderContext.setMainResource(resource);
            try {
                JCRSiteNode site = resource.getNode().getResolveSite();
                renderContext.setSite(site);
            } catch (RepositoryException e) {
            }

            action = templateService.getActions().get(resource.getResolvedTemplate());
        } else {
            String path = urlResolver.getPath();
            resource = urlResolver.getResource((path.endsWith("*") ? StringUtils.substringBeforeLast(path, "/") : path) + ".html");
            renderContext.setMainResource(resource);
            try {
                JCRSiteNode site = resource.getNode().getResolveSite();
                renderContext.setSite(site);
            } catch (RepositoryException e) {
            }
            action = defaultPostAction;
        }
View Full Code Here

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

                                target = (fileUpload.getParameterValues(TARGETDIRECTORY))[0];
                            } else if (isContributePost) {
                                String path = urlResolver.getPath();
                                path = (path.endsWith("*") ? StringUtils.substringBeforeLast(path, "/") : path);
                                JCRNodeWrapper sessionNode = session.getNode(path);
                                JCRSiteNode siteNode = sessionNode.getResolveSite();
                                if (siteNode != null) {
                                    String s = sessionNode.getResolveSite().getPath() + "/files/contributed/";
                                    String name = sessionNode.getPrimaryNodeTypeName().replaceAll(":", "_") + "_" + sessionNode.getName();
                                    target = s + name;
                                    try {
View Full Code Here

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

                    Resource resource;

                    resource = urlResolver.getResource();
                    renderContext.setMainResource(resource);

                    JCRSiteNode site = resource.getNode().getResolveSite();
                    if ((site == null && resource.getNode().getPath().startsWith("/sites/")) || (site != null
                            && (renderContext.getEditModeConfigName() == null
                            || !renderContext.getEditModeConfigName().equals(Studio.STUDIO_MODE))
                            && !(renderContext.isLiveMode() ? site.getActiveLanguagesAsLocales()
                                    .contains(urlResolver.getLocale()) : site
                                    .getLanguagesAsLocales().contains(urlResolver.getLocale())))) {
                        throw new PathNotFoundException("This language does not exist on this site");
                    }
                    renderContext.setSite(site);
//                    resource.pushWrapper("wrapper.fullpage");
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.