cancel
Showing results for 
Search instead for 
Did you mean: 

Where to put webscript

shemgp
Champ in-the-making
Champ in-the-making
Hello,

I have a script that looks like this:

                        webscript: {
                            name: "aiias/symbolic-link/node/{nodeRef}",
                            stem: Alfresco.constants.PROXY_URI,
                            method: Alfresco.util.Ajax.POST,
                            params: {
                               nodeRef: nodeRef.uri
                            },
                        },

Where should my webscript be placed in the AMP file?
Because http://localhost:8081/share/proxy/alfresco/aiias/symbolic-link/node/workspace/SpacesStore/681f51d8-d... generates a 404.

Thanks for the help.
5 REPLIES 5

romschn
Star Collaborator
Star Collaborator
You should place it under config/alfresco/extension/templates/webscript.
For your reference, here is the link about AMP structure - http://docs.alfresco.com/community/topic/com.alfresco.community.doc/concepts/dev-extensions-modules-...

Hope this helps.

shemgp
Champ in-the-making
Champ in-the-making
I placed my code in src/main/amp/config/alfresco/extension/templates/webscripts/edu/aiias/symbolic-link/symbolic-link.post.desc.xml

<?xml version="1.0" encoding="UTF-8" ?>
<webscript>
    <shortname>Symbolic Link</shortname>
    <description>Create a link to a document in another folder.</description>
    <url>/aiias/symbolic-link/site/{site}/{container}/{path}</url>
    <url>/aiias/symbolic-link/site/{site}/{container}</url>
    <url>/aiias/symbolic-link/node/{store_type}/{store_id}/{id}/{path}</url>
    <url>/aiias/symbolic-link/node/{store_type}/{store_id}/{id}</url>
    <url>/aiias/symbolic-link/node/{store_type}/{store_id}</url>
    <format default="json">argument</format>
    <authentication>user</authentication>
    <transaction>required</transaction>
    <lifecycle>internal</lifecycle>
</webscript>

symbolic-link.post.json.js

<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js">

/*
* linkTo.post.js – Controller script for the linkTo action
* Copyright (C) 2013  Eric MSP Veith <eric.veith@wb-fernstudium.de>
*/


/**
* Entrypoint required by action.lib.js
*
* @method runAction
* @param p_params {object} Object literal containing files array
* @return {object|null} object representation of action results
*/
function runAction(p_params)
{
    var destNode = p_params.destNode;
    var files = p_params.files;
    var results = [];

    // Must have array of files
    if (!files || !files.length || files.length == 0) {
        status.setCode(status.STATUS_BAD_REQUEST, "No files given.");
        return;
    }
   
    files.forEach(function(ref, i) {
        var fileNode = search.findNode(ref);
        var result = {
            nodeRef: ref,
            action: "linkTo",
            success: false
        };

        if (null == fileNode) {
            results.push(result);
            return;
        }

        var symlink = destNode.createNode(fileNode.name, "app:filelink", {
              "cm:destination": fileNode
           });
        if (symlink) {
            symlink.save();
           
            result.id = symlink.name;
            result.nodeRef = symlink.nodeRef.toString();
            result.success = true;
        }

        results.push(result);
    });

    return results;
}

// Bootstrap the action script:

main();


But when I access http://localhost:8081/share/page/index I cannot find the webscript listed there. But when I place the webscript in src/main/amp/config/alfresco/site-webscripts/edu/aiias/symbolic-link/ then I could find the webscript in http://localhost:8081/share/page/index. My question is, am I on the right track? Why could I not find the webscript when I place in the src/main/amp/config/alfresco/extension/templates/webscripts/ folder?

Thanks.

kaynezhang
World-Class Innovator
World-Class Innovator
if you want to develop amp  for share
you can put webscripts  in

classpath:alfresco/site-webscripts/****
classpath:alfresco/web-extension/site-webscripts/***
classpath:web-extension/****
classpath:alfresco/webscripts/***
classpath:webscripts/***
                                                                                                                                                                                                                                                                                                                                                      

if you want to develop amp for alfresco
you can put webscripts  in

repository path:  company home/data dictionary/extensionwebscripts
repository path:  company home/data dictionary/webscripts
classpath:alfresco/extension/templates/webscripts/***
classpath:alfresco/templates/webscripts/****
classpath:alfresco/webscripts/***
classpath:webscripts/***

kaynezhang
World-Class Innovator
World-Class Innovator
if you want to develop amp  for share
you can put webscripts  in

classpath:alfresco/site-webscripts/****
classpath:alfresco/web-extension/site-webscripts/***
classpath:web-extension/****
classpath:alfresco/webscripts/***
classpath:webscripts/***
                                                                                                                                                                                                                                                                                                                                                      

if you want to develop amp for alfresco
you can put webscripts  in

repository path:  company home/data dictionary/extensionwebscripts
repository path:  company home/data dictionary/webscripts
classpath:alfresco/extension/templates/webscripts/***
classpath:alfresco/templates/webscripts/****
classpath:alfresco/webscripts/***
classpath:webscripts/***

shemgp
Champ in-the-making
Champ in-the-making
Hi again,

I placed the symbolic-link.post.json.js script in classpath:alfresco/site-webscripts/edu/aiias/symbolic-link folder but when I try to run it it displays a 500 internal server error. Looking at the logs, it says:

2014-05-14 10:24:20,811  ERROR [extensions.webscripts.AbstractRuntime] [http-bio-8081-exec-14] Exception from executeScript - redirecting to status template error: 04140001 Failed to execute script 'classpath*:alfresco/site-webscripts/edu/aiias/symbolic-link/symbolic-link.post.json.js': null
org.springframework.extensions.webscripts.WebScriptException: 04140001 Failed to execute script 'classpath*:alfresco/site-webscripts/edu/aiias/symbolic-link/symbolic-link.post.json.js': null
        at org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:200)
        at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1305)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
        at org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:70)
        at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:236)

The contents of symbolic-link.post.json.js are just like in above.

I'm wondering why alfresco share can't execute my script?

Thanks for your help.