08-24-2013 09:44 AM
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException:
Type 'cmis:document,P:cm:titled' is unknown!
package Main;
import java.util.HashMap;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.Document;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Map<String, String> parameter = new HashMap<String, String>();
// Set the user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// Specify the connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// Create a session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, "doc1");
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled");
properties.put("cm:description", "My document");
Document doc = session.getRootFolder().createDocument(properties, null, null);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="lib/activation-1.1.jar"/>
<classpathentry kind="lib" path="lib/alfresco-opencmis-extension-0.3.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-client-api-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-client-bindings-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-client-impl-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-commons-api-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-commons-impl-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-test-tck-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/chemistry-opencmis-workbench-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/groovy-all-2.1.3.jar"/>
<classpathentry kind="lib" path="lib/jaxb-api-2.1.jar"/>
<classpathentry kind="lib" path="lib/jaxb-impl-2.1.11.jar"/>
<classpathentry kind="lib" path="lib/jaxws-api-2.1.jar"/>
<classpathentry kind="lib" path="lib/jaxws-rt-2.1.7.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/mimepull-1.3.jar"/>
<classpathentry kind="lib" path="lib/resolver-20050927.jar"/>
<classpathentry kind="lib" path="lib/saaj-api-1.3.jar"/>
<classpathentry kind="lib" path="lib/saaj-impl-1.3.3.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/sqljdbc4.jar"/>
<classpathentry kind="lib" path="lib/stax-api-1.0-2.jar"/>
<classpathentry kind="lib" path="lib/stax-api-1.0.jar"/>
<classpathentry kind="lib" path="lib/stax-ex-1.2.jar"/>
<classpathentry kind="lib" path="lib/stax2-api-3.1.1.jar"/>
<classpathentry kind="lib" path="lib/streambuffer-0.9.jar"/>
<classpathentry kind="lib" path="lib/woodstox-core-asl-4.2.0.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4-javadoc.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4-tests.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.4-test-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
08-24-2013 10:54 AM
08-24-2013 11:54 AM
08-24-2013 04:29 PM
Map<String, Object> props = new HashMap<String, Object>();
props.put(PropertyIds.NAME, "doc1");
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
props.put("cm:description", "My document");
Folder doc = session.getRootFolder().createFolder(props);
Exception in thread "main" java.lang.IllegalArgumentException: Property 'cm:description' is not valid for this type or one of the secondary types!
Allowed Child Object Types Ids cmis:allowedChildObjectTypeIds id []
Object Type Id cmis:objectTypeId id [cmis:folder]
Path cmis:path string [/IMAP-Anlagen]
Name cmis:name string [IMAP-Anlagen]
Creation Date cmis:creationDate datetime [java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+02:00",offset=7200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=2013,MONTH=7,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=15,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=21,MINUTE=0,SECOND=56,MILLISECOND=614,ZONE_OFFSET=?,DST_OFFSET=?]]
Change token cmis:changeToken string []
Last Modified By cmis:lastModifiedBy string [System]
Created by cmis:createdBy string [System]
Object Id cmis:objectId id [workspace://SpacesStore/250cfec1-867c-49ca-bea9-00967f322478]
Base Type Id cmis:baseTypeId id [cmis:folder]
Alfresco Node Ref alfcmis:nodeRef id [workspace://SpacesStore/250cfec1-867c-49ca-bea9-00967f322478]
Parent Id cmis:parentId id [workspace://SpacesStore/a1e29e1c-1250-4085-916d-c5ed5fc7bab4]
Last Modified Date cmis:lastModificationDate datetime [java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+02:00",offset=7200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=2013,MONTH=7,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=15,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=21,MINUTE=1,SECOND=15,MILLISECOND=505,ZONE_OFFSET=?,DST_OFFSET=?]]
08-24-2013 10:41 PM
08-25-2013 05:53 AM
08-26-2013 10:30 AM
<type name="em:emailfolder">
<title>Email Archive</title>
<parent>cm:folder</parent>
<properties>
<property name="em:mailfolder.mailid">
<type>d:text</type>
</property>
<property name="em:mailfolder.from">
<type>d:text</type>
</property>
<property name="em:mailfolder.to">
<type>d:text</type>
</property>
<property name="em:mailfolder.subject">
<type>d:text</type>
</property>
</properties>
<mandatory-aspects>
<aspect>cm:titled</aspect>
</mandatory-aspects>
</type>
<type name="em:email">
<title>Email</title>
<parent>cm:content</parent>
<properties>
<property name="em:mail.mailid">
<type>d:text</type>
</property>
<property name="em:mail.subject">
<type>d:text</type>
</property>
</properties>
<mandatory-aspects>
<aspect>cm:titled</aspect>
</mandatory-aspects>
</type>
10-03-2013 06:12 AM
10-06-2013 06:20 AM
public void createDocument()
{
String servalUrl = "http://localhost:8080/alfresco/cmisatom";
String userName = "admin";
String password = "admin";
Map<String, Object> properties = new HashMap<String, Object>();
//properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled");
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:em:email,P:cm:titled");
properties.put(PropertyIds.NAME, "TESTDOCUMENT2");
properties.put(PropertyIds.CREATED_BY, "admin");
properties.put("cm:title", "Title");
properties.put("cm:description", "Desc");
Session session = getSession(servalUrl, userName, password);
try {
AlfrescoFolder folder1 = (AlfrescoFolder) session
.getObjectByPath("/TESTFOLDER1/TESTFOLDER4");
File file = new File("C:\\userguide.pdf");
InputStream fis = new FileInputStream(file);
VersioningState vs = VersioningState.MAJOR;
DataInputStream dis = new DataInputStream(fis);
byte[] bytes = new byte[(int) file.length()];
dis.readFully(bytes);
ContentStream contentStream = new ContentStreamImpl(file
.getAbsolutePath(), null, "application/pdf",
new ByteArrayInputStream(bytes));
AlfrescoDocument newDocument = (AlfrescoDocument) folder1
.createDocument(properties, contentStream, vs);
System.out.println(newDocument.getId());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
CMISTest t = new CMISTest();
t.createDocument();
}
01-06-2015 05:21 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.