예제 #1
0
 /**
  * Imposta i parametri di una redirezione.
  *
  * @param redirDestPage Il codice della pagina su cui si vuole redirezionare.
  * @param reqCtx Il contesto di richiesta.
  * @return L'indicativo del tipo di redirezione in uscita del controlService. Può essere una delle
  *     costanti definite in ControllerManager.
  */
 protected int redirect(String redirDestPage, RequestContext reqCtx) {
   int retStatus;
   try {
     String redirPar = this.getParameter(RequestContext.PAR_REDIRECT_FLAG, reqCtx);
     if (redirPar == null || "".equals(redirPar)) {
       PageURL url = this.getUrlManager().createURL(reqCtx);
       url.setPageCode(redirDestPage);
       url.addParam(RequestContext.PAR_REDIRECT_FLAG, "1");
       String redirUrl = url.getURL();
       if (_log.isLoggable(Level.FINEST)) {
         _log.finest("Redirecting to " + redirUrl);
       }
       reqCtx.clearError();
       reqCtx.addExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL, redirUrl);
       retStatus = ControllerManager.REDIRECT;
     } else {
       reqCtx.setHTTPError(HttpServletResponse.SC_BAD_REQUEST);
       retStatus = ControllerManager.ERROR;
     }
   } catch (Throwable t) {
     retStatus = ControllerManager.SYS_ERROR;
     reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
     ApsSystemUtils.logThrowable(
         t, this, "redirect", "Error on creation redirect to page " + redirDestPage);
   }
   return retStatus;
 }
 @Override
 public String resolveLink(SymbolicLink symbolicLink, RequestContext reqCtx) {
   if (null == symbolicLink) {
     ApsSystemUtils.getLogger().severe("Null Symbolic Link");
     return "";
   }
   String url = null;
   try {
     if (symbolicLink.getDestType() == SymbolicLink.URL_TYPE) {
       url = symbolicLink.getUrlDest();
     } else if (symbolicLink.getDestType() == SymbolicLink.PAGE_TYPE) {
       PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
       pageUrl.setPageCode(symbolicLink.getPageDest());
       url = pageUrl.getURL();
     } else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_ON_PAGE_TYPE) {
       PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
       pageUrl.setPageCode(symbolicLink.getPageDest());
       pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, symbolicLink.getContentDest());
       url = pageUrl.getURL();
     } else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_TYPE) {
       PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
       String contentId = symbolicLink.getContentDest();
       String pageCode = this.getContentPageMapperManager().getPageCode(contentId);
       boolean forwardToDefaultPage = !this.isPageAllowed(reqCtx, pageCode);
       if (forwardToDefaultPage) {
         String viewPageCode = this.getContentManager().getViewPage(contentId);
         pageUrl.setPageCode(viewPageCode);
         pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, contentId);
       } else {
         pageUrl.setPageCode(pageCode);
       }
       url = pageUrl.getURL();
     }
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "resolveLink", "Error resolve link from SymbolicLink");
     throw new RuntimeException("Error resolve link from SymbolicLink", t);
   }
   return url;
 }