Search in sources :

Example 36 with PortalException

use of org.apereo.portal.PortalException in project uPortal by Jasig.

the class UserLayoutHelperImpl method resetStylesheetUserPreferencesForProfile.

private void resetStylesheetUserPreferencesForProfile(IPerson person, IUserProfile profile) {
    try {
        // Structure
        final IStylesheetDescriptor sDescriptor = stylesheetDescriptorDao.getStylesheetDescriptor(profile.getStructureStylesheetId());
        logger.debug("Obtained the following IStylesheetDescriptor for person [{}] and profile='{}':  [{}]", person, profile.getProfileFname(), sDescriptor);
        final IStylesheetUserPreferences sPreferences = stylesheetUserPreferencesDao.getStylesheetUserPreferences(sDescriptor, person, profile);
        logger.debug("Obtained the following IStylesheetUserPreferences for descriptor [{}], person [{}], and profile='{}':  [{}]", sDescriptor, person, profile.getProfileFname(), sPreferences);
        if (sPreferences != null) {
            stylesheetUserPreferencesDao.deleteStylesheetUserPreferences(sPreferences);
        }
        // Theme
        final IStylesheetDescriptor tDescriptor = stylesheetDescriptorDao.getStylesheetDescriptor(profile.getThemeStylesheetId());
        logger.debug("Obtained the following IStylesheetDescriptor for person [{}] and profile='{}':  [{}]", person, profile.getProfileFname(), tDescriptor);
        final IStylesheetUserPreferences tPreferences = stylesheetUserPreferencesDao.getStylesheetUserPreferences(tDescriptor, person, profile);
        logger.debug("Obtained the following IStylesheetUserPreferences for descriptor [{}], person [{}], and profile='{}':  [{}]", tDescriptor, person, profile.getProfileFname(), tPreferences);
        if (tPreferences != null) {
            stylesheetUserPreferencesDao.deleteStylesheetUserPreferences(tPreferences);
        }
        logger.info("resetStylesheetUserPreferencesForProfile complete for person [{}] and profile='{}'", person, profile.getProfileFname());
    } catch (Exception e) {
        logger.error("Error during resetStylesheetUserPreferencesForProfile for person [{}] and profile='{}'", person, profile.getProfileFname(), e);
        throw new PortalException("Error during resetStylesheetUserPreferencesForProfile", e);
    }
}
Also used : IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) IStylesheetUserPreferences(org.apereo.portal.layout.om.IStylesheetUserPreferences) PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException)

Example 37 with PortalException

use of org.apereo.portal.PortalException in project uPortal by Jasig.

the class UserLayoutHelperImpl method resetUserLayoutForProfileByName.

private void resetUserLayoutForProfileByName(IPerson person, IUserProfile profile) {
    try {
        // Finally set the layout id to 0.  This orphans the existing layout but it will be
        // replaced by the default
        // when the user logs in
        profile.setLayoutId(0);
        // persist the change
        userLayoutStore.updateUserProfile(person, profile);
        logger.info("resetUserLayoutForProfileByName complete for person [{}] and profile='{}'", person, profile.getProfileFname());
    } catch (Exception e) {
        logger.error("Error during resetUserLayoutForProfileByName for person [{}] and profile='{}'", person, profile.getProfileFname(), e);
        throw new PortalException("Error during resetUserLayoutForProfileByName", e);
    }
}
Also used : PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException)

Example 38 with PortalException

use of org.apereo.portal.PortalException in project uPortal by Jasig.

the class TransientUserLayoutManagerWrapper method getTransientNode.

/**
 * Return an IUserLayoutChannelDescription by way of nodeId
 *
 * @param nodeId the node (subscribe) id to get the channel for.
 * @return a <code>IUserLayoutNodeDescription</code>
 */
