本文整理汇总了Java中javax.portlet.ResourceResponse类的典型用法代码示例。如果您正苦于以下问题:Java ResourceResponse类的具体用法?Java ResourceResponse怎么用?Java ResourceResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceResponse类属于javax.portlet包,在下文中一共展示了ResourceResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest request, ResourceResponse response)
throws Exception {
String cmd = ParamUtil.getString(request, Constants.CMD);
String serializedJson = "";
if(cmd.equals(CMD_PAGELIST)) {
serializedJson = getPageLists(request,response );
} else {
_log.error("Unknown command is passed <" + cmd + ">");
}
HttpServletResponse servletResponse = _portal.getHttpServletResponse(
response);
servletResponse.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(servletResponse, serializedJson);
}
示例2: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
PortletRequestDispatcher portletRequestDispatcher = null;
if (cmd.equals(Constants.IMPORT)) {
portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp");
} else {
portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest,
"/import/new_import/import_task_records_resources.jsp");
}
portletRequestDispatcher.include(resourceRequest, resourceResponse);
}
示例3: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
PortletRequestDispatcher portletRequestDispatcher = null;
if (cmd.equals(Constants.IMPORT)) {
portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp");
} else {
portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest,
"/import/new_import/import_contacts_resources.jsp");
}
portletRequestDispatcher.include(resourceRequest, resourceResponse);
}
示例4: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(
ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
if (_log.isDebugEnabled()) {
_log.debug("GetHelpTextMVCResourceCommand.doServeResource()");
}
JSONObject helpObject = JSONFactoryUtil.createJSONObject();
helpObject.put(GSearchWebKeys.HELP_TEXT, getHelpText(resourceRequest));
JSONPortletResponseUtil.writeJSON(
resourceRequest, resourceResponse, helpObject);
}
示例5: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
String serializedJson = "";
if (cmd.equals(CMD_ROLELIST)) {
serializedJson = getRoleLists(resourceRequest, resourceResponse);
} else {
_log.error("Unknown command is passed <" + cmd + ">");
}
HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(response, serializedJson);
}
示例6: createReturnJson
import javax.portlet.ResourceResponse; //导入依赖的package包/类
/**
* Create Return json value
*
* @param resourceRequest
* @param resourceResponse
* @param urls URL string list
* @return json URL strings
*/
protected String createReturnJson(ResourceRequest resourceRequest, ResourceResponse resourceResponse, List<String> urls) {
JSONObject rootJSONObject = JSONFactoryUtil.createJSONObject();
//Add plain text with line breaks for textarea
rootJSONObject.put("urlstr", String.join(LDFPortletKeys.EOL, urls));
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
for ( String url : urls) {
JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject();
curUserJSONObject.put("url", url);
jsonArray.put(curUserJSONObject);
}
rootJSONObject.put("urllist", jsonArray);
return rootJSONObject.toJSONString();
}
示例7: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
String serializedJson = "";
if(cmd.equals(CMD_THREAD_LIST)) {
serializedJson = getThreadList(resourceRequest,resourceResponse );
} else if (cmd.equals(CMD_CATEGORY_LIST)) {
serializedJson = getCategoryList(resourceRequest,resourceResponse );
} else {
_log.error("Unknown command is passed <" + cmd + ">");
}
HttpServletResponse response = _portal.getHttpServletResponse(
resourceResponse);
response.setContentType(ContentTypes.APPLICATION_JSON);
ServletResponseUtil.write(response, serializedJson);
}
示例8: doServeResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
// _log.info("doServeResource()");
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
// _log.info("cmd = " + cmd);
PortletRequestDispatcher portletRequestDispatcher = null;
if (cmd.equals(Constants.IMPORT)) {
portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp");
} else {
portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest,
"/import/new_import/import_measurements_resources.jsp");
}
portletRequestDispatcher.include(resourceRequest, resourceResponse);
}
示例9: determineDefaultPhase
import javax.portlet.ResourceResponse; //导入依赖的package包/类
private String determineDefaultPhase(Method handlerMethod) {
if (void.class != handlerMethod.getReturnType()) {
return PortletRequest.RENDER_PHASE;
}
for (Class<?> argType : handlerMethod.getParameterTypes()) {
if (ActionRequest.class.isAssignableFrom(argType) || ActionResponse.class.isAssignableFrom(argType) ||
InputStream.class.isAssignableFrom(argType) || Reader.class.isAssignableFrom(argType)) {
return PortletRequest.ACTION_PHASE;
}
else if (RenderRequest.class.isAssignableFrom(argType) || RenderResponse.class.isAssignableFrom(argType) ||
OutputStream.class.isAssignableFrom(argType) || Writer.class.isAssignableFrom(argType)) {
return PortletRequest.RENDER_PHASE;
}
else if (ResourceRequest.class.isAssignableFrom(argType) || ResourceResponse.class.isAssignableFrom(argType)) {
return PortletRequest.RESOURCE_PHASE;
}
else if (EventRequest.class.isAssignableFrom(argType) || EventResponse.class.isAssignableFrom(argType)) {
return PortletRequest.EVENT_PHASE;
}
}
return "";
}
示例10: processHandlerException
import javax.portlet.ResourceResponse; //导入依赖的package包/类
/**
* Determine an error ModelAndView via the registered HandlerExceptionResolvers.
* @param request current portlet request
* @param response current portlet response
* @param handler the executed handler, or null if none chosen at the time of
* the exception (for example, if multipart resolution failed)
* @param ex the exception that got thrown during handler execution
* @return a corresponding ModelAndView to forward to
* @throws Exception if no error ModelAndView found
*/
protected ModelAndView processHandlerException(
ResourceRequest request, ResourceResponse response, Object handler, Exception ex)
throws Exception {
ModelAndView exMv = null;
for (Iterator<HandlerExceptionResolver> it = this.handlerExceptionResolvers.iterator(); exMv == null && it.hasNext();) {
HandlerExceptionResolver resolver = it.next();
exMv = resolver.resolveException(request, response, handler, ex);
}
if (exMv != null) {
if (logger.isDebugEnabled()) {
logger.debug("HandlerExceptionResolver returned ModelAndView [" + exMv + "] for exception");
}
logger.warn("Handler execution resulted in exception - forwarding to resolved error view", ex);
return exMv;
}
else {
throw ex;
}
}
示例11: triggerAfterResourceCompletion
import javax.portlet.ResourceResponse; //导入依赖的package包/类
/**
* Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
* Will just invoke afterCompletion for all interceptors whose preHandle
* invocation has successfully completed and returned true.
* @param mappedHandler the mapped HandlerExecutionChain
* @param interceptorIndex index of last interceptor that successfully completed
* @param ex Exception thrown on handler execution, or null if none
* @see HandlerInterceptor#afterRenderCompletion
*/
private void triggerAfterResourceCompletion(HandlerExecutionChain mappedHandler, int interceptorIndex,
ResourceRequest request, ResourceResponse response, Exception ex)
throws Exception {
// Apply afterCompletion methods of registered interceptors.
if (mappedHandler != null) {
HandlerInterceptor[] interceptors = mappedHandler.getInterceptors();
if (interceptors != null) {
for (int i = interceptorIndex; i >= 0; i--) {
HandlerInterceptor interceptor = interceptors[i];
try {
interceptor.afterResourceCompletion(request, response, mappedHandler.getHandler(), ex);
}
catch (Throwable ex2) {
logger.error("HandlerInterceptor.afterCompletion threw exception", ex2);
}
}
}
}
}
示例12: serveResource
import javax.portlet.ResourceResponse; //导入依赖的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");
}
}
示例13: serveResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
public boolean serveResource(
ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws PortletException {
final String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
if (cmd.equals("BOOKMARK_ORDERABLE")) {
serveOlderUserBookmarks(resourceRequest, resourceResponse);
}
else {
_editFolderMVCResourceCommand.serveResource(
resourceRequest, resourceResponse);
}
return true;
}
示例14: serveResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
public boolean serveResource(
ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws PortletException {
if (_log.isInfoEnabled()) {
_log.info("get captcha resource ");
}
try {
CaptchaUtil.serveImage(resourceRequest, resourceResponse);
return false;
}
catch (Exception e) {
_log.error(e, e);
return true;
}
}
示例15: serveResource
import javax.portlet.ResourceResponse; //导入依赖的package包/类
@Override
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws IOException,
PortletException {
System.out.println("#############AJAX CALL####################");
String diagram = ParamUtil.getString(resourceRequest, "diagram");
JSONObject diagramJSON = new JSONObject(diagram);
//System.out.println(diagram);
System.out.println(diagramJSON.get("nodes"));
JSONArray arrDiagram = diagramJSON.getJSONArray("nodes");
for (int i = 0; i < arrDiagram.length(); i++) {
}
resourceResponse.setContentType("text/html");
PrintWriter writer = resourceResponse.getWriter();
writer.print(diagram);
writer.write("Hello");
writer.flush();
writer.close();
super.serveResource(resourceRequest, resourceResponse);
}