コード例 #1
0
  @Override
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  public FactoryResource findResource(String path) throws FactoryException {
    logIt("findResource(...) called");
    logIt("params : path=" + path);

    try {
      FactoryResourceIdentifier identifier = binding.lookup(path);

      if (!identifier.getService().equals(SERVICE_NAME)) {
        throw new CoreServiceException(
            "Resource " + identifier + " is not managed by " + SERVICE_NAME);
      }

      if (identifier.getType().equals(Forum.RESOURCE_NAME)) {
        return readForum(path);
      } else if (identifier.getType().equals(ThreadMessage.RESOURCE_NAME)) {
        return readThreadMessage(path);
      }

      throw new CoreServiceException(
          "Resource " + identifier + " is not managed by " + SERVICE_NAME);

    } catch (Exception e) {
      logger.error("unable to find the resource at path " + path, e);
      throw new CoreServiceException("unable to find the resource at path " + path, e);
    }
  }
コード例 #2
0
 @Override
 public Forum[] getForumsByStatus(String path, String status) throws ForumServiceException {
   Forum[] items = null;
   logIt("get forums under" + path + " with status " + status);
   try {
     // Security check
     String caller = membership.getProfilePathForConnectedIdentifier();
     if (caller == null) {
       throw new ForumServiceException("Could not get connected profile");
     }
     logIt("caller: " + caller);
     pep.checkSecurity(caller, path, "read");
     // Check if given path is valid
     FactoryResourceIdentifier identifier = binding.lookup(path);
     // FIXME change restriction of parent. Forum should be created under
     // any path
     if (identifier != null
         && (identifier.getService().equals(SERVICE_NAME)
             || identifier.getService().equals(CoreService.SERVICE_NAME)
             || identifier.getService().equals(DocumentService.SERVICE_NAME))) {
       String servicePattern = ForumService.SERVICE_NAME;
       String typePattern = Forum.RESOURCE_NAME;
       String[] forumChildren = browser.listChildrenOfType(path, servicePattern, typePattern);
       if (forumChildren != null && forumChildren.length > 0) {
         logIt("Number of forums under " + path + " : " + forumChildren.length);
         Vector<Forum> forumsVector = new Vector<Forum>();
         for (int i = 0; i < forumChildren.length; i++) {
           logIt("child #" + i + ". " + forumChildren[i]);
           Forum tmpForum = readForum(forumChildren[i]);
           if (tmpForum != null && tmpForum.getStatus().equals(status)) {
             forumsVector.add(tmpForum);
           }
         }
         if (forumsVector != null && forumsVector.size() > 0) {
           items = forumsVector.toArray(new Forum[forumsVector.size()]);
         }
       }
     } else {
       throw new ForumServiceException("Given path is not valid.");
     }
   } catch (Exception e) {
     // ctx.setRollbackOnly();
     logger.error("Unable to retrieve the forums at path " + path, e);
     throw new ForumServiceException("Unable to retrieve the forums at path " + path, e);
   }
   return items;
 }
コード例 #3
0
 private void checkResourceType(FactoryResourceIdentifier identifier, String resourceType)
     throws MembershipServiceException {
   if (!identifier.getService().equals(getServiceName())) {
     throw new MembershipServiceException(
         "resource identifier " + identifier + " does not refer to service " + getServiceName());
   }
   if (!identifier.getType().equals(resourceType)) {
     throw new MembershipServiceException(
         "resource identifier "
             + identifier
             + " does not refer to a resource of type "
             + resourceType);
   }
 }
コード例 #4
0
  /**
   * Read name with an optional pep check.
   *
   * @param path path to the given resource.
   * @param pepCheck true to make the check.
   * @return a factoryResource if it can be find.
   */
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  private FactoryResource findResource(String path, boolean pepCheck) throws FactoryException {
    try {
      FactoryResourceIdentifier identifier = binding.lookup(path);

      if (!identifier.getService().equals(GreetingService.SERVICE_NAME)) {
        throw new GreetingServiceException(
            "Resource " + identifier + " is not managed by " + GreetingService.SERVICE_NAME);
      }

      if (identifier.getType().equals(Name.RESOURCE_NAME)) {
        return readName(path, pepCheck);
      }

      throw new GreetingServiceException(
          "Resource " + identifier + " is not managed by Greeting Service");

    } catch (Exception e) {
      logger.error("unable to find the resource at path " + path, e);
      throw new GreetingServiceException("unable to find the resource at path " + path, e);
    }
  }
コード例 #5
0
  @Override
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  public FactoryResource findResource(String path) throws FactoryException {
    try {
      FactoryResourceIdentifier identifier = binding.lookup(path);

      if (!identifier.getService().equals(ProjectService.SERVICE_NAME)) {
        throw new CoreServiceException(
            "Resource " + identifier + " is not managed by " + ProjectService.SERVICE_NAME);
      }

      if (identifier.getType().equals("Project")) {
        return getProject(path);
      }

      throw new CoreServiceException(
          "Resource " + identifier + " is not managed by " + ProjectService.SERVICE_NAME);

    } catch (Exception e) {
      throw new CoreServiceException("unable to find the resource at path " + path, e);
    }
  }