()
{
@Override
public NodeRef execute() throws Exception
{
final NodeRef newNodeRef = createDownloadTypeNode(newName);
Serializable content = nodeService.getProperty(modelNodeRef, ContentModel.PROP_CONTENT);
nodeService.setProperty(newNodeRef, ContentModel.PROP_CONTENT, content);
return newNodeRef;
}
});
}
/**
* Creates node with a type {@link DownloadModel#TYPE_DOWNLOAD} within the
* download container (see
* {@link DownloadStorage#getOrCreateDowloadContainer()} )
*
* Also, the {@code IndexControlAspect} is applied to the created node.
*
* @param name the node name
* @return the created nodeRef
*/
private NodeRef createDownloadTypeNode(final String name)
{
final NodeRef newNodeRef = nodeService.createNode(
downloadStorage.getOrCreateDowloadContainer(),
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
DownloadModel.TYPE_DOWNLOAD,
Collections. singletonMap(ContentModel.PROP_NAME, name)).getChildRef();
Map aspectProperties = new HashMap<>(2);
aspectProperties.put(ContentModel.PROP_IS_INDEXED, Boolean.FALSE);
aspectProperties.put(ContentModel.PROP_IS_CONTENT_INDEXED, Boolean.FALSE);
nodeService.addAspect(newNodeRef, ContentModel.ASPECT_INDEX_CONTROL, aspectProperties);
return newNodeRef;
}
@Override
public CustomModelsInfo getCustomModelsInfo()
{
List page = getCustomModels(new PagingRequest(0, Integer.MAX_VALUE)).getPage();
int activeModels = 0;
int activeTypes = 0;
int activeAspects = 0;
for (CustomModelDefinition cm : page)
{
if (cm.isActive())
{
activeModels++;
activeTypes += cm.getTypeDefinitions().size();
activeAspects += cm.getAspectDefinitions().size();
}
}
CustomModelsInfo info = new CustomModelsInfo();
info.setNumberOfActiveModels(activeModels);
info.setNumberOfActiveTypes(activeTypes);
info.setNumberOfActiveAspects(activeAspects);
return info;
}
}