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);
    }
  }
  @Override
  protected void doExportStagedModel(PortletDataContext portletDataContext, DDLRecord record)
      throws Exception {

    StagedModelDataHandlerUtil.exportReferenceStagedModel(
        portletDataContext,
        record,
        record.getRecordSet(),
        PortletDataContext.REFERENCE_TYPE_STRONG);

    DDLRecordVersion recordVersion = record.getRecordVersion();

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

    String fieldsPath = ExportImportPathUtil.getModelPath(record, "fields.xml");

    portletDataContext.addZipEntry(fieldsPath, fields);

    Element recordElement = portletDataContext.getExportDataElement(record);

    recordElement.addAttribute("fields-path", fieldsPath);

    portletDataContext.addClassedModel(
        recordElement, ExportImportPathUtil.getModelPath(record), record);
  }
Exemplo n.º 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);
  }
Exemplo n.º 4
0
  public DDLRecord getRecord(long recordId) throws PortalException, SystemException {

    DDLRecord record = ddlRecordLocalService.getDDLRecord(recordId);

    DDLRecordSetPermission.check(getPermissionChecker(), record.getRecordSetId(), ActionKeys.VIEW);

    return record;
  }
Exemplo n.º 5
0
  public DDLRecord updateRecord(
      long recordId,
      int displayIndex,
      Map<String, Serializable> fieldsMap,
      boolean mergeFields,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    DDLRecord record = ddlRecordLocalService.getDDLRecord(recordId);

    DDLRecordSetPermission.check(
        getPermissionChecker(), record.getRecordSetId(), ActionKeys.UPDATE);

    return ddlRecordLocalService.updateRecord(
        getUserId(), recordId, displayIndex, fieldsMap, mergeFields, serviceContext);
  }
Exemplo n.º 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;
  }
  /**
   * Adds the d d l record to the database. Also notifies the appropriate model listeners.
   *
   * @param ddlRecord the d d l record
   * @return the d d l record that was added
   * @throws SystemException if a system exception occurred
   */
  public DDLRecord addDDLRecord(DDLRecord ddlRecord) throws SystemException {
    ddlRecord.setNew(true);

    ddlRecord = ddlRecordPersistence.update(ddlRecord, false);

    Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());

    if (indexer != null) {
      try {
        indexer.reindex(ddlRecord);
      } catch (SearchException se) {
        if (_log.isWarnEnabled()) {
          _log.warn(se, se);
        }
      }
    }

    return ddlRecord;
  }
  @Override
  protected void validateExport(PortletDataContext portletDataContext, DDLRecord record)
      throws PortletDataException {

    int status = WorkflowConstants.STATUS_ANY;

    try {
      status = record.getStatus();
    } catch (Exception e) {
      throw new PortletDataException(e);
    }

    if (!ArrayUtil.contains(getExportableStatuses(), status)) {
      PortletDataException pde = new PortletDataException(PortletDataException.STATUS_UNAVAILABLE);

      pde.setStagedModel(record);

      throw pde;
    }
  }
  @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);
  }
 @Override
 public String getDisplayName(DDLRecord record) {
   return record.getUuid();
 }