Skip to content

Commit

Permalink
support aspectNames with multipart upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nbarithel authored Dec 26, 2024
1 parent ba68efe commit 66e817f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions remote-api/src/main/java/org/alfresco/rest/api/impl/NodesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2995,6 +2995,7 @@ public Node upload(String parentFolderNodeId, FormData formData, Parameters para
Boolean versionMajor = null;
String versionComment = null;
String relativePath = null;
String aspectNames = null;
String renditionNames = null;
boolean versioningEnabled = true;

Expand Down Expand Up @@ -3050,6 +3051,10 @@ public Node upload(String parentFolderNodeId, FormData formData, Parameters para
relativePath = getStringOrNull(field.getValue());
break;

case "aspectnames":
aspectNames = getStringOrNull(field.getValue());
break;

case "renditions":
renditionNames = getStringOrNull(field.getValue());
break;
Expand Down Expand Up @@ -3101,8 +3106,10 @@ public Node upload(String parentFolderNodeId, FormData formData, Parameters para
// if requested, make (get or create) path
parentNodeRef = getOrCreatePath(parentNodeRef, relativePath);
final QName assocTypeQName = ContentModel.ASSOC_CONTAINS;
final Set<String> renditions = getRequestedRenditions(renditionNames);
final Set<String> renditions = getRequestedNames(renditionNames);

final Set<String> qnameStrAspects = getRequestedNames(aspectNames)
validateAspects(qnameStrAspects, EXCLUDED_NS, EXCLUDED_ASPECTS);
validateProperties(qnameStrProps, EXCLUDED_NS, Arrays.asList());
try
{
Expand Down Expand Up @@ -3149,7 +3156,9 @@ else if (overwrite && nodeService.hasAspect(existingFile, ContentModel.ASPECT_VE

// Create a new file.
NodeRef nodeRef = createNewFile(parentNodeRef, fileName, nodeTypeQName, content, properties, assocTypeQName, parameters, versionMajor, versionComment);


addCustomAspects(nodeRef, qnameStrAspects, EXCLUDED_ASPECTS);

// Create the response
final Node fileNode = getFolderOrDocumentFullInfo(nodeRef, parentNodeRef, nodeTypeQName, parameters);

Expand Down Expand Up @@ -3235,25 +3244,25 @@ private void checkRenditionNames(Set<String> renditionNames)
}
}

static Set<String> getRequestedRenditions(String renditionsParam)
static Set<String> getRequestedNames(String namesParam)
{
if (renditionsParam == null)
if (namesParam == null)
{
return null;
}

String[] renditionNames = renditionsParam.split(",");
String[] namesArray = namesParam.split(",");

Set<String> renditions = new LinkedHashSet<>(renditionNames.length);
for (String name : renditionNames)
Set<String> names = new LinkedHashSet<>(namesArray.length);
for (String name : namesArray)
{
name = name.trim();
if (!name.isEmpty())
{
renditions.add(name.trim());
names.add(name.trim());
}
}
return renditions;
return names;
}

private void requestRenditions(Set<String> renditionNames, Node fileNode)
Expand Down

0 comments on commit 66e817f

Please sign in to comment.