Search in sources :

Example 41 with PortalException

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

the class DeleteManager method addDeleteDirective.

/**
 * This method does the actual work of adding a delete directive and then recursively calling
 * itself for any incoporated children that need to be deleted as well.
 */
private static void addDeleteDirective(Element compViewNode, String elementID, IPerson person, Document plf, Element delSet) throws PortalException {
    String ID = null;
    try {
        ID = getDLS().getNextStructDirectiveId(person);
    } catch (Exception e) {
        throw new PortalException("Exception encountered while " + "generating new delete node " + "Id for userId=" + person.getID(), e);
    }
    Element delete = plf.createElement(Constants.ELM_DELETE);
    delete.setAttribute(Constants.ATT_TYPE, Constants.ELM_DELETE);
    delete.setAttribute(Constants.ATT_ID, ID);
    delete.setAttributeNS(Constants.NS_URI, Constants.ATT_NAME, elementID);
    delSet.appendChild(delete);
    // now pass through children and add delete directives for those with
    // IDs indicating that they were incorporated
    Element child = (Element) compViewNode.getFirstChild();
    while (child != null) {
        String childID = child.getAttribute("ID");
        if (childID.startsWith(Constants.FRAGMENT_ID_USER_PREFIX))
            addDeleteDirective(child, childID, person, plf, delSet);
        child = (Element) child.getNextSibling();
    }
}
Also used : Element(org.w3c.dom.Element) PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException)

Example 42 with PortalException

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

the class EditManager method addDirective.

/**
 * Create and append an edit directive to the edit set if not there.
 */
private static void addDirective(Element plfNode, String attributeName, String type, IPerson person) throws PortalException {
    Document plf = (Document) person.getAttribute(Constants.PLF);
    Element editSet = getEditSet(plfNode, plf, person, true);
    // see if attributes has already been marked as being edited
    Element child = (Element) editSet.getFirstChild();
    Element edit = null;
    while (child != null && edit == null) {
        if (child.getNodeName().equals(type) && child.getAttribute(Constants.ATT_NAME).equals(attributeName))
            edit = child;
        child = (Element) child.getNextSibling();
    }
    if (// if not found then newly mark as edited
    edit == null) {
        String ID = null;
        try {
            ID = getDLS().getNextStructDirectiveId(person);
        } catch (Exception e) {
            throw new PortalException("Exception encountered while " + "generating new edit node " + "Id for userId=" + person.getID(), e);
        }
        edit = plf.createElement(type);
        edit.setAttribute(Constants.ATT_TYPE, type);
        edit.setAttribute(Constants.ATT_ID, ID);
        edit.setAttribute(Constants.ATT_NAME, attributeName);
        editSet.appendChild(edit);
    }
}
Also used : Element(org.w3c.dom.Element) PortalException(org.apereo.portal.PortalException) Document(org.w3c.dom.Document) PortalException(org.apereo.portal.PortalException)

Example 43 with PortalException

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

the class ParameterEditManager method getParmEditSet.

/**
 * Get the parameter edits set if any stored in the root of the document or create it if
 * passed-in create flag is true.
 */
private static Element getParmEditSet(Document plf, IPerson person, boolean create) throws PortalException {
    Node root = plf.getDocumentElement();
    Node child = root.getFirstChild();
    while (child != null) {
        if (child.getNodeName().equals(Constants.ELM_PARM_SET))
            return (Element) child;
        child = child.getNextSibling();
    }
    if (create == false)
        return null;
    String ID = null;
    try {
        ID = getDLS().getNextStructDirectiveId(person);
    } catch (Exception e) {
        throw new PortalException("Exception encountered while " + "generating new parameter edit set node " + "Id for userId=" + person.getID(), e);
    }
    Element parmSet = plf.createElement(Constants.ELM_PARM_SET);
    parmSet.setAttribute(Constants.ATT_TYPE, Constants.ELM_PARM_SET);
    parmSet.setAttribute(Constants.ATT_ID, ID);
    parmSet.setIdAttribute(Constants.ATT_ID, true);
    root.appendChild(parmSet);
    return parmSet;
}
Also used : Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException)

Example 44 with PortalException

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

the class ParameterEditManager method addParmEditDirective.

/**
 * This method does the actual work of adding a newly created parameter edit and adding it to
 * the parameter edits set.
 */
private static void addParmEditDirective(String targetID, String name, String value, IPerson person, Document plf, Element parmSet) throws PortalException {
    String ID = null;
    try {
        ID = getDLS().getNextStructDirectiveId(person);
    } catch (Exception e) {
        throw new PortalException("Exception encountered while " + "generating new parameter edit node " + "Id for userId=" + person.getID(), e);
    }
    Element parm = plf.createElement(Constants.ELM_PARM_EDIT);
    parm.setAttribute(Constants.ATT_TYPE, Constants.ELM_PARM_EDIT);
    parm.setAttribute(Constants.ATT_ID, ID);
    parm.setIdAttribute(Constants.ATT_ID, true);
    parm.setAttributeNS(Constants.NS_URI, Constants.ATT_TARGET, targetID);
    parm.setAttribute(Constants.ATT_NAME, name);
    parm.setAttribute(Constants.ATT_USER_VALUE, value);
    parmSet.appendChild(parm);
}
Also used : Element(org.w3c.dom.Element) PortalException(org.apereo.portal.PortalException) PortalException(org.apereo.portal.PortalException)

Example 45 with PortalException

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

the class PositionManager method getPositionSet.

/**
 * This method locates the position set element in the child list of the passed in plfParent or
 * if not found it will create one automatically and return it if the passed in create flag is
 * true.
 */
private static Element getPositionSet(Element plfParent, IPerson person, boolean create) throws PortalException {
    Node child = plfParent.getFirstChild();
    while (child != null) {
        if (child.getNodeName().equals(Constants.ELM_POSITION_SET))
            return (Element) child;
        child = child.getNextSibling();
    }
    if (create == false)
        return null;
    String ID = null;
    try {
        ID = getDLS().getNextStructDirectiveId(person);
    } catch (Exception e) {
        throw new PortalException("Exception encountered while " + "generating new position set node " + "Id for userId=" + person.getID(), e);
    }
    Document plf = plfParent.getOwnerDocument();
    Element positions = plf.createElement(Constants.ELM_POSITION_SET);
    positions.setAttribute(Constants.ATT_TYPE, Constants.ELM_POSITION_SET);
    positions.setAttribute(Constants.ATT_ID, ID);
    plfParent.appendChild(positions);
    return positions;
}
Also used : Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) PortalException(org.apereo.portal.PortalException) Document(org.w3c.dom.Document) XPathExpressionException(javax.xml.xpath.XPathExpressionException) PortalException(org.apereo.portal.PortalException) DOMException(org.w3c.dom.DOMException)

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