diff --git a/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java b/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java index 471ad85..a7f1eef 100644 --- a/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java +++ b/csv-importer-studio-component/src/main/java/com/coremedia/csv/studio/CSVImportResource.java @@ -55,7 +55,7 @@ public class CSVImportResource { /** * Import process logger. */ - private static Logger logger = LoggerFactory.getLogger(CSVImportResource.class); + private static final Logger logger = LoggerFactory.getLogger(CSVImportResource.class); /** * Sets the content repository. @@ -96,8 +96,7 @@ public void setAuthorizedGroups(List authorizedGroups) { @PostMapping(value = "importcsv/uploadfile", produces = "text/json", consumes = "multipart/form-data") - public ResponseEntity importCSV(@HeaderParam("site") String siteId, - @HeaderParam("folderUri") String folderUri, + public ResponseEntity importCSV(@RequestParam("template") String template, @RequestParam("file") MultipartFile file) throws IOException { // Check that the user is a member of the requisite group @@ -106,7 +105,6 @@ public ResponseEntity importCSV(@HeaderParam("site") String siteId, } boolean autoPublish = false; - String template = "default"; BufferedReader reader = new BufferedReader(new InputStreamReader(file.getInputStream())); CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader()); CSVParserHelper handler = new CSVParserHelper(autoPublish, contentRepository, logger); diff --git a/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as b/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as index 199a253..42951fa 100644 --- a/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as +++ b/csv-studio-importer/src/main/joo/com/coremedia/csv/studio/importer/CSVImportDialogBase.as @@ -1,20 +1,18 @@ package com.coremedia.csv.studio.importer { -import com.coremedia.cap.content.Content; import com.coremedia.cms.editor.sdk.upload.FileWrapper; -import com.coremedia.cms.editor.sdk.upload.UploadManager; -import com.coremedia.cms.editor.sdk.upload.UploadSettings; import com.coremedia.cms.editor.sdk.upload.dialog.FileContainer; import com.coremedia.cms.editor.sdk.upload.dialog.FileContainersObservable; import com.coremedia.cms.editor.sdk.upload.dialog.UploadDialog; import com.coremedia.cms.editor.sdk.util.MessageBoxUtil; +import com.coremedia.cms.editor.sdk.util.StudioConfigurationUtil; import com.coremedia.ui.data.ValueExpression; import com.coremedia.ui.data.ValueExpressionFactory; import com.coremedia.ui.data.error.RemoteError; import com.coremedia.ui.data.impl.RemoteService; +import com.coremedia.ui.logging.Logger; import com.coremedia.ui.util.EventUtil; import ext.Ext; - import ext.MessageBox; import ext.container.Container; @@ -22,12 +20,21 @@ import js.XMLHttpRequest; public class CSVImportDialogBase extends UploadDialog { + public static const REPORTING_SETTINGS_NAME:String = "ReportingSettings"; + public static const DEFAULT_TEMPLATE_SETTING:String = "defaultImportTemplate"; + private var fileContainers:FileContainersObservable; private var validationExpression:ValueExpression; private var uploadDropAreaDisabled:Boolean; public function CSVImportDialogBase(config:CSVImportDialogBase = null) { super(config); + showFolderChooser = false; // disables the FolderChooser, as it is not used and confuses the user otherwise + } + + protected function getDefaultImportTemplate():String { + var configuration:* = StudioConfigurationUtil.getConfiguration(REPORTING_SETTINGS_NAME, DEFAULT_TEMPLATE_SETTING); + return (configuration == null) ? 'default' : configuration; } /** @@ -165,6 +172,10 @@ public class CSVImportDialogBase extends UploadDialog { formData.append('contentName', contentName); } + var defaultImportTemplate:String = getDefaultImportTemplate(); + Logger.info("Template used for import: " + defaultImportTemplate); + formData.append('template', defaultImportTemplate); + uploadRequest = new XMLHttpRequest(); uploadRequest.open('POST', url, true); diff --git a/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml b/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml index 1a65fa2..a2c7344 100644 --- a/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml +++ b/csv-studio/src/main/joo/com/coremedia/csv/studio/CSVExportLibraryPlugin.mxml @@ -1,6 +1,7 @@ @@ -24,7 +25,7 @@ - + diff --git a/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml b/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml index 374b3d3..b740b7c 100644 --- a/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml +++ b/csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml @@ -3,6 +3,47 @@ en-US +default +
+
CLICK ME, to read the list of the default 'cvsHeaders' you can use without a 'csvProperties'-Mapping
+Id                      => Integer.toString(IdHelper.parseContentId(content.getId()))
+Name                    => content.getName()
+Path                    => content.getPath()
+URL                     => linkFormatter.formatLink(contentBean, null, request, response, false)
+Type                    => content.getType().getName()
+CreationDate            => content.getCreationDate()
+CreatedBy               => content.getCreator().getName()
+LastModificationDate    => content.getModificationDate()
+LastModifiedBy          => content.getModifier().getName()
+VersionStatus           => see below
+PublicationDate         => contentRepository.getPublicationService().getPublicationDate(content)
+
+protected String getContentVersionStatusString(Content content) {
+  PublicationService publicationService = contentRepository.getPublicationService();
+  String status = "";
+  if (content.isCheckedOut()) {
+    status = "Checked Out";
+  } else {
+    Version version = content.getWorkingVersion();
+    if (version == null) {
+      version = content.getCheckedInVersion();
+    }
+    if (version != null) {
+      status = "Checked In";
+      if (publicationService.isApproved(version)) {
+        status = "Approved";
+      }
+      if (publicationService.isPublished(version)) {
+        status = "Published";
+      }
+    }
+    if (publicationService.isNew(content)) {
+      status = "Created";
+    }
+  }
+  return status;
+}
+
diff --git a/documentation/Configuration.md b/documentation/Configuration.md index bea540d..e1900c0 100644 --- a/documentation/Configuration.md +++ b/documentation/Configuration.md @@ -10,6 +10,7 @@ See the “default” template for an example of how to format custom templates. To add a column to the CSV exporter output, simply add the desired header to the “csvHeaders” string list in the template. Additionally, the value in this new column will need to be configured. ### Configuring Static Properties (Metadata) Metadata for a content object must be added to a CSV record via the Java code. Each supported metadata value corresponds to a preset header value, such as "Id", "Name", or "URL." See the “populateContentMetadataFields” method in BaseCSVUtil.java for examples of how to include such properties. +For a list of all currently available metadata fields, see 'documentation' in [ReportingSettings.xml](../csv-test-data/content/Settings/Options/Settings/ReportingSettings.xml) ### Configuring Dynamic Properties Content properties may be configured dynamically through the “csvProperties” struct in a template, which maps template headers to content properties. To add a new column, create an entry with the header as the key and the property name as the value. Properties defined in a content’s local settings may be accessed through using the "localSettings" property. This will output the entire localSettings for each content reported in Markup, which gives the flexibility to add, remove, or change localSettings for content in bulk. ### Configuring Custom Values