@Override
  public void deleteStagedModel(String uuid, long groupId, String className, String extraData)
      throws PortalException, SystemException {

    DDLRecord record = DDLRecordLocalServiceUtil.fetchDDLRecordByUuidAndGroupId(uuid, groupId);

    if (record != null) {
      DDLRecordLocalServiceUtil.deleteRecord(record);
    }
  }
  protected void sendDDMRecordFile(
      HttpServletRequest request, HttpServletResponse response, String[] pathArray)
      throws Exception {

    if (pathArray.length == 4) {
      String className = GetterUtil.getString(pathArray[1]);
      long classPK = GetterUtil.getLong(pathArray[2]);
      String fieldName = GetterUtil.getString(pathArray[3]);

      Field field = null;

      if (className.equals(DDLRecord.class.getName())) {
        DDLRecord ddlRecord = DDLRecordLocalServiceUtil.getRecord(classPK);

        field = ddlRecord.getField(fieldName);
      } else if (className.equals(DLFileEntryMetadata.class.getName())) {
        DLFileEntryMetadata fileEntryMetadata =
            DLFileEntryMetadataLocalServiceUtil.getDLFileEntryMetadata(classPK);

        Fields fields = StorageEngineUtil.getFields(fileEntryMetadata.getDDMStorageId());

        field = fields.get(fieldName);
      }

      DDMUtil.sendFieldFile(request, response, field);
    }
  }
Пример #3
0
  @Override
  public boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId)
      throws Exception {

    DDLRecord record = DDLRecordLocalServiceUtil.getRecord(classPK);

    return DDLRecordSetPermission.contains(permissionChecker, record.getRecordSet(), actionId);
  }
  private static void _checkDDMRecord(String[] pathArray) throws Exception {
    if (pathArray.length == 3) {
      String className = GetterUtil.getString(pathArray[1]);
      long classPK = GetterUtil.getLong(pathArray[2]);

      if (className.equals(DDLRecord.class.getName())) {
        DDLRecordLocalServiceUtil.getRecord(classPK);
      } else if (className.equals(DLFileEntryMetadata.class.getName())) {
        DLFileEntryMetadataLocalServiceUtil.getDLFileEntryMetadata(classPK);
      }
    }
  }
Пример #5
0
  public static boolean hasSubmitted(HttpServletRequest request, long recordSetId)
      throws PortalException, SystemException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    List<DDLRecord> records =
        DDLRecordLocalServiceUtil.getRecords(recordSetId, themeDisplay.getUserId());

    if (records.isEmpty()) {
      return false;
    }

    return true;
  }
Пример #6
0
  @Override
  public AssetRenderer getAssetRenderer(long classPK, int type)
      throws PortalException, SystemException {

    DDLRecord record = null;
    DDLRecordVersion recordVersion = null;

    if (type == TYPE_LATEST) {
      recordVersion = DDLRecordLocalServiceUtil.getRecordVersion(classPK);

      record = recordVersion.getRecord();
    } else {
      record = DDLRecordLocalServiceUtil.getRecord(classPK);

      recordVersion = record.getRecordVersion();
    }

    DDLRecordAssetRenderer ddlRecordAssetRenderer =
        new DDLRecordAssetRenderer(record, recordVersion);

    ddlRecordAssetRenderer.setAssetRendererType(type);

    return ddlRecordAssetRenderer;
  }
  @Override
  protected void doImportStagedModel(PortletDataContext portletDataContext, DDLRecord record)
      throws Exception {

    long userId = portletDataContext.getUserId(record.getUserUuid());

    StagedModelDataHandlerUtil.importReferenceStagedModel(
        portletDataContext, record, DDLRecordSet.class, record.getRecordSetId());

    Map<Long, Long> recordSetIds =
        (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(DDLRecordSet.class);

    long recordSetId =
        MapUtil.getLong(recordSetIds, record.getRecordSetId(), record.getRecordSetId());

    ServiceContext serviceContext = portletDataContext.createServiceContext(record);

    Element recordElement = portletDataContext.getImportDataElement(record);

    Fields fields =
        (Fields)
            portletDataContext.getZipEntryAsObject(recordElement.attributeValue("fields-path"));

    DDLRecord importedRecord = null;

    if (portletDataContext.isDataStrategyMirror()) {
      DDLRecord existingRecord =
          DDLRecordLocalServiceUtil.fetchDDLRecordByUuidAndGroupId(
              record.getUuid(), portletDataContext.getScopeGroupId());

      if (existingRecord == null) {
        serviceContext.setUuid(record.getUuid());

        importedRecord =
            DDLRecordLocalServiceUtil.addRecord(
                userId,
                portletDataContext.getScopeGroupId(),
                recordSetId,
                record.getDisplayIndex(),
                fields,
                serviceContext);
      } else {
        importedRecord =
            DDLRecordLocalServiceUtil.updateRecord(
                userId,
                existingRecord.getRecordId(),
                false,
                record.getDisplayIndex(),
                fields,
                true,
                serviceContext);
      }
    } else {
      importedRecord =
          DDLRecordLocalServiceUtil.addRecord(
              userId,
              portletDataContext.getScopeGroupId(),
              recordSetId,
              record.getDisplayIndex(),
              fields,
              serviceContext);
    }

    portletDataContext.importClassedModel(record, importedRecord);
  }