Ejemplo n.º 1
0
 protected String getCurrentMainTabFromRequest() {
   URLPolicyService service = Framework.getService(URLPolicyService.class);
   ServletRequest request =
       (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
   if (request instanceof HttpServletRequest) {
     DocumentView docView = service.getDocumentViewFromRequest((HttpServletRequest) request);
     if (docView == null) {
       return null;
     }
     String tabIds = docView.getParameter(WebActions.TAB_IDS_PARAMETER);
     String mainTabId = docView.getParameter(WebActions.MAIN_TAB_ID_PARAMETER);
     if (mainTabId != null && !mainTabId.isEmpty()) {
       tabIds = mainTabId;
     }
     if (tabIds != null && tabIds.contains(WebActions.MAIN_TABS_CATEGORY)) {
       String[] encodedActions = tabIds.split(",");
       for (String encodedAction : encodedActions) {
         if (encodedAction.startsWith(WebActions.MAIN_TABS_CATEGORY)) {
           String[] actionInfo = encodedAction.split(":");
           if (actionInfo != null && actionInfo.length > 1) {
             return actionInfo[1];
           }
         }
       }
     }
   }
   return null;
 }
Ejemplo n.º 2
0
 public static String getFilename(DocumentModel doc, DocumentView docView) {
   String filename = docView.getParameter(FILENAME_KEY);
   if (filename == null) {
     // try to get it from document
     String propertyPath = docView.getParameter(FILENAME_PROPERTY_PATH_KEY);
     String propertyName = DocumentModelUtils.decodePropertyName(propertyPath);
     if (propertyName != null) {
       filename = (String) DocumentModelUtils.getPropertyValue(doc, propertyName);
     }
   }
   return filename;
 }
Ejemplo n.º 3
0
 @Override
 public String getUrlFromDocumentView(DocumentView docView) {
   DocumentLocation docLoc = docView.getDocumentLocation();
   String filepath = docView.getParameter(FILE_PROPERTY_PATH_KEY);
   String filename = docView.getParameter(FILENAME_KEY);
   if (docLoc != null && filepath != null && filename != null) {
     StringBuilder buf = new StringBuilder();
     buf.append(getPrefix());
     buf.append("/");
     buf.append(docLoc.getServerName());
     buf.append("/");
     buf.append(docLoc.getDocRef().toString());
     buf.append("/");
     buf.append(filepath);
     buf.append("/");
     buf.append(URIUtils.quoteURIPathToken(filename));
     String uri = buf.toString();
     Map<String, String> requestParams = new HashMap<String, String>(docView.getParameters());
     requestParams.remove(FILE_PROPERTY_PATH_KEY);
     requestParams.remove(FILENAME_KEY);
     return URIUtils.addParametersToURIQuery(uri, requestParams);
   }
   return null;
 }