Beispiel #1
0
 public void setUp() throws Exception {
   super.setUp();
   taxonomyService = (TaxonomyService) container.getComponentInstanceOfType(TaxonomyService.class);
   mockTaxonomyService =
       (MockTaxonomyService) container.getComponentInstanceOfType(MockTaxonomyService.class);
   dmsSesssion =
       sessionProviderService_.getSystemSessionProvider(null).getSession(DMSSYSTEM_WS, repository);
   nodeHierarchyCreator =
       (NodeHierarchyCreator) container.getComponentInstanceOfType(NodeHierarchyCreator.class);
   linkManage = (LinkManager) container.getComponentInstanceOfType(LinkManager.class);
   definitionPath = nodeHierarchyCreator.getJcrPath(BasePath.TAXONOMIES_TREE_DEFINITION_PATH);
   storagePath = nodeHierarchyCreator.getJcrPath(BasePath.TAXONOMIES_TREE_STORAGE_PATH);
 }
  public String getHomePageLogoURI() {
    SessionProvider sProvider = SessionProvider.createSystemProvider();
    Node rootNode = null;
    Node publicApplicationNode = null;
    String pathImageNode = null;
    Node ImageNode = null;
    Session session = null;
    try {
      publicApplicationNode = nodeCreator.getPublicApplicationNode(sProvider);
      session = publicApplicationNode.getSession();
      rootNode = session.getRootNode();
      Node logosNode = rootNode.getNode(path);
      if (logosNode.hasNode(logo_name)) {
        ImageNode = logosNode.getNode(logo_name);
        pathImageNode = ImageNode.getPath() + "?" + System.currentTimeMillis();
      }
    } catch (Exception e) {
      LOG.error("Can not get path of Logo : default LOGO will be used" + e.getMessage(), e);
      return null;
    } finally {
      if (session != null) session.logout();

      if (sProvider != null) sProvider.close();
    }

    return pathImageNode;
  }
