本文整理匯總了Java中javax.portlet.PortletException類的典型用法代碼示例。如果您正苦於以下問題:Java PortletException類的具體用法?Java PortletException怎麽用?Java PortletException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PortletException類屬於javax.portlet包,在下文中一共展示了PortletException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: render
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {
_log.info("render()");
try {
TaskRecord taskRecord = ActionUtil.getTaskRecord(renderRequest);
renderRequest.setAttribute(TimetrackerWebKeys.TASK_RECORD, taskRecord);
} catch (Exception e) {
if (e instanceof NoSuchTaskRecordException || e instanceof PrincipalException) {
SessionErrors.add(renderRequest, e.getClass());
return "/error.jsp";
} else {
throw new PortletException(e);
}
}
return getPath();
}
示例2: doEdit
import javax.portlet.PortletException; //導入依賴的package包/類
/**
* Routes between global configuration editing and tab editing
*
* @param request The request
* @param response The response
* @throws PortletException If something goes wrong
* @throws IOException If something goes wrong
*/
@Override
protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// Very, very simple routing. That's all we need, folks.
String editModeParam = ParamUtil.get(request, PortletRequestParameter.EDIT_MODE.getName(), StringPool.BLANK);
EditMode editMode = EditMode.getEditMode(editModeParam);
switch(editMode) {
case TAB:
this.doEditTab(request, response);
break;
case FACET:
this.doEditFacet(request, response);
break;
default:
this.doEditGlobal(request, response);
break;
}
}
示例3: actionSaveGlobal
import javax.portlet.PortletException; //導入依賴的package包/類
/**
* Saves the global aspect of the configuration
*
* @param request The request
* @param response The response
* @throws IOException If something goes wrong
* @throws PortletException If something goes wrong
*/
@ProcessAction(name = ACTION_NAME_SAVE_GLOBAL)
public void actionSaveGlobal(ActionRequest request, ActionResponse response) throws IOException, PortletException {
String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK);
String adtUuid = ParamUtil.get(request, FORM_FIELD_ADT_UUID, StringPool.BLANK);
boolean doSearchOnStartup = ParamUtil.getBoolean(request, FORM_FIELD_DO_SEARCH_ON_STARTUP, false);
if (!PATTERN_UUID.matcher(adtUuid).matches()) {
adtUuid = StringPool.BLANK;
}
String doSearchOnStartupKeywords = ParamUtil.getString(request, FORM_FIELD_DO_SEARCH_ON_STARTUP_KEYWORDS, FlashlightSearchService.CONFIGURATION_DEFAULT_SEARCH_KEYWORDS);
this.searchService.saveGlobalSettings(adtUuid, doSearchOnStartup, doSearchOnStartupKeywords, request.getPreferences());
SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED);
if (!redirectUrl.isEmpty()) {
response.sendRedirect(redirectUrl);
}
}
示例4: actionSaveFacetConfig
import javax.portlet.PortletException; //導入依賴的package包/類
/**
* This action saves the Liferay facet configuration for a given tab
*
* @param request The request
* @param response The response
* @throws PortletException If something goes wrong
* @throws IOException If something goes wrong
*/
@ProcessAction(name = ACTION_NAME_SAVE_FACET_CONFIG)
public void actionSaveFacetConfig(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK);
String facetClassName = ParamUtil.get(request, FORM_FIELD_FACET_CLASS_NAME, StringPool.BLANK);
String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK);
PortletPreferences preferences = request.getPreferences();
FlashlightSearchConfiguration configuration = this.searchService.readConfiguration(preferences);
SearchFacet targetFacet = this.getSearchFacetFromRequest(tabId, facetClassName, configuration);
if(targetFacet != null) {
JSONObject facetConfiguration = targetFacet.getJSONData(request);
targetFacet.getFacetConfiguration().setDataJSONObject(facetConfiguration);
this.searchService.saveSearchFacetConfig(configuration.getTabs().get(tabId), targetFacet, preferences);
SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED);
response.sendRedirect(redirectUrl);
}
}
示例5: actionDeleteTab
import javax.portlet.PortletException; //導入依賴的package包/類
/**
* Deletes a tab from the configuration
*
* @param request The request
* @param response The response
* @throws PortletException If something goes wrong
* @throws IOException If something goes wrong
*/
@ProcessAction(name = ACTION_NAME_DELETE_TAB)
public void actionDeleteTab(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK);
String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK);
if (tabId != null && PATTERN_UUID.matcher(tabId).matches()) {
PortletPreferences preferences = request.getPreferences();
Map<String, FlashlightSearchConfigurationTab> tabs = this.searchService.readConfiguration(preferences).getTabs();
if (tabs.containsKey(tabId)) {
this.searchService.deleteConfigurationTab(tabId, preferences);
}
}
SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED);
if (!redirectUrl.isEmpty()) {
response.sendRedirect(redirectUrl);
}
}
示例6: init
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public void init(PortletConfig config) throws PortletException {
super.init(config);
this.templatesPath = config.getInitParameter(INIT_PARAM_TEMPLATES_PATH);
if(this.templatesPath == null) {
throw new PortletException("Templates path not specified in init parameters.");
}
if(!this.templatesPath.endsWith(StringPool.SLASH)) {
this.templatesPath = this.templatesPath.concat(StringPool.SLASH);
}
this.portal = this.getPortal();
this.templateManager = this.getTemplateManager();
try {
this.templateResourceLoader = TemplateResourceLoaderUtil.getTemplateResourceLoader(this.templateManager.getName());
} catch(TemplateException e) {
throw new PortletException(e);
}
}
示例7: render
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {
_log.info("render()");
try {
Contact contact = ActionUtil.getContact(renderRequest);
renderRequest.setAttribute(ContactManagerWebKeys.CONTACT, contact);
} catch (Exception e) {
if (e instanceof NoSuchContactException || e instanceof PrincipalException) {
SessionErrors.add(renderRequest, e.getClass());
return "/error.jsp";
} else {
throw new PortletException(e);
}
}
return getPath();
}
示例8: renderFromMobilink
import javax.portlet.PortletException; //導入依賴的package包/類
private void renderFromMobilink(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
renderFrontendWebEmployeePortlet(renderRequest, renderResponse);
renderFrontendWebJobposPortlet(renderRequest, renderResponse);
renderFrontendWebAdminPortlet(renderRequest, renderResponse);
renderFrontendWebWorkingUnitPortlet(renderRequest, renderResponse);
renderFrontendWebNotificationPortlet(renderRequest, renderResponse);
renderRequest.setAttribute(
"url", generateURLCommon(renderRequest, renderResponse));
renderRequest.setAttribute("constants", generalConstantsCommon(renderRequest));
renderRequest.setAttribute("param", generalParamsCommon(renderRequest));
}
示例9: render
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {
// Get Mode
String mode = ParamUtil.getString(
renderRequest,
LDFPortletKeys.MODE,
LDFPortletKeys.MODE_ORGANIZAION);
// Carry around mode
renderRequest.setAttribute(LDFPortletKeys.MODE, mode);
if(_log.isDebugEnabled()) {
_log.debug("mode <" + mode + ">");
_log.debug("jsp <" + _commonUtil
.getPageFromMode()
.getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION) + ">");
}
return _commonUtil
.getPageFromMode()
.getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION);
}
示例10: render
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {
_log.info("render()");
try {
Measurement measurement = ActionUtil.getMeasurement(renderRequest);
renderRequest.setAttribute(DataManagerWebKeys.MEASUREMENT, measurement);
} catch (Exception e) {
if (e instanceof NoSuchMeasurementException || e instanceof PrincipalException) {
SessionErrors.add(renderRequest, e.getClass());
return "/error.jsp";
} else {
throw new PortletException(e);
}
}
return getPath();
}
示例11: validate
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public void validate(PortletRequest request) throws PortletException {
if (!PortletAnnotationMappingUtils.checkHeaders(this.headers, request)) {
throw new PortletRequestBindingException("Header conditions \"" +
StringUtils.arrayToDelimitedString(this.headers, ", ") +
"\" not met for actual request");
}
if (!this.methods.isEmpty()) {
if (!(request instanceof ClientDataRequest)) {
throw new PortletRequestMethodNotSupportedException(StringUtils.toStringArray(this.methods));
}
String method = ((ClientDataRequest) request).getMethod();
if (!this.methods.contains(method)) {
throw new PortletRequestMethodNotSupportedException(method, StringUtils.toStringArray(this.methods));
}
}
}
示例12: postProcessAfterInitialization
import javax.portlet.PortletException; //導入依賴的package包/類
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof Portlet) {
PortletConfig config = this.portletConfig;
if (config == null || !this.useSharedPortletConfig) {
config = new DelegatingPortletConfig(beanName, this.portletContext, this.portletConfig);
}
try {
((Portlet) bean).init(config);
}
catch (PortletException ex) {
throw new BeanInitializationException("Portlet.init threw exception", ex);
}
}
return bean;
}
示例13: PortletConfigPropertyValues
import javax.portlet.PortletException; //導入依賴的package包/類
/**
* Create new PortletConfigPropertyValues.
* @param config PortletConfig we'll use to take PropertyValues from
* @param requiredProperties set of property names we need, where
* we can't accept default values
* @throws PortletException if any required properties are missing
*/
private PortletConfigPropertyValues(PortletConfig config, Set<String> requiredProperties)
throws PortletException {
Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ?
new HashSet<String>(requiredProperties) : null;
Enumeration<String> en = config.getInitParameterNames();
while (en.hasMoreElements()) {
String property = en.nextElement();
Object value = config.getInitParameter(property);
addPropertyValue(new PropertyValue(property, value));
if (missingProps != null) {
missingProps.remove(property);
}
}
// fail if we are still missing properties
if (missingProps != null && missingProps.size() > 0) {
throw new PortletException(
"Initialization from PortletConfig for portlet '" + config.getPortletName() +
"' failed; the following required properties were missing: " +
StringUtils.collectionToDelimitedString(missingProps, ", "));
}
}
示例14: serveResource
import javax.portlet.PortletException; //導入依賴的package包/類
/**
* Serve the resource as specified in the given request to the given response,
* using the PortletContext's request dispatcher.
* <p>This is roughly equivalent to Portlet 2.0 GenericPortlet.
* @param request the current resource request
* @param response the current resource response
* @param context the current Portlet's PortletContext
* @throws PortletException propagated from Portlet API's forward method
* @throws IOException propagated from Portlet API's forward method
*/
public static void serveResource(ResourceRequest request, ResourceResponse response, PortletContext context)
throws PortletException, IOException {
String id = request.getResourceID();
if (id != null) {
if (!PortletUtils.isProtectedResource(id)) {
PortletRequestDispatcher rd = context.getRequestDispatcher(id);
if (rd != null) {
rd.forward(request, response);
return;
}
}
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, "404");
}
}
示例15: unknownRequiredInitParameter
import javax.portlet.PortletException; //導入依賴的package包/類
@Test
public void unknownRequiredInitParameter() throws Exception {
String testParam = "testParam";
String testValue = "testValue";
portletConfig.addInitParameter(testParam, testValue);
TestPortletBean portletBean = new TestPortletBean();
portletBean.addRequiredProperty("unknownParam");
assertNull(portletBean.getTestParam());
try {
portletBean.init(portletConfig);
fail("should have thrown PortletException");
}
catch (PortletException ex) {
// expected
}
assertNull(portletBean.getTestParam());
}