コード例 #1
0
  @Override
  @SystemEvent(action = SystemEventConstants.ACTION_SKIP, type = SystemEventConstants.TYPE_DELETE)
  public LayoutPrototype deleteLayoutPrototype(LayoutPrototype layoutPrototype)
      throws PortalException, SystemException {

    // Group

    if (layoutPersistence.countByLayoutPrototypeUuid(layoutPrototype.getUuid()) > 0) {

      throw new RequiredLayoutPrototypeException();
    }

    Group group = layoutPrototype.getGroup();

    groupLocalService.deleteGroup(group);

    // Resources

    resourceLocalService.deleteResource(
        layoutPrototype.getCompanyId(),
        LayoutPrototype.class.getName(),
        ResourceConstants.SCOPE_INDIVIDUAL,
        layoutPrototype.getLayoutPrototypeId());

    // Layout Prototype

    layoutPrototypePersistence.remove(layoutPrototype);

    // Permission cache

    PermissionCacheUtil.clearCache();

    return layoutPrototype;
  }
コード例 #2
0
  @Test
  @Transactional
  public void testExportImportLayoutSetPrototypeInvalidLARType() throws Exception {

    // Import LayoutSetPrototype to LayoutSet

    LayoutSetPrototype layoutSetPrototype =
        LayoutTestUtil.addLayoutSetPrototype(ServiceTestUtil.randomString());

    group = layoutSetPrototype.getGroup();
    importedGroup = GroupTestUtil.addGroup();

    long[] layoutIds = new long[0];

    try {
      exportImportLayouts(layoutIds, getImportParameterMap());

      Assert.fail();
    } catch (LARTypeException lte) {
    }

    // Import LayoutSetPrototype to LayoutPrototyope

    LayoutPrototype layoutPrototype =
        LayoutTestUtil.addLayoutPrototype(ServiceTestUtil.randomString());

    importedGroup = layoutPrototype.getGroup();

    try {
      exportImportLayouts(layoutIds, getImportParameterMap());

      Assert.fail();
    } catch (LARTypeException lte) {
    }
  }
コード例 #3
0
  @Test
  public void testExportImportLayoutSetPrototypeInvalidLARType() throws Exception {

    // Import a layout set prototype to a layout set

    LayoutSetPrototype layoutSetPrototype =
        LayoutTestUtil.addLayoutSetPrototype(RandomTestUtil.randomString());

    try {
      group = layoutSetPrototype.getGroup();
      importedGroup = GroupTestUtil.addGroup();

      long[] layoutIds = new long[0];

      try {
        exportImportLayouts(layoutIds, getImportParameterMap());

        Assert.fail();
      } catch (LARTypeException lte) {
      }

      // Import a layout set prototype to a layout prototyope

      LayoutPrototype layoutPrototype =
          LayoutTestUtil.addLayoutPrototype(RandomTestUtil.randomString());

      importedGroup = layoutPrototype.getGroup();

      try {
        exportImportLayouts(layoutIds, getImportParameterMap());

        Assert.fail();
      } catch (LARTypeException lte) {
      }
    } finally {
      LayoutSetPrototypeLocalServiceUtil.deleteLayoutSetPrototype(layoutSetPrototype);

      group = null;
    }
  }
コード例 #4
0
  public static Layout getSourcePrototypeLayout(Layout layout) {
    if (Validator.isNull(layout.getUuid())) {
      return null;
    }

    try {
      Group group = null;

      if (Validator.isNotNull(layout.getLayoutPrototypeUuid())) {
        LayoutPrototype layoutPrototype =
            LayoutPrototypeLocalServiceUtil.getLayoutPrototypeByUuid(
                layout.getLayoutPrototypeUuid());

        group = layoutPrototype.getGroup();
      } else {
        LayoutSet layoutSet = layout.getLayoutSet();

        if (Validator.isNull(layoutSet.getLayoutSetPrototypeUuid())) {
          return null;
        }

        LayoutSetPrototype layoutSetPrototype =
            LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototypeByUuid(
                layoutSet.getLayoutSetPrototypeUuid());

        group = layoutSetPrototype.getGroup();
      }

      return LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId(
          layout.getSourcePrototypeLayoutUuid(), group.getGroupId());
    } catch (Exception e) {
      _log.error(e, e);
    }

    return null;
  }