Can we get AxisConfiguration from Craboncontext? On 21 March 2013 13:18, Pradeep Fernando <[email protected]> wrote:
> How about overriding the getAxisConfig() method in your admin service, to > get the CarbonContext from ThreadLoacal ? > Im not sure how its going to affect other use-cases though. > > --Pradeep > > > On Thu, Mar 21, 2013 at 1:02 PM, Vijayaratha Vijayasingam <[email protected] > > wrote: > >> Hi Pradeep/Azeez; >> >> Our scenario is, >> >> We login the publisher as a tenant and when we deploy the API to gateway, >> we call an AdminService. Before deploying to the gateway,we login the >> AdminService with the supertenant's credentials. So, now the AdminService >> login happens as supertenant and when we deploy the API, we want to make >> that in the TenantSpace. For that ,we pass tenant domain as a parameter to >> the AdminService and setting tenant domain like here[1]. After that when we >> try to retrive the SynapseConfiguration, we call another adminService[2] >> which gets SynapseConfiguration from Axis2Configuration. The second >> AdminService extends the AbstarctAdmin service and in the AbstarctAdmin >> service, here is how we create the Axis2configuration;[3] >> In the 3rd step, we don't consider the "ThreadLocalCarbonContext()" and >> it gives the Supertenant's synapse configuartion. >> >> How should we fix this? >> Thanks >> -Ratha >> >> >> [1] if (tenantDomain != null && !("").equals(tenantDomain) && >> >> !tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { >> PrivilegedCarbonContext.startTenantFlow(); >> >> PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, >> true); >> } >> >> finally { >> PrivilegedCarbonContext.endTenantFlow(); >> } >> >> *[2] return (SynapseConfiguration) getAxisConfig().getParameter( >> SynapseConstants.SYNAPSE_CONFIG).getValue(); >> >> [3] >> getConfigContext().getAxisConfiguration(); >> >> protected ConfigurationContext getConfigContext() { >> checkAdminService(); >> if(configurationContext != null) { >> return configurationContext; >> } >> MessageContext msgContext = >> MessageContext.getCurrentMessageContext(); >> if (msgContext != null) { >> ConfigurationContext mainConfigContext = >> msgContext.getConfigurationContext(); >> >> // If a tenant has been set, then try to get the >> ConfigurationContext of that tenant >> PrivilegedCarbonContext carbonContext = >> PrivilegedCarbonContext. >> getCurrentContext(msgContext); >> String domain = carbonContext.getTenantDomain(); >> if (domain != null && >> !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { >> return >> TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); >> } else if(carbonContext.getTenantId() == >> MultitenantConstants.SUPER_TENANT_ID) { >> return mainConfigContext; >> } else { >> throw new UnsupportedOperationException("Tenant domain >> unidentified. " + >> "Upstream code needs to identify & set the tenant >> domain & tenant ID. " + >> " The TenantDomain SOAP header could be set by >> the clients or " + >> "tenant authentication should be carried out."); >> } >> } else { >> return >> CarbonConfigurationContextFactory.getConfigurationContext(); >> } >> } >> >> * >> >> On 21 March 2013 11:15, Pradeep Fernando <[email protected]> wrote: >> >>> Hi Ratha, >>> >>> Can you please explain what your are trying to do. Seems like you are >>> starting a tenant flow in one of your Admin service calls... why is that ? >>> >>> And after creating a tenant flow, the preferred way is to >>> getThreadLocalCarbonContext. >>> >>> >>> >>> >>> On Thu, Mar 21, 2013 at 1:17 AM, Vijayaratha Vijayasingam < >>> [email protected]> wrote: >>> >>>> Hi all; >>>> Im getting following issue [1] when i try to set a tenant domain for a >>>> particular tenant. >>>> >>>> My code is like this ; >>>> >>>> *PrivilegedCarbonContext.startTenantFlow(); >>>> PrivilegedCarbonContext.getCurrentContext().setTenantDomain(tenantDomain, >>>> true); >>>> finally{ >>>> PrivilegedCarbonContext.endTenantFlow();* >>>> } >>>> >>>> Can anyone point me the issue? >>>> >>>> thanks, >>>> >>>> [1] >>>> at java.lang.Thread.run(Thread.java:662) >>>> Caused by: org.apache.axis2.AxisFault: Error while adding new API >>>> at >>>> org.wso2.carbon.apimgt.impl.utils.RESTAPIAdminClient.addApi(RESTAPIAdminClient.java:52) >>>> at >>>> org.wso2.carbon.apimgt.impl.APIProviderImpl.publishToGateway(APIProviderImpl.java:739) >>>> ... 53 more >>>> Caused by: org.apache.axis2.AxisFault: Cannot create tenant >>>> ConfigurationContext for tenant ratha.com >>>> at >>>> org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) >>>> at >>>> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:367) >>>> at >>>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:413) >>>> at >>>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:224) >>>> at >>>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:149) >>>> at >>>> org.wso2.carbon.rest.api.stub.RestApiAdminStub.addApiForTenant(RestApiAdminStub.java:371) >>>> at >>>> org.wso2.carbon.apimgt.impl.utils.RESTAPIAdminClient.addApi(RESTAPIAdminClient.java:47) >>>> >>>> _______________________________________________ >>>> Dev mailing list >>>> [email protected] >>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>> >>>> >>> >>> >>> -- >>> *Pradeep Fernando* >>> Member, Management Committee - Platform & Cloud Technologies >>> Senior Software Engineer;WSO2 Inc.; http://wso2.com >>> >>> blog: http://pradeepfernando.blogspot.com >>> m: +94776603662 >>> >> >> > > > -- > *Pradeep Fernando* > Member, Management Committee - Platform & Cloud Technologies > Senior Software Engineer;WSO2 Inc.; http://wso2.com > > blog: http://pradeepfernando.blogspot.com > m: +94776603662 >
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
