01-23-2008 10:31 AM
public static boolean write(File inputFile) throws Exception
{
AuthenticationUtils.startSession(USERNAME, PASSWORD);
String filename = inputFile.getName();
String file = inputFile.getPath();
String filetype = "text/html";
try {
ParentReference parentReference = new ParentReference(STORE, null, location ,ASSOC_CONTAINS, ASSOC_CONTAINS);
NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, filename)};
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[]{create});
NamedValue[] titledProps = new NamedValue[1];
Predicate predicate = new Predicate(new Reference[]{parentReference}, STORE, null);
titledProps[0] = Utils.createNamedValue("rls:city","testcity");
//I tried using {http://www.alfresco.org/model/content/1.0}<namespace:aspectname> as well, no luck.
CMLAddAspect addAspect = new CMLAddAspect("rls:locatable",titledProps, predicate, null);
cml.setAddAspect(new CMLAddAspect[] {addAspect});
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference newContentNode = result[0].getDestination();
ContentFormat format = new ContentFormat(filetype, "UTF-8");
InputStream viewStream = new FileInputStream(inputFile);
byte[] bytes = ContentUtils.convertToByteArray(viewStream);
WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, format);
} catch (Exception e) {
e.printStackTrace();
return false; //will cause the calling class to delete the file if written in the repository
} finally {
AuthenticationUtils.endSession();
return true; //this gives me a warning, and rightly so.
}
<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<!– The important part here is the name - Note: the use of the my: namespace
which is defined further on in the document –>
<model name="rls:cvmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!– Optional meta-data about the model –>
<description>Example custom Model</description>
<author></author>
<version>1.0</version>
<!– Imports are required to allow references to definitions in other models –>
<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 my.new.model should be changed to reflect your own namespace –>
<namespaces>
<namespace uri="realsoftware.be" prefix="rls"/>
</namespaces>
<types>
<!– Definition of new Content Type: Real CV –>
<type name="rls:cv">
<title>Real CV</title>
<parent>cm:content</parent>
<properties>
<property name="rls:name">
<type>d:text</type>
</property>
</properties>
<mandatory-aspects>
<aspect>cm:versionable</aspect>
<aspect>rls:locatable</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<!– Definition of new Content Aspect: Locatable –>
<aspect name="rls:locatable">
<title>Locatable</title>
<properties>
<property name="rls:address">
<type>d:text</type>
</property>
<property name="rls:city">
<type>d:text</type>
</property>
<property name="rlsostalCode">
<type>d:text</type>
</property>
<property name="rls:country">
<type>d:text</type>
</property>
</properties>
</aspect>
<!– Definition of new Content Aspect: Skillable –>
<aspect name="rls:skillable">
<title>Skillable</title>
<properties>
<property name="rls:IT-Languages">
<type>d:text</type>
</property>
<property name="rls:Certificate">
<type>d:text</type>
</property>
<property name="rls:Methodologies">
<type>d:text</type>
</property>
<property name="rlsatabases">
<type>d:text</type>
</property>
<property name="rls:Hardware">
<type>d:text</type>
</property>
<property name="rlsS">
<type>d:text</type>
</property>
<property name="rls:Business">
<type>d:text</type>
</property>
<property name="rlsther">
<type>d:text</type>
</property>
</properties>
</aspect>
<!– Definition of new Content Aspect: Experienceable –>
<aspect name="rls:experienceable">
<title>Experienceable</title>
<properties>
<property name="rls:Company-Name">
<type>d:text</type>
</property>
<property name="rls:Company-Profile">
<type>d:text</type>
</property>
<property name="rls:Timeframe">
<type>d:text</type>
</property>
<property name="rlsroject-Name">
<type>d:text</type>
</property>
<property name="rlsroject-Description">
<type>d:text</type>
</property>
<property name="rls:Technologies">
<type>d:text</type>
</property>
<property name="rls:Role">
<type>d:text</type>
</property>
</properties>
</aspect>
</aspects>
</model>
01-23-2008 11:07 AM
01-24-2008 07:26 AM
Predicate predicate = new Predicate(new Reference[]{parentReference}, STORE, null);Predicate predicate = new Predicate(new Reference[]{parentReference}, null, null);CMLAddAspect addAspect = new CMLAddAspect("{realsoftware.be}locatable",titledProps, predicate, null);CMLAddAspect addAspect = new CMLAddAspect("{realsoftware.be}locatable",titledProps, predicate, "1");01-24-2008 07:46 AM
titledProps[0] = Utils.createNamedValue("{realsoftware.be}address","testaddress");
titledProps[1] = Utils.createNamedValue("{realsoftware.be}city","testcity");
titledProps[2] = Utils.createNamedValue("{realsoftware.be}postalCode","testpostalCode");
titledProps[3] = Utils.createNamedValue("{realsoftware.be}country","testcountry");
CMLAddAspect addAspect = new CMLAddAspect("{realsoftware.be}locatable",titledProps, predicate, "1");01-25-2008 05:36 AM
<alfresco-config>
<!– Model Registration ***************************************** –>
<config evaluator="string-compare" condition="Content Wizards">
<content-types>
<type name="rls:cv"/>
</content-types>
</config>
<config evaluator="node-type" condition="rls:cv">
<property-sheet>
<show-property name="rls:name" />
</property-sheet>
</config>
<config evaluator="string-compare" condition="Action Wizards">
<content-types>
<type name="rls:cv"/>
</content-types>
</config>
<!– Aspect Registration **************************************** –>
<config evaluator="aspect-name" condition="rls:locatable">
<property-sheet>
<show-property name="rls:address"/>
<show-property name="rls:city"/>
<show-property name="rls:postalCode"/>
<show-property name="rls:country"/>
</property-sheet>
</config>
<config evaluator="string-compare" condition="Action Wizards">
<types>
<type name="folder" displayLabelId="space"/>
<type name="content"/>
</types>
<aspects>
<aspect name="rls:locatable" displayLabel="Locatable"/>
<aspect name="rls:skillable" displayLabel="Skillable"/>
<aspect name="rls:experienceable" displayLabel="Experienceable"/>
</aspects>
</config>
<config evaluator="aspect-name" condition="rls:skillable">
<property-sheet>
<show-property name="rls:IT-Languages" display-label="Languages"/>
<show-property name="rls:Certificate" display-label="Certificates"/>
<show-property name="rls:Methodologies" display-label="Methodologies"/>
<show-property name="rls:Databases" display-label="Databases"/>
<show-property name="rls:Hardware" display-label="Hardware"/>
<show-property name="rls:OS" display-label="Operating Systems"/>
<show-property name="rls:Business" display-label="Business Knowledge"/>
<show-property name="rls:Other" display-label="Other"/>
<show-property name="rls:Frameworks" display-label="Frameworks"/>
<show-property name="rls:Tools" display-label="Tools"/>
</property-sheet>
</config>
<config evaluator="aspect-name" condition="rls:experienceable" multiple="true">
<property-sheet>
<show-property name="rls:Company-Name" display-label="Company Name"/>
<show-property name="rls:Company-Profile" display-label="Company Profile"/>
<show-property name="rls:Timeframe" display-label="Year-Year"/>
<show-property name="rls:Project-Name" display-label="Project Name"/>
<show-property name="rls:Project-Description" display-label="Project Description"/>
<show-property name="rls:Technologies" display-label="Technologies"/>
<show-property name="rls:Role" display-label="Role"/>
</property-sheet>
</config>
<!– Example of overriding the from email address –>
<!–
<config>
<client>
<from-email-address>someone@your-domain.com</from-email-address>
<search-max-results>100</search-max-results>
</client>
</config>
–>
<!– Example of adding languages to the list in the login page –>
<config evaluator="string-compare" condition="Languages">
<languages>
<language locale="ca_ES">Catalan</language>
<language locale="hr_HR">Croatian</language>
<language locale="cs_CZ">Czech</language>
<language locale="da_DK">Danish</language>
<language locale="de_DE">German</language>
<language locale="es_ES">Spanish</language>
<language locale="el_GR">Greek</language>
<language locale="fi_FI">Finnish</language>
<language locale="fr_FR">French</language>
<language locale="it_IT">Italian</language>
<language locale="ja_JP">Japanese</language>
<language locale="du_NL">Dutch</language>
<language locale="pl_PL">Polish</language>
<language locale="pt_PT">Portuguese</language>
<language locale="pt_BR">Portuguese (Brazilian)</language>
<language locale="ru_RU">Russian</language>
<language locale="sv_SV">Swedish</language>
<language locale="tr_TR">Turkish</language>
<language locale="zh_CN">Simplified Chinese</language>
</languages>
</config>
<!– Example of configuring advanced search –>
<!–
<config evaluator="string-compare" condition="Advanced Search">
<advanced-search>
<content-types>
</content-types>
<custom-properties>
<meta-data aspect="app:simpleworkflow" property="app:approveStep" />
</custom-properties>
</advanced-search>
</config>
–>
<!– Example of changing the sort direction for a view in the client –>
<!–
<config evaluator="string-compare" condition="Views">
<views>
<view-defaults>
<topic>
<sort-direction>ascending</sort-direction>
</topic>
</view-defaults>
</views>
</config>
–>
<!– Example of adding a custom icon to the Create Space dialog –>
<!–
<config evaluator="string-compare" condition="cm:folder icons">
<icons>
<icon name="space-icon-custom" path="/images/icons/space-icon-custom.gif" />
</icons>
</config>
–>
<!– The config below shows how to incorporate the example model–>
<!– into the web client, for this to work you will need to –>
<!– rename example-model-context.xml.sample to example-model-context.xml –>
<!–
<config evaluator="string-compare" condition="Content Wizards">
<content-types>
<type name="my:sop" />
</content-types>
</config>
<config evaluator="node-type" condition="my:sop">
<property-sheet>
<show-property name="mimetype" display-label-id="content_type"
component-generator="MimeTypeSelectorGenerator" />
<show-property name="size" display-label-id="size"
converter="org.alfresco.faces.ByteSizeConverter"
show-in-edit-mode="false" />
<show-property name="my:publishedDate" />
<show-association name="my:signOff" />
<show-property name="my:authorisedBy" />
<show-child-association name="my:processSteps" />
</property-sheet>
</config>
<config evaluator="aspect-name" condition="my:imageClassification">
<property-sheet>
<show-property name="my:width"/>
<show-property name="my:height"/>
<show-property name="my:resolution"/>
</property-sheet>
</config>
<config evaluator="string-compare" condition="Action Wizards">
<aspects>
<aspect name="my:imageClassification"/>
</aspects>
</config>
<config evaluator="string-compare" condition="Advanced Search">
<advanced-search>
<content-types>
<type name="my:sop" />
</content-types>
<custom-properties>
<meta-data type="my:sop" property="my:authorisedBy" />
<meta-data aspect="my:imageClassification" property="my:resolution" />
</custom-properties>
</advanced-search>
</config>
–>
</alfresco-config>
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.