Exemplo n.º 1
0
  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);
    }
  }
  @Override
  protected void validateImport(
      Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception {

    List<StagedModel> ddmStructureDependentStagedModels =
        dependentStagedModelsMap.get(DDMStructure.class.getSimpleName());

    Assert.assertEquals(1, ddmStructureDependentStagedModels.size());

    DDMStructure ddmStructure = (DDMStructure) ddmStructureDependentStagedModels.get(0);

    DDMStructureLocalServiceUtil.getDDMStructureByUuidAndGroupId(
        ddmStructure.getUuid(), group.getGroupId());

    List<StagedModel> ddmTemplateDependentStagedModels =
        dependentStagedModelsMap.get(DDMTemplate.class.getSimpleName());

    Assert.assertEquals(2, ddmTemplateDependentStagedModels.size());

    for (StagedModel ddmTemplateDependentStagedModel : ddmTemplateDependentStagedModels) {

      DDMTemplateLocalServiceUtil.getDDMTemplateByUuidAndGroupId(
          ddmTemplateDependentStagedModel.getUuid(), group.getGroupId());
    }
  }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
  @Override
  public DDMForm getDDMForm(long classNameId, long classPK) throws PortalException {

    if ((classNameId <= 0) || (classPK <= 0)) {
      return null;
    }

    long ddmStructureClassNameId = PortalUtil.getClassNameId(DDMStructure.class);
    long ddmTemplateClassNameId = PortalUtil.getClassNameId(DDMTemplate.class);

    if (classNameId == ddmStructureClassNameId) {
      DDMStructure structure = DDMStructureLocalServiceUtil.getStructure(classPK);

      DDMForm ddmForm = structure.getFullHierarchyDDMForm();

      return ddmForm;
    } else if (classNameId == ddmTemplateClassNameId) {
      DDMTemplate template = DDMTemplateLocalServiceUtil.getTemplate(classPK);

      return DDMFormJSONDeserializerUtil.deserialize(template.getScript());
    }

    return null;
  }