public static Resource getResource(
      WebDAVRequest webDAVRequest, String rootPath, String token, long classNameId)
      throws WebDAVException {

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

      if (pathArray.length == 2) {
        String path = rootPath + webDAVRequest.getPath();

        return new BaseResourceImpl(path, StringPool.BLANK, token);
      } else if (pathArray.length == 3) {
        String type = pathArray[2];

        return toResource(webDAVRequest, type, rootPath, false);
      } else if (pathArray.length == 4) {
        String type = pathArray[2];
        String typeId = pathArray[3];

        if (type.equals(TYPE_STRUCTURES)) {
          DDMStructure structure =
              DDMStructureLocalServiceUtil.fetchStructure(GetterUtil.getLong(typeId));

          if (structure == null) {
            structure =
                DDMStructureLocalServiceUtil.fetchStructure(
                    webDAVRequest.getGroupId(), classNameId, typeId);
          }

          if (structure == null) {
            return null;
          }

          return DDMWebDavUtil.toResource(webDAVRequest, structure, rootPath, false);
        } else if (type.equals(TYPE_TEMPLATES)) {
          DDMTemplate template =
              DDMTemplateLocalServiceUtil.fetchDDMTemplate(GetterUtil.getLong(typeId));

          if (template == null) {
            template =
                DDMTemplateLocalServiceUtil.fetchTemplate(
                    webDAVRequest.getGroupId(), classNameId, typeId);
          }

          if (template == null) {
            return null;
          }

          return DDMWebDavUtil.toResource(webDAVRequest, template, rootPath, false);
        }
      }

      return null;
    } catch (Exception e) {
      throw new WebDAVException(e);
    }
  }
Esempio n. 2
0
  protected DDMStructure getDDMStructure(long ddmStructureId, long ddmTemplateId)
      throws PortalException {

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.getStructure(ddmStructureId);

    DDMTemplate ddmTemplate = DDMTemplateLocalServiceUtil.fetchDDMTemplate(ddmTemplateId);

    if (ddmTemplate != null) {

      // Clone ddmStructure to make sure changes are never persisted

      ddmStructure = (DDMStructure) ddmStructure.clone();

      ddmStructure.setDefinition(ddmTemplate.getScript());
    }

    return ddmStructure;
  }