use of org.apereo.portal.PortalException in project uPortal by Jasig.
the class DistributedLayoutManager method getAllSubscribedChannels.
@Override
public Set<String> getAllSubscribedChannels() {
final Document uld = this.getUserLayoutDOM();
if (uld == null) {
throw new PortalException("UserLayout has not been initialized for " + owner.getAttribute(IPerson.USERNAME));
}
final NodeList channelElements = uld.getElementsByTagName(CHANNEL);
final Set<String> allSubscribedChannels = new LinkedHashSet<String>(channelElements.getLength());
for (int nodeIndex = 0; nodeIndex < channelElements.getLength(); nodeIndex++) {
final Element channelElement = (Element) channelElements.item(nodeIndex);
final String subscribeId = channelElement.getAttribute("ID");
allSubscribedChannels.add(subscribeId);
}
return allSubscribedChannels;
}
use of org.apereo.portal.PortalException in project uPortal by Jasig.
the class DistributedLayoutManager method getParentId.
public String getParentId(String nodeId) throws PortalException {
Document uld = this.getUserLayoutDOM();
Element nelement = uld.getElementById(nodeId);
if (nelement != null) {
Node parent = nelement.getParentNode();
if (parent != null) {
if (parent.getNodeType() != Node.ELEMENT_NODE) {
throw new PortalException("Node with id=\"" + nodeId + "\" is attached to something other then an element node.");
}
Element e = (Element) parent;
return e.getAttribute("ID");
}
return null;
}
throw new PortalException("Node with id=\"" + nodeId + "\" doesn't exist. Occurred in layout for " + owner.getAttribute(IPerson.USERNAME) + ".");
}
use of org.apereo.portal.PortalException in project uPortal by Jasig.
the class DistributedLayoutManager method getRootFolderId.
/* Returns the ID attribute of the root folder of the layout. This folder
* is defined to be the single child of the top most "layout" Element.
*
* @see org.apereo.portal.layout.IUserLayoutManager#getRootFolderId()
* @see org.apereo.portal.layout.dlm.RootLocator
*/
public String getRootFolderId() {
if (rootNodeId == null) {
Document layout = getUserLayoutDOM();
Element rootNode = this.xpathOperations.evaluate("//layout/folder", layout, XPathConstants.NODE);
if (rootNode == null || !rootNode.getAttribute(Constants.ATT_TYPE).equals(Constants.ROOT_FOLDER_ID)) {
LOG.error("Unable to locate root node in layout of " + owner.getAttribute(IPerson.USERNAME) + ". Resetting corrupted layout.");
resetLayout((String) null);
rootNode = this.xpathOperations.evaluate("//layout/folder", layout, XPathConstants.NODE);
if (rootNode == null || !rootNode.getAttribute(Constants.ATT_TYPE).equals(Constants.ROOT_FOLDER_ID)) {
throw new PortalException("Corrupted layout detected for " + owner.getAttribute(IPerson.USERNAME) + " and resetting layout failed.");
}
}
rootNodeId = rootNode.getAttribute("ID");
}
return rootNodeId;
}
use of org.apereo.portal.PortalException in project uPortal by Jasig.
the class HandlerUtils method createILFCopy.
/** Creates a copy of an ilf node in the plf and sets up necessary storage attributes. */
private static Element createILFCopy(Element compViewNode, Element compViewParent, boolean includeChildNodes, Document plf, Element plfParent, IPerson person) throws PortalException {
Element plfNode = (Element) plf.importNode(compViewNode, includeChildNodes);
// make sure that we don't include ILF restriction params in the PLF if
// this ILF node contained any.
plfNode.removeAttributeNS(Constants.NS_URI, Constants.LCL_ADD_CHILD_ALLOWED);
plfNode.removeAttributeNS(Constants.NS_URI, Constants.LCL_DELETE_ALLOWED);
plfNode.removeAttributeNS(Constants.NS_URI, Constants.LCL_EDIT_ALLOWED);
plfNode.removeAttributeNS(Constants.NS_URI, Constants.LCL_MOVE_ALLOWED);
String ID = plfNode.getAttribute(Constants.ATT_ID);
plfNode.setIdAttribute(Constants.ATT_ID, true);
IUserLayoutStore uls = null;
uls = UserLayoutStoreLocator.getUserLayoutStore();
if (plfNode.getAttribute(Constants.ATT_PLF_ID).equals("")) {
String plfID = null;
try {
if (!plfNode.getAttribute(Constants.ATT_CHANNEL_ID).equals(// dealing with a channel
""))
plfID = uls.generateNewChannelSubscribeId(person);
else
plfID = uls.generateNewFolderId(person);
} catch (Exception e) {
throw new PortalException("Exception encountered while " + "generating new user layout node " + "Id for userId=" + person.getID(), e);
}
plfNode.setAttributeNS(Constants.NS_URI, Constants.ATT_PLF_ID, plfID);
plfNode.setAttributeNS(Constants.NS_URI, Constants.ATT_ORIGIN, ID);
}
plfParent.appendChild(plfNode);
PositionManager.updatePositionSet(compViewParent, plfParent, person);
return plfNode;
}
use of org.apereo.portal.PortalException in project uPortal by Jasig.
the class EditManager method getEditSet.
/**
* Get the edit set if any stored in the passed in node. If not found and if the create flag is
* true then create a new edit set and add it as a child to the passed in node. Then return it.
*/
private static Element getEditSet(Element node, Document plf, IPerson person, boolean create) throws PortalException {
Node child = node.getFirstChild();
while (child != null) {
if (child.getNodeName().equals(Constants.ELM_EDIT_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 edit set node " + "Id for userId=" + person.getID(), e);
}
Element editSet = plf.createElement(Constants.ELM_EDIT_SET);
editSet.setAttribute(Constants.ATT_TYPE, Constants.ELM_EDIT_SET);
editSet.setAttribute(Constants.ATT_ID, ID);
node.appendChild(editSet);
return editSet;
}
Aggregations