cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create sub-folders?

sscbrian
Champ on-the-rise
Champ on-the-rise
I'm working on an InboundSMTP override and am hung up with what seems like it should be a simple part…  How to create a sub-folder given a particular nodeRef.  Here's what I've got so far:


        ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/application-context.xml");
//        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("classpath:alfresco/extension/subsystems/email/InboundSMTP/inbound/InboundSMTP-context.xml");
        ServiceRegistry serviceRegistry = (ServiceRegistry) appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
        FileFolderService fileFolderService=serviceRegistry.getFileFolderService();
        FileInfo object = fileFolderService.create(nodeRef, messageSubject, ContentModel.TYPE_FOLDER);


I've narrowed it down to trying to get the application context.  That single line (either of the ways listed above) results in the following very confusing (what patches?) error in the log when an e-mail is received:


ERROR [org.springframework.extensions.surf.util.AbstractLifecycleBean] [org.subethamail.smtp.server.Session-/2001:470:c27d:18:0:0:0:17:62204] 06300186 Email message processing failed
org.alfresco.error.AlfrescoRuntimeException: 06300186 Email message processing failed
   at org.alfresco.email.server.EmailServiceImpl.processMessage(EmailServiceImpl.java:324)
   at org.alfresco.email.server.EmailServiceImpl.importMessage(EmailServiceImpl.java:180)
   at org.alfresco.email.server.impl.subetha.SubethaEmailServer$Handler.processDelivery(SubethaEmailServer.java:223)
   at org.alfresco.email.server.impl.subetha.SubethaEmailServer$Handler.data(SubethaEmailServer.java:184)
   at org.subethamail.smtp.command.DataCommand.execute(DataCommand.java:61)
   at org.subethamail.smtp.server.RequireTLSCommandWrapper.execute(RequireTLSCommandWrapper.java:27)
   at org.subethamail.smtp.server.CommandHandler.handleCommand(CommandHandler.java:98)
   at org.subethamail.smtp.server.Session.runCommandLoop(Session.java:222)
   at org.subethamail.smtp.server.Session.run(Session.java:125)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 06300185 Not all patches could be applied
   at org.alfresco.repo.admin.patch.PatchExecuter.applyOutstandingPatches(PatchExecuter.java:111)
   at org.alfresco.repo.admin.patch.PatchExecuter$1.doWork(PatchExecuter.java:124)
   at org.alfresco.repo.admin.patch.PatchExecuter$1.doWork(PatchExecuter.java:120)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:548)
   at org.alfresco.repo.admin.patch.PatchExecuter.onBootstrap(PatchExecuter.java:128)
   at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
   at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEventInternal(SafeApplicationEventMulticaster.java:209)
   at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:180)
   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)
   at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
   at com.sscorp.CustomFolderEmailMessageHandler.addAlfrescoContent(CustomFolderEmailMessageHandler.java:132)
   at com.sscorp.CustomFolderEmailMessageHandler.processMessage(CustomFolderEmailMessageHandler.java:94)
   at org.alfresco.email.server.EmailServiceImpl$3.execute(EmailServiceImpl.java:296)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:454)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:342)
   at org.alfresco.email.server.EmailServiceImpl$4.doWork(EmailServiceImpl.java:304)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:548)
   at org.alfresco.email.server.EmailServiceImpl.processMessage(EmailServiceImpl.java:307)
   … 8 more


What am I missing?  Is there an easier way to go about doing this?
1 REPLY 1

sscbrian
Champ on-the-rise
Champ on-the-rise
With some outside help, I was shown the best way to do this.

First, inject FileFolderService bean into my e-mail handling bean via the following code added to my bean's entry in InboundSMTP-context.xml:


<property name="fileFolderService">
  <ref bean="FileFolderService" />
</property>


On the code side, add the setter for the incoming FileFolderService, and then the actual code to make the folder (and get the node ID of it) becomes a simple:


final FileInfo newFolder = fileFolderService.create(firstNodeRef, messageSubject, ContentModel.TYPE_FOLDER);
final NodeRef storageRef=newFolder.getNodeRef();
Getting started

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.