behaviour cancel delete node
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2010 05:29 AM
I need to implement a behaviour to check some conditions before deleting a node. Can I cancel the delete action if the node does not match all conditions?
thanks!
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2010 11:27 AM
Look at org.alfresco.repo.model.ml.MultilingualDocumentAspect for an example of how you can react to 'beforeDeleteNode'. Throw any exception to terminate the process and force a rollback. You may need to do some UI work to ensure the user gets to see pretty messages.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2010 04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 10:39 AM
I try to throw a new AlfrescoRuntimeException, constructor needs "String msgId" but it is actually the string he shows on screen. how could I show messages from webclient.properties? Because messages should be showed in different languages.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 11:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 12:28 PM
Yes, I think so, I add the message to the file properties
message_delete1=Document cannot be deleted.
and I try to throw the exception
throw new AlfrescoRuntimeException("message_delete1");
when it shows the bar on the top it says:
Error Please correct the errors below then click OK.
* Unable to delete File due to system error: message_delete1
is there any other exception I can use to cancel the delete node and show another message less… "fatalistic" it is just the node could not be deleted because it do not match a condition is not a real system error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 01:02 PM
You would need a bean like this to load your resources:
<bean id="emailResourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent"> <property name="resourceBundles"> <list> <value>alfresco.messages.email-service</value> </list> </property> </bean>
If you want to change the reporting behaviour, you will have to hack BaseDialogBean.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 01:42 PM
does Alfresco know by itself those String are message ids ? do not they need any '#' or something like jsp's with labels? …
and… EDIT: I have just noticed that Alfresco doesn't show any of my messages if I set the language to Spanish. It shows only the head
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 02:01 PM
You probably need the bean and the resource file as the error message is generated in the repository. Hacking the dialog bean will suit you best, it seems.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2010 05:55 AM
I have those properties files within alfresco.messages:
delete-behaviour.properties
message_delete1=Document cannot be deleted. Document is not in draft status.message_delete2=You do not have permissions to delete the document. You are not part of coordinators group.message_delete3=You cannot delete the document. There was a fail trying to get the authors list.message_delete4=You do not have permissions to delete the document. You do not belong to the authors list.message_delete5=Document cannot be deleted. It has other documents related besides their own renditions.
delete-behaviour_es_ES.properties
message_delete1=No se puede borrar el documento. No se encuentra en estado borrador.message_delete2=No tiene permisos para borrar el documento. No pertenece al grupo de coordinadores.message_delete3=No puede borrar el documento. No puede comprobarse que usted pertenece a la lista de autores.message_delete4=Usted no esta autorizado a borrar el documento. No pertenece a la lista de autores o autores externos.message_delete5=No puede borrarse el documento. Contiene otros documentos relacionados además de la rendition.
the bean in behaviours-context.xml
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'><beans> <bean id="SGDocumentBeforeDeleteBehaviour" class="com.sysdoc.behaviours.SGDocumentBeforeDeleteBehaviour" init-method="init"> <property name="policyComponent"> <ref bean="policyComponent" /> </property> </bean> <bean id="SGDocumentDeleteBehaviour" class="com.sysdoc.behaviours.SGDocumentDeleteBehaviour" init-method="init"> <property name="policyComponent"> <ref bean="policyComponent" /> </property> <property name="nodeService"> <ref bean="nodeService" /> </property> </bean> <bean id="deleteResourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent"> <property name="resourceBundles"> <list> <value>alfresco.messages.delete-behaviour</value> </list> </property> </bean></beans>
now, it shows the English messages but it misses the Spanish language. I mean. If I select English it shows something like:
Please correct the errors below then click OK. * Unable to delete File due to system error: Document cannot be deleted. Document is not in draft status.
whereas if language is Spanish it shows:
Por favor corrija los errores siguientes y pulse Aceptar. * No se puede eliminar el fichero debido a un error del sistema:
As you can see message is missed. Should I report it in jira??
