2

I'm trying to add some extra functionality to the site creation form of Alfresco 5 by creating a web script. I'm creating a jar file containing the module extension.

I have successfully modified the actual site creation for by adding a new site type (this was done for testing purposes only). I did this by adding the following to the extension-module.xml file:

<module>
    <id>Create Site Extension</id>
    <version>1.0</version>
    <customizations>
        <customization>
            <targetPackageRoot>org.alfresco.modules</targetPackageRoot>
            <sourcePackageRoot>create-site</sourcePackageRoot>
        </customization>
    </customizations>
</module>

/config/alfresco/web-scripts/create-site.get.js

model.sitePresets.push({
    id: "site-test",
    name: "TEST"
});

When added to tomcat/webapps/share/WEB-INF/lib and activated through the Alfresco module management page it works perfectly. I can see TEST in the list of site types.

I'm trying to do the exact same type of thing but with create-site.post.json.js. No matter what I do, I can't get my create-site.post.json.js web-script to fire. Is it possible to extend the .post.json.js file for create-site?

UPDATE In case anyone wants to look at the raw source, here it is: Module Srouce

Everything in the module works correctly except for the create-site.post.json.js. I know for a fact that the deleteDashboard method inside the .post.json.js file works correctly and it's what I've been using to attempt to debug the script (in case the debugger was running it but not breaking into it for some reason. If it runs, it should delete the test site "good-site"'s dashboard so if it worked, the dashboard will be empty/nonexistent.

vane
  • 2,125
  • 1
  • 21
  • 40
  • It could be done in an quite ugly way: http://experiencewithalfresco.blogspot.se/2014/02/monkey-patching-alfresco-repo-js.html – billerby Sep 02 '15 at 07:52

1 Answers1

0

The issue is obvious. Because you are using extension module and overriding out of box webscript. Now if you change the type of webscript from get to post it will not override it. So, if you really want to replace out of box webscript with yours then you need to get to the point where this component is called and override that. You will also require to create full post webscript (all related files)

mitpatoliya
  • 2,037
  • 12
  • 23
  • I don't understand what you mean. Alfresco provides this exact type of mechanism; they allow you to "extend" not override the `.get.js` controller scripts by creating an extension module. I'm not trying to "change" the `.get.js` to `.post.json.js`, a post script already exists, I'm trying to extend it in the same way they allow .get.js files to be extended. This is the way Alfresco outlines the process and requires that it's not in one of a few ways including an extension module. – vane Sep 03 '15 at 05:39
  • When you create a `.get.js` file inside an extension module of the same name as the existing file inside Alfresco then it's script contents are executed after the built in script is run, almost as if the 2 files are concatenated together. – vane Sep 03 '15 at 05:41