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 <[email protected]> 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(). > setTenantDomain(carbonContext.getTenantDomain()); > PrivilegedCarbonContext.getThreadLocalCarbonContext(). > setTenantId(carbonContext.getTenantId()); > > *** Registry userRegistry = getUserRegistry();* > GenericArtifactManager manager = new GenericArtifactManager( > userRegistry,"api"); > GenericArtifact apiGenericArtifact = manager.getGenericArtifact(apiUUID); > 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. > getThreadLocalCarbonContext(); > RegistryService registryService = (RegistryService) > carbonContext.getOSGiService(RegistryService.class, null); > return registryService.getGovernanceUserRegistry("admin", > carbonContext.getTenantId()); > } > > Method 2 > > protected Registry getUserRegistry() { > return (Registry)CarbonContext.getThreadLocalCarbonContext(). > getRegistry(RegistryType.USER_GOVERNANCE); > } > > Method 3 > > protected Registry getUserRegistry() { > ServiceDataHolder.getInstance().getTenantRegistryLoader(). > loadTenantRegistry(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: [email protected] > mobile: 0711644470 > > -- *Danesh Kuruppu* Senior Software Engineer | WSO2 Email: [email protected] Mobile: +94 (77) 1690552 Web: WSO2 Inc <https://wso2.com/signature>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
