public String navigateToCurrentUserPersonalWorkspace() {
    if (!initialized) {
      initialize();
    }
    String returnView = DOCUMENT_VIEW;

    // force return to Documents tab
    webActions.setCurrentTabId(WebActions.MAIN_TABS_CATEGORY, DOCUMENT_MANAGEMENT_ACTION);

    // Rux INA-221: separated links for going to workspaces
    DocumentModel currentUserPersonalWorkspace = getCurrentUserPersonalWorkspace();
    DocumentModel currentDocument = navigationContext.getCurrentDocument();
    if (!isShowingPersonalWorkspace()
        && currentDocument != null
        && currentDocument.getPath().segment(0) != null) {
      lastAccessedDocument =
          mainTabsActions.getDocumentFor(
              DOCUMENT_MANAGEMENT_ACTION, navigationContext.getCurrentDocument());
    }
    navigationContext.setCurrentDocument(currentUserPersonalWorkspace);
    showingPersonalWorkspace = true;

    Events.instance().raiseEvent(EventNames.GO_PERSONAL_WORKSPACE);

    return returnView;
  }
 /**
  * Handle complete table selection event after having ensured that the navigation context stills
  * points to currentDocumentRef to protect against browsers' back button errors
  *
  * @throws ClientException if currentDocRef is not a valid document
  */
 public void checkCurrentDocAndProcessSelectPage(
     String contentViewName, String listName, Boolean selection, String currentDocRef)
     throws ClientException {
   DocumentRef currentDocumentRef = new IdRef(currentDocRef);
   if (!currentDocumentRef.equals(navigationContext.getCurrentDocument().getRef())) {
     navigationContext.navigateToRef(currentDocumentRef);
   }
   processSelectPage(contentViewName, listName, selection);
 }
  /**
   * Handle version row selection event after having ensured that the navigation context stills
   * points to currentDocumentRef to protect against browsers' back button errors.
   *
   * @param versionModelSelection the version model selection
   * @param requestedCurrentDocRef the requested current doc ref
   * @throws ClientException if currentDocRef is not a valid document
   * @since 5.6
   */
  public void checkCurrentDocAndProcessVersionSelectRow(
      PageSelection<VersionModel> versionModelSelection, String requestedCurrentDocRef)
      throws ClientException {

    DocumentRef requestedCurrentDocumentRef = new IdRef(requestedCurrentDocRef);
    DocumentRef currentDocumentRef = null;
    DocumentModel currentDocument = navigationContext.getCurrentDocument();
    if (currentDocument != null) {
      currentDocumentRef = currentDocument.getRef();
    }
    if (!requestedCurrentDocumentRef.equals(currentDocumentRef)) {
      navigationContext.navigateToRef(requestedCurrentDocumentRef);
    }
    processVersionSelectRow(versionModelSelection);
  }
  @Factory(value = "isInsidePersonalWorkspace", scope = ScopeType.EVENT)
  public boolean isShowingPersonalWorkspace() {
    if (!initialized) {
      initialize();
    }

    // NXP-9813 : navigating to a tab different than Documents should not change
    // the value for showingPersonalWorkspace
    if (mainTabsActions.isOnMainTab(DOCUMENT_MANAGEMENT_ACTION)) {
      DocumentModel currentDoc = navigationContext.getCurrentDocument();

      if (currentDoc == null || currentDoc.getPath().segmentCount() < 2) {
        return false;
      }

      String rootChild = currentDoc.getPath().segment(1);
      String wsName = currentDoc.getPath().segment(2);
      showingPersonalWorkspace =
          rootChild != null
              && rootChild.startsWith(UserWorkspaceConstants.USERS_PERSONAL_WORKSPACES_ROOT)
              && wsName != null
              && wsName.equals(currentUser.getName());
    }
    return showingPersonalWorkspace;
  }
  /**
   * Processes the version selection row.
   *
   * @param versionModelSelection the version model selection
   * @throws ClientException the client exception
   */
  protected final void processVersionSelectRow(PageSelection<VersionModel> versionModelSelection)
      throws ClientException {

    DocumentModel currentDocument = navigationContext.getCurrentDocument();
    if (currentDocument == null) {
      throw new ClientException(
          "Cannot process version select row since current document is null.");
    }

    DocumentModel version =
        documentManager.getDocumentWithVersion(
            currentDocument.getRef(), versionModelSelection.getData());
    if (version == null) {
      throw new ClientException(
          "Cannot process version select row since selected version document is null.");
    }

    if (Boolean.TRUE.equals(versionModelSelection.isSelected())) {
      documentsListsManager.addToWorkingList(
          DocumentsListsManager.CURRENT_VERSION_SELECTION, version);
    } else {
      documentsListsManager.removeFromWorkingList(
          DocumentsListsManager.CURRENT_VERSION_SELECTION, version);
    }
  }
 /** @deprecated this information is now held by content views */
 @Deprecated
 @Factory(value = "currentListingLayoutName", scope = EVENT)
 public String getLayoutForCurrentDocument() {
   if (currentListingLayoutName == null) {
     DocumentModel currentDocument = navigationContext.getCurrentDocument();
     currentListingLayoutName = getLayoutForDocument(currentDocument);
   }
   return currentListingLayoutName;
 }
 /** @deprecated this information is now held by content views */
 @Deprecated
 @Factory(value = "currentAvailableListingLayoutNames", scope = EVENT)
 public List<String> getAvailableLayoutsForCurrentDocument() {
   if (currentAvailableListingLayoutNames == null) {
     DocumentModel currentDocument = navigationContext.getCurrentDocument();
     currentAvailableListingLayoutNames = getAvailableLayoutsForDocument(currentDocument);
   }
   return currentAvailableListingLayoutNames;
 }
 /**
  * Handle row selection event after having ensured that the navigation context stills points to
  * currentDocumentRef to protect against browsers' back button errors
  *
  * @throws ClientException if currentDocRef is not a valid document
  */
 public void checkCurrentDocAndProcessSelectRow(
     String docRef,
     String providerName,
     String listName,
     Boolean selection,
     String requestedCurrentDocRef)
     throws ClientException {
   DocumentRef requestedCurrentDocumentRef = new IdRef(requestedCurrentDocRef);
   DocumentRef currentDocumentRef = null;
   DocumentModel currentDocument = navigationContext.getCurrentDocument();
   if (currentDocument != null) {
     currentDocumentRef = currentDocument.getRef();
   }
   if (!requestedCurrentDocumentRef.equals(currentDocumentRef)) {
     navigationContext.navigateToRef(requestedCurrentDocumentRef);
   }
   processSelectRow(docRef, providerName, listName, selection);
 }
