Cannot find template in Java web script in alfresco - alfresco

I have followed this tutorial to create a send email custom action using Java backed Webscript:
http://ecmstuff.blogspot.com/2012/04/adding-document-library-actions-in.html?showComment=1403279845779#c303784066266925848
As has been mentioned above, there is an AbstractWebScript class defined just to execute the action without using a freemaker template, but I get this error:
Cannot locate template processor for template sendDocInEmail.get.html
I guess, there is a problem with the -context.xml file
My files are placed in the following folders:
1. the java .class files are in \tomcat\webapps\alfresco\WEB-INF\classes (placed with the package structure)
2. sendDocInEmail.get.desc in \tomcat\shared\classes\alfresco\extension\templates\webscripts folder (with the package structure)
3. services-context.xml file in the folder \tomcat\webapps\alfresco\WEB-INF\classes\alfresco\module (again with the package structure)
Please help!
Thanks in advance.

You most likely derived your class from DeclarativeWebScript which extends AbstractWebScript and adds the template processing. Make sure to derive your class from the latter.

Related

Spring project package problem that needs to be addressed

I have tried my every possible ways of adding class in different packages such as application class in package com.packagename and my controller in different package named model and when i try to execute the program it returns the default white label error and when i put the classes in the same package it runs successfully.
So i wanted to ask if there is any problem with the project or i need to give any path.
Before I have also tried notations that says component scan and all but that to did not came handy
Let's say your main class(which is annotated with #SpringBootApplication) is in the package "com.somepackage", then try putting your controller in "com.somepackage.controller"(It is recommended that other classes are placed in the subpackage of your main class). with this change it should work.
You put your classes in wrong places and your package are very messy. You should have a structure like this
--src
main
java
com.boltforever.moviecatalog
model
service
MyService.java
controller
MyController.java
MovieCatalogServiceApplication.java
And this should work

Is it possible to override/extend onNewFolder in Alfresco?

I'm using Alfresco 5. I have create a custom type (parent type is cm:folder) and
added an entry for this type in the Document Library "Create" menu.
I would like to override the default folder create function so that I can do
some custom processing.
I would like to create some content within the new folder each time.
You can use alfresco behaviour/policies for your requirement.
For creating policy you need to create below things.
1.Spring Bean in context file
2.One class which implements onCreateNode from org.alfresco.repo.node.NodeServicePolicies
For more information regarding policies read below blog written by Jeff Potts
http://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html
Apart from behaviour/policies easier option would be using rule and script.
You can create a rule which will be executed on creation of new
folder.
Create alfresco java script which will do processing you required on creation of
new folder.
Hook up script with rule.

How to create my own custom version of Jaxb2RootElementHttpMessageConverter?

How to create my own custom version of Jaxb2RootElementHttpMessageConverter; so I can give it my own defined JAXB2 Marshaller via the application context xml configuration file?
Thanks,
Tonté
Just create a sub-class of the Jaxb2RootElementHttpMessageConverter.java and then override the necessary methods. Or you can complete create your own class by copying and pasting the source code of the Jaxb2RootElementHttpMessageConverter.java and then update class as necessary.

How do I call GetLocalResource in another class

So I have Test1.aspx, Test1.aspx.vb. The LocalResource files, in the App_LocalResources folder, Test1.aspx.resx and Test1.aspx.es.resx. I also have a class called TestTheData.vb in the App_Code folder.
Now what I want to do is call GetLocalResource("stringObjRes").ToString in the TestTheData.vb class. The method however is not showing up in Intellisense. When I try to type manually, I get the error lines in my code.
I've imported:
Globalization
Threading
Threading.Thread
Web
Web.UI.Page.
No luck. So how I am supposed to do this....?
Well it seems that Local Resources can't be accessed in files that are in the App_Code folder. So I used Global Resources instead.
I know it's 1 year old but I just added the comment if some others are also searching for this:
Your guess is right, you cannot access the Local Resource Object from another class. GetLocalResourceObject only exists within the code of the page, in your case Test1.aspx.vb. If you are calling the class function from your Test1.aspx.vb you could of course retrieve the Local resource from there and then supply it to your TestTheData.vb as a parameter. But if you need the 'stringObjRes' in several places (not only in Test1.aspx) then a global resource is of course preferred. Details here: http://msdn.microsoft.com/en-us/library/ms227982(v=vs.100).aspx

why are some IronPython dlls generated with a DLRCachedCode class inside?

when I compile some .py codefiles with no class definitions into dlls , the compiled dll is created with a "DRLCachedCode" class inside. Why is that?
When you compile IronPython code it doesn't get compiled to normal .NET code where you'd have a class at the IL level for each class you have at the source level. Instead it gets compiled into the same form that we compile to internally using the DLR.
For user code this is just a bunch of executable methods. There's one method for each module, function definition, and class definition. When the module code runs it executes against a dictionary. Depending on what you do in the module the .NET method may publish into the dictionary a:
PythonType for new-style classes
An OldClass for old-style classes
A PythonFunction object for function
definitions
Any values that you assign to (e.g.
Foo=42)
Any side effects of doing exec w/o providing a dictionary (e.g. exec "x=42")
etc...
The final piece of the puzzle is where is this dictionary stored and how do you get at it? The dictionary is stored in a PythonModule object and we create it when the user imports the pre-compiled module and then we execute the module against it. Therefore this code is only available via Python's import statement (or the extension method on ScriptEngine "ImportModule" which is exposed via IronPython.Hosting.Python class).
So all of the layout of the code is considered an internal implementation detail which we reserve the right to change at any point in time.
Finally the name DLRCachedCode comes because the DLR (outer layer) saves this code for us. Multiple languages can actually be saved into a single DLL if someone really wanted to.
This link answers the question: http://www.ironpython.info/index.php/Using_Compiled_Python_Classes_from_.NET/CSharp_IP_2.6 how to access an IronPython class from C#.
Manual compilation: \IronPython 2.7\Tools\Scripts>ipy pyc.py /out:MyClass /target:dll MyClass.py did not work. Only when I used SharpDevelop with IronPython it worked as in the post.

Resources