private IUserLayoutChannelDescription getTransientNode(String nodeId) throws PortalException {
    // get fname from subscribe id
    final String fname = getFname(nodeId);
    if (null == fname || fname.equals("")) {
        return null;
    }
    try {
        // check cache first
        IPortletDefinition chanDef = mChanMap.get(nodeId);
        if (null == chanDef) {
            chanDef = PortletDefinitionRegistryLocator.getPortletDefinitionRegistry().getPortletDefinitionByFname(fname);
            mChanMap.put(nodeId, chanDef);
        }
        return createUserLayoutChannelDescription(nodeId, chanDef);
    } catch (Exception e) {
        throw new PortalException("Failed to obtain channel definition using fname: " + fname);
    }
}
Also used : PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 39 with PortalException

use of org.apereo.portal.PortalException in project uPortal by Jasig.

the class TransientUserLayoutManagerWrapper method getChannelDefinition.

/**
 * Given a subscribe Id, return a ChannelDefinition.
 *
 * @param subId the subscribe id for the ChannelDefinition.
 * @return a <code>ChannelDefinition</code>
 */
protected IPortletDefinition getChannelDefinition(String subId) throws PortalException {
    IPortletDefinition chanDef = mChanMap.get(subId);
    if (null == chanDef) {
        String fname = getFname(subId);
        if (log.isDebugEnabled())
            log.debug("TransientUserLayoutManagerWrapper>>getChannelDefinition, " + "attempting to get a channel definition using functional name: " + fname);
        try {
            chanDef = PortletDefinitionRegistryLocator.getPortletDefinitionRegistry().getPortletDefinitionByFname(fname);
        } catch (Exception e) {
            throw new PortalException("Failed to get channel information " + "for subscribeId: " + subId);
        }
        mChanMap.put(subId, chanDef);
    }
    return chanDef;
}
Also used : PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 40 with PortalException

use of org.apereo.portal.PortalException in project uPortal by Jasig.

the class TransientUserLayoutManagerWrapper method getSubscribeId.

/**
 * Given an functional name, return its subscribe id.
 *
 * @param fname the functional name to lookup
 * @return the fname's subscribe id.
 */
public String getSubscribeId(String fname) throws PortalException {
    // see if a given subscribe id is already in the map
    String subId = mFnameMap.get(fname);
    if (subId == null) {
        // see if a given subscribe id is already in the layout
        subId = man.getSubscribeId(fname);
    }
    // assign a new transient channel id
    if (subId == null) {
        try {
            IPortletDefinition chanDef = PortletDefinitionRegistryLocator.getPortletDefinitionRegistry().getPortletDefinitionByFname(fname);
            if (chanDef != null) {
                // assign a new id
                subId = getNextSubscribeId();
                mFnameMap.put(fname, subId);
                mSubIdMap.put(subId, fname);
                mChanMap.put(subId, chanDef);
            }
        } catch (Exception e) {
            log.error("TransientUserLayoutManagerWrapper::getSubscribeId() : " + "an exception encountered while trying to obtain " + "ChannelDefinition for fname \"" + fname + "\" : " + e);
            subId = null;
        }
    }
    return subId;
}
Also used : PortalException(org.apereo.portal.PortalException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

PortalException (org.apereo.portal.PortalException)47 Element (org.w3c.dom.Element)18 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)16 IUserInstance (org.apereo.portal.user.IUserInstance)14 Document (org.w3c.dom.Document)14 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)13 IUserLayoutNodeDescription (org.apereo.portal.layout.node.IUserLayoutNodeDescription)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ModelAndView (org.springframework.web.servlet.ModelAndView)13 Node (org.w3c.dom.Node)9 IPerson (org.apereo.portal.security.IPerson)8 Locale (java.util.Locale)7 IUserLayoutFolderDescription (org.apereo.portal.layout.node.IUserLayoutFolderDescription)7 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 HashMap (java.util.HashMap)6 IUserLayoutChannelDescription (org.apereo.portal.layout.node.IUserLayoutChannelDescription)6 XMLStreamException (javax.xml.stream.XMLStreamException)4 UserLayoutFolderDescription (org.apereo.portal.layout.node.UserLayoutFolderDescription)4 IOException (java.io.IOException)3 Enumeration (java.util.Enumeration)3