Beispiel #3
0
  /**
   * get the space name of node
   *
   * @param node
   * @return
   * @throws Exception
   */
  private static String getSpaceName(Node node) throws Exception {
    NodeHierarchyCreator nodeHierarchyCreator =
        (NodeHierarchyCreator)
            ExoContainerContext.getCurrentContainer()
                .getComponentInstanceOfType(NodeHierarchyCreator.class);
    String groupPath = nodeHierarchyCreator.getJcrPath(BasePath.CMS_GROUPS_PATH);
    String spacesFolder = groupPath + "/spaces/";
    String spaceName = "";
    String nodePath = node.getPath();
    if (nodePath.startsWith(spacesFolder)) {
      spaceName = nodePath.substring(spacesFolder.length());
      spaceName = spaceName.substring(0, spaceName.indexOf("/"));
    }

    return spaceName;
  }
  public void testSave() throws Exception {
    UserStateModel userModel =
        new UserStateModel(
            session.getUserID(), new Date().getTime(), UserStateService.DEFAULT_STATUS);
    userStateService.save(userModel);

    SessionProvider sessionProvider = SessionProvider.createSystemProvider();
    try {
      Node userNodeApp =
          nodeHierarchyCreator.getUserApplicationNode(sessionProvider, session.getUserID());
      assertTrue(userNodeApp.hasNode(VIDEOCALLS_BASE_PATH));

      Node videoCallNode = userNodeApp.getNode(VIDEOCALLS_BASE_PATH);
      assertTrue(videoCallNode.isNodeType(USER_STATATUS_NODETYPE));

      assertTrue(videoCallNode.hasProperty(USER_ID_PROP));
      assertEquals(userModel.getUserId(), videoCallNode.getProperty(USER_ID_PROP).getString());

      assertTrue(videoCallNode.hasProperty(LAST_ACTIVITY_PROP));
      assertEquals(
          userModel.getLastActivity(), videoCallNode.getProperty(LAST_ACTIVITY_PROP).getLong());

      assertTrue(videoCallNode.hasProperty(STATUS_PROP));
      assertEquals(userModel.getStatus(), videoCallNode.getProperty(STATUS_PROP).getString());
    } finally {
      sessionProvider.close();
    }
  }
 /**
  * Check existed software registration node
  *
  * @return
  */
 private boolean hasSoftwareRegistration() {
   SessionProvider sessionProvider = null;
   try {
     if (hasSoftwareRegisteredNode) {
       return hasSoftwareRegisteredNode;
     } else {
       try {
         sessionProvider = SessionProvider.createSystemProvider();
         Node publicApplicationNode =
             nodeHierarchyCreator.getPublicApplicationNode(sessionProvider);
         if (publicApplicationNode.hasNode(SW_NODE_NAME)) {
           hasSoftwareRegisteredNode = true;
         } else {
           hasSoftwareRegisteredNode = false;
         }
       } catch (Exception e) {
         LOG.error("Software Registration: cannot get node", e);
         hasSoftwareRegisteredNode = false;
       } finally {
         sessionProvider.close();
       }
       return hasSoftwareRegisteredNode;
     }
   } catch (Exception e) {
     LOG.error("Software Registration: cannot check node", e);
   }
   return hasSoftwareRegisteredNode;
 }
  /** {@inheritDoc} */
  public void start() {
    configuredTemplates_ = new HashMap<String, Set<String>>();
    RepositoryEntry repositoryEntry = null;
    try {
      repositoryEntry = repositoryService.getCurrentRepository().getConfiguration();
    } catch (RepositoryException e) {
      if (LOG.isErrorEnabled()) {
        LOG.error(e.getMessage(), e);
      }
    }

    String repoName = repositoryEntry.getName();
    String workspaceName = repositoryEntry.getSystemWorkspaceName();
    storedWorkspaces.put(repoName, workspaceName);
    basedApplicationTemplatesPath = hierarchyCreator.getJcrPath(BasePath.CMS_VIEWTEMPLATES_PATH);

    SessionProvider sessionProvider = SessionProvider.createSystemProvider();
    for (Iterator<String> repositories = storedWorkspaces.keySet().iterator();
        repositories.hasNext(); ) {
      String repository = repositories.next();
      try {
        Node storedTemplateHome = getBasedApplicationTemplatesHome(sessionProvider);
        importPredefinedTemplateToDB(storedTemplateHome);
      } catch (Exception e) {
        if (LOG.isErrorEnabled()) {
          LOG.error(
              "Exception when import predefine application template into repository: " + repository,
              e);
        }
      }
    }
    sessionProvider.close();
  }
 private void importPredefineViews() throws Exception {
   configuredTemplate_ = new HashSet<String>();
   configuredViews_ = new HashSet<String>();
   Iterator<ObjectParameter> it = params_.getObjectParamIterator();
   String viewsPath = nodeHierarchyCreator_.getJcrPath(BasePath.CMS_VIEWS_PATH);
   String templatesPath = nodeHierarchyCreator_.getJcrPath(BasePath.CMS_VIEWTEMPLATES_PATH);
   String warViewPath =
       predefinedViewsLocation_
           + templatesPath.substring(templatesPath.lastIndexOf("exo:ecm") + 7);
   ManageableRepository manageableRepository = repositoryService_.getCurrentRepository();
   DMSRepositoryConfiguration dmsRepoConfig = dmsConfiguration_.getConfig();
   Session session = manageableRepository.getSystemSession(dmsRepoConfig.getSystemWorkspace());
   ViewConfig viewObject = null;
   TemplateConfig templateObject = null;
   Node viewHomeNode = (Node) session.getItem(viewsPath);
   while (it.hasNext()) {
     Object object = it.next().getObject();
     if (object instanceof ViewConfig) {
       viewObject = (ViewConfig) object;
       String viewNodeName = viewObject.getName();
       configuredViews_.add(viewNodeName);
       if (viewHomeNode.hasNode(viewNodeName)
           || Utils.getAllEditedConfiguredData(
                   this.getClass().getSimpleName(), EDITED_CONFIGURED_VIEWS, true)
               .contains(viewNodeName)) continue;
       Node viewNode =
           addView(
               viewHomeNode,
               viewNodeName,
               viewObject.getPermissions(),
               viewObject.isHideExplorerPanel(),
               viewObject.getTemplate());
       Utils.addEditedConfiguredData(
           viewNodeName, this.getClass().getSimpleName(), EDITED_CONFIGURED_VIEWS, true);
       for (Tab tab : viewObject.getTabList()) {
         addTab(viewNode, tab.getTabName(), tab.getButtons());
       }
     } else if (object instanceof TemplateConfig) {
       templateObject = (TemplateConfig) object;
       addTemplate(templateObject, session, warViewPath);
     }
   }
   session.save();
   session.logout();
 }
