05-12-2009 03:36 AM
/**
* Inserts the new in protocol record in alfresco
* @param bean
* @return boolean
*/
public void insertNewInProtocol(ProtocolBean bean) {
logger.info("Method insertNewInProtocol of ContentManager");
NodeRef assigned = getNodeRef(protocolRootNode, this.divisionsMap.get(bean.getAssegnatari().get(0)));
UserTransaction tx = null;
TransactionService transactionService = serviceRegistry.getTransactionService();
InputStream is = null;
try{
tx = transactionService.getUserTransaction();
tx.begin();
Map<QName, Serializable> protocolData = getProtocolValues(bean);
ChildAssociationRef nodeRef = nodeService.createNode(assigned,
ContentModel.ASSOC_CONTAINS,
QName.createQName(ProtocolListenersModel.fl, bean.getNumeroProtocollo()),
ProtocolListenersModel.PROTOCOLLO_DOCUMENTO,
protocolData);
NodeRef node = nodeRef.getChildRef();
// Put the titled aspect
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>();
titledProps.put(ContentModel.PROP_TITLE, bean.getNumeroProtocollo());
titledProps.put(ContentModel.PROP_DESCRIPTION, "Importato da Protocollo");
nodeService.addAspect(node, ContentModel.ASPECT_TITLED, titledProps);
ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
MimetypeService mimetypeService = serviceRegistry.getMimetypeService();
writer.setMimetype(mimetypeService.guessMimetype(bean.getPathImmagine()));
writer.setEncoding("UTF-8");
is = bean.getImmaginedocumento();
writer.putContent(is);
tx.commit();
logger.info("End Method insertNewInProtocol of ContentManager");
} catch (Exception e) {
logger.error(e.getMessage());
}
}
<type name="fl:protocolloDocument">
<title>Documento Protocollato</title>
<parent>cm:content</parent>
<properties>
<property name="fl:type" >
<type>d:text</type>
<mandatory>true</mandatory>
<default>I</default>
<constraints>
<constraint ref="fl:protocolType"/>
</constraints>
</property>
<property name="fl:numeroProtocollo" >
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fl:assegnatario">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fl:dataRegistrazione">
<type>d:date</type>
</property>
<property name="fl:status" >
<type>d:text</type>
<mandatory>false</mandatory>
<default>Assegnato</default>
<constraints>
<constraint ref="fl:documentStatus"/>
</constraints>
</property>
<property name="fl:oggetto" >
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fl:oggettoEsteso" >
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="fl:mittente" >
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fl:destinatario" >
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fl:protocolloMittente" >
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="fl:dataProtocolloMittente">
<type>d:date</type>
</property>
<property name="fl:incaricato">
<type>d:text</type>
</property>
<property name="fl:note">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="fl:riservato">
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
</type>
05-12-2009 03:40 AM
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.