use of org.apereo.portal.portlet.om.IPortletDefinitionParameter in project uPortal by Jasig.
the class RDBMDistributedLayoutStore method saveStructure.
@Override
protected int saveStructure(Node node, PreparedStatement structStmt, PreparedStatement parmStmt) throws SQLException {
if (node == null) {
// No more
return 0;
}
if (node.getNodeName().equals("parameter")) {
// parameter, skip it and go on to the next node
return this.saveStructure(node.getNextSibling(), structStmt, parmStmt);
}
if (!(node instanceof Element)) {
return 0;
}
final Element structure = (Element) node;
if (logger.isDebugEnabled()) {
logger.debug("saveStructure XML content: {}", XmlUtilitiesImpl.toString(node));
}
// determine the struct_id for storing in the db. For incorporated nodes in
// the plf their ID is a system-wide unique ID while their struct_id for
// storing in the db is cached in a dlm:plfID attribute.
int saveStructId = -1;
final String plfID = structure.getAttribute(Constants.ATT_PLF_ID);
if (!plfID.equals("")) {
saveStructId = Integer.parseInt(plfID.substring(1));
} else {
final String id = structure.getAttribute("ID");
saveStructId = Integer.parseInt(id.substring(1));
}
int nextStructId = 0;
int childStructId = 0;
int chanId = -1;
IPortletDefinition portletDef = null;
final boolean isChannel = node.getNodeName().equals("channel");
if (isChannel) {
chanId = Integer.parseInt(node.getAttributes().getNamedItem("chanID").getNodeValue());
portletDef = this.portletDefinitionRegistry.getPortletDefinition(String.valueOf(chanId));
if (portletDef == null) {
// Portlet doesn't exist any more, drop the layout node
return 0;
}
}
if (node.hasChildNodes()) {
childStructId = this.saveStructure(node.getFirstChild(), structStmt, parmStmt);
}
nextStructId = this.saveStructure(node.getNextSibling(), structStmt, parmStmt);
structStmt.clearParameters();
structStmt.setInt(1, saveStructId);
structStmt.setInt(2, nextStructId);
structStmt.setInt(3, childStructId);
final String externalId = structure.getAttribute("external_id");
if (externalId != null && externalId.trim().length() > 0) {
final Integer eID = new Integer(externalId);
structStmt.setInt(4, eID.intValue());
} else {
structStmt.setNull(4, java.sql.Types.NUMERIC);
}
if (isChannel) {
structStmt.setInt(5, chanId);
structStmt.setNull(6, java.sql.Types.VARCHAR);
} else {
structStmt.setNull(5, java.sql.Types.NUMERIC);
structStmt.setString(6, structure.getAttribute("name"));
}
final String structType = structure.getAttribute("type");
structStmt.setString(7, structType);
structStmt.setString(8, RDBMServices.dbFlag(xmlBool(structure.getAttribute("hidden"))));
structStmt.setString(9, RDBMServices.dbFlag(xmlBool(structure.getAttribute("immutable"))));
structStmt.setString(10, RDBMServices.dbFlag(xmlBool(structure.getAttribute("unremovable"))));
logger.debug(structStmt.toString());
structStmt.executeUpdate();
// code to persist extension attributes for dlm
final NamedNodeMap attribs = node.getAttributes();
for (int i = 0; i < attribs.getLength(); i++) {
final Node attrib = attribs.item(i);
final String name = attrib.getNodeName();
if (name.startsWith(Constants.NS) && !name.equals(Constants.ATT_PLF_ID) && !name.equals(Constants.ATT_FRAGMENT) && !name.equals(Constants.ATT_PRECEDENCE)) {
// a cp extension attribute. Push into param table.
parmStmt.clearParameters();
parmStmt.setInt(1, saveStructId);
parmStmt.setString(2, name);
parmStmt.setString(3, attrib.getNodeValue());
logger.debug(parmStmt.toString());
parmStmt.executeUpdate();
}
}
final NodeList parameters = node.getChildNodes();
if (parameters != null && isChannel) {
for (int i = 0; i < parameters.getLength(); i++) {
if (parameters.item(i).getNodeName().equals("parameter")) {
final Element parmElement = (Element) parameters.item(i);
final NamedNodeMap nm = parmElement.getAttributes();
final String parmName = nm.getNamedItem("name").getNodeValue();
final String parmValue = nm.getNamedItem("value").getNodeValue();
final Node override = nm.getNamedItem("override");
// if no override specified then default to allowed
if (override != null && !override.getNodeValue().equals("yes")) {
// can't override
} else {
// override only for adhoc or if diff from chan def
final IPortletDefinitionParameter cp = portletDef.getParameter(parmName);
if (cp == null || !cp.getValue().equals(parmValue)) {
parmStmt.clearParameters();
parmStmt.setInt(1, saveStructId);
parmStmt.setString(2, parmName);
parmStmt.setString(3, parmValue);
logger.debug(parmStmt.toString());
parmStmt.executeUpdate();
}
}
}
}
}
return saveStructId;
}
use of org.apereo.portal.portlet.om.IPortletDefinitionParameter in project uPortal by Jasig.
the class PortletExecutionManager method doPortletAction.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.rendering.IPortletExecutionManager#doPortletAction(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public void doPortletAction(IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
final long timeout = getPortletActionTimeout(portletWindowId, request);
final IPortletExecutionWorker<Long> portletActionExecutionWorker = this.portletWorkerFactory.createActionWorker(request, response, portletWindowId);
portletActionExecutionWorker.submit();
try {
portletActionExecutionWorker.get(timeout);
} catch (Exception e) {
// put the exception into the error map for the session
final Map<IPortletWindowId, Exception> portletFailureMap = getPortletErrorMap(request);
portletFailureMap.put(portletWindowId, e);
}
// If the worker is still running add it to the hung-workers queue
if (!portletActionExecutionWorker.isComplete()) {
cancelWorker(request, portletActionExecutionWorker);
}
// Is this portlet permitted to emit events? (Or is it disablePortletEvents=true?)
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(request, portletWindowId);
IPortletDefinition portletDefinition = portletWindow.getPortletEntity().getPortletDefinition();
IPortletDefinitionParameter disablePortletEvents = portletDefinition.getParameter(DISABLE_PORTLET_EVENTS_PARAMETER);
if (disablePortletEvents != null && Boolean.parseBoolean(disablePortletEvents.getValue())) {
logger.info("Ignoring portlet events for portlet '{}' because they have been disabled.", portletDefinition.getFName());
} else {
// Proceed with events...
final PortletEventQueue portletEventQueue = this.eventCoordinationService.getPortletEventQueue(request);
this.doPortletEvents(portletEventQueue, request, response);
}
}
use of org.apereo.portal.portlet.om.IPortletDefinitionParameter in project uPortal by Jasig.
the class ChannelListController method preparePortletDefinitionBean.
private PortletDefinitionBean preparePortletDefinitionBean(WebRequest req, IPortletDefinition portlet, Locale locale) {
MarketplacePortletDefinition mktpd = marketplaceService.getOrCreateMarketplacePortletDefinition(portlet);
PortletDefinitionBean rslt = PortletDefinitionBean.fromMarketplacePortletDefinition(mktpd, locale);
// See api docs for postProcessIconUrlParameter() below
IPortletDefinitionParameter iconParameter = rslt.getParameters().get(ICON_URL_PARAMETER_NAME);
if (iconParameter != null) {
IPortletDefinitionParameter evaluated = postProcessIconUrlParameter(iconParameter, req);
rslt.putParameter(evaluated);
}
return rslt;
}
use of org.apereo.portal.portlet.om.IPortletDefinitionParameter in project uPortal by Jasig.
the class TransientUserLayoutManagerWrapper method createUserLayoutChannelDescription.
protected IUserLayoutChannelDescription createUserLayoutChannelDescription(String nodeId, IPortletDefinition chanDef) {
IUserLayoutChannelDescription ulnd = new UserLayoutChannelDescription();
ulnd.setId(nodeId);
ulnd.setName(chanDef.getName());
ulnd.setUnremovable(true);
ulnd.setImmutable(true);
ulnd.setHidden(false);
ulnd.setTitle(chanDef.getTitle());
ulnd.setDescription(chanDef.getDescription());
ulnd.setChannelPublishId("" + chanDef.getPortletDefinitionId().getStringId());
ulnd.setChannelTypeId("" + chanDef.getType().getId());
ulnd.setFunctionalName(chanDef.getFName());
ulnd.setTimeout(chanDef.getTimeout());
Set<IPortletDefinitionParameter> parms = chanDef.getParameters();
for (IPortletDefinitionParameter parm : parms) {
ulnd.setParameterValue(parm.getName(), parm.getValue());
}
return ulnd;
}
use of org.apereo.portal.portlet.om.IPortletDefinitionParameter in project uPortal by Jasig.
the class ChannelListController method getChannel.
private ChannelBean getChannel(IPortletDefinition definition, WebRequest request, Locale locale) {
ChannelBean channel = new ChannelBean();
channel.setId(definition.getPortletDefinitionId().getStringId());
channel.setDescription(definition.getDescription(locale.toString()));
channel.setFname(definition.getFName());
channel.setName(definition.getName(locale.toString()));
channel.setState(definition.getLifecycleState().toString());
channel.setTitle(definition.getTitle(locale.toString()));
channel.setTypeId(definition.getType().getId());
// See api docs for postProcessIconUrlParameter() below
IPortletDefinitionParameter iconParameter = definition.getParameter(ICON_URL_PARAMETER_NAME);
if (iconParameter != null) {
IPortletDefinitionParameter evaluated = postProcessIconUrlParameter(iconParameter, request);
channel.setIconUrl(evaluated.getValue());
}
return channel;
}
Aggregations