Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
chamikasudusinghe committed Jun 20, 2023
1 parent dcd10fe commit 6896e84
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected static String getElectedResource(org.apache.synapse.MessageContext mes
return (String) messageContext.getProperty("API_ELECTED_RESOURCE");
}

protected static String getResourceCacheKey(org.apache.synapse.MessageContext messageContext){
protected static String getResourceCacheKey(org.apache.synapse.MessageContext messageContext) {
return (String) messageContext.getProperty("API_RESOURCE_CACHE_KEY");
}

Expand Down Expand Up @@ -136,17 +136,17 @@ protected static String getMatchingLogLevel(MessageContext messageContext,
//obtain the selected API by context and path
API selectedApi = Utils.getAPIByContext(messageContext);
//obtaining required parameters to execute findResource method
String apiContext = ((Axis2MessageContext)messageContext).getAxis2MessageContext().
getProperty("TransportInURL").toString();
String httpMethod = (String) ((Axis2MessageContext) messageContext).getAxis2MessageContext().
getProperty(Constants.Configuration.HTTP_METHOD);
String apiContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext()
.getProperty("TransportInURL").toString();
String httpMethod = (String) ((Axis2MessageContext) messageContext).getAxis2MessageContext()
.getProperty(Constants.Configuration.HTTP_METHOD);

if (selectedApi != null) {
Utils.setSubRequestPath(selectedApi, messageContext);
//iterating through all the existing resources to match with the requesting method
Map<String,Resource> resourcesMap = selectedApi.getResourcesMap();
Set<Resource> acceptableResources = ApiUtils.
getAcceptableResources(resourcesMap, messageContext);
Map<String, Resource> resourcesMap = selectedApi.getResourcesMap();
Set<Resource> acceptableResources = ApiUtils
.getAcceptableResources(resourcesMap, messageContext);
if (!acceptableResources.isEmpty()) {
for (RESTDispatcher dispatcher : ApiUtils.getDispatchers()) {
selectedResource = dispatcher.findResource(messageContext, acceptableResources);
Expand All @@ -159,7 +159,7 @@ protected static String getMatchingLogLevel(MessageContext messageContext,
apiLogLevel = entry.getValue();
//matching the methods first and then the resource path
} else if (httpMethod.equals(key.get("resourceMethod"))) {
if(helper.getString().equals(key.get("resourcePath"))) {
if (helper.getString().equals(key.get("resourcePath"))) {
resourceLogLevel = entry.getValue();
resourcePath = key.get("resourcePath");
resourceMethod = key.get("resourceMethod");
Expand All @@ -177,8 +177,8 @@ protected static String getMatchingLogLevel(MessageContext messageContext,
isResourceLevelHasHighPriority = true;
break;
case APIConstants.LOG_LEVEL_STANDARD:
if (apiLogLevel != null && (apiLogLevel.equals(APIConstants.LOG_LEVEL_BASIC) ||
apiLogLevel.equals(APIConstants.LOG_LEVEL_OFF))) {
if (apiLogLevel != null && (apiLogLevel.equals(APIConstants.LOG_LEVEL_BASIC)
|| apiLogLevel.equals(APIConstants.LOG_LEVEL_OFF))) {
isResourceLevelHasHighPriority = true;
break;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public static X509Certificate convertCertificateToX509Certificate(Certificate ce
}

/**
* Using the api context to match API path to get the invoked API from an API Collection
* Using the api context to match API path to get the invoked API from an API Collection.
*
* @param messageContext MessageContext
* @return selected API based on the API path
Expand All @@ -701,7 +701,7 @@ public static API getAPIByContext(MessageContext messageContext) {
}

/**
* Select acceptable resources from the set of all resources based on requesting methods
* Select acceptable resources from the set of all resources based on requesting methods.
*
* @return set of acceptable resources
*/
Expand All @@ -711,17 +711,17 @@ public static Set<Resource> getAcceptableResources(Resource[] allAPIResources,
for (Resource resource : allAPIResources) {
//If the requesting method is OPTIONS or if the Resource contains the requesting method
String [] resourceMethods = resource.getMethods();
if ((RESTConstants.METHOD_OPTIONS.equals(httpMethod) && resourceMethods != null &&
Arrays.asList(resourceMethods).contains(corsRequestMethod)) ||
(resourceMethods != null && Arrays.asList(resourceMethods).contains(httpMethod))) {
if ((RESTConstants.METHOD_OPTIONS.equals(httpMethod) && resourceMethods != null
&& Arrays.asList(resourceMethods).contains(corsRequestMethod))
|| (resourceMethods != null && Arrays.asList(resourceMethods).contains(httpMethod))) {
acceptableResources.add(resource);
}
}
return acceptableResources;
}

/**
* Obtain the selected resource from the message context for CORSRequestHandler
* Obtain the selected resource from the message context for CORSRequestHandler.
*
* @return selected resource
*/
Expand All @@ -730,9 +730,9 @@ public static Resource getSelectedResource(MessageContext messageContext,
Resource selectedResource = null;
Resource resource = (Resource) messageContext.getProperty(LogsHandler.SELECTED_RESOURCE);
String [] resourceMethods = resource.getMethods();
if ((RESTConstants.METHOD_OPTIONS.equals(httpMethod) && resourceMethods != null &&
Arrays.asList(resourceMethods).contains(corsRequestMethod)) ||
(resourceMethods != null && Arrays.asList(resourceMethods).contains(httpMethod))) {
if ((RESTConstants.METHOD_OPTIONS.equals(httpMethod) && resourceMethods != null
&& Arrays.asList(resourceMethods).contains(corsRequestMethod))
|| (resourceMethods != null && Arrays.asList(resourceMethods).contains(httpMethod))) {
selectedResource = resource;
}
return selectedResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public boolean handleRequest(MessageContext messageContext) {
}
String apiContext = (String) messageContext.getProperty(RESTConstants.REST_API_CONTEXT);
String apiVersion = (String) messageContext.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION);
String httpMethod = (String) ((Axis2MessageContext) messageContext).getAxis2MessageContext().
getProperty(Constants.Configuration.HTTP_METHOD);
String httpMethod = (String) ((Axis2MessageContext) messageContext).getAxis2MessageContext()
.getProperty(Constants.Configuration.HTTP_METHOD);
API selectedApi = Utils.getSelectedAPI(messageContext);
org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext)
.getAxis2MessageContext();
Expand All @@ -167,8 +167,8 @@ public boolean handleRequest(MessageContext messageContext) {
Utils.setSubRequestPath(selectedApi, messageContext);

if (selectedApi != null) {
if ((messageContext.getProperty(LogsHandler.SELECTED_RESOURCE) != null)){
selectedResource = Utils.getSelectedResource(messageContext,httpMethod, corsRequestMethod);
if ((messageContext.getProperty(LogsHandler.SELECTED_RESOURCE) != null)) {
selectedResource = Utils.getSelectedResource(messageContext, httpMethod, corsRequestMethod);
} else {
Resource[] allAPIResources = selectedApi.getResources();
Set<Resource> acceptableResources
Expand Down

0 comments on commit 6896e84

Please sign in to comment.