use of org.wso2.carbon.apimgt.api.OrganizationResolver in project carbon-apimgt by wso2.
the class RestApiUtil method resolveOrganization.
/**
* Method to resolve the organization
* @param message Message
* @return organization
*/
public static String resolveOrganization(Message message) throws APIManagementException {
OrganizationResolver resolver = APIUtil.getOrganizationResolver();
// populate properties needed for the resolver.
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put(APIConstants.PROPERTY_HEADERS_KEY, message.get(Message.PROTOCOL_HEADERS));
properties.put(APIConstants.PROPERTY_QUERY_KEY, message.get(Message.QUERY_STRING));
String organization = resolver.resolve(properties);
return organization;
}
use of org.wso2.carbon.apimgt.api.OrganizationResolver in project carbon-apimgt by wso2.
the class OrganizationInterceptor method handleMessage.
@Override
public void handleMessage(Message message) throws Fault {
try {
OrganizationResolver resolver = APIUtil.getOrganizationResolver();
// populate properties needed for the resolver.
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put(APIConstants.PROPERTY_HEADERS_KEY, message.get(Message.PROTOCOL_HEADERS));
properties.put(APIConstants.PROPERTY_QUERY_KEY, message.get(Message.QUERY_STRING));
String organization = resolver.resolve(properties);
message.put(RestApiConstants.ORGANIZATION, organization);
} catch (APIManagementException e) {
if (e instanceof APIMgtBadRequestException) {
RestApiUtil.handleBadRequest(e.getMessage(), 901300L, logger);
} else {
RestApiUtil.handleInternalServerError("Error while resolving the organization resolver", e, logger);
}
}
logger.debug("Organization :" + message.get(RestApiConstants.ORGANIZATION));
}
use of org.wso2.carbon.apimgt.api.OrganizationResolver in project carbon-apimgt by wso2.
the class RestApiUtil method resolveOrganization.
public static String resolveOrganization(HashMap<String, Object> message) throws APIManagementException {
OrganizationResolver resolver = APIUtil.getOrganizationResolver();
// populate properties needed for the resolver.
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put(APIConstants.PROPERTY_HEADERS_KEY, message.get(Message.PROTOCOL_HEADERS));
properties.put(APIConstants.PROPERTY_QUERY_KEY, message.get(Message.QUERY_STRING));
String organization = resolver.resolve(properties);
return organization;
}
Aggregations