Exemplo n.º 9
0
 @Observer({NAVIGATE_TO_DOCUMENT})
 public void updateContextualDocument() {
   if (!shouldHandleRequest()) {
     return;
   }
   String currentMainTab = getCurrentMainTabFromRequest();
   if (currentMainTab == null) {
     currentMainTab = webActions.getCurrentTabId(WebActions.MAIN_TABS_CATEGORY);
   }
   DocumentModel currentDocument = navigationContext.getCurrentDocument();
   documentsByMainTabs.put(currentMainTab, currentDocument);
 }
 public String getCurrentLocalFlavorName() throws ClientException {
   DocumentModel currentSuperSpace = navigationContext.getCurrentSuperSpace();
   if (currentSuperSpace != null) {
     LocalThemeConfig localThemeConfig = LocalThemeHelper.getLocalThemeConfig(currentSuperSpace);
     if (localThemeConfig != null) {
       // extract the flavor
       String flavor = localThemeConfig.getFlavor();
       return flavor;
     }
   }
   return null;
 }
  // Rux INA-221: create a new method for the 2 separated links
  public String navigateToOverallWorkspace() {
    if (!initialized) {
      initialize();
    }
    String returnView = DOCUMENT_VIEW;

    // force return to Documents tab
    webActions.setCurrentTabIds(DOCUMENT_MANAGEMENT_TAB);

    if (lastAccessedDocument != null) {
      navigationContext.setCurrentDocument(lastAccessedDocument);
    } else if (navigationContext.getCurrentDomain() != null) {
      navigationContext.setCurrentDocument(navigationContext.getCurrentDomain());
    } else if (documentManager.hasPermission(
        documentManager.getRootDocument().getRef(), SecurityConstants.READ_CHILDREN)) {
      navigationContext.setCurrentDocument(documentManager.getRootDocument());
    } else {
      navigationContext.setCurrentDocument(null);
      returnView = dashboardNavigationHelper.navigateToDashboard();
    }
    showingPersonalWorkspace = false;

    Events.instance().raiseEvent(EventNames.GO_HOME);

    return returnView;
  }
