01-03-2014 10:04 AM
<?xml version="1.0" encoding="UTF-8"?>
<!– Custom Model –>
<!– Note: This model is pre-configured to load at startup of the Repository. So, all custom –>
<!– types and aspects added here will automatically be registered –>
<model name="sc:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!– Optional meta-data about the model –>
<description>Custom Model</description>
<author></author>
<version>1.0</version>
<imports>
<!– Import Alfresco Dictionary Definitions –>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!– Import Alfresco Content Domain Model Definitions –>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<!– Introduction of new namespaces defined by this model –>
<!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
<namespaces>
<!–namespace uri="custom.model" prefix="custom"/–>
<namespace uri="http://www.someco.com/model/content/1.0" prefix="sc" />
</namespaces>
<types>
<!– Enterprise-wide generic document type –>
<type name="sc:doc">
<title>Someco Document</title>
<parent>cm:content</parent>
<associations>
<association name="sc:relatedDocuments">
<title>Related Documents</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>sc:doc</class>
<mandatory>false</mandatory>
<many>true</many> </target>
</association>
</associations>
<mandatory-aspects>
<aspect>cm:generalclassifiable</aspect>
</mandatory-aspects>
</type>
<type name="sc:whitepaper">
<title>Someco Whitepaper</title>
<parent>sc:doc</parent>
</type>
</types>
<aspects>
<aspect name="sc:webable">
<title>Someco Webable</title>
<properties>
<property name="sc:published">
<type>d:date</type>
</property>
<property name="sc:isActive">
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
</aspect>
<aspect name="sc:productRelated">
<title>Someco Product Metadata</title>
<properties>
<property name="sc:product">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="sc:version">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
</aspects>
</model>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!– Registration of new models –>
<bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/extension/customModel.xml</value>
</list>
</property>
</bean>
</beans>
<alfresco-config>
<!– Repository Library config section –>
<config evaluator="string-compare" condition="RepositoryLibrary" replace="true">
<!–
Whether the link to the Repository Library appears in the header component or not.
–>
<visible>true</visible>
</config>
<config evaluator="string-compare" condition="Remote">
<remote>
<endpoint>
<id>alfresco-noauth</id>
<name>Alfresco - unauthenticated access</name>
<description>Access to Alfresco Repository WebScripts that do not require authentication</description>
<connector-id>alfresco</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<identity>none</identity>
</endpoint>
<endpoint>
<id>alfresco</id>
<name>Alfresco - user access</name>
<description>Access to Alfresco Repository WebScripts that require user authentication</description>
<connector-id>alfresco</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<identity>user</identity>
</endpoint>
<endpoint>
<id>alfresco-feed</id>
<name>Alfresco Feed</name>
<description>Alfresco Feed - supports basic HTTP authentication via the EndPointProxyServlet</description>
<connector-id>http</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<basic-auth>true</basic-auth>
<identity>user</identity>
</endpoint>
<endpoint>
<id>activiti-admin</id>
<name>Activiti Admin UI - user access</name>
<description>Access to Activiti Admin UI, that requires user authentication</description>
<connector-id>activiti-admin-connector</connector-id>
<endpoint-url>http://localhost:8080/alfresco/activiti-admin</endpoint-url>
<identity>user</identity>
</endpoint>
</remote>
</config>
<!– Document Library config section –>
<config evaluator="string-compare" condition="DocumentLibrary">
<aspects>
<!– Aspects that a user can see –>
<visible>
<aspect name="sc:webable" />
<aspect name="sc:productRelated" />
</visible>
<!– Aspects that a user can add. Same as "visible" if left empty –>
<addable>
</addable>
<!– Aspects that a user can remove. Same as "visible" if left empty
–>
<removeable>
</removeable>
</aspects>
<types>
<type name="cm:content">
<subtype name="sc:doc" />
<subtype name="sc:whitepaper" />
</type>
<type name="sc:doc">
<subtype name="sc:whitepaper" />
</type>
</types>
</config>
</alfresco-config>
01-09-2014 04:18 AM
01-09-2014 11:08 AM
FileInputStream fis = new FileInputStream(file);
DataInputStream dis = new DataInputStream(fis);
byte[] bytes = new byte[(int) file.length()];
dis.readFully(bytes);
Map newDocProps = new HashMap();
newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled,P:sc:webable");
newDocProps.put(PropertyIds.NAME, file.getName());
newDocProps.put("cm:title", "modulo A1");
newDocProps.put("cm:description", "Tiff modulo A1 accorpati");
newDocProps.put("sc:isActive", true);
List addAces = new LinkedList();
List removeAces = new LinkedList();
List policies = new LinkedList();
try {
ContentStream contentStream = new ContentStreamImpl(file.getAbsolutePath(), null, "application/pdf",
new ByteArrayInputStream(bytes));
org.apache.chemistry.opencmis.client.api.Document doc = target.createDocument(newDocProps, contentStream,
VersioningState.NONE, policies, removeAces, addAces, session.getDefaultContext());
AlfrescoDocument alfDoc = (AlfrescoDocument) doc;
alfDoc.addAspect("P:sc:webable");
} catch (Exception e) {
e.printStackTrace();
}
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.