Skip to content

Commit

Permalink
Merge pull request #1 from madusankapremaratne/release-1.9.1
Browse files Browse the repository at this point in the history
Release 1.9.1 - Code Improvements
  • Loading branch information
jaadds committed Aug 6, 2015
2 parents 4b8fe28 + 510dc82 commit 783d979
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.wso2.carbon.apimgt.api.dto.UserApplicationAPIUsage;
import org.wso2.carbon.apimgt.api.model.*;

import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -393,7 +394,8 @@ public boolean updateAPIsInExternalAPIStores(API api, Set<APIStore> apiStoreSet,
public boolean isSynapseGateway() throws APIManagementException;

/**
* Search API by Document Content
* Search APIs by swagger document content. This method searches the given search term in the registry and returns
* a set of APIs which satisfies the given search term
*
* @param searchTerm Search Term
* @param searchType Search Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpHost;
Expand Down Expand Up @@ -56,17 +57,17 @@
import org.wso2.carbon.apimgt.impl.APIManagerConfiguration;
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.apimgt.impl.UserAwareAPIProvider;
import org.wso2.carbon.apimgt.impl.factory.KeyManagerHolder;
import org.wso2.carbon.apimgt.impl.handlers.ScopesIssuer;
import org.wso2.carbon.apimgt.impl.definitions.APIDefinitionFromSwagger20;
import org.wso2.carbon.apimgt.impl.dto.Environment;
import org.wso2.carbon.apimgt.impl.dto.TierPermissionDTO;
import org.wso2.carbon.apimgt.impl.factory.KeyManagerHolder;
import org.wso2.carbon.apimgt.impl.handlers.ScopesIssuer;
import org.wso2.carbon.apimgt.impl.utils.APIAuthenticationAdminClient;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.apimgt.impl.utils.APIVersionComparator;
import org.wso2.carbon.apimgt.impl.utils.APIVersionStringComparator;
import org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient;
import org.wso2.carbon.apimgt.keymgt.client.ProviderKeyMgtClient;
import org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient;
import org.wso2.carbon.apimgt.usage.client.APIUsageStatisticsClient;
import org.wso2.carbon.apimgt.usage.client.dto.*;
import org.wso2.carbon.apimgt.usage.client.exception.APIMgtUsageQueryServiceClientException;
Expand All @@ -86,12 +87,12 @@
import javax.cache.Caching;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -701,7 +702,7 @@ public static boolean jsFunction_updateAPIDesign(Context cx, Scriptable thisObj,
}
if (apiData.containsKey("wsdl")) {
String wsdl = (String) apiData.get("wsdl", apiData);
if(wsdl != null && !wsdl.isEmpty()) {
if (StringUtils.isNotEmpty(wsdl)) {
api.setWsdlUrl(wsdl);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3479,7 +3479,7 @@ public static boolean jsFunction_updateApplication(Context cx,
throws ScriptException, APIManagementException {

if (args != null && args.length > 5 && isStringArray(args)) {
String name = (String) args[0];
String newName = (String) args[0];
String oldName = (String) args[1];
String username = (String) args[2];
String tier = (String) args[3];
Expand All @@ -3504,13 +3504,13 @@ public static boolean jsFunction_updateApplication(Context cx,
}

// check whether there is an app with same name
if (!name.equals(oldName) && appsMap.containsKey(name)) {
handleException("An application already exist by the name " + name);
if (!newName.equals(oldName) && appsMap.containsKey(newName)) {
handleException("An application already exist by the name " + newName);
}

for (Application app : apps) {
if (app.getName().equals(oldName)) {
Application application = new Application(name, subscriber);
Application application = new Application(newName, subscriber);
application.setId(app.getId());
application.setTier(tier);
application.setCallbackUrl(callbackUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.wso2.carbon.apimgt.impl;

import javax.ws.rs.POST;
import javax.xml.namespace.QName;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -734,5 +733,25 @@ public static enum SupportedHTTPVerbs {
public static final String SWAGGER_INFO = "info";
public static final String SWAGGER_RESPONSE_200 = "200";

//swagger v1.2 constants
public static final String SWAGGER_RESOURCES = "resources";
public static final String ENVIRONMENTS_NONE = "none";
public static final String SWAGGER_BASEPATH = "basePath";
public static final String SWAGGER_OPERATIONS = "operations";
public static final String METHOD_PATCH = "PATCH";
public static final String SWAGGER_SCOPE = "scope";
public static final String SWAGGER_AUTH_TYPE = "auth_type";
public static final String API_THROTTLING_TIER = "throttling_tier";
public static final String API_MEDIATION_SCRIPT = "mediation_script";
public static final String API_SWAGGER_DOC = "api_doc";
public static final String SWAGGER_12_AUTH = "authorizations";
public static final String SWAGGER_12_OAUTH2 = "oauth2";
public static final String SWAGGER_12_SCOPES = "scopes";
public static final String API_ARRAY_NAME = "apis";
public static final String SWAGGER_HTTP_METHOD = "method";
public static final String SWAGGER_FILE = "file";
public static final String SWAGGER_RESOURCE_PATH = "resourcePath";
public static final String API_VERSION = "apiVersion";


}
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ public void updateAPI(API api) throws APIManagementException, FaultGatewaysExcep
Map<String, Map<String, String>> failedGateways = new ConcurrentHashMap<String, Map<String, String>>();
API oldApi = getAPI(api.getId());
if (oldApi.getStatus().equals(api.getStatus())) {
try {

String previousDefaultVersion = getDefaultVersion(api.getId());
String publishedDefaultVersion = getPublishedDefaultVersion(api.getId());
Expand Down Expand Up @@ -675,9 +674,7 @@ public void updateAPI(API api) throws APIManagementException, FaultGatewaysExcep
contextCache.put(api.getContext(), true);
}

} catch (APIManagementException e) {
handleException("Error while updating the API :" + api.getId().getApiName() + ". " + e.getMessage(), e);
}

} else {
// We don't allow API status updates via this method.
// Use changeAPIStatus for that kind of updates.
Expand Down Expand Up @@ -2451,8 +2448,6 @@ public void saveSwagger20Definition(APIIdentifier apiId, String jsonText) throws
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
definitionFromSwagger20.saveAPIDefinition(getAPI(apiId), jsonText, registry);

} catch (APIManagementException e) {
handleException("Error while adding Swagger v2.0 Definition for " + apiId.getApiName() + "-" + apiId.getVersion(), e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
Expand Down

0 comments on commit 783d979

Please sign in to comment.