cancel
Showing results for 
Search instead for 
Did you mean: 

Getting RM's java interfaces

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Hi,
I need to do some work in the Records Management system. Particularly I need to create a record programmatically. I couldn't find any docs about it. I tried to investigate Alfresco's sources I found here: http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/modules/dod-5015/source/java/o...
In the class org.alfresco.module.org_alfresco_module_dod5015.test.TestUtilities I discovered that I could create the needed interfaces in this way:
RecordsManagementService recordsManagementService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
RecordsManagementActionService recordsManagementActionService = RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService");

But I got a fail. I don't know why, but the system cannot find that beans. I use Alfresco Enterprise 3.2.0r with the intalled Records Management module…
When I tried to inject the beans RecordsManagementActionService & RecordsManagementService in my own bean I got the exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iconnector.AlfrescoConnector' defined in file [C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\module\iconnector\module-context.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'RecordsManagementActionService' is defined
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'RecordsManagementActionService' is defined
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:360)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:914)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:757)
   at com.smartech.iconnector.AlfrescoConnector.Init(AlfrescoConnector.java:200)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:69)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:516)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

What may be wrong? Is it the right way that I'm trying to use the interfaces RecordsManagementActionService and RecordsManagementService for my purpose?
5 REPLIES 5

marianov
Champ in-the-making
Champ in-the-making
Did you find a solution? I'm trying to figure out a way for an application to send files to RM, set the mandatory metadata for the file and declare it as a record. I'd like to do it using some REST interface, but I could use a Java version if there is no other way. I posted a message about this but unfortunately got no replies.

Mariano

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Hi Mariano,
I think threre are ways to create a record using REST. I created ordinary content in this way. Pethaps, there is something for RM.
But I dont't use it. For creating records I use Java. I fixed the described problem. I get the RM interfaced via injection them in my Spring config. In module-context.xml there is a such bean:
<bean id="iconnector.AlfrescoConnector"
      class="com.AlfrescoConnector"
      init-method="Init" depends-on="org_alfresco_module_dod5015_userRolesExtractor,org_alfresco_module_dod5015_namePathExtractor,org_alfresco_module_dod5015_nodeRefPathExtractor,org_alfresco_module_dod5015_identifierExtractor">                               
        <property name="recordsManagementService">
         <ref bean="RecordsManagementService" />
      </property>      
      <property name="recordsManagementActionService">
         <ref bean="RecordsManagementActionService" />
      </property>
                  
   </bean>
And you have to create the setters in the com.AlfrescoConnector class for the RM properties defined in the bean.

marianov
Champ in-the-making
Champ in-the-making
Alex,

just for future reference, wrikwinlof gave me a good pointer on how to use RM via REST: http://forums.alfresco.com/en/viewtopic.php?f=51&t=39099

Basically you can use Firebug to inspect de POST requests made by RM when using it normally, and replicate them in code.

Mariano

rwetherall
Confirmed Champ
Confirmed Champ
Hi All,

Creating a record programatically is something that seems to crop up a lot and I don't have a definitive answer to hand.

I'll try and work up some examples of how things could be done for future reference and put the details on my blog.  Hopefully that will be helpful.

The good news is that going forward we want to make this kind of API access to the records management service much easier.

hanscrg
Champ in-the-making
Champ in-the-making
rwetherall,
I am also looking for a way to use Java Record servive API to decalre record. Does not get it work though. I am looking forward to your examples.

Thanks in advance.