Beispiel #8
0
  /**
   * check the nodes that we support to post activities
   *
   * @param node for checking
   * @return result of checking
   * @throws RepositoryException
   */
  private static boolean isSupportedContent(Node node) throws Exception {
    if (getActivityOwnerId(node) != null && getActivityOwnerId(node).length() > 0) {
      NodeHierarchyCreator nodeHierarchyCreator =
          (NodeHierarchyCreator)
              ExoContainerContext.getCurrentContainer()
                  .getComponentInstanceOfType(NodeHierarchyCreator.class);
      SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider();
      if (sessionProvider == null) {
        sessionProvider = WCMCoreUtils.getSystemSessionProvider();
      }
      Node userNode = nodeHierarchyCreator.getUserNode(sessionProvider, getActivityOwnerId(node));
      if (userNode != null && node.getPath().startsWith(userNode.getPath() + "/Private/")) {
        return false;
      }
    }

    return true;
  }
  public void postSave(Membership m, boolean isNew) throws Exception {

    String username = m.getUserName();
    String groupId = m.getGroupId();
    cservice_.addUserContactInAddressBook(username, groupId);
    DataStorage storage_ = new JCRDataStorage(nodeHierarchyCreator_, reposervice_);
    SessionProvider systemSession = SessionProvider.createSystemProvider();
    try {
      String usersPath = nodeHierarchyCreator_.getJcrPath(DataStorage.USERS_PATH);
      Contact contact = cservice_.getPublicContact(username);
      QueryManager qm = getSession(systemSession).getWorkspace().getQueryManager();
      Map<String, String> groups = new LinkedHashMap<String, String>();
      for (String group : contact.getAddressBookIds()) groups.put(group, group);
      groups.put(groupId, groupId);
      contact.setAddressBookIds(groups.keySet().toArray(new String[] {}));
      cservice_.saveContact(username, contact, false);
      StringBuffer queryString =
          new StringBuffer(
                  "/jcr:root"
                      + usersPath
                      + "//element(*,exo:contactGroup)[@exo:viewPermissionGroups='")
              .append(groupId + "']");
      Query query = qm.createQuery(queryString.toString(), Query.XPATH);
      QueryResult result = query.execute();
      NodeIterator nodes = result.getNodes();
      List<String> to = Arrays.asList(new String[] {username});
      while (nodes.hasNext()) {
        Node address = nodes.nextNode();
        String from = address.getProperty("exo:sharedUserId").getString();
        String addressBookId = address.getProperty("exo:id").getString();
        storage_.shareAddressBook(from, addressBookId, to);
      }
      queryString =
          new StringBuffer(
                  "/jcr:root" + usersPath + "//element(*,exo:contact)[@exo:viewPermissionGroups='")
              .append(groupId + "']");
      query = qm.createQuery(queryString.toString(), Query.XPATH);
      result = query.execute();
      nodes = result.getNodes();
      while (nodes.hasNext()) {
        Node contactNode = nodes.nextNode();
        String split = "/";
        String temp = contactNode.getPath().split(usersPath)[1];
        String userId = temp.split(split)[1];
        String[] addressBookIds = new String[] {contactNode.getProperty("exo:id").getString()};
        storage_.shareContact(userId, addressBookIds, to);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      systemSession.close();
    }
  }
Beispiel #10
0
  public Node getSelectedTag(String tagName) throws Exception {
    NewFolksonomyService newFolksonomyService = getApplicationComponent(NewFolksonomyService.class);
    NodeHierarchyCreator nodeHierarchyCreator = getApplicationComponent(NodeHierarchyCreator.class);
    UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class);
    UITaggingForm uiTaggingForm = getChild(UITaggingForm.class);

    String workspace = uiExplorer.getRepository().getConfiguration().getDefaultWorkspaceName();
    String userName = uiExplorer.getSession().getUserID();
    String tagScope = uiTaggingForm.getUIFormSelectBox(UITaggingForm.TAG_SCOPES).getValue();
    int scope = uiTaggingForm.getIntValue(tagScope);
    uiExplorer.setTagScope(scope);

    String publicTagNodePath = nodeHierarchyCreator.getJcrPath(UITaggingForm.PUBLIC_TAG_NODE_PATH);

    List<Node> tagList =
        (scope == NewFolksonomyService.PUBLIC)
            ? newFolksonomyService.getAllPublicTags(publicTagNodePath, workspace)
            : newFolksonomyService.getAllPrivateTags(userName);

    for (Node tag : tagList) if (tag.getName().equals(tagName)) return tag;
    return null;
  }
 /** Create software registration node */
 private void createSoftwareRegistrationNode() {
   SessionProvider sessionProvider = SessionProvider.createSystemProvider();
   try {
     Node publicApplicationNode = nodeHierarchyCreator.getPublicApplicationNode(sessionProvider);
     if (!publicApplicationNode.hasNode(SW_NODE_NAME)) {
       publicApplicationNode = publicApplicationNode.addNode(SW_NODE_NAME, "nt:folder");
       publicApplicationNode.addMixin("mix:referenceable");
       publicApplicationNode.getSession().save();
     }
   } catch (Exception e) {
     LOG.error("Software Registration: cannot create node", e);
   } finally {
     if (sessionProvider != null) {
       sessionProvider.close();
     }
   }
 }
 private void addTemplate(TemplateConfig tempObject, Session session, String warViewPath)
     throws Exception {
   String type = tempObject.getTemplateType();
   String alias = "";
   if (type.equals(ECM_EXPLORER_TEMPLATE)) {
     alias = BasePath.ECM_EXPLORER_TEMPLATES;
   }
   String templateHomePath = nodeHierarchyCreator_.getJcrPath(alias);
   Node templateHomeNode = (Node) session.getItem(templateHomePath);
   String templateName = tempObject.getName();
   if (templateHomeNode.hasNode(templateName)
       || Utils.getAllEditedConfiguredData(
               this.getClass().getSimpleName(), EDITED_CONFIGURED_VIEWS_TEMPLATES, true)
           .contains(templateName)) return;
   String warPath = warViewPath + tempObject.getWarPath();
   InputStream in = cservice_.getInputStream(warPath);
   templateService.createTemplate(
       templateHomeNode, templateName, templateName, in, new String[] {"*"});
   configuredTemplate_.add(templateName);
   Utils.addEditedConfiguredData(
       templateName, this.getClass().getSimpleName(), EDITED_CONFIGURED_VIEWS_TEMPLATES, true);
 }
