Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

WIP:MNT-18497: Improve Share's rendering of linkedNodes #900

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,37 @@ public JSONObject toJSONObject(final NodeRef nodeRef, final boolean useShortQNam

return json;
}

/**
* MNT-18497
* Convert a linkedNode reference to a JSON object. Selects the correct converter based on selection
* implementation. Skips adding properties and aspects of targetNodeRef
*/
@SuppressWarnings("unchecked")
public JSONObject linkedNodeToJSONObject(final NodeRef nodeRef, final boolean useShortQNames)
{
final JSONObject json = new JSONObject();

if (this.nodeService.exists(nodeRef))
{
if (publicServiceAccessService.hasAccess(ServiceRegistry.NODE_SERVICE.getLocalName(), "getProperties", nodeRef) == AccessStatus.ALLOWED)
{
// init namespace prefix cache
namespacePrefixCache.get().clear();

// Get node info
FileInfo nodeInfo = this.fileFolderService.getFileInfo(nodeRef);

// Set root values
setRootValues(nodeInfo, json, useShortQNames);

// add permissions
json.put("permissions", permissionsToJSON(nodeRef));
}
}

return json;
}

/**
*
Expand All @@ -257,7 +288,7 @@ protected void setRootValues(final FileInfo nodeInfo, final JSONObject rootJSONO
NodeRef targetNodeRef = nodeInfo.getLinkNodeRef();
if (targetNodeRef != null)
{
rootJSONObject.put("linkedNode", toJSONObject(targetNodeRef, useShortQNames));
rootJSONObject.put("linkedNode", linkedNodeToJSONObject(targetNodeRef, useShortQNames));
}
}

Expand Down