Exemplo n.º 12
0
  public String getViewFor(Action mainTabAction) {
    if (!mainTabAction.getId().equals(WebActions.DOCUMENTS_MAIN_TAB_ID)) {
      return mainTabAction.getLink();
    }

    DocumentModel doc =
        getDocumentFor(mainTabAction.getId(), navigationContext.getCurrentDocument());
    if (doc != null) {
      TypeInfo typeInfo = doc.getAdapter(TypeInfo.class);
      return typeInfo.getDefaultView();
    }
    return DEFAULT_VIEW;
  }
 public DocumentModel getCurrentUserPersonalWorkspace() {
   if (!initialized) {
     initialize();
   }
   // protection in case we have not yet chosen a repository. if not
   // repository, then there is no documentManager(session)
   if (documentManager == null) {
     return null; // this is ok because it eventually will be
     // dealt with by setCurrentDocument, which will deal with
     // the lack of a documentManager
   }
   return getUserWorkspaceService()
       .getCurrentUserPersonalWorkspace(documentManager, navigationContext.getCurrentDocument());
 }
Exemplo n.º 14
0
  public String checkCurrentInbox() {
    DocumentModel mailFolder = navigationContext.getCurrentDocument();

    try {
      MailCoreHelper.checkMail(mailFolder, documentManager);
    } catch (MessagingException e) {
      log.debug(e, e);
      facesMessages.add(
          StatusMessage.Severity.ERROR,
          resourcesAccessor.getMessages().get("feedback.check.mail.error") + e.getMessage());

      return CURRENT_PAGE;
    }

    facesMessages.add(
        StatusMessage.Severity.INFO,
        resourcesAccessor.getMessages().get("feedback.check.mail.success"));
    Events.instance().raiseEvent("documentChildrenChanged");

    return CURRENT_PAGE;
  }
