Examples of IStylesheetUserPreferences


Examples of org.jasig.portal.layout.om.IStylesheetUserPreferences

    @Transactional
    @Override
    public void clearLayoutAttributes(HttpServletRequest request, PreferencesScope prefScope, String nodeId) {
        final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
       
        final IStylesheetUserPreferences stylesheetUserPreferences = this.getStylesheetUserPreferences(request, stylesheetPreferencesKey);
        if (stylesheetUserPreferences != null) {
            stylesheetUserPreferences.clearLayoutAttributes(nodeId);
            this.stylesheetUserPreferencesDao.storeStylesheetUserPreferences(stylesheetUserPreferences);
        }
       
        final HttpSession session = request.getSession(false);
        if (session != null) {
View Full Code Here

Examples of org.jasig.portal.layout.om.IStylesheetUserPreferences

    @Transactional
    @Override
    public void clearAllLayoutAttributes(HttpServletRequest request, PreferencesScope prefScope) {
        final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
       
        final IStylesheetUserPreferences stylesheetUserPreferences = this.getStylesheetUserPreferences(request, stylesheetPreferencesKey);
        if (stylesheetUserPreferences != null) {
            stylesheetUserPreferences.clearAllLayoutAttributes();
            this.stylesheetUserPreferencesDao.storeStylesheetUserPreferences(stylesheetUserPreferences);
        }
       
        final HttpSession session = request.getSession(false);
        if (session != null) {
View Full Code Here

Examples of org.jasig.portal.layout.om.IStylesheetUserPreferences

        }

        final Locale locale = profile.getLocaleManager().getLocales()[0];
        final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetDescriptorDao
                .getStylesheetDescriptor(stylesheetDescriptorId);
        final IStylesheetUserPreferences stylesheetUserPreferences = this.stylesheetUserPreferencesDao
                .getStylesheetUserPreferences(stylesheetDescriptor, person, profile);

        final IStylesheetUserPreferences distributedStylesheetUserPreferences = new StylesheetUserPreferencesImpl(
                stylesheetDescriptorId, person.getID(), profile.getProfileId());

        final FragmentActivator fragmentActivator = this.getFragmentActivator();

        for (final String fragName : fragmentNames) {
            final FragmentDefinition fragmentDefinition = this.configurationLoader.getFragmentByName(fragName);

            //UserView may be missing if the fragment isn't defined correctly
            final UserView userView = fragmentActivator.getUserView(fragmentDefinition, locale);
            if (userView == null) {
                logger.warn("No UserView is present for fragment {} it will be skipped when loading distributed stylesheet user preferences",
                            fragmentDefinition.getName());
                continue;
            }

            //IStylesheetUserPreferences only exist if something was actually set
            final IStylesheetUserPreferences fragmentStylesheetUserPreferences = this.stylesheetUserPreferencesDao
                    .getStylesheetUserPreferences(stylesheetDescriptor, userView.getUserId(), userView.profileId);
            if (fragmentStylesheetUserPreferences == null) {
                continue;
            }

            //Get the info needed to DLMify node IDs
            final Element root = userView.layout.getDocumentElement();
            final String labelBase = root.getAttribute(Constants.ATT_ID);

            boolean modified = false;

            //Copy all of the fragment preferences into the distributed preferences
            final Collection<String> allLayoutAttributeNodeIds = fragmentStylesheetUserPreferences
                    .getAllLayoutAttributeNodeIds();
            for (final String fragmentNodeId : allLayoutAttributeNodeIds) {
                final String userNodeId;
                if (!fragmentNodeId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) {
                    userNodeId = labelBase + fragmentNodeId;
                }
                else {
                    userNodeId = fragmentNodeId;
                }

                final MapPopulator<String, String> layoutAttributesPopulator = new MapPopulator<String, String>();
                fragmentStylesheetUserPreferences.populateLayoutAttributes(fragmentNodeId, layoutAttributesPopulator);
                final Map<String, String> layoutAttributes = layoutAttributesPopulator.getMap();
                for (final Map.Entry<String, String> layoutAttributesEntry : layoutAttributes.entrySet()) {
                    final String name = layoutAttributesEntry.getKey();
                    final String value = layoutAttributesEntry.getValue();
View Full Code Here

Examples of org.jasig.portal.layout.om.IStylesheetUserPreferences

    protected void addStylesheetUserPreferencesAttributes(IPerson person, IUserProfile profile,
            org.dom4j.Document layoutDoc, int stylesheetId, String attributeType) {
        final IStylesheetDescriptor structureStylesheetDescriptor = this.stylesheetDescriptorDao
                .getStylesheetDescriptor(stylesheetId);

        final IStylesheetUserPreferences ssup = this.stylesheetUserPreferencesDao
                .getStylesheetUserPreferences(structureStylesheetDescriptor, person, profile);

        if (ssup != null) {
            final Collection<String> allLayoutAttributeNodeIds = ssup.getAllLayoutAttributeNodeIds();
            for (final String nodeId : allLayoutAttributeNodeIds) {

                final MapPopulator<String, String> layoutAttributesPopulator = new MapPopulator<String, String>();
                ssup.populateLayoutAttributes(nodeId, layoutAttributesPopulator);
                final Map<String, String> layoutAttributes = layoutAttributesPopulator.getMap();

                final org.dom4j.Element element = layoutDoc.elementByID(nodeId);
                if (element == null) {
                    logger.warn("No node with id '{}' found in layout for: {}. Stylesheet user preference layout attributes will be ignored: {}", nodeId, person.getUserName(), layoutAttributes);
View Full Code Here

Examples of org.jasig.portal.layout.om.IStylesheetUserPreferences

        final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetDescriptorDao
                .getStylesheetDescriptor(structureStylesheetId);
        final List<org.dom4j.Element> structureAttributes = layout.selectNodes("//" + nodeType + "-attribute");

        IStylesheetUserPreferences ssup = this.stylesheetUserPreferencesDao
                .getStylesheetUserPreferences(stylesheetDescriptor, person, profile);
        if (structureAttributes.isEmpty()) {
            if (ssup != null) {
                this.stylesheetUserPreferencesDao.deleteStylesheetUserPreferences(ssup);
            }
        }
        else {
            if (ssup == null) {
                ssup = this.stylesheetUserPreferencesDao.createStylesheetUserPreferences(stylesheetDescriptor,
                        person,
                        profile);
            }

            final Map<String, Map<String, String>> oldLayoutAttributes = new HashMap<String, Map<String,String>>();
            for (final String nodeId : ssup.getAllLayoutAttributeNodeIds()) {
                final MapPopulator<String, String> nodeAttributes = new MapPopulator<String, String>();
                ssup.populateLayoutAttributes(nodeId, nodeAttributes);
                oldLayoutAttributes.put(nodeId, nodeAttributes.getMap());
            }

            for (final org.dom4j.Element structureAttribute : structureAttributes) {
                final org.dom4j.Element layoutElement = structureAttribute.getParent();
                final String nodeId = layoutElement.valueOf("@ID");
                if (StringUtils.isEmpty(nodeId)) {
                    logger.warn("@ID is empty for layout element, the attribute will be ignored: {}", structureAttribute.asXML());
                }

                final String name = structureAttribute.valueOf("name");
                if (StringUtils.isEmpty(nodeId)) {
                    logger.warn("name is empty for layout element, the attribute will be ignored: {}", structureAttribute.asXML());
                    continue;
                }

                final String value = structureAttribute.valueOf("value");
                if (StringUtils.isEmpty(nodeId)) {
                    logger.warn("value is empty for layout element, the attribute will be ignored: {}", structureAttribute.asXML());
                    continue;
                }
               
                //Remove from the old attrs set as we've updated it
                final Map<String, String> oldAttrs = oldLayoutAttributes.get(nodeId);
                if (oldAttrs != null) {
                    oldAttrs.remove(name);
                }

                ssup.setLayoutAttribute(nodeId, name, value);

                // Remove the layout attribute element or DLM fails
                layoutElement.remove(structureAttribute);
            }
           
            //Purge orphaned entries
            for (final Entry<String, Map<String, String>> oldAttributeEntry : oldLayoutAttributes.entrySet()) {
                final String nodeId = oldAttributeEntry.getKey();
                for (final String name : oldAttributeEntry.getValue().keySet()) {
                    ssup.removeLayoutAttribute(nodeId, name);
                }
            }

            this.stylesheetUserPreferencesDao.storeStylesheetUserPreferences(ssup);
        }
View Full Code Here

Examples of org.jasig.portal.layout.om.IStylesheetUserPreferences

            }
            super.setUserLayout(person, profile, PLF, false);
        }

        final int structureStylesheetId = profile.getStructureStylesheetId();
        final IStylesheetUserPreferences distributedStructureStylesheetUserPreferences = this
                .loadDistributedStylesheetUserPreferences(person, profile, structureStylesheetId, fragmentNames);

        final int themeStylesheetId = profile.getThemeStylesheetId();
        final IStylesheetUserPreferences distributedThemeStylesheetUserPreferences = this
                .loadDistributedStylesheetUserPreferences(person, profile, themeStylesheetId, fragmentNames);

        return new DistributedUserLayout(ILF, fragmentNames, distributedStructureStylesheetUserPreferences,
                distributedThemeStylesheetUserPreferences);
    }
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.