Examples of JahiaSite


Examples of org.jahia.services.sites.JahiaSite

                }
            } else {
                if (request.getParameter("site") != null) {
                    params.put(JahiaGWTParameters.SITE_UUID, request.getParameter("site"));
                } else {
                    final JahiaSite attribute = (JahiaSite) request.getSession().getAttribute(ProcessingContext.SESSION_SITE);
                    if (attribute != null && !"".equals(attribute.getSiteKey())) {
                        try {
                            params.put(JahiaGWTParameters.SITE_UUID, ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(attribute.getSiteKey()).getUuid());
                            params.put(JahiaGWTParameters.SITE_KEY, attribute.getSiteKey());
                        } catch (JahiaException e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

            authContext.getSessionFactory().setCurrentUser(theUser);

            // do a switch to the user's preferred language
            if (SettingsBean.getInstance().isConsiderPreferredLanguageAfterLogin()) {
                Locale preferredUserLocale = UserPreferencesHelper.getPreferredLocale(theUser, LanguageCodeConverters.resolveLocaleForGuest(httpServletRequest));
                JahiaSite site = (JahiaSite) authContext.getRequest().getSession().getAttribute(ProcessingContext.SESSION_SITE);
                if (site != null) {
                    List<Locale> siteLocales = site.getLanguagesAsLocales();
                    if (siteLocales.contains(preferredUserLocale)) {
                        httpServletRequest.getSession()
                                .setAttribute(ProcessingContext.SESSION_LOCALE, preferredUserLocale);
                    }
                }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

     * supposes that the current data has been already initialized and is available : - JahiaSite - JahiaUser - Session
     *
     * @return an List of Locale objects that contain the list of locale that are active for the current session, user and site.
     */
    public List<Locale> getLocales() throws JahiaException {
        JahiaSite site = getSite();
        if (site != null && site.getID()>0) {
            return getLocales(site.isMixLanguagesActive());
        }
        return getLocales(false);
    }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

    }

    protected void setSiteInfoFromSiteFound() {
        setSiteID(getSite().getID());
        setSiteKey(getSite().getSiteKey());
        final JahiaSite oldSite = (JahiaSite) getSessionState().getAttribute(
                SESSION_SITE);
        if (oldSite == null) {
            setSiteHasChanged(true);
        } else if (oldSite.getID() != getSite().getID()) {
            setSiteHasChanged(true);
            // setUserGuest(this.getSiteID());
        }

        // if (! (settings().isSiteIDInURL())) {
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

     *
     * @return site by the host name
     * @throws JahiaException in case of an error
     */
    protected JahiaSite getSiteByHostName() throws JahiaException {
        JahiaSite resolvedSite = null;

        if (getServerName() != null && isValidServerName(getServerName().toLowerCase())) {
            resolvedSite = REGISTRY.getJahiaSitesService().getSite(
                    getServerName());
        }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

        redirect(redirect, response);
    }

    protected JCRSiteNode resolveSite(HttpServletRequest request, String workspace) throws JahiaException, RepositoryException {
        JahiaSitesService siteService = JahiaSitesBaseService.getInstance();
        JahiaSite resolvedSite = !URLGenerator.isLocalhost(request.getServerName()) ? siteService.getSiteByServerName(request.getServerName()) : null;
        if (resolvedSite == null) {
            resolvedSite = siteService.getDefaultSite();
        }
        return resolvedSite != null ? (JCRSiteNode) JCRStoreService.getInstance().getSessionFactory()
                .getCurrentUserSession(workspace).getNode(resolvedSite.getJCRLocalPath()) : null;
    }
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

                        Node groupNode;
                        try {
                            if (siteID1 <= 0) {
                                groupNode = session.getNode("/groups/" + name.trim());
                            } else {
                                JahiaSite site = sitesService.getSite(siteID1);
                                if (site == null) {
                                    // This can happen if this method is called during the creation of the site !
                                    logger.warn("Site " + siteID1 + " is not available, maybe it's being created ?");
                                    return null;
                                }
                                String siteName = site.getSiteKey();
                                groupNode = session.getNode("/sites/" + siteName + "/groups/" + name.trim());
                            }
                        } catch (PathNotFoundException e) {
                            getCache().put(trueGroupKey, null);
                            return null;
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

            site.getLanguages().removeAll(deletedLanguageList);
        }
        try {
            JahiaSitesService service = ServicesRegistry.getInstance().getJahiaSitesService();
            service.updateSite(site);
            JahiaSite jahiaSite = service.getSiteByKey(JahiaSitesBaseService.SYSTEM_SITE_KEY);
            jahiaSite.getLanguages().addAll(site.getLanguages());
            service.updateSite(jahiaSite);
        } catch (JahiaException e) {
            logger.error(e.getMessage(), e);
        }
        // finally the most complicated operation, let's delete the
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

            op = "";
        final String operation = op;

        ParamBean jParams = initAdminJahiaData(request, response, session);
        final JahiaUser user = jParams.getUser();
        final JahiaSite site = jParams.getSite();

        try {
                Boolean accessGranted = (Boolean) session.getAttribute(CLASS_NAME + "accessGranted");
                if (accessGranted == null) {
                    accessGranted = Boolean.FALSE;
                }

                if (accessGranted) {
                    Locale uiLocale = (Locale) request.getSession().getAttribute(ProcessingContext.SESSION_UI_LOCALE);
                    if(request.getParameter("switchUiLocale") != null) {
                        uiLocale = LanguageCodeConverters.languageCodeToLocale(request.getParameter("switchUiLocale"));
                        request.getSession().setAttribute(ProcessingContext.SESSION_UI_LOCALE, uiLocale);
                        user.setProperty("preferredLanguage", uiLocale.toString());
                    }

                    Config.set(request, Config.FMT_LOCALIZATION_CONTEXT,
                            new LocalizationContext(new JahiaResourceBundle(uiLocale, site.getTemplatePackageName()), uiLocale));

                    AdministrationModulesRegistry modulesRegistry = (AdministrationModulesRegistry) SpringContextSingleton.getInstance().getContext().getBean("administrationModulesRegistry");
                    AdministrationModule currentModule = modulesRegistry.getServerAdministrationModule(operation);
                    if (currentModule != null) {
                        if (hasSitePermission(currentModule.getPermissionName(), site.getSiteKey()) || hasServerPermission(currentModule.getPermissionName())) {
                            session.setAttribute(CLASS_NAME + "configJahia", Boolean.TRUE);
                            /** todo clean up this hardcoded mess. Is it even used anymore ? */
                            if ("sharecomponents".equals(operation) && user.isRoot()) {
                                request.setAttribute("showAllComponents", Boolean.TRUE);
                            }

                            currentModule.service(request, response);
                        } else if ("sites".equals(operation) && (session.getAttribute(JahiaAdministration.CLASS_NAME + "redirectToJahia") != null)) {
                            session.setAttribute(CLASS_NAME + "configJahia", Boolean.TRUE);
                            currentModule.service(request, response);
                        }
                    } else {
                        currentModule = modulesRegistry.getSiteAdministrationModule(operation);
                        if (currentModule != null) {
                            if (hasSitePermission(currentModule.getPermissionName(), site.getSiteKey())) {
                                session.setAttribute(CLASS_NAME + "configJahia", Boolean.FALSE);
                                if ("search".equals(operation)) {
                                    // Use response wrapper to ensure correct handling of Application fields output to the response
                                    // @todo is this still necessary with Pluto wrapper in effect ?
                                    currentModule.service(new ServletIncludeRequestWrapper(request), new ServletIncludeResponseWrapper(response, true, SettingsBean.getInstance().getCharacterEncoding()));
View Full Code Here

Examples of org.jahia.services.sites.JahiaSite

            throws IOException, ServletException {
        List<JahiaSite> grantedSites = new ArrayList<JahiaSite>();
        JahiaUser theUser;

        logger.debug("started ");
        JahiaSite theSite = (JahiaSite) session.getAttribute(ProcessingContext.SESSION_SITE);

        if (theSite == null) {
            logger.debug("session site is null ! ");
        } else {
            // try to get site from cache
            try {
                theSite = ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(theSite.getSiteKey());
            } catch (Exception e) {
                logger.debug(e.getMessage(), e);
                theSite = null;
            }
        }

        // get sites where the user has an admin access...
        try {
            theUser = (JahiaUser) session.getAttribute(ProcessingContext.SESSION_USER);
            if (theUser != null) {
                grantedSites = getAdminGrantedSites(theUser);
            }
        } catch (Exception e) {
            logger.debug(e.getMessage(), e);
        }

        if (grantedSites == null) {
            logger.debug("can not admin any site at all !!! ");
            grantedSites = new ArrayList<JahiaSite>();
        } else {
            Locale defaultLocale = (Locale) session.getAttribute(ProcessingContext.SESSION_LOCALE);
            if (defaultLocale != null) {
                Collections.sort(grantedSites, JahiaSite.getTitleComparator(defaultLocale));
            } else {
                Collections.sort(grantedSites, JahiaSite.getTitleComparator());
            }
        }

        if (theSite == null && grantedSites.size() > 0) {
            theSite = grantedSites.get(0);
        }

        // check if the user is created on this site...
        if (theSite != null) {
            session.setAttribute(CLASS_NAME + "manageSiteID", theSite.getID());
            session.setAttribute(ProcessingContext.SESSION_SITE, theSite);
        }

        request.setAttribute("site", theSite);
        request.setAttribute("sitesList", grantedSites);
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.