Below is other piece of code from asset.js
Manager = function (registry, type) {
var carbon = require('carbon');
this.registry = registry;
this.type = type;
this.user = require('/modules/user.js');
Packages.org.wso2.carbon.governance.api.util.GovernanceUtils.loadGovernanceArtifacts(registry.registry);
new Log().info(registry.registry);
this.manager = new carbon.registry.ArtifactManager(registry, type);
this.sorter = new Sorter(registry);
};
On Mon, Jun 10, 2013 at 11:09 AM, Chan <[email protected]> wrote:
> Below are my codes -
> ROUTER
> var publisher = require('/modules/publisher.js');
> var t = "android";
> publisher.addAsset(t, {
> type:t,
> path:
> "/_system/governance/"+t+"/"+ctx.provider+"/"+ctx.version+"/"+ctx.name,
> lifecycle:["CREATED", "REVIEW", "PUBLISH", "REJECT", "REMOVED"],
> lifecycleState: "CREATED",
> mediaType: "application/vnd.wso2-"+t+"+xml",
> attributes: {
> overview_status: "CREATED",
> overview_name: ctx.name,
> overview_version: ctx.version,
> overview_url: ctx.url,
> overview_provider: ctx.provider
> },
> images :{
> thumbnail:'http://localhost:9763/portal/gadgets/co2-emission/thumbnail.jpg
> ',
> banner:'http://localhost:9763/portal/gadgets/electric-power/banner.jpg'
> }
> });
>
> asset.js
> Manager.prototype.add = function (options) {
> var log = new Log();
> log.info("Caught SSS");
> log.info(this.manager);
> return this.manager.add(options);
> };
>
> publisher.js
> addAsset = function (type, options) {
> new Log().info(options);
> assetManager(type).add(options);
> };
>
>
> var assetManager = function (type) {
> var manager, azzet, assetManagers, context, path,
> server = require('/modules/server.js'),
> user = require('/modules/user.js').current();
> context = user ? session : application;
> assetManagers = {};
> // if (!assetManagers) {
> // assetManagers = {};
> // context.put(ASSET_MANAGERS, assetManagers);
> // }
> // manager = assetManagers[type];
> // if (manager) {
> // return manager;
> // }
> path = ASSETS_EXT_PATH + type + '/asset.js';
> azzet = new File(path).isExists() ? require(path) :
> require('/modules/asset.js');
> var r =registry();
> log.info(type);
> //log.info(assetManagers);
> return (assetManagers[type] = new azzet.Manager(r, type));
> };
>
> You can find the full code in
> https://github.com/dulichan/wso2storepublisher/tree/api.
>
> Thanks
>
>
> On Mon, Jun 10, 2013 at 10:03 AM, Eranda Sooriyabandara
> <[email protected]>wrote:
>
>> Hi Dulitha,
>> Please ignore my comments. I was referring to the java code.
>>
>> thanks
>> Eranda
>>
>>
>> On Mon, Jun 10, 2013 at 9:56 AM, Eranda Sooriyabandara
>> <[email protected]>wrote:
>>
>>> Hi Dulitha,
>>> Why you using ArtifactManager? Do you have any new artifact type
>>> defined? If yes then how you define the ArtifactManager?, please attach the
>>> code.
>>>
>>> thanks
>>> Eranda
>>>
>>>
>>> On Mon, Jun 10, 2013 at 8:17 AM, Chan <[email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to insert a json object to registry and the ArtifactManager is
>>>> giving me trouble. The registry method that gets the current user's
>>>> registry is working (store.js:92). I print out that object and below is the
>>>> result -
>>>>
>>>> RESULT -
>>>> {"server" : {"url" : "https://localhost:9443/admin"}, "tenantId" :
>>>> -1234, "username" : "admin", "registry" : {}, "versioning" : {"comments" :
>>>> true}}
>>>>
>>>> I suspect the problem is with registry having no objects inside of it.
>>>> Why is the registry not having any objects?
>>>>
>>>> Thank you,
>>>>
>>>> ERROR
>>>>
>>>>
>>>> [2013-06-10 08:02:35,519] ERROR
>>>> {org.jaggeryjs.scriptengine.engine.RhinoEngine} -
>>>> org.mozilla.javascript.EcmaError: TypeError: Cannot call method
>>>> "newGovernanceArtifact" of undefined (artifacts#37)
>>>> [2013-06-10 08:02:35,519] ERROR
>>>> {org.jaggeryjs.jaggery.core.manager.WebAppManager} -
>>>> org.mozilla.javascript.EcmaError: TypeError: Cannot call method
>>>> "newGovernanceArtifact" of undefined (artifacts#37)
>>>> org.jaggeryjs.scriptengine.exceptions.ScriptException:
>>>> org.mozilla.javascript.EcmaError: TypeError: Cannot call method
>>>> "newGovernanceArtifact" of undefined (artifacts#37)
>>>> at
>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:582)
>>>> at
>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:280)
>>>> at
>>>> org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:377)
>>>> at
>>>> org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>>>> at
>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>>>> at
>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>>> at
>>>> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
>>>> at
>>>> org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
>>>> at
>>>> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
>>>> at
>>>> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
>>>> at
>>>> org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
>>>> at
>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>>>> at
>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>>> at
>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
>>>> at
>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
>>>> at
>>>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
>>>> at
>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
>>>> at
>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:177)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:161)
>>>> at
>>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
>>>> at
>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>>> at
>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
>>>> at
>>>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
>>>> at
>>>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
>>>> at
>>>> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>>>> at java.lang.Thread.run(Thread.java:722)
>>>> Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call
>>>> method "newGovernanceArtifact" of undefined (artifacts#37)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3693)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3712)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3731)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2258)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2251)
>>>> at org.mozilla.javascript.gen.artifacts_13._c_anonymous_5(artifacts:37)
>>>> at org.mozilla.javascript.gen.artifacts_13.call(artifacts)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
>>>> at
>>>> org.mozilla.javascript.gen.artifacts_13._c_anonymous_12(artifacts:130)
>>>> at org.mozilla.javascript.gen.artifacts_13.call(artifacts)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c6._c_anonymous_18(/publisher/modules/asset.js:139)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c6.call(/publisher/modules/asset.js)
>>>> at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c5._c_anonymous_30(/publisher/modules/publisher.js:312)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c5.call(/publisher/modules/publisher.js)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.c1._c_anonymous_3(/publisher//index.jag:27)
>>>> at org.jaggeryjs.rhino.publisher.c1.call(/publisher//index.jag)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c4._c_anonymous_9(/publisher/modules/goose.js:85)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c4.call(/publisher/modules/goose.js)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c2._c_callAPI_12(/publisher/modules/absolute.js:138)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c2.call(/publisher/modules/absolute.js)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c2._c_anonymous_14(/publisher/modules/absolute.js:169)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.modules.c2.call(/publisher/modules/absolute.js)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
>>>> at
>>>> org.jaggeryjs.rhino.publisher.c1._c_script_0(/publisher//index.jag:83)
>>>> at org.jaggeryjs.rhino.publisher.c1.call(/publisher//index.jag)
>>>> at
>>>> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
>>>> at org.jaggeryjs.rhino.publisher.c1.call(/publisher//index.jag)
>>>> at org.jaggeryjs.rhino.publisher.c1.exec(/publisher//index.jag)
>>>> at
>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:577)
>>>> ... 31 more
>>>>
>>>>
>>>>
>>>> --
>>>> Chan (Dulitha Wijewantha)
>>>> Software Engineer - Mobile Development
>>>> WSO2Mobile
>>>> Lean.Enterprise.Mobileware
>>>> * ~Email [email protected]*
>>>> * ~Mobile +94712112165*
>>>> * ~Website dulithawijewantha.com
>>>> *
>>>> * ~Blog
>>>> blog.dulithawijewantha.com<http://dulichan.github.io/chan/>
>>>> *
>>>> * ~Twitter @dulitharw <https://twitter.com/dulitharw>*
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [email protected]
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> *Eranda Sooriyabandara
>>> *Software Engineer;
>>> Integration Technologies Team;
>>> WSO2 Inc.; http://wso2.com
>>> Lean . Enterprise . Middleware
>>>
>>> E-mail: eranda AT wso2.com
>>> Mobile: +94 716 472 816
>>> Linked-In: http://www.linkedin.com/in/erandasooriyabandara
>>> Blog: http://emsooriyabandara.blogspot.com/
>>>
>>>
>>>
>>> *
>>> *
>>>
>>
>>
>>
>> --
>> *Eranda Sooriyabandara
>> *Software Engineer;
>> Integration Technologies Team;
>> WSO2 Inc.; http://wso2.com
>> Lean . Enterprise . Middleware
>>
>> E-mail: eranda AT wso2.com
>> Mobile: +94 716 472 816
>> Linked-In: http://www.linkedin.com/in/erandasooriyabandara
>> Blog: http://emsooriyabandara.blogspot.com/
>>
>>
>>
>> *
>> *
>>
>
>
>
> --
> Chan (Dulitha Wijewantha)
> Software Engineer - Mobile Development
> WSO2Mobile
> Lean.Enterprise.Mobileware
> * ~Email [email protected]*
> * ~Mobile +94712112165*
> * ~Website dulithawijewantha.com
> *
> * ~Blog blog.dulithawijewantha.com<http://dulichan.github.io/chan/>
> *
> * ~Twitter @dulitharw <https://twitter.com/dulitharw>*
>
--
Chan (Dulitha Wijewantha)
Software Engineer - Mobile Development
WSO2Mobile
Lean.Enterprise.Mobileware
* ~Email [email protected]*
* ~Mobile +94712112165*
* ~Website dulithawijewantha.com
*
* ~Blog blog.dulithawijewantha.com<http://dulichan.github.io/chan/>
*
* ~Twitter @dulitharw <https://twitter.com/dulitharw>*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev