本文整理汇总了Java中org.alfresco.webservice.types.Predicate类的典型用法代码示例。如果您正苦于以下问题:Java Predicate类的具体用法?Java Predicate怎么用?Java Predicate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Predicate类属于org.alfresco.webservice.types包,在下文中一共展示了Predicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContentForNode
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
private void addContentForNode(CMLHelper sCMLHelper, Document sDocument, Predicate sPredicate, int sNodeIndex) throws IOException {
if (sendContents && (sDocument.getContentPath() != null) && (sDocument.getContentPath().length() > 0)) {
// If the document has a content path, the file must exist
File aFile = new File(sDocument.getContentPath());
if (aFile.exists() && aFile.isFile()) {
FileInputStream aInputStream = new FileInputStream(aFile);
try {
sCMLHelper.addWriteContent(new CMLWriteContent(Constants.PROP_CONTENT, ContentUtils.convertToByteArray(aInputStream), new ContentFormat(
sDocument.getMimeType(), sDocument.getEncoding()), sPredicate, ((sPredicate != null) ? null : Integer.toString(sNodeIndex))));
} catch (Exception e) {
throw new IOException("Cannot convert and write content", e);
}
} else {
throw new IOException("Cannot find content file: " + sDocument.getContentPath());
}
}
}
示例2: addAssociationsForNode
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
private void addAssociationsForNode(CMLHelper sCMHelper, Node sNode, Predicate sPredicate, Map<String, List<Integer>> sNodesRefIndexes, int sNodeIndex) {
List<Association> aAssociationList = sNode.getAssociations();
if (aAssociationList.size() > 0) {
for (Association aAssociation : aAssociationList) {
if (aAssociation instanceof RefAssociation) {
List<Integer> aTargetIndex = sNodesRefIndexes.get(((RefAssociation) aAssociation).getReference());
if (aTargetIndex != null) {
for (Integer aIndex : aTargetIndex) {
sCMHelper.addCreateAssociation(new CMLCreateAssociation(sPredicate, ((sPredicate != null) ? null : Integer.toString(sNodeIndex)),
null, aIndex.toString(), aAssociation.getType().toString()));
}
}
} else if (aAssociation instanceof QueryAssociation) {
Query aQuery = new Query(((QueryAssociation) aAssociation).getQueryLanguage(), ((QueryAssociation) aAssociation).getQuery());
Predicate aQueryPredicate = new Predicate(null, STORE, aQuery);
sCMHelper.addCreateAssociation(new CMLCreateAssociation(sPredicate, ((sPredicate != null) ? null : Integer.toString(sNodeIndex)),
aQueryPredicate, null, aAssociation.getType().toString()));
}
}
}
}
示例3: setUp
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
RepositoryServiceSoapBindingStub aRepoService = mock(RepositoryServiceSoapBindingStub.class);
AlfrescoServiceImpl aAlfrescoService = mock(AlfrescoServiceImpl.class);
when(aAlfrescoService.getRepositoryService()).thenReturn(aRepoService);
when(aAlfrescoService.getEndpointAddress()).thenReturn("endpoint");
when(aAlfrescoService.getUsername()).thenReturn("username");
UpdateResult[] aUpdateResult = new UpdateResult[1];
aUpdateResult[0] = new UpdateResult();
aUpdateResult[0].setDestination(null);
when(aRepoService.update(any(CML.class))).thenReturn(aUpdateResult); // FIXME : add a CML matcher that helps to verify the send CML
Node[] aRootNode = new Node[1];
aRootNode[0] = new Node();
aRootNode[0].setReference(new Reference(fr.acxio.tools.agia.alfresco.AlfrescoServicesConsumer.STORE, "00000000-0000-0000-0000-000000000001", null));
Reference aRootReference = new Reference(AlfrescoServicesConsumer.STORE, null, "/app:company_home");
Predicate aRootPredicate = new Predicate(new Reference[]{aRootReference}, null, null);
when(aRepoService.get(eq(aRootPredicate))).thenReturn(aRootNode);
nodeWriter.setAlfrescoService(aAlfrescoService);
nodeWriter.init();
}
示例4: updateMockContext
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
private void updateMockContext(RepositoryServiceSoapBindingStub sRepoService, String sId, String sFullPath) throws IOException {
Node[] aLevel1Node = new Node[1];
aLevel1Node[0] = new Node();
aLevel1Node[0].setReference(new Reference(fr.acxio.tools.agia.alfresco.AlfrescoServicesConsumer.STORE, "00000000-0000-0000-0000-000000000002", null));
Reference aLevel1Reference = new Reference(AlfrescoServicesConsumer.STORE, null, "/app:company_home/cm:Test_x0020_Batch_x0020_Writer");
Predicate aLevel1Predicate = new Predicate(new Reference[]{aLevel1Reference}, null, null);
when(sRepoService.get(eq(aLevel1Predicate))).thenReturn(aLevel1Node);
Node[] aLevel2Node = new Node[1];
aLevel2Node[0] = new Node();
aLevel2Node[0].setReference(new Reference(fr.acxio.tools.agia.alfresco.AlfrescoServicesConsumer.STORE, sId, null));
Reference aLevel2Reference = new Reference(AlfrescoServicesConsumer.STORE, null, sFullPath);
Predicate aLevel2Predicate = new Predicate(new Reference[]{aLevel2Reference}, null, null);
when(sRepoService.get(eq(aLevel2Predicate))).thenReturn(aLevel2Node);
}
示例5: testWrite
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
@Test
public void testWrite() throws Exception {
RepositoryServiceSoapBindingStub aRepoService = nodeWriter.getAlfrescoService().getRepositoryService();
CML aCML = createDefaultMockResult(aRepoService, "Test Batch Writer Content", "Text content", "/app:company_home/cm:Test_x0020_Batch_x0020_Writer/cm:Test_x0020_Batch_x0020_Writer_x0020_Content", "00000000-0000-0000-0000-000000000003", false);
List<NodeList> aData = createDefaultNodeListList("Test Batch Writer Content", "Text content", "cm:Test_x0020_Batch_x0020_Writer_x0020_Content", null, false);
compositeWriter.write(aData);
// Verify sent CML
verify(aRepoService, times(1)).update(eq(aCML));
verify(aRepoService, times(0)).query(any(Store.class), any(Query.class), anyBoolean());
verify(aRepoService, times(3)).get(any(Predicate.class));
RestTemplate aRestTemplate = contentWriter.getRestTemplate();
verify(aRestTemplate, times(1)).put(any(String.class), any(Object.class), Matchers.<Map<String,?>>any());
}
示例6: retrieveContent
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
private byte[] retrieveContent(Reference ref) throws IOException {
Content[] readResult = getAlfrescoContentService().read(
new Predicate(new Reference[]{ref}, ALFRESCO_STORE, null),
Constants.PROP_CONTENT);
InputStream is = ContentUtils.getContentAsInputStream(readResult[0]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int nread = 0;
byte[] buffer = new byte[4096];
while ((nread = is.read(buffer)) > 0)
baos.write(buffer, 0, nread);
return baos.toByteArray();
}
示例7: updateNodeProperties
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
public void updateNodeProperties(Reference ref, Map<String, String> properties) throws RepositoryFault, RemoteException {
NamedValue[] props = new NamedValue[properties.size()];
int index = 0;
for (String p: properties.keySet())
props[index++] = Utils.createNamedValue(p, properties.get(p));
CMLUpdate update = new CMLUpdate(
props,
new Predicate(new Reference[] {ref}, ALFRESCO_STORE, null),
null);
CML cml = new CML();
cml.setUpdate(new CMLUpdate[]{update});
getAlfrescoRepositoryService().update(cml);
}
示例8: retrieveContent
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
public byte[] retrieveContent(Reference ref) throws IOException {
Content[] readResult = getAlfrescoContentService().read(
new Predicate(new Reference[]{ref}, ALFRESCO_STORE, null),
Constants.PROP_CONTENT);
InputStream is = ContentUtils.getContentAsInputStream(readResult[0]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int nread = 0;
byte[] buffer = new byte[4096];
while ((nread = is.read(buffer)) > 0)
baos.write(buffer, 0, nread);
return baos.toByteArray();
}
示例9: retrieveContentFromParent
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
public byte[] retrieveContentFromParent(Reference parent, String contentName) throws IOException {
Content[] readResult = getAlfrescoContentService().read(
new Predicate(new Reference[]{parent}, ALFRESCO_STORE, null),
Constants.PROP_CONTENT);
if (readResult.length > 0) {
Reference ref = new Reference(
ALFRESCO_STORE,
null,
readResult[0].getNode().getPath() + "/cm:" + normalizeNodeName(contentName));
return retrieveContent(ref);
}
return null;
}
示例10: deleteContentFromParent
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
public void deleteContentFromParent(Reference parent, String contentName) throws IOException {
Content[] readResult = getAlfrescoContentService().read(
new Predicate(new Reference[]{parent}, ALFRESCO_STORE, null),
Constants.PROP_CONTENT);
if (readResult.length > 0) {
Reference ref = new Reference(
ALFRESCO_STORE,
null,
readResult[0].getNode().getPath() + "/cm:" + normalizeNodeName(contentName));
deleteContent(ref);
}
}
示例11: toCMLUpdate
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
public CMLUpdate toCMLUpdate(Reference ref) {
logger.debug("Converting doc to CMLUpdate: {}", doc.name);
Predicate pred = new Predicate(new Reference[] {ref},
WebServiceRepositoryAccessSession.store, null);
return new CMLUpdate(getContentPropsAndCreateIfNotExists(), pred, null);
}
示例12: createOrUpdateNode
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
protected void createOrUpdateNode(RepositoryServiceSoapBindingStub sRepositoryService, CMLHelper sCMLHelper, Map<Node, Integer> sNodesIndexes,
Map<String, List<Integer>> sNodesRefIndexes, String sCurrentNodePath, Node sNode) throws NodePathException, VersionOperationException, IOException,
RemoteException {
org.alfresco.webservice.types.Node[] nodes = getRepositoryMatchingNodes(sRepositoryService, sCurrentNodePath);
if ((nodes != null) && (nodes.length > 0)) {
if (nodes.length > 1) {
throw new VersionOperationException("Too many matching nodes");
}
org.alfresco.webservice.types.Node aRepositoryNode = nodes[0];
Predicate sWhereNode = new Predicate(new Reference[] { aRepositoryNode.getReference() }, null, null);
// If this is a folder, just ignore it or update props ?
// If this is a document, replace, version or leave it as it is
if (sNode instanceof Document) {
updateDocument(sRepositoryService, sCMLHelper, sNodesIndexes, sCurrentNodePath, sNodesRefIndexes, sNode, sWhereNode);
} else if (sNode instanceof Folder) {
updateFolder(sRepositoryService, sCMLHelper, sNodesIndexes, sCurrentNodePath, sNodesRefIndexes, sNode, sWhereNode);
}
} else {
createNewNode(sRepositoryService, sCMLHelper, sNodesIndexes, sCurrentNodePath, sNodesRefIndexes, sNode);
}
}
示例13: updateFolder
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
protected void updateFolder(RepositoryServiceSoapBindingStub sRepositoryService, CMLHelper sCMLHelper, Map<Node, Integer> sNodesIndexes,
String sCurrentNodePath, Map<String, List<Integer>> sNodesRefIndexes, Node sNode, Predicate sWhereNode) throws RemoteException {
// Node.VersionOperation.RAISEERROR : Do nothing
if (sNode.getVersionOperation().equals(Node.VersionOperation.REPLACE)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Will replace folder node " + sNode.getId());
}
// WARNING : The node is deleted OUT OF THE CURRENT TRANSACTION !!!
// But they are sent to the deleted items of the user used to
// connect to Alfresco
// FIXME : will fail if the folder is not empty
CML aCML = new CML();
aCML.setDelete(new CMLDelete[] { new CMLDelete(sWhereNode) });
sRepositoryService.update(aCML);
addCreateForNode(sCMLHelper, sNode, sNodesIndexes.get(sNode));
addAssociationsForNode(sCMLHelper, sNode, null, sNodesRefIndexes, sNodesIndexes.get(sNode));
// Clear the cache for the current node to force reload it
evictRepositoryNode(sCurrentNodePath);
} else if (sNode.getVersionOperation().equals(Node.VersionOperation.UPDATE) || sNode.getVersionOperation().equals(Node.VersionOperation.VERSION)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Will skip folder node " + sNode.getId());
}
// Folders are not versionable, just update them
sCMLHelper.addUpdate(new CMLUpdate(getProperties(sNode), sWhereNode, null));
addAspectsForNode(sCMLHelper, sNode, sWhereNode, 0);
addAssociationsForNode(sCMLHelper, sNode, sWhereNode, sNodesRefIndexes, 0);
// Clear the cache for the current node to force reload it
evictRepositoryNode(sCurrentNodePath);
}
}
示例14: addAspectsForNode
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
private void addAspectsForNode(CMLHelper sCMLHelper, Node sNode, Predicate sPredicate, int sNodeIndex) {
List<Aspect> aAspectsList = sNode.getAspects();
if (aAspectsList.size() > 0) {
for (Aspect aAspect : aAspectsList) {
sCMLHelper.addAddAspect(new CMLAddAspect(aAspect.getName().toString(), null, sPredicate, ((sPredicate != null) ? null : Integer
.toString(sNodeIndex))));
}
}
}
示例15: setUp
import org.alfresco.webservice.types.Predicate; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
RepositoryServiceSoapBindingStub aRepoService = mock(RepositoryServiceSoapBindingStub.class);
AlfrescoServiceImpl aAlfrescoService = mock(AlfrescoServiceImpl.class);
when(aAlfrescoService.getRepositoryService()).thenReturn(aRepoService);
when(aAlfrescoService.getEndpointAddress()).thenReturn("endpoint");
when(aAlfrescoService.getUsername()).thenReturn("username");
UpdateResult[] aUpdateResult = new UpdateResult[1];
aUpdateResult[0] = new UpdateResult();
aUpdateResult[0].setDestination(null);
when(aRepoService.update(any(CML.class))).thenReturn(aUpdateResult); // FIXME : add a CML matcher that helps to verify the send CML
Node[] aNode = new Node[1];
aNode[0] = new Node();
aNode[0].setReference(new Reference(fr.acxio.tools.agia.alfresco.AlfrescoServicesConsumer.STORE, "00000000-0000-0000-0000-000000000001", null));
Reference reference = new Reference(AlfrescoServicesConsumer.STORE, null, "/app:company_home");
Predicate predicate = new Predicate(new Reference[]{reference}, null, null);
when(aRepoService.get(eq(predicate))).thenReturn(aNode);
Node[] aManyNodes = new Node[2];
aManyNodes[0] = new Node();
aManyNodes[0].setReference(new Reference(fr.acxio.tools.agia.alfresco.AlfrescoServicesConsumer.STORE, "00000000-0000-0000-0000-000000000002", null));
aManyNodes[1] = new Node();
aManyNodes[1].setReference(new Reference(fr.acxio.tools.agia.alfresco.AlfrescoServicesConsumer.STORE, "00000000-0000-0000-0000-000000000003", null));
Reference referenceMany = new Reference(AlfrescoServicesConsumer.STORE, null, "/cm:many");
Predicate predicateMany = new Predicate(new Reference[]{referenceMany}, null, null);
when(aRepoService.get(eq(predicateMany))).thenReturn(aManyNodes);
nodeWriter.setAlfrescoService(aAlfrescoService);
nodeWriter.setNodePathResolver(nodePathResolver);
nodeWriter.init();
}