Search in sources :

Example 21 with PortalException

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

the class DistributedLayoutManager method getPreviousSiblingId.

public String getPreviousSiblingId(String nodeId) throws PortalException {
    Document uld = this.getUserLayoutDOM();
    Element nelement = uld.getElementById(nodeId);
    if (nelement != null) {
        Node nsibling = nelement.getPreviousSibling();
        // scroll to the next element node
        while (nsibling != null && nsibling.getNodeType() != Node.ELEMENT_NODE) {
            nsibling = nsibling.getNextSibling();
        }
        if (nsibling != null) {
            Element e = (Element) nsibling;
            return e.getAttribute("ID");
        }
        return null;
    }
    throw new PortalException("Node with id=\"" + nodeId + "\" doesn't exist. Occurred in layout for " + owner.getAttribute(IPerson.USERNAME) + ".");
}
Also used : Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) PortalException(org.apereo.portal.PortalException) Document(org.w3c.dom.Document)

Example 22 with PortalException

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

the class DistributedLayoutManager method saveUserLayout.

public synchronized void saveUserLayout() throws PortalException {
    Document uld = this.getUserLayoutDOM();
    if (uld == null) {
        throw new PortalException("UserLayout has not been initialized for " + owner.getAttribute(IPerson.USERNAME) + ".");
    }
    try {
        this.distributedLayoutStore.setUserLayout(this.owner, this.profile, uld, channelsAdded);
    } catch (Exception e) {
        throw new PortalException("Exception encountered while " + "saving layout for userId=" + this.owner.getID() + ", profileId=" + this.profile.getProfileId(), e);
    }
    this.channelsAdded = false;
}
Also used : PortalException(org.apereo.portal.PortalException) Document(org.w3c.dom.Document) XMLStreamException(javax.xml.stream.XMLStreamException) PortalException(org.apereo.portal.PortalException)

Example 23 with PortalException

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

the class DistributedLayoutManager method canAddNode.

protected boolean canAddNode(IUserLayoutNodeDescription node, IUserLayoutNodeDescription parent, String nextSiblingId) throws PortalException {
    // make sure sibling exists and is a child of nodeId
    if (nextSiblingId != null && !nextSiblingId.equals("")) {
        IUserLayoutNodeDescription sibling = getNode(nextSiblingId);
        if (sibling == null) {
            throw new PortalException("Unable to find a sibling node " + "with id=\"" + nextSiblingId + "\".  Occurred " + "in layout for " + owner.getAttribute(IPerson.USERNAME) + ".");
        }
        if (!parent.getId().equals(getParentId(nextSiblingId))) {
            throw new PortalException("Given sibling (\"" + nextSiblingId + "\") is not a child of a given parentId (\"" + parent.getId() + "\"). Occurred " + "in layout for " + owner.getAttribute(IPerson.USERNAME) + ".");
        }
    }
    if (parent == null || !(node.isMoveAllowed() || isFragmentOwner))
        return false;
    if (parent instanceof IUserLayoutFolderDescription && !(((IUserLayoutFolderDescription) parent).isAddChildAllowed()) && !isFragmentOwner)
        return false;
    if (// end of list targeted
    nextSiblingId == null || nextSiblingId.equals(""))
        return true;
    // so lets see if we can place it at the end of the sibling list and
    // hop left until we get into the correct position.
    Enumeration sibIds = getVisibleChildIds(parent.getId());
    List sibs = Collections.list(sibIds);
    if (// last node in list so should be ok
    sibs.size() == 0)
        return true;
    // unprocessed nodes is not altered.
    for (int idx = sibs.size() - 1; idx >= 0; idx--) {
        IUserLayoutNodeDescription prev = getNode((String) sibs.get(idx));
        if (!isFragmentOwner && !MovementRules.canHopLeft(node, prev))
            return false;
        if (prev.getId().equals(nextSiblingId))
            return true;
    }
    // oops never found the sib
    return false;
}
Also used : IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) Enumeration(java.util.Enumeration) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) PortalException(org.apereo.portal.PortalException) IUserLayoutFolderDescription(org.apereo.portal.layout.node.IUserLayoutFolderDescription)

Example 24 with PortalException

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

the class DistributedLayoutManager method getNextSiblingId.

public String getNextSiblingId(String nodeId) throws PortalException {
    Document uld = this.getUserLayoutDOM();
    Element nelement = uld.getElementById(nodeId);
    if (nelement != null) {
        Node nsibling = nelement.getNextSibling();
        // scroll to the next element node
        while (nsibling != null && nsibling.getNodeType() != Node.ELEMENT_NODE) {
            nsibling = nsibling.getNextSibling();
        }
        if (nsibling != null) {
            Element e = (Element) nsibling;
            return e.getAttribute("ID");
        }
        return null;
    }
    throw new PortalException("Node with id=\"" + nodeId + "\" doesn't exist. Occurred " + "in layout for " + owner.getAttribute(IPerson.USERNAME) + ".");
}
Also used : Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) PortalException(org.apereo.portal.PortalException) Document(org.w3c.dom.Document)

Example 25 with PortalException

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

the class LogoutController method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    final Map<String, String> rdHash = new HashMap<String, String>(1);
    try {
        // We retrieve the redirect strings for each context
        // from the security properties file.
        String key;
        final Properties props = ResourceLoader.getResourceAsProperties(LogoutController.class, "/properties/security.properties");
        final Enumeration propNames = props.propertyNames();
        while (propNames.hasMoreElements()) {
            final String propName = (String) propNames.nextElement();
            final String propValue = props.getProperty(propName);
            if (propName.startsWith("logoutRedirect.")) {
                key = propName.substring(15);
                key = key.startsWith("root.") ? key.substring(5) : key;
                if (log.isDebugEnabled()) {
                    log.debug("Redirect key=" + key + ", value=" + propValue);
                }
                rdHash.put(key, propValue);
            }
        }
    } catch (final PortalException pe) {
        log.error("Failed to load logout redirect URLs", pe);
    } catch (final IOException ioe) {
        log.error("Failed to load logout redirect URLs", ioe);
    }
    this.redirectMap = rdHash;
}
Also used : Enumeration(java.util.Enumeration) HashMap(java.util.HashMap) PortalException(org.apereo.portal.PortalException) IOException(java.io.IOException) Properties(java.util.Properties)

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