本文整理汇总了Java中org.alfresco.repo.download.DownloadModel类的典型用法代码示例。如果您正苦于以下问题:Java DownloadModel类的具体用法?Java DownloadModel怎么用?Java DownloadModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DownloadModel类属于org.alfresco.repo.download包,在下文中一共展示了DownloadModel类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDownloadTypeNode
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
/**
* Creates node with a type {@link DownloadModel#TYPE_DOWNLOAD} within the
* download container (see
* {@link DownloadStorage#getOrCreateDowloadContainer()} )
* <p>
* 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.<QName, Serializable> singletonMap(ContentModel.PROP_NAME, name)).getChildRef();
Map<QName, Serializable> 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;
}
示例2: getDownloadsCannedQuery
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
public CannedQuery<DownloadEntity> getDownloadsCannedQuery(NodeRef containerNode, Date before)
{
ParameterCheck.mandatory("before", before);
GetDownloadsCannedQueryParams parameterBean = new GetDownloadsCannedQueryParams
(
getNodeId(containerNode),
getQNameId(ContentModel.PROP_NAME),
getQNameId(DownloadModel.TYPE_DOWNLOAD),
before
);
CannedQueryParameters params = new CannedQueryParameters(parameterBean);
final GetDownloadsCannedQuery cq = new GetDownloadsCannedQuery(
cannedQueryDAO, methodSecurity, params
);
return cq;
}
示例3: createAssociation
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Override
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
{
Reference targetReference = Reference.fromNodeRef(targetRef);
if (targetReference != null
&& getTrait().getType(materializeIfPossible(sourceRef)).equals(DownloadModel.TYPE_DOWNLOAD))
{
// NOTE : this is enables downloads of virtual structures
createDownloadAssociation(sourceRef,
targetRef);
AssociationRef assocRef = new AssociationRef(sourceRef,
assocTypeQName,
targetRef);
return assocRef;
}
else
{
return getTrait().createAssociation(materializeIfPossible(sourceRef),
materializeIfPossible(targetRef),
assocTypeQName);
}
}
示例4: createAssociation
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Override
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
{
if (Reference.isReference(targetRef)
&& getTrait().getType(materializeIfPossible(sourceRef)).equals(DownloadModel.TYPE_DOWNLOAD))
{
// NOTE : this is enables downloads of virtual structures
createDownloadAssociation(sourceRef,
targetRef);
AssociationRef assocRef = new AssociationRef(sourceRef,
assocTypeQName,
targetRef);
return assocRef;
}
else
{
return getTrait().createAssociation(materializeIfPossible(sourceRef),
materializeIfPossible(targetRef),
assocTypeQName);
}
}
示例5: getDownloadTargetAssocs
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
private List<AssociationRef> getDownloadTargetAssocs(NodeRef sourceNodeRef)
{
try
{
List<AssociationRef> result = new ArrayList<AssociationRef>();
NodeRef tempFolderNodeRef = downloadAssociationsFolder.resolve();
if (tempFolderNodeRef == null)
{
return result;
}
String tempFileName = sourceNodeRef.getId();
NodeRef tempFileNodeRef = environment.getChildByName(tempFolderNodeRef,
ContentModel.ASSOC_CONTAINS,
tempFileName);
if (tempFileNodeRef == null)
{
return result;
}
List<String> readLines = IOUtils.readLines(environment.openContentStream(tempFileNodeRef),
StandardCharsets.UTF_8);
for (String line : readLines)
{
NodeRef targetRef = new NodeRef(line);
AssociationRef assocRef = new AssociationRef(sourceNodeRef,
DownloadModel.ASSOC_REQUESTED_NODES,
targetRef);
result.add(assocRef);
}
return result;
}
catch (IOException e)
{
throw new VirtualizationException(e);
}
}
示例6: deleteNode
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Override
public void deleteNode(NodeRef nodeRef) throws InvalidNodeRefException
{
NodeServiceTrait theTrait = getTrait();
NodeRef materialNode = smartStore.materializeIfPossible(nodeRef);
boolean isDownload = DownloadModel.TYPE_DOWNLOAD.equals(theTrait.getType(materialNode));
theTrait.deleteNode(materialNode);
if (isDownload)
{
cleanUpDownloadTargetAssocs(nodeRef);
}
}
示例7: testCreateAssociation
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Test
public void testCreateAssociation() throws Exception
{
NodeRef createDownloadNode = createDownloadNode();
NodeRef node2 = nodeService.getChildByName(virtualFolder1NodeRef,
ContentModel.ASSOC_CONTAINS,
"Node2");
nodeService.createAssociation(createDownloadNode,
node2,
DownloadModel.ASSOC_REQUESTED_NODES);
}
示例8: testGetSourceAssocs_download
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Test
public void testGetSourceAssocs_download() throws Exception
{
NodeRef node2 = nodeService.getChildByName(virtualFolder1NodeRef,
ContentModel.ASSOC_CONTAINS,
"Node2");
List<AssociationRef> sourceAssocs = null;
sourceAssocs = nodeService.getSourceAssocs(node2,
RegexQNamePattern.MATCH_ALL);
assertEquals(0,
sourceAssocs.size());
sourceAssocs = nodeService.getSourceAssocs(node2,
DownloadModel.ASSOC_REQUESTED_NODES);
assertEquals(0,
sourceAssocs.size());
// one virtual noderef
NodeRef createDownloadNode = createDownloadNode();
nodeService.createAssociation(createDownloadNode,
node2,
DownloadModel.ASSOC_REQUESTED_NODES);
sourceAssocs = nodeService.getSourceAssocs(node2,
DownloadModel.ASSOC_REQUESTED_NODES);
// sources are deliberately not virtualized due to performance and
// complexity issues
assertEquals(0,
sourceAssocs.size());
}
示例9: checkIsDownloadNodeType
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
protected void checkIsDownloadNodeType(NodeRef downloadNodeRef)
{
QName nodeIdType = this.nodeService.getType(downloadNodeRef);
if(!nodeIdType.equals(DownloadModel.TYPE_DOWNLOAD)){
throw new InvalidArgumentException("Please specify the nodeId of a download node.");
}
}
示例10: getTargetAssocs
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Override
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
{
NodeServiceTrait theTrait = getTrait();
List<AssociationRef> targetAssocs = null;
Reference reference = Reference.fromNodeRef(sourceRef);
if (reference != null)
{
if (smartStore.canMaterialize(reference))
{
NodeRef materializedReferece = smartStore.materialize(reference);
targetAssocs = theTrait.getTargetAssocs(materializedReferece,
qnamePattern);
}
else
{
targetAssocs = new LinkedList<>();
}
}
else
{
targetAssocs = theTrait.getTargetAssocs(sourceRef,
qnamePattern);
}
List<AssociationRef> virtualizedIfNeededTargetAssocs = null;
Reference sourceReference = Reference.fromNodeRef(sourceRef);
if (sourceReference != null)
{
virtualizedIfNeededTargetAssocs = new LinkedList<>();
for (AssociationRef associationRef : targetAssocs)
{
NodeRef targetNodeRef = associationRef.getTargetRef();
Reference targetReference = NodeProtocol.newReference(targetNodeRef,
sourceReference
.execute(new GetParentReferenceMethod()));
AssociationRef virtualAssocRef = new AssociationRef(associationRef.getId(),
sourceRef,
associationRef.getTypeQName(),
targetReference.toNodeRef(targetNodeRef
.getStoreRef()));
virtualizedIfNeededTargetAssocs.add(virtualAssocRef);
}
}
else
{
virtualizedIfNeededTargetAssocs = targetAssocs;
if (DownloadModel.TYPE_DOWNLOAD.equals(environment.getType(sourceRef)))
{
if (qnamePattern.isMatch(DownloadModel.ASSOC_REQUESTED_NODES))
{
List<AssociationRef> virtualTargetAssocs = getDownloadTargetAssocs(sourceRef);
virtualizedIfNeededTargetAssocs.addAll(virtualTargetAssocs);
}
}
}
return virtualizedIfNeededTargetAssocs;
}
示例11: testGetTargetAssocs_download
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Test
public void testGetTargetAssocs_download() throws Exception
{
NodeRef node2 = nodeService.getChildByName(virtualFolder1NodeRef,
ContentModel.ASSOC_CONTAINS,
"Node2");
List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(node2,
DownloadModel.ASSOC_REQUESTED_NODES);
assertEquals(0,
targetAssocs.size());
// one virtual noderef
NodeRef createDownloadNode = createDownloadNode();
nodeService.createAssociation(createDownloadNode,
node2,
DownloadModel.ASSOC_REQUESTED_NODES);
targetAssocs = nodeService.getTargetAssocs(createDownloadNode,
ContentModel.ASSOC_CONTAINS);
assertEquals(0,
targetAssocs.size());
targetAssocs = nodeService.getTargetAssocs(createDownloadNode,
DownloadModel.ASSOC_REQUESTED_NODES);
assertEquals(1,
targetAssocs.size());
// 2 virtual node ref ...associations have to be created again since
// they are removed after they are obtained in
// order to cleanup temp node refs from repository.
NodeRef node2_1 = nodeService.getChildByName(node2,
ContentModel.ASSOC_CONTAINS,
"Node2_1");
nodeService.createAssociation(createDownloadNode,
node2,
DownloadModel.ASSOC_REQUESTED_NODES);
nodeService.createAssociation(createDownloadNode,
node2_1,
DownloadModel.ASSOC_REQUESTED_NODES);
targetAssocs = nodeService.getTargetAssocs(createDownloadNode,
ContentModel.ASSOC_CONTAINS);
assertEquals(0,
targetAssocs.size());
for (int i = 0; i < 2; i++)
{
targetAssocs = nodeService.getTargetAssocs(createDownloadNode,
DownloadModel.ASSOC_REQUESTED_NODES);
assertEquals("Try # " + (i + 1),
2,
targetAssocs.size());
}
List<NodeRef> targets = new LinkedList<>();
for (AssociationRef assocs : targetAssocs)
{
targets.add(assocs.getTargetRef());
}
assertTrue(targets.contains(node2));
assertTrue(targets.contains(node2_1));
NodeRefExpression downloadAsocsFolderExpr = virtualizationConfigTestBootstrap.getDownloadAssocaiationsFolder();
NodeRef downloadAssocsFolder = downloadAsocsFolderExpr.resolve();
NodeRef tempDownloadSourceAssocs = nodeService.getChildByName(downloadAssocsFolder,
ContentModel.ASSOC_CONTAINS,
createDownloadNode.getId());
assertNotNull(tempDownloadSourceAssocs);
downloadStorage.delete(createDownloadNode);
assertFalse("Association information was not removed when removing the source.",
nodeService.exists(tempDownloadSourceAssocs));
}
示例12: getTargetAssocs
import org.alfresco.repo.download.DownloadModel; //导入依赖的package包/类
@Override
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
{
NodeServiceTrait theTrait = getTrait();
List<AssociationRef> targetAssocs = null;
if (Reference.isReference(sourceRef))
{
Reference reference = Reference.fromNodeRef(sourceRef);
if (smartStore.canMaterialize(reference))
{
NodeRef materializedReferece = smartStore.materialize(reference);
targetAssocs = theTrait.getTargetAssocs(materializedReferece,
qnamePattern);
}
else
{
targetAssocs = new LinkedList<>();
}
}
else
{
targetAssocs = theTrait.getTargetAssocs(sourceRef,
qnamePattern);
}
List<AssociationRef> virtualizedIfNeededTargetAssocs = null;
if (Reference.isReference(sourceRef))
{
virtualizedIfNeededTargetAssocs = new LinkedList<>();
Reference sourceReference = Reference.fromNodeRef(sourceRef);
for (AssociationRef associationRef : targetAssocs)
{
NodeRef targetNodeRef = associationRef.getTargetRef();
Reference targetReference = NodeProtocol.newReference(targetNodeRef,
sourceReference
.execute(new GetParentReferenceMethod()));
AssociationRef virtualAssocRef = new AssociationRef(associationRef.getId(),
sourceRef,
associationRef.getTypeQName(),
targetReference.toNodeRef(targetNodeRef
.getStoreRef()));
virtualizedIfNeededTargetAssocs.add(virtualAssocRef);
}
}
else
{
virtualizedIfNeededTargetAssocs = targetAssocs;
if (DownloadModel.TYPE_DOWNLOAD.equals(environment.getType(sourceRef)))
{
if (qnamePattern.isMatch(DownloadModel.ASSOC_REQUESTED_NODES))
{
List<AssociationRef> virtualTargetAssocs = getDownloadTargetAssocs(sourceRef);
virtualizedIfNeededTargetAssocs.addAll(virtualTargetAssocs);
}
}
}
return virtualizedIfNeededTargetAssocs;
}