Пример #1
0
  protected long getFolderId(long companyId, String[] pathArray, boolean parent) throws Exception {

    long folderId = IGFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    if (pathArray.length <= 1) {
      return folderId;
    } else {
      long groupId = WebDAVUtil.getGroupId(companyId, pathArray);

      int x = pathArray.length;

      if (parent) {
        x--;
      }

      for (int i = 2; i < x; i++) {
        String name = pathArray[i];

        IGFolder folder = IGFolderServiceUtil.getFolder(groupId, folderId, name);

        if (groupId == folder.getGroupId()) {
          folderId = folder.getFolderId();
        }
      }
    }

    return folderId;
  }
Пример #2
0
  public Resource getResource(WebDAVRequest webDavRequest) throws WebDAVException {

    try {
      String[] pathArray = webDavRequest.getPathArray();

      long companyId = webDavRequest.getCompanyId();
      long parentFolderId = getParentFolderId(companyId, pathArray);
      String name = WebDAVUtil.getResourceName(pathArray);

      if (Validator.isNull(name)) {
        String path = getRootPath() + webDavRequest.getPath();

        return new BaseResourceImpl(path, StringPool.BLANK, getToken());
      }

      try {
        IGFolder folder =
            IGFolderServiceUtil.getFolder(webDavRequest.getGroupId(), parentFolderId, name);

        if ((folder.getParentFolderId() != parentFolderId)
            || (webDavRequest.getGroupId() != folder.getGroupId())) {

          throw new NoSuchFolderException();
        }

        return toResource(webDavRequest, folder, false);
      } catch (NoSuchFolderException nsfe) {
        try {
          long groupId = webDavRequest.getGroupId();

          IGImage image =
              IGImageServiceUtil.getImageByFolderIdAndNameWithExtension(
                  groupId, parentFolderId, name);

          return toResource(webDavRequest, image, false);
        } catch (NoSuchImageException nsie) {
          return null;
        }
      }
    } catch (Exception e) {
      throw new WebDAVException(e);
    }
  }
Пример #3
0
  protected boolean deleteResource(long groupId, long parentFolderId, String name)
      throws PortalException, SystemException {

    try {
      IGFolder folder = IGFolderServiceUtil.getFolder(groupId, parentFolderId, name);

      IGFolderServiceUtil.deleteFolder(folder.getFolderId());

      return true;
    } catch (NoSuchFolderException nsfe) {
      if (name.indexOf(StringPool.PERIOD) == -1) {
        return false;
      }

      try {
        IGImageServiceUtil.deleteImageByFolderIdAndNameWithExtension(groupId, parentFolderId, name);

        return true;
      } catch (NoSuchImageException nsie) {
      }
    }

    return false;
  }