📄 basejetspeedlink.java
字号:
* <dt>JetspeedLink.USER</dt><dd>Link will be to a User PSML. rootValue is a User Name</dd>
* </dl>
* @param rootValue See description of rootType
* @param pageName Name of page. null = default page
* @param elementType
* <dl>
* <dt>JetspeedLink.CURRENT</dt><dd>The link will retain the current Pane/Portlet referance. elementValue is not used</dd>
* <dt>JetspeedLink.DEFAULT</dt><dd>The link will NOT referance a pane or portlet. elementValue is not used</dd>
* <dt>JetspeedLink.PANE_ID</dt><dd>Link will be to a Pane using it's ID. elementValue is a Pane's ID</dd>
* <dt>JetspeedLink.PANE_NAME</dt><dd>Link will be to a Pane using it's Name. elementValue is a Pane's Name</dd>
* <dt>JetspeedLink.PORTLET_ID</dt><dd>Link will be to a Portlet using it's ID. elementValue is a Portlet's ID</dd>
* <dt>JetspeedLink.PORTLET_NAME</dt><dd>Link will be to a Portlet using it's Name. elementValue is a Portlet's Name</dd>
* <dt>JetspeedLink.PORTLET_ID_QUERY</dt><dd>Link will be to a Portlet using it's ID based on portlet name provided. elementValue is a Portlet's name. ID is for the first portlet with matching name</dd>
* </dl>
* @param elementValue
* See description of elementType
* @param actionName Name of action. If no action is desired use JetspeedLink.NO_ACTION.
* @param templateName
* Name of template. If no template is desired use JetspeedLink.NO_TEMPLATE.
* @param mediaType Desired media type. null = default media type
* @param language Desired language. null = default language
* @param country Desired country. null = default language
* @return URI to specific portlet
*/
public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName, String mediaType, String language, String country)
{
String uriPathType = null;
String uriPathElement = null;
try
{
DynamicURI uri = getRoot();
// Set Group/Role/User in path
switch (rootType)
{
case JetspeedLink.DEFAULT:
case JetspeedLink.CURRENT:
break;
case JetspeedLink.GROUP:
uriPathType = Profiler.PARAM_GROUP;
break;
case JetspeedLink.ROLE:
uriPathType = Profiler.PARAM_ROLE;
break;
case JetspeedLink.USER:
uriPathType = Profiler.PARAM_USER;
break;
}
if (rootType != JetspeedLink.CURRENT)
{
// Cleanup URI
uri.removePathInfo(Profiler.PARAM_GROUP);
uri.removePathInfo(Profiler.PARAM_ROLE);
uri.removePathInfo(Profiler.PARAM_USER);
if ((rootType != JetspeedLink.DEFAULT) && (rootValue != null) && (rootValue.trim().length() > 0))
{
uri.addPathInfo(uriPathType, rootValue);
}
}
// Set Page in path
if (pageName != null)
{
uri.removePathInfo(Profiler.PARAM_PAGE);
if (pageName.trim().length() > 0)
{
uri.addPathInfo(Profiler.PARAM_PAGE, pageName);
}
}
// Set Portlet/Pane in path
switch (elementType)
{
case JetspeedLink.CURRENT:
case JetspeedLink.DEFAULT:
break;
case JetspeedLink.PANE_ID:
uriPathElement = JetspeedResources.PATH_PANEID_KEY;
break;
case JetspeedLink.PANE_NAME:
uriPathElement = JetspeedResources.PATH_PANENAME_KEY;
break;
case JetspeedLink.PORTLET_ID:
uriPathElement = JetspeedResources.PATH_PORTLETID_KEY;
break;
case JetspeedLink.PORTLET_NAME:
uriPathElement = JetspeedResources.PATH_PORTLET_KEY;
break;
case JetspeedLink.PORTLET_ID_QUERY:
if (logger.isDebugEnabled())
{
logger.debug("BaseJetspeedLink: elementValue = " + elementValue);
}
uriPathElement = JetspeedResources.PATH_PORTLETID_KEY;
ProfileLocator baseLocator = Profiler.createLocator();
Profile baseProfile = null;
switch (rootType)
{
case JetspeedLink.DEFAULT:
break;
case JetspeedLink.CURRENT:
baseProfile = rundata.getProfile();
break;
case JetspeedLink.GROUP:
baseLocator.setGroupByName(rootValue);
break;
case JetspeedLink.ROLE:
baseLocator.setRoleByName(rootValue);
break;
case JetspeedLink.USER:
try
{
if (logger.isDebugEnabled())
{
logger.debug("BaseJetspeedLink: rootValue user = " + rootValue);
}
baseLocator.setUser(org.apache.jetspeed.services.JetspeedSecurity.getUser(rootValue));
}
catch (Exception se)
{
logger.error("Exception", se);
return null;
}
break;
}
if ((rootType != JetspeedLink.CURRENT) && (rootType != JetspeedLink.DEFAULT))
{
if (mediaType != null && mediaType.length() > 0)
{
baseLocator.setMediaType(mediaType);
}
if (language != null && language.length() > 0)
{
baseLocator.setLanguage(language);
}
if (country != null && country.length() > 0)
{
baseLocator.setCountry(country);
}
if (pageName != null && pageName.length() > 0)
{
baseLocator.setName(pageName);
}
baseProfile = Profiler.getProfile(baseLocator);
}
if (logger.isDebugEnabled())
{
logger.debug("BaseJetspeedLink: baseLocator = " + baseLocator.getPath());
}
if ((baseProfile != null) && (elementValue != null))
{
if (logger.isDebugEnabled())
{
logger.debug("BaseJetspeedLink: baseProfile = " + baseProfile.toString());
}
if (baseProfile.getDocument() != null)
{
if (logger.isDebugEnabled())
{
logger.debug("BaseJetspeedLink: baseProfile.getDocment() = " + baseProfile.getDocument());
}
Entry entry = baseProfile.getDocument().getEntry(elementValue);
if (entry != null)
{
if (logger.isDebugEnabled())
{
logger.debug("BaseJetspeedLink: entry id = " + entry.getId());
}
elementValue = entry.getId();
}
else
{
elementValue = null;
}
}
}
break;
}
if (elementType != JetspeedLink.CURRENT)
{
// Remove Group/Role/User in URI
uri.removePathInfo(JetspeedResources.PATH_PANEID_KEY);
uri.removePathInfo(JetspeedResources.PATH_PANENAME_KEY);
uri.removePathInfo(JetspeedResources.PATH_PORTLETID_KEY);
uri.removePathInfo(JetspeedResources.PATH_PORTLET_KEY);
if ((elementType != JetspeedLink.DEFAULT) && (elementValue != null) && (elementValue.length() > 0))
{
uri.addPathInfo(uriPathElement, elementValue);
}
}
// Set Template in path
if (templateName != null)
{
uri.removePathInfo(JetspeedResources.PATH_TEMPLATE_KEY);
if (templateName.length() > 0)
{
uri.addPathInfo(JetspeedResources.PATH_TEMPLATE_KEY, templateName);
}
}
// Set Action in path
if (actionName != null)
{
uri.removeQueryData(JetspeedResources.PATH_ACTION_KEY);
if (actionName.length() > 0)
{
uri.addQueryData(JetspeedResources.PATH_ACTION_KEY, actionName);
}
}
// Set MediaType in path
if (mediaType != null)
{
uri.removePathInfo(Profiler.PARAM_MEDIA_TYPE);
if (mediaType.length() > 0)
{
uri.addPathInfo(Profiler.PARAM_MEDIA_TYPE, mediaType);
}
}
// Set Language in path
if (language != null)
{
uri.removePathInfo(Profiler.PARAM_LANGUAGE);
if (language.length() > 0)
{
uri.addPathInfo(Profiler.PARAM_LANGUAGE, language);
}
}
// Set Country in path
if (country != null)
{
uri.removePathInfo(Profiler.PARAM_COUNTRY);
if (country.length() > 0)
{
uri.addPathInfo(Profiler.PARAM_COUNTRY, country);
}
}
return uri;
}
catch (ProfileException e)
{
logger.error("Exception", e);
return null;
}
}
public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName, String mediaType, String language)
{
return getLink(rootType, rootValue, pageName, elementType, elementValue, actionName, templateName, mediaType, language, null);
}
public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName, String mediaType)
{
return getLink(rootType, rootValue, pageName, elementType, elementValue, actionName, templateName, mediaType, null, null);
}
public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName)
{
return getLink(rootType, rootValue, pageName, elementType, elementValue, actionName, actionName, null, null, null);
}
public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName)
{
return getLink(rootType, rootValue, pageName, elementType, elementValue, actionName, null, null, null, null);
}
/**
*/
public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue)
{
return getLink(rootType, rootValue, pageName, elementType, elementValue, null, null, null, null, null);
}
/**
* Return a link that includes an action
*
* @param action action
* @return DynamicURI that includes the desire action
*/
public DynamicURI getAction(String action)
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.CURRENT, null, action, null, null, null, null);
}
/**
* Return a link that includes an action to a specific portlet, as defined
* by an entry
*
* @param action Desired action
* @param entry to receive the action
* @return DynamicURI that includes the desire action
*/
public DynamicURI getAction(String action, Entry entry)
{
if (entry != null)
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, entry.getId(), null, action, null, null, null);
}
else
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, null, null, action, null, null, null);
}
}
/**
* Return a link that includes an action to a specific portlet
*
* @param action Desired action
* @param portlet to receive the action
* @return DynamicURI that includes the desire action
*/
public DynamicURI getAction(String action, Portlet portlet)
{
if (portlet != null)
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, portlet.getID(), action, null, null, null, null);
}
else
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, null, action, null, null, null, null);
}
}
/**
* Return a link that includes an action to a specific portlet, as defined
* by a portlets
*
* @param action Desired action
* @param portlets to receive the action
* @return DynamicURI that includes the desire action
*/
public DynamicURI getAction(String action, Portlets portlets)
{
if (portlets != null)
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, portlets.getId(), action, null, null, null, null);
}
else
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, null, action, null, null, null, null);
}
}
/**
* Return a link that includes an action to a specific portlet, as defined
* by a PEID
*
* @param action Desired action
* @param peid Id of the portlet to receive the action
* @return DynamicURI that includes the desire action
*/
public DynamicURI getAction(String action, String peid)
{
return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.PORTLET_ID, peid, action, null, null, null, null);
}
/**
* Return a link to a default page for the group
*
* @param group Desired group
* @return DynamicURI that to the default page for the group
*/
public DynamicURI getGroup(String group)
{
return getLink(JetspeedLink.GROUP, group, "", JetspeedLink.DEFAULT, null, null, null, null, null, null);
}
/**
* Return a link to a desired page for the group
*
* @param page Desired page
* @param group Desired group
* @return DynamicURI that to the desired group and page
*/
public DynamicURI getGroup(String group, String page)
{
return getLink(JetspeedLink.GROUP, group, page, JetspeedLink.DEFAULT, null, null, null, null, null, null);
}
/**
* Return a link to a default page for the
* current user, group, or role.
*
* @return DynamicURI that to the default page
*/
public DynamicURI getPage()
{
return getLink(JetspeedLink.CURRENT, null, "", JetspeedLink.DEFAULT, null, null, null, null, null, null);
}
/**
* Return a link to a desired page for the
* current user, group, or role.
*
* @param page Desired page
* @return DynamicURI that to the desired page
*/
public DynamicURI getPage(String page)
{
return getLink(JetspeedLink.CURRENT, null, page, JetspeedLink.DEFAULT, null, null, null, null, null, null);
}
/**
* Return a link to a desired page and pane for the
* current user, group, or role.
*
* @param page Desired page
* @param paneName Name of the desired pane
* @return DynamicURI that to the desired page
*/
public DynamicURI getPage(String page, String paneName)
{
return getLink(JetspeedLink.CURRENT, null, page, JetspeedLink.PANE_NAME, paneName, null, null, null, null, null);
}
/**
* Return a link to a specific pane using the pane's id
*
* @param paneId of the Pane
* @return URI to specific portlet
*/
public DynamicURI getPaneById(String paneId)
{
return getLink(JetspeedLink.CURRENT, null, this.getPageName(), JetspeedLink.PANE_ID, paneId, null, null, null, null, null);
}
/**
* Return a link to a specific pane using the pane's id
*
* @param paneName Name of the Pane
* @return URI to specific portlet
*/
public DynamicURI getPaneByName(String paneName)
{
return getLink(JetspeedLink.CURRENT, null, this.getPageName(), JetspeedLink.PANE_NAME, paneName, null, null, null, null, null);
}
/**
* Return an link to a specific portlet using the portet's id
*
* @param peid of the portlet
* @return DynamicURI to specific portlet
*/
public DynamicURI getPortletById(String peid)
{
return getLink(JetspeedLink.CURRENT, null, this.getPageName(), JetspeedLink.PORTLET_ID, peid, null, null, null, null, null);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -