Hi Rajith/Danesh,

I tried in this way with the code block below. With and without starting a
new tenant flow and i am getting the following error.I am trying this for
the default rest service which comes with the GREG. Seems as though it is
not picking up the correct registry. Since when i update with the UI it
works. Is there a way to troubleshoot it? Should we retrieve the governance
user registry or the governance registry?









*String resourcePath =
requestContext.getResourcePath().getPath();Association[] associations = new
Association[0];GovernanceArtifact governanceArtifact =
GovernanceUtils.retrieveGovernanceArtifactByPath(requestContext.getSystemRegistry(),resourcePath);GovernanceArtifactManager
governanceArtifactManager = new
GovernanceArtifactManager(requestContext.getSystemRegistry(),"application/vnd.wso2-restservice+xml","overview_name",null,"metadata","http://www.wso2.org/governance/metadata
<http://www.wso2.org/governance/metadata>","/trunk/restservices/@{overview_version}/@{overview_name}",associations);governanceArtifact.setAttribute("uritemplate_urlPattern","/test/wso2");governanceArtifactManager.updateGovernanceArtifact(governanceArtifact);*

[2016-09-29 17:16:15,598] ERROR
{org.wso2.carbon.commonAPI.lifecycleManager.APILifecycleExecutor} -  Error
updating
[2016-09-29 17:16:15,601] ERROR
{org.wso2.carbon.commonAPI.lifecycleManager.APILifecycleExecutor} -
 org.wso2.carbon.governance.api.exception.GovernanceException: No artifact
found for the artifact id :67dbd592-0533-4133-a372-5408d2f839e0.
[2016-09-29 17:16:15,766]  INFO
{org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService} -  Configured
Registry in 2ms
[2016-09-29 17:16:15,890] ERROR {rxt.asset} -  Failed to invoke action:
Promote for the asset of id: "67dbd592-0533-4133-a372-5408d2f839e0".The
following exception was thrown: JavaException:
org.wso2.carbon.registry.core.exceptions.RegistryException: The transaction
is already rollbacked, you can not commit a transaction already rollbacked,
nested depth: 1.
[2016-09-29 17:16:15,892] ERROR
{JAGGERY.extensions.assets.default.apis.asset:jag} -
 org.wso2.carbon.registry.core.exceptions.RegistryException: The
transaction is already rollbacked, you can not commit a transaction already
rollbacked, nested depth: 1.

Regards,
Shenavi



*Shenavi de Mel*
Software Engineer
WSO2 Inc: http://wso2.com
email: shen...@wso2.com
mobile: 0711644470


On Thu, Sep 29, 2016 at 12:33 PM, Rajith Roshan <raji...@wso2.com> wrote:

> Hi,
>
> You can use the "updateGovernanceArtifact" method in the
> GovernanceArtifactManager class.
>
> governanceArtifactManager.updateGovernanceArtifact(governanceArtifact);
>
> Thanks!
> Rajith
>
> On Thu, Sep 29, 2016 at 12:15 PM, Shenavi de Mel <shen...@wso2.com> wrote:
>
>> Hi Rajith,
>>
>> To update i have used this method bekiw. In this case should we update
>> uisng the normal registry put method?
>>
>> manager.updateGenericArtifact(apiGenericArtifact);
>>
>> *Shenavi de Mel*
>> Software Engineer
>> WSO2 Inc: http://wso2.com
>> email: shen...@wso2.com
>> mobile: 0711644470
>>
>>
>> On Thu, Sep 29, 2016 at 10:01 AM, Rajith Roshan <raji...@wso2.com> wrote:
>>
>>> Hi Shenavi,
>>>
>>> As Danesh suggested can you check whether the following method works.
>>>
>>> Registry registry = requestContext.getRegistry();
>>> String resourcePath = requestContext.getResourcePath().getPath();
>>>
>>> governanceArtifact = 
>>> GovernanceUtils.retrieveGovernanceArtifactByPath(requestContext.getSystemRegistry(),
>>>  resourcePath);
>>>
>>> governanceArtifact.setAttribute("","");
>>>
>>>
>>> Thanks!
>>>
>>> Rajith
>>>
>>>
>>> On Thu, Sep 29, 2016 at 9:31 AM, Danesh Kuruppu <dan...@wso2.com> wrote:
>>>
>>>> Hi Shenavi,
>>>>
>>>> Did you try with the registry comes with requestContext as below.
>>>> requestContext does have a registry, we can use that for registry
>>>> operations
>>>>
>>>> requestContext.getRegistry()
>>>>>
>>>>
>>>>
>>>> Thanks
>>>> Danesh
>>>>
>>>> On Thu, Sep 29, 2016 at 12:55 AM, Shenavi de Mel <shen...@wso2.com>
>>>> wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I am trying to update an artifact created out of my custom API rxt in
>>>>> greg inside the lifecycle executor class. Inside the lifecycle executer
>>>>> class I need to modify the value of the field "implement_sandboxURL". When
>>>>> i try to  update it using the java API it returns as a success but the
>>>>> registry asset does not get updated with the value being passed in the
>>>>> registry.
>>>>>
>>>>> Am I doing something wrong in how I am updating it? Your help would be
>>>>> appreciated. Below is a block of code from inside the execution class 
>>>>> which
>>>>> corresponds to the update.
>>>>>
>>>>> {code}
>>>>> Resource apiResource = requestContext.getResource();
>>>>> String apiUUID = apiResource.getUUID();
>>>>>
>>>>> PrivilegedCarbonContext.startTenantFlow();
>>>>> PrivilegedCarbonContext.getThreadLocalCarbonContext().setTen
>>>>> antDomain(carbonContext.getTenantDomain());
>>>>> PrivilegedCarbonContext.getThreadLocalCarbonContext().setTen
>>>>> antId(carbonContext.getTenantId());
>>>>>
>>>>> *** Registry userRegistry = getUserRegistry();*
>>>>> GenericArtifactManager manager = new GenericArtifactManager(userReg
>>>>> istry,"api");
>>>>> GenericArtifact apiGenericArtifact = manager.getGenericArtifact(api
>>>>> UUID);
>>>>> apiGenericArtifact.setAttribute("implement_sandboxURL","http
>>>>> ://test.wso2.com");
>>>>> manager.updateGenericArtifact(apiGenericArtifact);
>>>>>
>>>>> PrivilegedCarbonContext.endTenantFlow();
>>>>>
>>>>> {code}
>>>>>
>>>>>
>>>>> *** Different methods tried to retrieve the registry instance*
>>>>>
>>>>> Method 1
>>>>>
>>>>> protected Registry getUserRegistry() throws RegistryException {
>>>>>         CarbonContext carbonContext = PrivilegedCarbonContext.getThr
>>>>> eadLocalCarbonContext();
>>>>>         RegistryService registryService = (RegistryService)
>>>>> carbonContext.getOSGiService(RegistryService.class, null);
>>>>>         return registryService.getGovernanceUserRegistry("admin",
>>>>> carbonContext.getTenantId());
>>>>> }
>>>>>
>>>>> Method 2
>>>>>
>>>>> protected Registry getUserRegistry() {
>>>>>         return (Registry)CarbonContext.getThr
>>>>> eadLocalCarbonContext().getRegistry(RegistryType.USER_GOVERNANCE);
>>>>> }
>>>>>
>>>>> Method 3
>>>>>
>>>>> protected Registry getUserRegistry() {
>>>>>       ServiceDataHolder.getInstance().getTenantRegistryLoader().lo
>>>>> adTenantRegistry(carbonContext.getTenantId());
>>>>>      return ServiceDataHolder.getInstance(
>>>>> ).getRegistryService().getGovernanceUserRegistry("admin");
>>>>> }
>>>>>
>>>>> Am I missing something? What may be the reason the artifact does not
>>>>> get updated? When i update using the edit option in the UI it works but 
>>>>> not
>>>>> through the code. Also i debugged in both cases and the flow was identical
>>>>> as well.
>>>>>
>>>>> Thanks
>>>>> Shenavi
>>>>>
>>>>> *Shenavi de Mel*
>>>>> Software Engineer
>>>>> WSO2 Inc: http://wso2.com
>>>>> email: shen...@wso2.com
>>>>> mobile: 0711644470
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> *Danesh Kuruppu*
>>>> Senior Software Engineer | WSO2
>>>>
>>>> Email: dan...@wso2.com
>>>> Mobile: +94 (77) 1690552
>>>> Web: WSO2 Inc <https://wso2.com/signature>
>>>>
>>>>
>>>
>>>
>>> --
>>> Rajith Roshan
>>> Software Engineer, WSO2 Inc.
>>> Mobile: +94-72-642-8350 <%2B94-71-554-8430>
>>>
>>
>>
>
>
> --
> Rajith Roshan
> Software Engineer, WSO2 Inc.
> Mobile: +94-72-642-8350 <%2B94-71-554-8430>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to