@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); }
@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); }
@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); }
@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); }
@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); }
/** * 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(); }
@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); }
@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); }
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 ""; }
/** * 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; } }
/** * 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); } } } } }
/** * 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"); } }
@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; }
@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; } }
@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); }
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { System.out.println("=====serveResource======="); String domainNo = ParamUtil.getString(resourceRequest, "domainNo"); String administrationNo = ParamUtil.getString(resourceRequest, "administrationNo"); PrintWriter pw = resourceResponse.getWriter(); JSONObject juser = JSONFactoryUtil.createJSONObject(); juser.put("domainNo", domainNo); juser.put("administrationNo", administrationNo); pw.println(juser.toString()); PortletSession session = resourceRequest.getPortletSession(); // PortletMode portletMode= resourceRequest.getPortletMode(); // portletMode.s session.setAttribute("domainNo", domainNo); System.out.println(juser.toString()); }
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { System.out.println("=====serveResource======="); String domainNo = ParamUtil.getString(resourceRequest, "domainNo"); String administrationNo = ParamUtil.getString(resourceRequest, "administrationNo"); PrintWriter pw = resourceResponse.getWriter(); JSONObject juser = JSONFactoryUtil.createJSONObject(); juser.put("domainNo", domainNo); juser.put("administrationNo", administrationNo); pw.println(juser.toString()); PortletSession session = resourceRequest.getPortletSession(); session.setAttribute("domainNo", domainNo); }
private void uploadPHPFile(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException { UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(resourceRequest); File objFile = uploadRequest.getFile("PHPFILE"); String objFileName = uploadRequest.getFileName("PHPFILE"); _log.info("objFile: [" + objFile + "], objFileName: [" + objFileName + "]"); InputStream is = new FileInputStream(objFile); byte[] buff = new byte[is.available()]; is.read(buff); is.close(); String publicKeyStr = new String(buff); resourceResponse.setContentType("text/html"); PrintWriter writer = resourceResponse.getWriter(); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); String[] arrStr = publicKeyStr.split("-----BEGIN PUBLIC KEY-----"); publicKeyStr = arrStr[1]; arrStr = publicKeyStr.split("-----END PUBLIC KEY-----"); jsonObject.put("publicKey", arrStr[0]); phpPublicKey = arrStr[0]; writer.print(jsonObject.toString()); writer.flush(); writer.close(); }
public void serveResource(ResourceRequest request, ResourceResponse response)throws PortletException, IOException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String action = ParamUtil.getString(request, "action"); if(action.equals("getCourses")){ JSONArray usersJSONArray = JSONFactoryUtil.createJSONArray(); String freeText = ParamUtil.getString(request, "courseTitle"); List<Course> listCourse = CourseLocalServiceUtil.getCoursesCatalogByTitleCategoriesTags(freeText, null, null, themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), themeDisplay.getLanguageId(), -1, -1); JSONObject userJSON = null; for (Course course : listCourse) { userJSON = JSONFactoryUtil.createJSONObject(); userJSON.put("courseTitle", course.getTitle(themeDisplay.getLocale())); userJSON.put("courseDescription", course.getDescription(themeDisplay.getLocale())); usersJSONArray.put(userJSON); } PrintWriter out = response.getWriter(); out.println(usersJSONArray.toString()); } }
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { String action = ParamUtil.getString(resourceRequest, "action"); ThemeDisplay themeDisplay =(ThemeDisplay)resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long teamId = ParamUtil.getLong(resourceRequest, "teamId", 0); if("export".equals(action)){ long courseId = ParamUtil.getLong(resourceRequest, "courseId",0); exportCourse(resourceResponse, courseId, teamId, themeDisplay); } else if("exportModule".equals(action)){ long moduleId = ParamUtil.getLong(resourceRequest, "moduleId",0); exportModule(resourceResponse, moduleId, teamId, themeDisplay, resourceRequest); } }
@Override public void serveResource(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { resourceResponse.setContentType("image/png"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=5, must-revalidate"); OutputStream out = resourceResponse.getPortletOutputStream(); InputStream is=getClass().getClassLoader().getResourceAsStream("asposeicon/aspose.png"); byte[] bytes = IOUtils.toByteArray(is); out.write(bytes, 0, bytes.length); out.close(); }
private String determineDefaultPhase(Method handlerMethod) { if (!void.class.equals(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 ""; }
@Override public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); portletResp.getWriter(); // Multilevel forward / include portletReq.setAttribute(ATTR_DISPATCH_ACTION, "include"); String targ = SERVLET_PREFIX + "DispatcherTests5_SPEC2_19_IncThenIncludeServletResource_servlet" + EXTRA_PATH + "?" + QUERY_STRING; portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ); // Now do the actual dispatch String target = SERVLET_INCFWD + "?" + QUERY_STRING; PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target); rd.include(portletReq, portletResp); }
public PortletAsyncContextImpl(AsyncContext actx, PortletResourceRequestContext prctx, ResourceRequest resreq, ResourceResponse resresp, boolean origReqResp) { this.actx = actx; this.prctx = prctx; this.resreq = resreq; this.resresp = resresp; this.hasOriginalReqResp = origReqResp; this.hreq = (HttpServletRequest) actx.getRequest(); this.beanmgr = prctx.getBeanManager(); // get the original container req & resp to pass to listener for resource releasing HttpServletRequest creq = prctx.getContainerRequest(); HttpServletResponse cresp = prctx.getContainerResponse(); pal = new PortletAsyncContextListener(this); actx.addListener(pal, creq, cresp); }
@Override public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceRequest_getAttribute portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceRequest_getAttribute", "Value1"); // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceRequest_getAttributeNames portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceRequest_getAttributeNames", "Value1"); // Now do the actual dispatch String target = JSP_PREFIX + "DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceRequest" + JSP_SUFFIX + "?" + QUERY_STRING; PortletRequestDispatcher rd = portletConfig.getPortletContext() .getRequestDispatcher(target); rd.forward(portletReq, portletResp); }
@Override public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); // Prereq for: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceRequest_getAttribute portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceRequest_getAttribute", "Value1"); // Prereq for: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceRequest_getAttributeNames portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceRequest_getAttributeNames", "Value1"); // Now do the actual dispatch String target = SERVLET_PREFIX + "DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING; PortletRequestDispatcher rd = portletConfig.getPortletContext() .getRequestDispatcher(target); rd.include(portletReq, portletResp); }
@Override public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp) throws PortletException, IOException { long tid = Thread.currentThread().getId(); portletReq.setAttribute(THREADID_ATTR, tid); // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceRequest_getAttribute portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceRequest_getAttribute", "Value1"); // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceRequest_getAttributeNames portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceRequest_getAttributeNames", "Value1"); // Now do the actual dispatch String target = SERVLET_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING; PortletRequestDispatcher rd = portletConfig.getPortletContext() .getRequestDispatcher(target); rd.forward(portletReq, portletResp); }
/** * Routes between portlet resources * * @param request The request * @param response The response * * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @Override public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { PortletResource resource = PortletResource.getResource(request); switch(resource) { case LOAD_MORE: this.doLoadMore(request, response); break; default: response.setProperty(ResourceResponse.HTTP_STATUS_CODE, STATUS_CODE_NOT_FOUND); break; } }
@Override protected void doServeResource( ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { if (_log.isDebugEnabled()) { _log.debug("GetSuggestionsMVCResourceCommand.doServeResource()"); } JSONArray response = null; try { response = _gSearchSuggester.getSuggestions( resourceRequest); } catch (Exception e) { _log.error(e, e); return; } // Write response to the output stream. JSONPortletResponseUtil.writeJSON( resourceRequest, resourceResponse, response); }
/** * Get help text. * * @return String help test */ protected String getHelpText(ResourceRequest resourceRequest) { ResourceBundle resourceBundle = ResourceBundleUtil.getBundle( "content.Language", resourceRequest.getLocale(), GSearchPortlet.class); return LanguageUtil.get(resourceBundle, "helptext"); }
/** * Get Page lists * * Depending on the passed site groupd id, * fetch all pages in the site and return JSON object list. * * @param request * @param response * @return */ protected String getPageLists(ResourceRequest request, ResourceResponse response) { ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute( WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); long siteGroupId = ParamUtil.getLong(request, "siteGroupId", themeDisplay.getSiteGroupId()); List<Layout> layouts = _layoutLocalService.getLayouts( siteGroupId, false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for(Layout layout : layouts ) { JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject(); if(_log.isDebugEnabled()) { _log.debug("layout <" + layout.getName(themeDisplay.getLocale()) + ">"); _log.debug(layout.toString()); _log.debug("----------"); } curUserJSONObject.put("name" , layout.getName(themeDisplay.getLocale())); curUserJSONObject.put("parentLayoutId" , layout.getLayoutId()); jsonArray.put(curUserJSONObject); } return jsonArray.toJSONString(); }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { int numberOfCrawlers = ParamUtil.getInteger(resourceRequest, "numberOfCrawlers", -1); int maxDepthOfCrawling = ParamUtil.getInteger(resourceRequest, "maxDepthOfCrawling", -1); int maxPagesToFetch = ParamUtil.getInteger(resourceRequest, "maxPagesToFetch", -1); String tmpUrls = ParamUtil.getString(resourceRequest, "urls", "https://www.shutterstock.com/photos"); String[] strArray = tmpUrls.split(","); List<String> urls = new ArrayList<>(Arrays.asList(strArray)); List<String> result = Lists.newArrayList(); if(_log.isDebugEnabled()) { _log.debug("numberOfCrawlers : " + String.valueOf(numberOfCrawlers)); _log.debug("maxDepthOfCrawling : " + String.valueOf(maxDepthOfCrawling)); _log.debug("maxPagesToFetch : " + String.valueOf(maxPagesToFetch)); } if( numberOfCrawlers >= 0 && maxDepthOfCrawling >= 0 && maxPagesToFetch >= 0 ) { // Run image links crawler result = run(numberOfCrawlers, maxDepthOfCrawling, maxPagesToFetch, urls); } HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse); response.setContentType(ContentTypes.APPLICATION_JSON); String serializedJson = createReturnJson(resourceRequest, resourceResponse, result); ServletResponseUtil.write(response, serializedJson); }
/** * Get Category list * * @param resourceRequest * @param resourceResponse * @return * @throws PortalException */ private String getCategoryList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); String[] groupsStrIds = ParamUtil.getStringValues(resourceRequest, "groupIds", new String[] { String.valueOf(themeDisplay.getScopeGroupId()) }); long[] groupIds = CommonUtil.convertStringToLongArray(groupsStrIds); long siteGroupId = groupIds[0]; if(_log.isDebugEnabled()) { _log.debug("SiteGroup Id <" + String.valueOf(siteGroupId) + ">"); } List<MBCategory> categories = _mbCategoryLocalService.getCategories( siteGroupId, MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for(MBCategory category : categories ) { JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject(); if(_log.isDebugEnabled()) { _log.debug("Category name <" + category.getName() + ">"); _log.debug(category.toString()); _log.debug("----------"); } curUserJSONObject.put("categoryId" , category.getCategoryId()); curUserJSONObject.put("categoryName" , category.getName()); jsonArray.put(curUserJSONObject); } return jsonArray.toJSONString(); }
/** * Get Thread list * * Depending on the passed site groupd id, fetch all pages in the site and return JSON object list. * * @param resourceRequest * @param resourceResponse * @return * @throws PortalException */ protected String getThreadList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); long siteGroupId = ParamUtil.getLong(resourceRequest, "siteGroupId", themeDisplay.getSiteGroupId()); if(_log.isDebugEnabled()) { _log.debug("SiteGroup Id <" + String.valueOf(siteGroupId) + ">"); } List<MBThread> threads = _mbThreadLocalService.getThreads( siteGroupId, MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for(MBThread thread : threads ) { JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject(); MBMessage message = _mbMessageLocalService.getMessage(thread.getRootMessageId()); if(_log.isDebugEnabled()) { _log.debug("Root message <" + message.getSubject() + ">"); _log.debug(thread.toString()); _log.debug("----------"); } curUserJSONObject.put("rootMessageSubject" , message.getSubject()); curUserJSONObject.put("threadId" , thread.getThreadId()); curUserJSONObject.put("rootMessageId" , thread.getRootMessageId()); jsonArray.put(curUserJSONObject); } return jsonArray.toJSONString(); }
/** * Get Category list * * @param resourceRequest * @param resourceResponse * @return * @throws PortalException */ private String getCategoryList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortalException { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); long vocabularyId = ParamUtil.getLong(resourceRequest, "vocabularyId",0); if (_log.isDebugEnabled()) { _log.debug("Vocabulary Id <" + String.valueOf(vocabularyId) + ">"); } List<AssetCategory> categories = _assetCategoryLocalService.getVocabularyCategories( vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null ); for (AssetCategory category : categories) { JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject(); if (_log.isDebugEnabled()) { _log.debug("Category name <" + category.getName() + ">"); _log.debug(category.toString()); _log.debug("----------"); } curUserJSONObject.put("categoryId", category.getCategoryId()); curUserJSONObject.put("categoryName", category.getName()); jsonArray.put(curUserJSONObject); } return jsonArray.toJSONString(); }