I'm using Alfresco ECM to transform TIFF to PDF using the Tiger OCR library ()
My custom transformation xml (ocr-transformers-context) is
<?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="transformer.Ocr.Tiff2Pdf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="checkCommand">
<bean class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key=".*">
<list>
<value>c:\ocr\ocr.exe</value>
<value>--about</value>
</list>
</entry>
</map>
</property>
</bean>
</property>
<property name="transformCommand">
<bean class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Windows.*">
<list>
<value>c:\ocr\ocr.exe</value>
<value>--replace</value>
<value>--replace</value>
<value>--language en</value>
<value>--pdf</value>
<value>--output-file</value>
<value>${target}</value>
<value>${source}</value>
</list>
</entry>
</map>
</property>
</bean>
</property>
<property name="explicitTransformations">
<list>
<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
<property name="sourceMimetype"><value>image/tiff</value></property>
<property name="targetMimetype"><value>application/pdf</value></property>
</bean>
<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
<property name="sourceMimetype"><value>image/tiff</value></property>
<property name="targetMimetype"><value>text/plain</value></property>
</bean>
</list>
</property>
</bean>
</beans>
When I import a TIFF file into the Company Home folder I now expect that content to be transformed into a PDF. Now am I right in assuming that the transformation is automatic or do I need to invoke a rule on the space ?
Also, I have set the logging on the transformation to DEBUG and this is what I see in Alfresco logs
DEBUG [util.exec.RuntimeExec]
Execution result: os:
Windows XP command:
[c:\ocr\ocr.exe, --about]
succeeded: true exit code: 0
out: Intelliant OCR commandline
utility, version 1.1.0. Copyright ©
2006.
Credits:
TIFF Library Copyright (c)
1988-1997 Sam Leffler Copyright (c)
1991-1997 Silicon Graphics, Inc.
Independent JPEG Group Library
Copyright (C) 1991-19
User:admin DEBUG
[content.transform.ContentTransformerRegistry]
Searched for transformer: source
mimetype: image/tiff target
mimetype: text/plain transformers:
[]
Seems like its searching for a target of text/plain when I really need it to transform to PDF. What am I missing here ? Pls help
The only transform that'll be run automatically is the one to text plain, which is used for the full text indexing.
If you're using Share, then Share will try to do two more transformations for you. Firstly, it'll try to generate a thumbnail (via the rendition service) when you view the folder with your file in it. For this to work, you'd normally define a transformer from your new mime type to image/jpeg. Additionally, when you view the document details in Share, it'll try to give you a web preview.
If you'd like to have a PDF version of your document generated when you upload it, then you'll want to define a rule. You could do this with a transform content rule, or you could write a script to use the Rendition Service if you wanted a lot of control over it.
Related
This is my spring-servlet.xml file. I am new to spring MVC. Do we need to define bean for HelloWorld.Controller. If i don't define will it work?
<bean id="viewResolver" class=" org.springframework.web.servlet.view. InternalResourceViewResolver" >
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean name="/welcome.htm" class="com.vaannila.HelloWorldController" >
<property name="message" value="Hello World!" />
</bean>
</beans>
If i don't give this bean definition
<bean name="/welcome.htm" class="com.vaannila.HelloWorldController" >
<property name="message" value="Hello World!" />
</bean>
MyApplication should work or not? I am new to spring MVC. In few tutorial this code is there and in few its not there. Please explain.
Yes, you will need to define the bean (way to create instance of class) for all the Controller/Service/Dao/Components class you want to use and set relevant properties.
I would recommend you to use Annotation based configuration (spring boot) as it eases all this process. You can find lot of tutorials on getting stated with spring boot. Here is one such good tutorial https://www.mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/
I'm using Alfresco Community v5.2.0 to store some files (pdf, jpg/png essentially).
I'm creating a web app to retrieve this files.
I'm trying to create a grid of files from a specific folder in my application.
But when i'm retrieving the list of a specific folders with their thumbnails, the resolution of the thumbnail is very low (100x75).
How to configure Alfresco to generate a larger thumbnail ?
I tried to override the settings in :
C:\alfresco-community\tomcat\webapps\alfresco\cmisfs\stylesheets\
thumbnails.xsl
But this didn't work..
I'm using Alfresco on my computer (windows), with REST API call.
Where can i configure this resolution ?
Thanks in advance,
Julien
Lyon, FR.
Ok I found a way to ovveride the thumbnail definition :
I created a file
thumbnail-service-context.xml
in
[AlfrescoRootFolder]\tomcat\shared\classes\alfresco\extension\
In this file I wrote :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Slingshot Document Library image thumbnail options -->
<!-- Note that this will auto-register with parent="baseThumbnailDefinition" in the future -->
<bean id="thumbnailDefinitionDoclib" class="org.alfresco.repo.thumbnail.ThumbnailDefinition">
<property name="name" value="doclib" />
<property name="mimetype" value="image/png"/>
<property name="transformationOptions">
<bean parent="defaultImageTransformationOptions">
<property name="resizeOptions">
<bean parent="defaultImageResizeOptions">
<property name="width" value="900"/>
<property name="height" value="900"/>
<property name="allowEnlargement" value="false" />
</bean>
</property>
</bean>
</property>
<property name="placeHolderResourcePath" value="alfresco/thumbnail/thumbnail_placeholder_doclib.png" />
<property name="mimeAwarePlaceHolderResourcePath" value="alfresco/thumbnail/thumbnail_placeholder_doclib{0}.png" />
<property name="runAs" value="System"/>
<property name="failureHandlingOptions" ref="standardFailureOptions"/>
</bean>
</beans>
And now I can retrieve a thumbnail by calling :
/alfresco/api/-default-/public/alfresco/versions/1/nodes/{idDocAlfresco}/renditions/doclib/content
When I learnt about web scripts, the tutorials said to leave the Web Scripts folder alone and instead to add my web script to the Web Scripts Extensions folder. My understanding is that this is so that I do not pollute Alfresco's out-of-the-box web scripts, and upgrading will be easier.
Why is there no equivalent extensions folder for the Scripts folder?
Or is my understanding of the reason for the Web Scripts vs Web Scripts Extensions folders wrong?
Extension folders provide a way to override default behavior. You can put your code there if you like, but doing so makes it more difficult to override it. I will use the repository as an example. Similiar logic applies to share.
Have a look at alfresco/WEB-INF/classes/alfresco/web-scripts-application-context.xml. It reads:
<bean name="webscripts.store.repo.extension" parent="webscripts.repostore">
<property name="store"><value>workspace://SpacesStore</value></property>
<property name="path"><value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/cm:extensionwebscripts</value></property>
</bean>
<bean name="webscripts.store.repo" parent="webscripts.repostore">
<property name="mustExist"><value>true</value></property>
<property name="store"><value>workspace://SpacesStore</value></property>
<property name="path"><value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/cm:webscripts</value></property>
</bean>
<bean id="webscripts.repoclasspathstore" class="org.alfresco.repo.web.scripts.RepoClassPathStore" abstract="true" />
<bean id="webscripts.store" parent="webscripts.repoclasspathstore">
<property name="mustExist"><value>false</value></property>
<property name="classPath"><value>webscripts</value></property>
</bean>
<bean id="webscripts.store.alfresco" parent="webscripts.repoclasspathstore">
<property name="mustExist"><value>false</value></property>
<property name="classPath"><value>alfresco/webscripts</value></property>
</bean>
<bean id="webscripts.store.client" parent="webscripts.repoclasspathstore">
<property name="mustExist"><value>true</value></property>
<property name="classPath"><value>alfresco/templates/webscripts</value></property>
</bean>
<bean id="webscripts.store.client.extension" parent="webscripts.classpathstore">
<property name="classPath"><value>alfresco/extension/templates/webscripts</value></property>
</bean>
<bean id="webscripts.searchpath" class="org.springframework.extensions.webscripts.SearchPath">
<property name="searchPath">
<list>
<ref bean="webscripts.store.repo.extension" />
<ref bean="webscripts.store.repo" />
<ref bean="webscripts.store.client.extension" />
<ref bean="webscripts.store.client" />
<ref bean="webscripts.store.alfresco" />
<ref bean="webscripts.store" />
</list>
</property>
</bean>
The searchPath property of webscripts.searchpath shows the search order. Search terminates as soon as it has a match. As you can see, it is no problem to put custom code in non extension locations as long as their path is unique.
I personally only put override webscripts in extension locations.
You can create a folder under Scripts called Extension and put all your script in that. Or just create different folders under Scripts for each function or project, it doesn't matter. They get picked up by Alfresco.
I am using Spring MVC + FreeMarker integration. As I am new to FreeMarker i am not able to find out a way to configure FreeMarker labels from properties file.
Kindly help me out on this.
Thanks.
You can use, 'ResourceBundleMessageSource', message source for this.
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource"
<property name="basename" value="classpath:messages/messages" />
<property name="defaultEncoding" value="UTF-8"/>
/>
Define the locale resolver,
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
Define localeChangeInterceptor which detects the language parameter from the user session and call locale resolve. And register the interceptor in handler Mappings.
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" >
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
Property files need to be defined like,
messages_en.properties
messages_ar.properties
inside the messages folder path.
'ReloadableResourceBundleMessageSource' can be used if the language property files frequently changes. That means you don't have to restart the application in each language file change.
You need to import spring macro,
<#import "/spring.ftl" as spring/>
and
messages can be accessed inside a .ftl as follows.
<#spring.message "customMessageKey"/>
I want to run the extension
("C:\Alfresco\tomcat\shared\classes\alfresco\extension\scheduled-action-services-context.xml)
I have made some changes in it, however when I restart the server I don't see it in my log files.
Do I need something else to start it.
EDIT:
Here is the content of my scheduled action services:
<!--
Define the model factory used to generate object models suitable for use with freemarker templates.
-->
<bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
<!--
Execute the script /Company Home/Record Management/testscript.js
-->
<bean id="runScriptAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
<property name="actionName">
<value>script</value>
</property>
<property name="parameterTemplates">
<map>
<entry>
<key>
<value>script-ref</value>
</key>
<!-- Note that as of Alfresco 4.0, due to a Spring upgrade, the FreeMarker ${foo} entries must be escaped -->
<value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:send_mail.js"' )\}</value>
</entry>
</map>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="dictionaryService">
<ref bean="DictionaryService"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateService">
<ref bean="TemplateService"/>
</property>
</bean>
<!--
Run the script every minute - select the single node company home that is not used ...
-->
UNTIL_FIRST_FAILURE
IGNORE
lucene
workspace://SpacesStore
+#ia\:fromDate:\$\{luceneDateRange(now, \"P10D\")\} AND +PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*"</value>-->
+PATH:"/app:company_home/st:sites/cm:valdel/cm:calendar//*" AND +#ia\:fromDate:[NOW TO MAX]
</property>
<property name="cronExpression">
<value>0 * 8 * * ?</value>
</property>
<property name="jobName">
<value>jobD</value>
</property>
<property name="jobGroup">
<value>jobGroup</value>
</property>
<property name="triggerName">
<value>triggerD</value>
</property>
<property name="triggerGroup">
<value>triggerGroup</value>
</property>
<property name="scheduler">
<ref bean="schedulerFactory"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="templateActionDefinition">
<ref bean="runScriptAction"/> <!-- This is name of the action (bean) that gets run -->
</property>
<property name="transactionService">
<ref bean="TransactionService"/>
</property>
<property name="runAsUser">
<value>System</value>
</property>
</bean>
AND WHEN I CHECK THE STDOUT, I'M SEEEING THIS ERROR:
2012-03-30 11:00:00,230 ERROR [freemarker.runtime] [DefaultScheduler_Worker-8] Template processing error: "No nodes selected"
No nodes selected
The problematic instruction:
==> ${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:send_mail.js"' )} [on line 1, column 1 in string://fixed]
Java backtrace for programmers:
freemarker.template.TemplateModelException: No nodes selected
at org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory$QueryForSingleNodeFunction.exec(FreeMarkerWithLuceneExtensionsModelFactory.java:180)
Could someone explain me this.. I have written a cron to run every 8 minutes but its not working
"Run the extension" doesn't really make sense. When you start Tomcat, the Alfresco web application will load that Spring configuration file automatically because it is on the classpath (assuming you have set up your shared classloader correctly) and it ends in "context.xml". If you aren't seeing something you expect in the log files, check log4j.properties to make sure you have a logger set. If all else fails, use a remote debugger like Eclipse and set a breakpoint in one of the Java classes referred to by your context file.
Maybe your error is because of https://issues.alfresco.com/jira/browse/ALF-9981