本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Folder.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java Folder.getChildren方法的具体用法?Java Folder.getChildren怎么用?Java Folder.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.client.api.Folder
的用法示例。
在下文中一共展示了Folder.getChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDescriptorFile
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
@Override
public void updateDescriptorFile(String tenantId, String uuid, CMISEvidenceFile cmisFile) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + tenantId);
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, true);
for (CmisObject cmisObject : uuidFolder.getChildren()) {
if (cmisObject.getType().getId().equals(CMISEvidenceFile.PROPERTY_DOC_ID)) {
Document doc = (Document) cmisObject;
if (doc.getName().equals(cmisFile.getFileName())) {
Map<String, String> newDocProps = new HashMap<String, String>();
newDocProps.put(CMISEvidenceFile.PROPERTY_TRANSACTION_STATUS, cmisFile.getTransactionStatus());
doc.updateProperties(newDocProps);
// Recover mime type from stored content
ContentStream contentStream = new ContentStreamImpl(cmisFile.getFileName(), null, doc.getContentStreamMimeType(), cmisFile.getInputStream());
doc.setContentStream(contentStream, true);
} else {
log.warn("Found unexpected CMIS object type in descriptor folder: " + cmisObject.getName() + " - " + cmisObject.getType().getId() +
" (expected " + cmisFile.getFileName() + ")");
}
}
}
}
示例2: deleteAllContent
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
protected void deleteAllContent() {
Session session = createSession();
Folder rootFolder = session.getRootFolder();
ItemIterable<CmisObject> children = rootFolder.getChildren();
for (CmisObject cmisObject : children) {
if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
List<String> notDeltedIdList = ((Folder)cmisObject)
.deleteTree(true, UnfileObject.DELETE, true);
if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
throw new RuntimeException("Cannot empty repo");
}
} else {
cmisObject.delete(true);
}
}
session.getBinding().close();
}
示例3: getTargetFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
private CmisObject getTargetFolder(final Session session, final BatchClassCmisConfiguration batchClassCmisConfiguration) {
CmisObject targetFolder = null;
LOGGER.info("Acquiring Root Folder.");
final Folder root = session.getRootFolder();
final ItemIterable<CmisObject> children = root.getChildren();
LOGGER.info("Looping through Root Folder children.");
for (final CmisObject cmisObject : children) {
if (cmisObject != null && cmisObject.getName() != null
&& cmisObject.getName().equalsIgnoreCase(batchClassCmisConfiguration.getFolderName())
&& isObjectFolder(cmisObject)) {
LOGGER.info("Verified that the target is of type cmis:folder.");
LOGGER.info("Target folder, " + batchClassCmisConfiguration.getFolderName() + ", found.");
targetFolder = cmisObject;
break;
}
}
return targetFolder;
}
示例4: getDescriptorFile
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
private CMISEvidenceFile getDescriptorFile(Folder multitenantRootFolder, Session session, String uuid, String descriptorFileName) {
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, false);
CMISEvidenceFileImpl descriptorFile = new CMISEvidenceFileImpl();
for (CmisObject cmisObject : uuidFolder.getChildren()) {
if (cmisObject.getType().getId().equals(CMISEvidenceFile.PROPERTY_DOC_ID)) {
Document doc = (Document) cmisObject;
if (doc.getName().equals(descriptorFileName)) {
descriptorFile.setFileName(doc.getName());
descriptorFile.setMimeType(doc.getContentStreamMimeType());
descriptorFile.setInputStream(doc.getContentStream().getStream());
if (doc.getProperty(CMISEvidenceFile.PROPERTY_TRANSACTION_ID) != null && !doc.getProperty(CMISEvidenceFile.PROPERTY_TRANSACTION_ID).toString().equals("")) {
descriptorFile.setTransactionId(doc.getProperty(CMISEvidenceFile.PROPERTY_TRANSACTION_ID).toString());
} else {
descriptorFile.setTransactionId("");
}
descriptorFile.setTransactionStatus(doc.getProperty(CMISEvidenceFile.PROPERTY_TRANSACTION_STATUS).toString());
} else {
log.warn("Found unexpected CMIS object type in descriptor folder: " + cmisObject.getName() + " - " + cmisObject.getType().getId() +
" (expected " + descriptorFileName + ")");
}
}
}
return descriptorFile;
}
示例5: getContentFiles
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
@Override
public List<CMISFile> getContentFiles(String uuid) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + multiTenantContextResolver.resolveCurrentTenantIdentifier());
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, false);
Folder contentsFolder = getFolderByPath(session, CONTENT_FOLDER_NAME, uuidFolder, true);
List<CMISFile> cmisFiles = new ArrayList<CMISFile>();
for (CmisObject cmisObject : contentsFolder.getChildren()) {
if (cmisObject.getType().isBaseType() && cmisObject.getType().getId().equals(CMIS_DOCUMENT)) {
Document doc = (Document) cmisObject;
CMISFileImpl file = new CMISFileImpl();
file.setFileName(doc.getName());
file.setMimeType(doc.getContentStreamMimeType());
file.setInputStream(doc.getContentStream().getStream());
cmisFiles.add(file);
} else {
log.warn("Found unexpected CMIS object type in contents folder: " + cmisObject.getName() + " - " +cmisObject.getType().getId());
}
}
return cmisFiles;
}
示例6: getChildren
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public FolderNode getChildren(String folderId, int skipCount, int maxItems)
{
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
FolderNode ret = (FolderNode)CMISNode.createNode(f);
OperationContextImpl ctx = new OperationContextImpl();
ItemIterable<CmisObject> res = f.getChildren(ctx);
res.skipTo(skipCount);
ItemIterable<CmisObject> l = res.getPage(maxItems);
for(CmisObject c : l)
{
CMISNode child = null;
if(c.getBaseType() instanceof FolderTypeDefinition)
{
child = (FolderNode)CMISNode.createNode(c);
ret.addFolder((FolderNode)child);
}
else
{
child = CMISNode.createNode(c);
ret.addNode(child);
}
}
return ret;
}
else
{
throw new IllegalArgumentException("Folder does not exist or is not a folder");
}
}
示例7: processFolderRecursively
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
int processFolderRecursively(Folder folder) throws Exception {
processFolderNode(folder);
OperationContext operationContext = cmisConsumer.createOperationContext();
operationContext.setMaxItemsPerPage(pageSize);
int count = 0;
int pageNumber = 0;
boolean finished = false;
ItemIterable<CmisObject> itemIterable = folder.getChildren(operationContext);
while (!finished) {
ItemIterable<CmisObject> currentPage = itemIterable.skipTo(count).getPage();
LOG.debug("Processing page {}", pageNumber);
for (CmisObject child : currentPage) {
if (CMISHelper.isFolder(child)) {
Folder childFolder = (Folder)child;
processFolderRecursively(childFolder);
} else {
processNonFolderNode(child, folder);
}
count++;
if (totalPolled == readCount) {
finished = true;
break;
}
}
pageNumber++;
if (!currentPage.getHasMoreItems()) {
finished = true;
}
}
return totalPolled;
}
示例8: monitorTargetFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
private void monitorTargetFolder(final CmisObject cmisFolder, final BatchClassCmisConfiguration batchClassCmisConfiguration) {
final Folder targetFolder = (Folder) cmisFolder;
final ItemIterable<CmisObject> folderChildren = targetFolder.getChildren();
LOGGER.info("ImportFolder has children count of = " + folderChildren.getTotalNumItems());
LOGGER.info("Looping through " + batchClassCmisConfiguration.getFolderName() + " children...");
for (final CmisObject cmisObject : folderChildren) {
LOGGER.info("Name = " + cmisObject.getName() + "\nId = " + cmisObject.getId());
if (cmisObject instanceof Folder) {
LOGGER.info("Found sub folder :" + cmisObject.getName());
LOGGER.info("Skipping sub folder for processing");
// Uncomment below line for supporting the subfolder.
// monitorTargetFolder(cmisFolder);
} else if (eligibleForImport(cmisObject, batchClassCmisConfiguration)) {
LOGGER.info("Name = " + cmisObject.getName() + " HAS NOT BEEN IMPORTED TO EPHESOFT YET!");
// GETTING OBJECT CONTENT
String fileName = cmisObject.getName();
final String destinationFolder = batchClassCmisConfiguration.getBatchClass().getUncFolder() + File.separator
+ fileName.substring(0, fileName.indexOf('.')) + "_" + System.currentTimeMillis();
final String destinationFile = destinationFolder + File.separator + fileName;
copyObjectToLocation(getObjectContent(cmisObject), destinationFolder, destinationFile);
outputToXml(generatePropertiesXml(cmisObject), destinationFolder + File.separator + fileName + "_PROPERTIES" + ".xml");
setPropertyImportFlag(cmisObject, batchClassCmisConfiguration);
}
}
LOGGER.info("***** Target Folder Monitor Service Scan END *****");
}
示例9: getChildren
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public FolderNode getChildren(String folderId, int skipCount, int maxItems)
{
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
FolderNode ret = (FolderNode)CMISNode.createNode(f);
OperationContextImpl ctx = new OperationContextImpl();
ItemIterable<CmisObject> res = f.getChildren(ctx);
res.skipTo(skipCount);
ItemIterable<CmisObject> l = res.getPage(maxItems);
for(CmisObject c : l)
{
CMISNode child = null;
if(c.getBaseType() instanceof FolderTypeDefinition)
{
child = (FolderNode)CMISNode.createNode(c);
ret.addFolder((FolderNode)child);
}
else
{
child = CMISNode.createNode(c);
ret.addNode(child);
}
}
return ret;
}
else
{
throw new IllegalArgumentException("Folder does not exist or is not a folder");
}
}
示例10: onInventoryOpenEvent
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
@EventHandler
public void onInventoryOpenEvent(InventoryOpenEvent event)
{
InventoryType t = event.getInventory().getType();
if (InventoryType.CHEST.equals(t))
{
ContentCraftPlugin.logger.info("Player [" + event.getPlayer().getName() + "] accessing [" + t + "]");
// either side of the chest will provide the required meta-data
DoubleChest doubleChest = (DoubleChest)event.getInventory().getHolder();
Chest chest = (Chest)doubleChest.getLeftSide();
Block block = chest.getBlock();
if (BlockMetaData.hasMetadata(block, "folderId"))
{
// clear inventory
event.getInventory().clear();
// get the folder
String folderId = (String)BlockMetaData.getMetadata(block, "folderId");
Folder folder = (Folder)CMIS.getSession().getObject(folderId);
ContentCraftPlugin.logger.info("Filling chest with documents from folder [" + folderId + "]");
// add the documents to the chest
int i = 0;
for (CmisObject cmisObject : folder.getChildren())
{
if (cmisObject instanceof Document)
{
Document document = (Document)cmisObject;
event.getInventory().setItem(i, getBook(document));
i++;
}
}
}
}
}
示例11: doInBackground
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
@Override
protected String doInBackground(Void... arg0) {
// Initiates a Session Factory
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
// Initiates connection session parameters.
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
parameter.put(SessionParameter.ATOMPUB_URL, "http://192.168.1.36:8081/inmemory/atom/");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Retrieves repository information and create the session object.
Repository repository = sessionFactory.getRepositories(parameter).get(0);
parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());
Session session = sessionFactory.createSession(parameter);
// Retrieves media folder and list all this children.
String listChildren = "";
Folder mediaFolder = (Folder) session.getObjectByPath("/media");
ItemIterable<CmisObject> children = mediaFolder.getChildren();
for (CmisObject o : children) {
listChildren += o.getName() + " - " + o.getType().getDisplayName() + " - " + o.getCreatedBy() + "\b\n";
}
return listChildren;
}
示例12: run
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
@Override
public void run(Session session) {
Folder testFolder = getReadOnlyTestFolder(session);
checkChildren(session, testFolder, "Test folder children check");
boolean foundDocument = false;
boolean foundFolder = false;
for (CmisObject child : testFolder.getChildren(SELECT_ALL_NO_CACHE_OC)) {
addResult(checkObject(session, child, getAllProperties(child),
"Copied document check. Id: + " + child.getName()));
if (child instanceof Document) {
foundDocument = true;
} else if (child instanceof Folder) {
foundFolder = true;
}
}
if (!foundDocument) {
addResult(createResult(INFO, "Test folder does not contain a document!"));
}
if (!foundFolder) {
addResult(createResult(INFO, "Test folder does not contain a folder!"));
}
}
示例13: findADocument
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
protected Document findADocument(Folder folder) {
for (CmisObject child : folder.getChildren()) {
if (child instanceof Document) {
return (Document) child;
}
}
return null;
}
示例14: findAFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
protected Folder findAFolder(Folder folder) {
for (CmisObject child : folder.getChildren()) {
if (child instanceof Folder) {
return (Folder) child;
}
}
return null;
}
示例15: processCMISEvent
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unused")
protected EventResult processCMISEvent(Event event) throws Exception
{
super.suspendTimer(); // Timer control
CMISEventData data = (CMISEventData) event.getData();
// A quick double-check
if (data == null)
{
return new EventResult("Unable to get CMIS root folder; no session provided.", false);
}
if (data.getBreadcrumb().isEmpty())
{
return new EventResult("Unable to get CMIS folder listing; no folder provided.", false);
}
Folder folder = data.getBreadcrumb().getLast();
// Get details of how to page, etc
OperationContext ctx = data.getSession().getDefaultContext();
int pageSize = ctx.getMaxItemsPerPage();
super.resumeTimer(); // Timer control
ItemIterable<CmisObject> children = folder.getChildren();
long totalChildren = children.getTotalNumItems(); // For information only
int pageCount = 0;
// We have to iterate using paging
long skip = 0L;
ItemIterable<CmisObject> pageOfChildren = children.skipTo(skip);
while (pageOfChildren.getPageNumItems() > 0L)
{
pageCount++;
for (CmisObject cmisObject : pageOfChildren)
{
skip++;
}
// Get the next page of children
pageOfChildren = children.skipTo(skip);
}
super.stopTimer(); // Timer control
// Done
Event doneEvent = new Event(eventNameFolderContentsListed, data);
EventResult result = new EventResult(
BasicDBObjectBuilder
.start()
.append("msg", "Successfully retrieved folder listing.")
.push("folder")
.append("id", folder.getId())
.append("name", folder.getName())
.push("paging")
.append("pageSize", pageSize)
.append("totalChildren", totalChildren)
.append("pageCount", pageCount)
.pop()
.get(),
doneEvent);
// Done
return result;
}