Beispiel #13
0
  public void preDelete(Membership m) throws Exception {
    Contact contact = cservice_.getPublicContact(m.getUserName());
    Map<String, String> groupIds = new LinkedHashMap<String, String>();
    for (String group : contact.getAddressBookIds()) groupIds.put(group, group);
    groupIds.remove(m.getGroupId());
    contact.setAddressBookIds(groupIds.keySet().toArray(new String[] {}));
    SessionProvider systemSession = SessionProvider.createSystemProvider();
    try {
      cservice_.saveContact(m.getUserName(), contact, false);
      DataStorage storage_ = new JCRDataStorage(nodeHierarchyCreator_, reposervice_);
      String usersPath = nodeHierarchyCreator_.getJcrPath(DataStorage.USERS_PATH);
      QueryManager qm = getSession(systemSession).getWorkspace().getQueryManager();
      StringBuffer queryString =
          new StringBuffer(
                  "/jcr:root"
                      + usersPath
                      + "//element(*,exo:contactGroup)[@exo:viewPermissionGroups='")
              .append(m.getGroupId() + "']");
      Query query = qm.createQuery(queryString.toString(), Query.XPATH);
      QueryResult result = query.execute();
      NodeIterator nodes = result.getNodes();
      while (nodes.hasNext()) {
        Node address = nodes.nextNode();
        storage_.unshareAddressBook(
            address.getProperty("exo:sharedUserId").getString(),
            address.getProperty("exo:id").getString(),
            m.getUserName());
        for (Value groupShared : address.getProperty("exo:viewPermissionGroups").getValues()) {
          if (groupIds.keySet().contains(groupShared.getString())) {
            List<String> reciever = new ArrayList<String>();
            reciever.add(m.getUserName());
            storage_.shareAddressBook(
                address.getProperty("exo:sharedUserId").getString(),
                address.getProperty("exo:id").getString(),
                reciever);
          }
        }
      }
      queryString =
          new StringBuffer(
                  "/jcr:root" + usersPath + "//element(*,exo:contact)[@exo:viewPermissionGroups='")
              .append(m.getGroupId() + "']");
      query = qm.createQuery(queryString.toString(), Query.XPATH);
      result = query.execute();
      nodes = result.getNodes();
      while (nodes.hasNext()) {
        Node contactNode = nodes.nextNode();
        String split = "/";
        String temp = contactNode.getPath().split(usersPath)[1];
        String userId = temp.split(split)[1];
        storage_.removeUserShareContact(
            userId, contactNode.getProperty("exo:id").getString(), m.getUserName());
        for (Value groupShared : contactNode.getProperty("exo:viewPermissionGroups").getValues()) {
          if (groupIds.keySet().contains(groupShared.getString())) {
            List<String> reciever = new ArrayList<String>();
            reciever.add(m.getUserName());
            storage_.shareContact(
                userId, new String[] {contactNode.getProperty("exo:id").getString()}, reciever);
          }
        }
      }
    } catch (ReferentialIntegrityException e) {

    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      systemSession.close();
    }
  }