Hello,
Here is my configuration Alfresco 5.2.4 with ADF 3.4
I'm facing a problem while importing document with a custom property that can take multiple string values.
Here is the content-model.xml
<constraints>
<constraint name="multiplePropertylist" type="this.is.my.constraints.CustomConstraint">
<parameter name="allowedValues">
<list></list>
</parameter>
<parameter name="constraintName">
<value>MultipleProperty</value>
</parameter>
</constraint>
</constraints>
<types>
<type name="document">
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>custom:data</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<aspect name="custom:data">
...
<properties>
...
<property name="multipleProperty">
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>true</multiple>
<index enabled="true">
<facetable>true</facetable>
</index>
<constraints>
<constraint ref="multiplePropertylist"/>
</constraints>
</property>
</properties>
...
</aspect>
</aspects>
When I upload a document, the event is stopped and a popup is opened allowing me to modify the properties :
onBeginUpload(event: UploadFilesEvent) {
event.pauseUpload();
let listFiles: FileModel[];
listFiles = event.files || [];
if (listFiles.length > 0) {
const dialogUpload = this.dialog.open(DialogUploadComponent, {
width: '1000px',
autoFocus: false,
data: {
files: listFiles,
type: 'document',
mode: this.mode
}
});
dialogUpload.afterClosed().subscribe(result => {
if (result === 'OK') {
event.resumeUpload();
}
});
}
}Before closing the DialogUploadComponent popup, properties are setted to all files passed to the popup in listFiles :
uploadFiles() {
const values = this.customForm.form.values;
this.listFiles.forEach((file: FileModel) => {
file.options.nodeType = this.type;
const properties = {};
for (const key in values) {
if (key !== AppConstants._PROPERTY_CM_NAME) {
properties[key] = this.setValue(values[key]);
}
}
file.options['properties'] = properties;
});
this.closeDialog('OK');
}At that point, I can debug the process and see that multiple values are well passed to all files like this :
FileModel {status: 0, file: File, id: undefined, …}
data: null
errorCode: null
extension: (...)
file: File {…}
id: undefined
name: "toto.pdf"
options:
comment: undefined
majorVersion: false
newVersion: false
nodeType: "document"
parentId: "0f208ce6-bf7c-4e7d-8097-2f79d5a6abf8"
path: ""
properties:
...
multipleProperty: (2) ["4", "1"]
...
progress: {loaded: 0, total: 0, percent: 0}
size: 15659
status: 0
Then the UploadFilesEvent.resumeUpload() is emitted, and the next call is made to the backend :
POST http://localhost:4200/alfresco/api/-default-/public/alfresco/versions/1/nodes/0f208ce6-bf7c-4e7d-8097-2f79dAAAAAaa/children?autoRename=true&include=allowableOperations
Body :
------WebKitFormBoundarybVmxBA5ta4P5neSD
Content-Disposition: form-data; name="cm:title"
toto.pdf
------WebKitFormBoundarybVmxBA5ta4P5neSD
Content-Disposition: form-data; name="multipleProperty"
4
------WebKitFormBoundarybVmxBA5ta4P5neSD
Content-Disposition: form-data; name="multipleProperty"
1
------WebKitFormBoundarybVmxBA5ta4P5neSD
Content-Disposition: form-data; name="include"
allowableOperations
...
------WebKitFormBoundarybVmxBA5ta4P5neSD
Content-Disposition: form-data; name="autoRename"
true
------WebKitFormBoundarybVmxBA5ta4P5neSD
Content-Disposition: form-data; name="nodeType"
document
------WebKitFormBoundarybVmxBA5ta4P5neSD--
As a result, the document is saved with only one of the two value for the property "multipleProperty".
After that creation, it is possible to modify this property from the UI and add another value successfully, herre is the successful call :
PUT http://localhost:4200/alfresco/api/-default-/public/alfresco/versions/1/nodes/38b883ee-d5d4-4708-a797-3eb12BBBBbbb
Body :
{"name":"toto.pdf","properties":{"cm:title":"toto.pdf","multipleProperty":["8","1"]}}Is it possible to pass multiple value while uploading a document ?
Thanks for your answers !
Charles REY