Examples of JahiaSite


Examples of org.jahia.services.sites.JahiaSite

            List<JahiaSite> sites = new ArrayList<JahiaSite>();
            String[] sitekeys = request.getParameterValues("sitebox");
            for (int i = 0; i < sitekeys.length; i++) {
                String sitekey = sitekeys[i];
                try {
                    JahiaSite site = ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(sitekey);
                    sites.add(site);
                } catch (JahiaException e) {

                }
            }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

            displayEdit(request, response, session);
        }
    }

    private void changeSiteIfCurrent(HttpSession session, JahiaSite site) {
        JahiaSite sessSite = (JahiaSite) session.getAttribute(ProcessingContext.SESSION_SITE);

        if (sessSite != null && sessSite.getSiteKey().equals(site.getSiteKey())) {
            session.setAttribute(ProcessingContext.SESSION_SITE, null);
        }
        if (jParams.getSite() != null && jParams.getSite().getSiteKey().equals(site.getSiteKey())) {
            JahiaSite siteToUseNow = sMgr.getDefaultSite() != null ? sMgr.getDefaultSite() :
                    new JahiaSite(-1, "", "", "", "", new Properties(), null);
            jParams.setSite(siteToUseNow);
            jParams.setSiteKey(siteToUseNow.getSiteKey());
            session.setAttribute(ProcessingContext.SESSION_SITE, siteToUseNow);
        }
    }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

    }

    private void delete(JahiaSite site, JahiaUser theUser, boolean deleteFiles) throws JahiaException, IOException {
        // now let's check if this site is the default site, in which case
        // we need to change the default site to another one.
        JahiaSite defSite = getDefaultSite();

        // first let's build a list of the all the sites except the
        // current one.
        List<JahiaSite> otherSites = new ArrayList<JahiaSite>();
        for (Iterator<JahiaSite> siteIt = ServicesRegistry.getInstance().getJahiaSitesService().getSites();
             siteIt.hasNext();) {
            JahiaSite curSite = siteIt.next();
            if (!curSite.getSiteKey().equals(site.getSiteKey())) {
                otherSites.add(curSite);
            }
        }
        if (defSite == null) {
            // no default site, let's assign once that isn't the current
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

            for (Map<Object, Object> infos : importsInfos) {
                File file = (File) infos.get("importFile");
                if (request.getParameter(file.getName() + "selected") != null) {
                    if (infos.get("type").equals("files")) {
                        try {
                            JahiaSite system = ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(JahiaSitesBaseService.SYSTEM_SITE_KEY);

                            Map<String,String> pathMapping = JCRSessionFactory.getInstance().getCurrentUserSession().getPathMapping();
                            pathMapping.put("/shared/files/", "/sites/" + system.getSiteKey() + "/files/");
                            pathMapping.put("/shared/mashups/", "/sites/" + system.getSiteKey() + "/portlets/");

                            ImportExportBaseService.getInstance().importSiteZip(file, system, infos);
                        } catch (Exception e) {
                            logger.error("Error when getting templates", e);
                        } finally {
                            file.delete();
                        }
                    } else if (infos.get("type").equals("xml") &&
                            (infos.get("importFileName").equals("serverPermissions.xml") ||
                                    infos.get("importFileName").equals("users.xml"))) {

                    } else if (infos.get("type").equals("site")) {
                        // site import
                        String tpl = (String) infos.get("templates");
                        if ("".equals(tpl)) {
                            tpl = null;
                        }
                        Locale defaultLocale = determineDefaultLocale(jParams, infos);
                        try {
                            JahiaSite site = jahiaSitesService
                                    .addSite(jParams.getUser(), (String) infos.get("sitetitle"),
                                            (String) infos.get("siteservername"), (String) infos.get("sitekey"), "",
                                            defaultLocale, tpl, "fileImport", file,
                                            (String) infos.get("importFileName"), false, false, (String) infos.get("originatingJahiaRelease"));
                            session.setAttribute(ProcessingContext.SESSION_SITE, site);
                            jParams.setSite(site);
                            jParams.setSiteID(site.getID());
                            jParams.setSiteKey(site.getSiteKey());
                            jParams.setCurrentLocale(defaultLocale);


                        } catch (Exception e) {
                            logger.error("Cannot create site " + infos.get("sitetitle"), e);
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

        return targetSiteKey;
    }

    private static String lookupSiteKeyByServerName(String host) {
        JahiaSite site = null;
        if (SpringContextSingleton.getInstance().isInitialized()) {
            try {
                site = ServicesRegistry.getInstance().getJahiaSitesService()
                        .getSiteByServerName(host);
            } catch (JahiaException e) {
                logger.error("Error resolving site by server name '" + host + "'", e);
            }
        }
        return site != null ? site.getSiteKey() : "";
    }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

        }
        return site != null ? site.getSiteKey() : "";
    }

    private static String lookupSiteServerNameByKey(String key) {
        JahiaSite site = null;
        if (SpringContextSingleton.getInstance().isInitialized()) {
            try {
                site = ServicesRegistry.getInstance().getJahiaSitesService()
                        .getSiteByKey(key);
            } catch (JahiaException e) {
                logger.error("Error resolving site by key '" + key + "'", e);
            }
        }
        return site != null && !URLGenerator.isLocalhost(site.getServerName()) ? site.getServerName() : null;
    }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

        String currentSiteKey = getSiteKeyByServerName(request);
        boolean matches = currentSiteKey.equals(siteKey);
        request.setAttribute(ATTR_NAME_SITE_KEY_MATCHES, Boolean.valueOf(matches));

        try {
            JahiaSite siteByKey = ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(siteKey);
            request.setAttribute(ATTR_NAME_DEFAULT_LANG_MATCHES, Boolean.valueOf(siteByKey.getDefaultLanguage().equals(language)));
        } catch (JahiaException e) {
            logger.error("Error resolving site by key '" + siteKey + "'", e);
        }

        if (!matches) {
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

                    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];
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

                List<JahiaSite> sites = new ArrayList<JahiaSite>();
                String[] sitekeys = request.getParameterValues("sitebox");
                if (sitekeys != null) {
                    for (String sitekey : sitekeys) {
                        JahiaSite site = ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(sitekey);
                        sites.add(site);
                    }
                }

                if (sites.isEmpty()) {
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

        return isAdmin;
    }


    private boolean isUserMemberOf(String groupname, String site) {
        JahiaSite s = null;
        if (JahiaGroupManagerService.GUEST_GROUPNAME.equals(groupname)) {
            return true;
        }
        if (JahiaGroupManagerService.USERS_GROUPNAME.equals(groupname) && site == null && !JahiaUserManagerService.GUEST_USERNAME.equals(jahiaPrincipal.getName())) {
            return true;
        }
        int siteId = 0;
        if (site != null) {
            try {
                s = sitesService.getSiteByKey(site);
                if (s != null) {
                    siteId = s.getID();
                }
            } catch (JahiaException e) {
                logger.error("Error while retrieving site key" + site, e);
            }
        }
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.