本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Folder.createFolder方法的典型用法代码示例。如果您正苦于以下问题:Java Folder.createFolder方法的具体用法?Java Folder.createFolder怎么用?Java Folder.createFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.client.api.Folder
的用法示例。
在下文中一共展示了Folder.createFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: DISABLED_testBasicFileOps
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public void DISABLED_testBasicFileOps()
{
Repository repository = getRepository("admin", "admin");
Session session = repository.createSession();
Folder rootFolder = session.getRootFolder();
// create folder
Map<String,String> folderProps = new HashMap<String, String>();
{
folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate());
}
Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext());
Map<String, String> fileProps = new HashMap<String, String>();
{
fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
}
ContentStreamImpl fileContent = new ContentStreamImpl();
{
ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt"));
writer.putContent("Ipsum and so on");
ContentReader reader = writer.getReader();
fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
fileContent.setStream(reader.getContentInputStream());
}
folder.createDocument(fileProps, fileContent, VersioningState.MAJOR);
}
示例3: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
/**
*
* @param session Session
* @param name String
* @return Folder
*/
private Folder createFolder(Session session, String name)
{
Folder testFolder;
Folder folder = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, name);
testFolder = folder.createFolder(properties);
return testFolder;
}
示例4: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public Folder createFolder(String folderId, String name, Map<String, Serializable> properties)
{
CmisObject o = getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
if(properties == null)
{
properties = new HashMap<String, Serializable>();
}
String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID);
String type = "cmis:folder";
if(objectTypeId == null)
{
objectTypeId = type;
}
if(objectTypeId.indexOf(type) == -1)
{
StringBuilder sb = new StringBuilder(objectTypeId);
if(sb.length() > 0)
{
sb.append(",");
}
sb.append(type);
objectTypeId = sb.toString();
}
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
Folder res = f.createFolder(properties);
return res;
}
else
{
throw new IllegalArgumentException("Parent does not exist or is not a folder");
}
}
示例5: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public static String createFolder(Session pSession, String pStrParentFolderId, String pStrFolderName) {
String lStrFolderId = null;
mLog.debug("Start createFolder(", pSession, ",", pStrParentFolderId, ",", pStrFolderName, ")");
// recupero la cartella padre
Folder lFolder = (Folder) pSession.getObject(pStrParentFolderId);
// creo la cartella
Map<String, String> lMapProperties = new HashMap<String, String>();
lMapProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
lMapProperties.put(PropertyIds.NAME, pStrFolderName);
Folder lFolderNew;
try {
lFolderNew = lFolder.createFolder(lMapProperties);
lStrFolderId = lFolderNew.getId();
} catch (CmisContentAlreadyExistsException e) {
mLog.error("Il documento esiste già", e);
throw new AlfrescoException(e, AlfrescoException.FOLDER_ALREADY_EXISTS_EXCEPTION);
}
mLog.debug("End createFolder(", pSession, ",", pStrParentFolderId, ",", pStrFolderName, "): return ",
lStrFolderId);
return lStrFolderId;
}
示例6: storeFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
private Folder storeFolder(Folder parentFolder, Map<String, Object> cmisProperties) throws Exception {
if (!cmisProperties.containsKey(PropertyIds.OBJECT_TYPE_ID)) {
cmisProperties.put(PropertyIds.OBJECT_TYPE_ID, CamelCMISConstants.CMIS_FOLDER);
}
LOG.debug("Creating folder with properties: {}", cmisProperties);
return parentFolder.createFolder(cmisProperties);
}
示例7: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public Folder createFolder(String folderId, String name, Map<String, Serializable> properties)
{
CmisObject o = getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
if(properties == null)
{
properties = new HashMap<String, Serializable>();
}
String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID);
String type = "cmis:folder";
if(objectTypeId == null)
{
objectTypeId = type;
}
if(objectTypeId.indexOf(type) == -1)
{
StringBuilder sb = new StringBuilder(objectTypeId);
if(sb.length() > 0)
{
sb.append(",");
}
sb.append(type);
objectTypeId = sb.toString();
}
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
Folder res = f.createFolder(properties);
return res;
}
else
{
throw new IllegalArgumentException("Parent does not exist or is not a folder");
}
}
示例8: testCreate
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public void testCreate()
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
for(int i = 0; i < 50; i++)
{
AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("user"+i);
List<String> permissions = new ArrayList<String>(1);
permissions.add(BasicPermissions.READ);
List<Ace> addAces = new ArrayList<Ace>(1);
addAces.add(new AccessControlEntryImpl(principal, permissions));
newFolder.addAcl(addAces, AclPropagation.PROPAGATE);
Map<String, Object> updateProperties = new HashMap<String, Object>();
updateProperties.put("cm:title", "Update title "+i);
newFolder.updateProperties(properties);
if(i % 10 == 0)
{
System.out.println("@ "+i);
}
}
ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
assertTrue(result.getTotalNumItems() > 0);
result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertTrue(result.getTotalNumItems() > 0);
}
示例9: createFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public String createFolder(String parentPath, String name) {
Folder parent = (Folder) session.getObjectByPath(parentPath);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
Folder folder = parent.createFolder(properties);
logger.info("Folder path: " + folder.getPath());
return folder.getPath();
}
示例10: createApplicationRootFolder
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
/**
* Gets the application root folder and if it doesn't exist, creates
* it.
*/
protected Folder createApplicationRootFolder(Session session,
String path) {
try {
// get the folder
return (Folder) session.getObjectByPath(path,
CMISHelper.LIGHT_OPERATION_CONTEXT);
} catch (CmisObjectNotFoundException nfe) {
// folder doesn't exist -> create it
int x = path.lastIndexOf('/');
Folder parent = null;
if (x == 0) {
parent = session.getRootFolder();
} else {
parent = createApplicationRootFolder(session,
path.substring(0, x));
}
// create folder
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, path.substring(x + 1));
return parent.createFolder(properties, null, null, null,
CMISHelper.LIGHT_OPERATION_CONTEXT);
}
}
示例11: doPost
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
/**
* Creates a folder.
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response, Session session)
throws ServletException, IOException, TheBlendException {
String parentId = getRequiredStringParameter(request, PARAM_PARENT);
String typeId = getRequiredStringParameter(request, PARAM_TYPE_ID);
String name = getStringParameter(request, PARAM_NAME);
if (name == null || name.length() == 0) {
redirect(HTMLHelper.encodeUrlWithId(request, "browse", parentId),
request, response);
return;
}
// fetch the parent folder
Folder parent = CMISHelper.getFolder(session, parentId,
CMISHelper.LIGHT_OPERATION_CONTEXT, "parent folder");
// set name and type of the new folder
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, typeId);
// create the folder
try {
parent.createFolder(properties);
} catch (CmisBaseException cbe) {
throw new TheBlendException("Could not create folder: "
+ cbe.getMessage(), cbe);
}
redirect(HTMLHelper.encodeUrlWithId(request, "browse", parentId),
request, response);
}
示例12: createChildFolderWithName
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
protected Folder createChildFolderWithName(Folder parent, String childName) {
Map<String, String> newFolderProps = new HashMap<String, String>();
newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
newFolderProps.put(PropertyIds.NAME, childName);
return parent.createFolder(newFolderProps);
}
示例13: testCreateLots
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public void testCreateLots() throws Exception
{
Session session = getSession("admin", "admin");
Folder root = session.getRootFolder();
String folderNameBase = getRootFolderName();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderNameBase);
Folder base = root.createFolder(properties);
for(int i = 0; i < 10; i++)
{
AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(""+i+i+i);
List<String> permissions = new ArrayList<String>(1);
permissions.add(BasicPermissions.ALL);
List<Ace> addAces = new ArrayList<Ace>(1);
addAces.add(new AccessControlEntryImpl(principal, permissions));
base.addAcl(addAces, AclPropagation.PROPAGATE);
}
Thread last = null;
for(int i = 0; i < 10; i++)
{
Creator creator = new Creator(base.getPath(), i);
Thread thread = new Thread(creator);
thread.start();
last = thread;
}
if(last != null)
{
last.join();
}
ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
assertTrue(result.getTotalNumItems() > 0);
//result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
//assertTrue(result.getTotalNumItems() > 0);
}
示例14: testQueryFolderProperties
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public void testQueryFolderProperties()
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertEquals(1, result.getTotalNumItems());
String uniqueName = getUniqueName();
Map<String, Object> uProperties = new HashMap<String, Object>();
uProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
uProperties.put(PropertyIds.NAME, uniqueName);
Folder uniqueFolder = newFolder.createFolder(uProperties);
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND IN_FOLDER('"+ uniqueFolder.getParentId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where IN_FOLDER('"+ uniqueFolder.getParentId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:createdBy = '"+ uniqueFolder.getCreatedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:objectId = '"+ uniqueFolder.getId()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:lastModifiedBy = '"+ uniqueFolder.getLastModifiedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+ uniqueFolder.getName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
String creationDate = ISO8601DateFormat.format(uniqueFolder.getCreationDate().getTime());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:creationDate = '"+ creationDate +"'" , false);
assertEquals(1, result.getTotalNumItems());
String modificationDate = ISO8601DateFormat.format(uniqueFolder.getLastModificationDate().getTime());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:lastModificationDate = '"+ modificationDate+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:objectTypeId = '"+ uniqueFolder.getType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:baseTypeId = '"+ uniqueFolder.getBaseType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
}
示例15: testQueryDocumentProperties
import org.apache.chemistry.opencmis.client.api.Folder; //导入方法依赖的package包/类
public void testQueryDocumentProperties() throws Exception
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertEquals(1, result.getTotalNumItems());
Document uniqueDocument = createUniqueDocument(newFolder);
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND IN_FOLDER('"+ newFolder.getId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where IN_FOLDER('"+ newFolder.getId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:createdBy = '"+ uniqueDocument.getCreatedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:objectId = '"+ uniqueDocument.getId()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:lastModifiedBy = '"+ uniqueDocument.getLastModifiedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+ uniqueDocument.getName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
String creationDate = ISO8601DateFormat.format(uniqueDocument.getCreationDate().getTime());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:creationDate = '"+ creationDate +"'" , false);
assertEquals(1, result.getTotalNumItems());
String modificationDate = ISO8601DateFormat.format(uniqueDocument.getLastModificationDate().getTime());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:lastModificationDate = '"+ modificationDate+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:objectTypeId = '"+ uniqueDocument.getType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:baseTypeId = '"+ uniqueDocument.getBaseType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamFileName = '"+ uniqueDocument.getContentStreamFileName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamLength = '"+ uniqueDocument.getContentStreamLength()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamMimeType = '"+ uniqueDocument.getContentStreamMimeType()+"'" , false);
assertEquals(1, result.getTotalNumItems());
}