Exemplo n.º 15
0
  public String selectRepository(String repositoryName) throws ClientException {
    try {
      Repository selectedRepository = null;

      for (Repository repo : getRepositoryManager().getRepositories()) {
        if (repo.getName().equals(repositoryName)) {
          selectedRepository = repo;
          break;
        }
      }
      log.debug("Selected core name: " + repositoryName);
      if (selectedRepository != null) {
        RepositoryLocation selectedLocation = new RepositoryLocation(selectedRepository.getName());
        navigationContext.setCurrentServerLocation(selectedLocation);
        return DEFAULT_VIEW;
      } else {
        return null;
      }
    } catch (Throwable t) {
      throw ClientException.wrap(t);
    }
  }
  /**
   * Manejador principal del restlet.
   *
   * @param req Request
   * @param res Response
   */
  @Override
  public void handle(Request req, Response res) {
    /* Conflicto con Checkstyle. No se pueden declarar como final los m&eacute;todos de
     * beans EJB que hagan uso de dependencias inyectadas, ya que dichas
     * dependencias toman el valor null.
     * No se declara como final debido a que en ese caso
     * la inyecci&oacute;n de dependencias dejar&iacute;a de funcionar.
     */
    String repo = (String) req.getAttributes().get("repo");
    String cdcDocId = (String) req.getAttributes().get("docid");
    if (cdcDocId == null) {
      handleError(res, "you must specify a CdC source document Id.");
    } else {
      String depth = getQueryParamValue(req, "depth", "1");

      if (repo == null || repo.equals("*")) {
        handleError(res, "you must specify a repository");
      } else {

        int profundidad = Integer.parseInt(depth);
        // String cdcPath =
        // Framework.getProperty(ArchivoConstantes.PROPIEDAD_CDC_PATH);
        DOMDocumentFactory domFactory = new DOMDocumentFactory();
        DOMDocument result = (DOMDocument) domFactory.createDocument();
        try {

          navigationContext.setCurrentServerLocation(new RepositoryLocation(repo));
          documentManager = navigationContext.getOrCreateDocumentManager();
          DocumentModel cdcRoot = documentManager.getDocument(new IdRef(cdcDocId));
          if (cdcRoot != null) {
            Element current = result.createElement("document");

            current.setAttribute("title", cdcRoot.getTitle());
            current.setAttribute("type", cdcRoot.getType());
            current.setAttribute("id", cdcRoot.getId());
            current.setAttribute("path", cdcRoot.getPathAsString());

            result.setRootElement((org.dom4j.Element) current);

            addChildren(result, current, cdcRoot, profundidad);
          } else {
            Element noEncontrado = result.createElement("cdCNoRegistrado");
            noEncontrado.setAttribute("variable", ArchivoConstantes.PROPIEDAD_CDC_PATH);
            noEncontrado.setAttribute("valor", cdcDocId);
            result.setRootElement((org.dom4j.Element) noEncontrado);
            LOG.error(
                "No se ha configurado la ruta del CdC; por favor configure la ruta en la propiedad "
                    + ArchivoConstantes.PROPIEDAD_CDC_PATH);
          }

          res.setEntity(result.asXML(), MediaType.TEXT_XML);
          res.getEntity().setCharacterSet(CharacterSet.UTF_8);

        }
        /**
         * Conflicto con checkstyle. Es necesario capturar la excepci&oacute;n Exception, dado que
         * el c&oacute;digo nativo de Nuxeo lanza dicha excepci&oacute;n. En caso contrario, este
         * c&oacute;digo no compilar&iacute;a
         */
        catch (Exception e) {
          LOG.error(e);
          handleError(res, e);
        }
      }
    }
  }
  // MODIFORI
  public String addStatement(DocumentModel currentDoc) throws ClientException {
    Resource documentResource = getDocumentResource(currentDoc);
    if (documentResource == null) {
      throw new ClientException("Document resource could not be retrieved");
    }

    Resource predicate = new ResourceImpl(predicateUri);
    Node object = null;
    if (objectType.equals("literal")) {
      objectLiteralValue = objectLiteralValue.trim();
      object = new LiteralImpl(objectLiteralValue);
    } else if (objectType.equals("uri")) {
      objectUri = objectUri.trim();
      object = new ResourceImpl(objectUri);
    } else if (objectType.equals("document")) {
      objectDocumentUid = objectDocumentUid.trim();
      String repositoryName = navigationContext.getCurrentServerLocation().getName();
      String localName = repositoryName + "/" + objectDocumentUid;
      object = new QNameResourceImpl(RelationConstants.DOCUMENT_NAMESPACE, localName);
    }

    // if outgoing statement is null
    if (outgoingStatements == null) {
      getOutgoingStatementsInfo(currentDoc);
    }

    // create new statement
    Statement stmt = new StatementImpl(documentResource, predicate, object);
    if (!outgoingStatements.contains(stmt)) {
      // add statement to the graph
      List<Statement> stmts = new ArrayList<Statement>();
      String eventComment = null;
      if (comment != null) {
        comment = comment.trim();
        if (comment.length() > 0) {
          stmt.addProperty(RelationConstants.COMMENT, new LiteralImpl(comment));
          eventComment = comment;
        }
      }
      Literal now = RelationDate.getLiteralDate(new Date());
      stmt.addProperty(RelationConstants.CREATION_DATE, now);
      stmt.addProperty(RelationConstants.MODIFICATION_DATE, now);
      if (currentUser != null) {
        stmt.addProperty(RelationConstants.AUTHOR, new LiteralImpl(currentUser.getName()));
      }

      stmts.add(stmt);

      // notifications

      Map<String, Serializable> options = new HashMap<String, Serializable>();
      String currentLifeCycleState = currentDoc.getCurrentLifeCycleState();
      options.put(CoreEventConstants.DOC_LIFE_CYCLE, currentLifeCycleState);
      if (includeStatementsInEvents) {
        putStatements(options, stmt);
      }
      options.put(RelationEvents.GRAPH_NAME_EVENT_KEY, RelationConstants.GRAPH_NAME);

      // before notification
      notifyEvent(RelationEvents.BEFORE_RELATION_CREATION, currentDoc, options, eventComment);

      // add statement
      relationManager.add(RelationConstants.GRAPH_NAME, stmts);

      // XXX AT: try to refetch it from the graph so that resources are
      // transformed into qname resources: useful for indexing
      if (includeStatementsInEvents) {
        putStatements(options, relationManager.getStatements(RelationConstants.GRAPH_NAME, stmt));
      }

      // after notification
      notifyEvent(RelationEvents.AFTER_RELATION_CREATION, currentDoc, options, eventComment);

      // make sure statements will be recomputed
      resetStatements();

      // commenté pour ne pas affiché Relation créée qui ne parle pas à l'utilisateur
      // facesMessages.add(FacesMessage.SEVERITY_INFO,
      // resourcesAccessor.getMessages().get("label.relation.created"));
      resetCreateFormValues();
    } else {
      facesMessages.add(
          FacesMessage.SEVERITY_WARN,
          resourcesAccessor.getMessages().get("label.relation.already.exists"));
    }
    return "document_relations";
  }
