本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Folder类的典型用法代码示例。如果您正苦于以下问题:Java Folder类的具体用法?Java Folder怎么用?Java Folder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Folder类属于org.apache.chemistry.opencmis.client.api包,在下文中一共展示了Folder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectParents
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
public List<Folder> getObjectParents(String objectId)
{
CmisObject o = session.getObject(objectId);
if(o instanceof FileableCmisObject)
{
FileableCmisObject f = (FileableCmisObject)o;
OperationContextImpl ctx = new OperationContextImpl();
List<Folder> res = f.getParents(ctx);
return res;
}
else
{
throw new IllegalArgumentException("Object does not exist or is not a fileable cmis object");
}
}
示例2: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
/**
* Creates a new folder with the given name under the given folder.
*
* @param name
* the name of the folder.
* @param rootFolder
* the root folder.
* @return the created folder.
*/
public Folder createFolder(String name, Folder folder) {
logger.debug(DEBUG_CREATING_NEW_FOLDER, name, folder.getName());
Folder newFolder = null;
Map<String, String> newFolderProps = new HashMap<String, String>();
newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, CMIS_FOLDER_TYPE);
newFolderProps.put(PropertyIds.NAME, name);
try {
newFolder = folder.createFolder(newFolderProps);
} catch (CmisNameConstraintViolationException e) {
String errorMessage = MessageFormat.format(ERROR_FOLDER_ALREADY_EXISTS, name);
logger.error(errorMessage);
throw new IllegalArgumentException(errorMessage, e);
}
logger.debug(DEBUG_FOLDER_CREATED, name);
return newFolder;
}
示例3: getDescendants
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
public FolderNode getDescendants(String folderId, int depth)
{
Session session = getCMISSession();
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
OperationContextImpl ctx = new OperationContextImpl();
List<Tree<FileableCmisObject>> res = f.getDescendants(depth, ctx);
FolderNode ret = (FolderNode)CMISNode.createNode(f);
for(Tree<FileableCmisObject> t : res)
{
addChildren(ret, t);
}
return ret;
}
else
{
throw new IllegalArgumentException("Folder does not exist or is not a folder");
}
}
示例4: 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() + ")");
}
}
}
}
示例5: createDocument
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
/**
* Creates a new document with the given name and content under the given
* folder.
*
* @param name
* the name of the document.
* @param rootFolder
* the root folder.
* @param content
* the content of the document.
* @return the created document.
*/
public Document createDocument(Folder rootFolder, String fileName, InputStream inputStream) {
logger.debug(DEBUG_CREATING_NEW_DOCUMENT, fileName, rootFolder);
Document document = null;
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, CMIS_DOCUMENT_TYPE);
properties.put(PropertyIds.NAME, fileName);
ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(fileName, -1,
MIME_TYPE_TEXT_PLAIN_UTF_8, inputStream);
try {
document = rootFolder.createDocument(properties, contentStream, VersioningState.NONE);
} catch (CmisNameConstraintViolationException e) {
String errorMessage = MessageFormat.format(ERROR_FILE_ALREADY_EXISTS, fileName);
logger.error(errorMessage);
throw new CmisNameConstraintViolationException(errorMessage, e);
}
logger.debug(DEBUG_DOCUMENT_CREATED, fileName);
return document;
}
示例6: createDocument
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
private static Document createDocument(Folder target, String newDocName, Session session)
{
Map<String, String> props = new HashMap<String, String>();
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
props.put(PropertyIds.NAME, newDocName);
String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
byte[] buf = null;
try
{
buf = content.getBytes("ISO-8859-1"); // set the encoding here for the content stream
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
ByteArrayInputStream input = new ByteArrayInputStream(buf);
ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
"text/plain; charset=UTF-8", input); // additionally set the charset here
// NOTE that we intentionally specified the wrong charset here (as UTF-8)
// because Alfresco does automatic charset detection, so we will ignore this explicit request
return target.createDocument(props, contentStream, VersioningState.MAJOR);
}
示例7: directoryExistCMIS
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
/** Verifie qu'un dossier existe en mode CMIS
* @param idFolder
* @return
*/
private Boolean directoryExistCMIS(String idFolder, Session cmisSession) {
if (idFolder == null || idFolder.equals("")) {
return false;
}
try{
CmisObject object = cmisSession.getObject(cmisSession.createObjectId(idFolder));
if (!(object instanceof Folder)){
logger.error("Stockage de fichier - CMIS : l'object CMIS "+idFolder+" n'est pas un dossier");
return false;
}
}catch(Exception e){
logger.error("Stockage de fichier - CMIS : erreur sur l'object CMIS "+idFolder, e);
return false;
}
return true;
}
示例8: deleteCampagneFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
@Override
public Boolean deleteCampagneFolder(String codCampagne){
logger.debug("Suppression du dossier de campagne : "+codCampagne);
Session session = getCmisSession();
try{
/*Dossier de base pour les candidats*/
Folder master = getFolderCandidat();
/*Le dossier de la campagne*/
Folder folderCampagne = FileUtils.getFolder(master.getPath()+"/"+codCampagne, session);
logger.debug("Suppression du dossier de campagne, path="+folderCampagne.getPath()+", id="+folderCampagne.getId());
List<String> liste = folderCampagne.deleteTree(true, UnfileObject.DELETE, true);
if (liste !=null && liste.size()>0){
return false;
}
return true;
}catch(Exception e){
logger.error("Impossible de supprimer le dossier de campagne : "+codCampagne+", vous devez le supprimer à la main",e);
return false;
}
}
示例9: getFolderTree
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
public List<Tree<FileableCmisObject>> getFolderTree(String folderId, int depth)
{
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
OperationContextImpl ctx = new OperationContextImpl();
List<Tree<FileableCmisObject>> res = f.getFolderTree(depth, ctx);
return res;
}
else
{
throw new IllegalArgumentException("Object does not exist or is not a folder");
}
}
示例10: renameFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
public static void renameFolder(Session pSession, String pStrNodeRef, String pStrNewName) {
mLog.debug("ENTER renameFolder(<Session>, " + pStrNodeRef + ", " + pStrNewName + ")");
Folder lFolder = (Folder) pSession.getObject(pStrNodeRef);
Map<String, String> lMapProperties = new HashMap<String, String>();
lMapProperties.put(PropertyIds.NAME, pStrNewName);
try {
lFolder.updateProperties(lMapProperties, true);
} catch (CmisContentAlreadyExistsException e) {
mLog.error("Impossibile aggiornare le proprietà del documento", e);
throw new AlfrescoException(e, AlfrescoException.FOLDER_ALREADY_EXISTS_EXCEPTION);
}
mLog.debug("EXIT renameFolder(<Session>, " + pStrNodeRef + ", " + pStrNewName + ")");
}
示例11: createNode
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
private CmisObject createNode(Exchange exchange) throws Exception {
validateRequiredHeader(exchange, PropertyIds.NAME);
Message message = exchange.getIn();
String parentFolderPath = parentFolderPathFor(message);
Folder parentFolder = getFolderOnPath(exchange, parentFolderPath);
Map<String, Object> cmisProperties = filterTypeProperties(message.getHeaders());
if (isDocument(exchange)) {
String fileName = message.getHeader(PropertyIds.NAME, String.class);
String mimeType = getMimeType(message);
byte[] buf = getBodyData(message);
ContentStream contentStream = getSessionFacade().createContentStream(fileName, buf, mimeType);
return storeDocument(parentFolder, cmisProperties, contentStream);
} else if (isFolder(message)) {
return storeFolder(parentFolder, cmisProperties);
} else { // other types
return storeDocument(parentFolder, cmisProperties, null);
}
}
示例12: 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();
}
示例13: createDocumentAtSpecificPath
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
@Test
public void createDocumentAtSpecificPath() throws Exception {
Folder folder1 = createFolderWithName("Folder1");
createChildFolderWithName(folder1, "Folder2");
String existingFolderStructure = "/Folder1/Folder2";
Exchange exchange = createExchangeWithInBody("Some content to be stored");
exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
exchange.getIn().getHeaders().put(CamelCMISConstants.CMIS_FOLDER_PATH, existingFolderStructure);
template.send(exchange);
String newNodeId = exchange.getOut().getBody(String.class);
Document document = (Document) retrieveCMISObjectByIdFromServer(newNodeId);
String documentFullPath = document.getPaths().get(0);
assertEquals(existingFolderStructure + "/test.file", documentFullPath);
}
示例14: 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;
}
示例15: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入依赖的package包/类
private Folder createFolder(String path) throws Exception {
String[] subFolderNames = path.split("/");
Folder folder = getCmisSession().getRootFolder();
for (String subfolder : subFolderNames){
String folderPath = folder.getPath();
if (folder.getPath().equals("/")){
folderPath = "";
}
try{
folder = FileUtils.getFolder(folderPath + "/" + subfolder, getCmisSession());
logger.debug("Parent folder already exists, new folder value is: " + folder.getPath());
}
catch (CmisObjectNotFoundException e){
// The folder does not existe, we create it here
folder = FileUtils.createFolder(folder, subfolder, null);
logger.debug("New folder created, new folder value is: " + folder.getPath());
}
}
return folder;
}