Exemplo n.º 18
0
 public List<Type> getTypesWithSchemaFile() {
   DocumentModel document = navigationContext.getCurrentDocument();
   return getTypesWithSchemaFile(document);
 }
 /** @deprecated this information is now held by content views */
 @Deprecated
 public void setLayoutForCurrentDocument(String layoutName) {
   DocumentModel currentDocument = navigationContext.getCurrentDocument();
   setLayoutForDocument(currentDocument, layoutName);
   currentListingLayoutName = layoutName;
 }
Exemplo n.º 20
0
 public boolean isMailFolder() {
   DocumentModel currentDocument = navigationContext.getCurrentDocument();
   return MAIL_FOLDER_TYPE.equals(currentDocument.getType());
 }
 // MODIFORI
 public List<StatementInfo> getOutgoingStatementsInfo() throws ClientException {
   DocumentModel currentDoc = navigationContext.getCurrentDocument();
   return getOutgoingStatementsInfo(currentDoc);
 }
 // MODIFORI
 public String addStatement() throws ClientException {
   DocumentModel currentDoc = navigationContext.getCurrentDocument();
   return addStatement(currentDoc);
 }
Exemplo n.º 23
0
 public List<Type> getNotSelectedTypes() {
   DocumentModel currentDoc = navigationContext.getCurrentDocument();
   return getNotSelectedTypes(currentDoc);
 }
Exemplo n.º 24
0
 public DocumentModel getDocumentFor(String mainTabId) {
   return getDocumentFor(mainTabId, navigationContext.getCurrentDocument());
 }