parsing using jackson

This commit is contained in:
Radek Davidek 2025-10-16 13:30:19 +02:00
parent 5507cb938e
commit 8063ebb638
32 changed files with 9 additions and 3817 deletions

15
pom.xml
View File

@ -33,16 +33,6 @@
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.13.1</version> <version>2.13.1</version>
</dependency> </dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.4</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
@ -53,11 +43,6 @@
<artifactId>jackson-dataformat-yaml</artifactId> <artifactId>jackson-dataformat-yaml</artifactId>
<version>2.19.2</version> <version>2.19.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.18.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -17,8 +17,9 @@ import javax.net.ssl.HttpsURLConnection;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.Yaml;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
@ -37,7 +38,9 @@ public abstract class AbstractProcess {
protected Gson gson; protected Gson gson;
protected Yaml yaml; protected ObjectMapper mapper;
protected ObjectMapper mapperYaml;
protected ConfigManager config = ConfigManager.getInstance(); protected ConfigManager config = ConfigManager.getInstance();
@ -45,7 +48,8 @@ public abstract class AbstractProcess {
gson = new GsonBuilder().create(); gson = new GsonBuilder().create();
yaml = new Yaml(); mapper = new ObjectMapper();
mapperYaml = new ObjectMapper(new YAMLFactory());
setTrustStoreCredentials(); setTrustStoreCredentials();

View File

@ -14,10 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.Yaml;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -30,7 +27,6 @@ import cz.trask.migration.model.HttpResponse;
import cz.trask.migration.model.RegisterResponse; import cz.trask.migration.model.RegisterResponse;
import cz.trask.migration.model.TokenResponse; import cz.trask.migration.model.TokenResponse;
import cz.trask.migration.model.ZipEntryData; import cz.trask.migration.model.ZipEntryData;
import cz.trask.migration.model.v32.ApiDefinition;
import io.apicurio.registry.rest.client.RegistryClient; import io.apicurio.registry.rest.client.RegistryClient;
import io.apicurio.registry.rest.client.RegistryClientFactory; import io.apicurio.registry.rest.client.RegistryClientFactory;
import io.apicurio.registry.rest.client.exception.VersionAlreadyExistsException; import io.apicurio.registry.rest.client.exception.VersionAlreadyExistsException;
@ -177,7 +173,7 @@ public class ImportToApicurio extends AbstractProcess {
+ devPortUrl; + devPortUrl;
// 6) Update the swagger with the description and servers // 6) Update the swagger with the description and servers
Map<String, Object> swaggerMap = yaml.load(swagger); Map<String, Object> swaggerMap = mapperYaml.readValue(swagger, Map.class);
JsonObject swaggerObj = gson.toJsonTree(swaggerMap).getAsJsonObject(); JsonObject swaggerObj = gson.toJsonTree(swaggerMap).getAsJsonObject();
updateSwagger(swaggerObj, apiMap, fullDesc); updateSwagger(swaggerObj, apiMap, fullDesc);
@ -326,8 +322,7 @@ public class ImportToApicurio extends AbstractProcess {
for (ZipEntryData entry : zipEntries) { for (ZipEntryData entry : zipEntries) {
String artifactId = api.getName() + "/" + api.getVersion() + "/" + entry.getName(); String artifactId = api.getName() + "/" + api.getVersion() + "/" + entry.getName();
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); //ApiDefinition apiDef = mapper.readValue(entry.getContent(), ApiDefinition.class);
ApiDefinition apiDef = mapper.readValue(entry.getContent(), ApiDefinition.class);
// Create the artifact (versioned) // Create the artifact (versioned)
try (ByteArrayInputStream is = new ByteArrayInputStream(entry.getContent())) { try (ByteArrayInputStream is = new ByteArrayInputStream(entry.getContent())) {

File diff suppressed because it is too large Load Diff

View File

@ -1,80 +0,0 @@
/*
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
/**
* This class represents API Categories
*/
public class APICategory {
private String id;
private String name;
private String description;
private int numberOfAPIs;
private int tenantID;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public void setTenantID(int tenantID) {
this.tenantID = tenantID;
}
public int getTenantID() {
return tenantID;
}
public void setNumberOfAPIs(int numberOfAPIs) {
this.numberOfAPIs = numberOfAPIs;
}
public int getNumberOfAPIs() {
return numberOfAPIs;
}
/**
* Name,TenantID combination is unique and cannot be duplicated. Hence two API category objects t1 and t2 are
* considered equal if both have the same name and same tenant id
*
* @param obj
* @return
*/
public boolean equals(Object obj) {
return this.tenantID == ((APICategory)obj).getTenantID() && this.getName().equals(((APICategory) obj).getName());
}
}

View File

@ -1,67 +0,0 @@
/*
*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
public class APIEndpoint {
private Endpoint inline = null;
private String type = null;
private String key = null;
public Endpoint getInline() {
return inline;
}
public void setInline(Endpoint inline) {
this.inline = inline;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Override
public String toString() {
return "APIEndpoint{" +
"inline=" + inline +
", type='" + type + '\'' +
", key='" + key + '\'' +
'}';
}
}

View File

@ -1,128 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
/**
* An API can be uniquely identified by a combination of providerName,apiName & version.
* This class represents this unique identifier.
*/
@SuppressWarnings("unused")
public class APIIdentifier implements Serializable, Identifier {
private static final long serialVersionUID = 1L;
private final String providerName;
private final String apiName;
private final String version;
private String tier;
private String applicationId;
private String uuid;
private int id;
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getTier() {
return tier;
}
public void setTier(String tier) {
this.tier = tier;
}
public APIIdentifier(String providerName, String apiName, String version) {
this.providerName = providerName;
this.apiName = apiName;
this.version = version;
}
public APIIdentifier(String apiId) throws Exception {
//eg: apiId = "P1_API1_v1.0.0"
String[] split = apiId.split("_");
if (split.length == 3) {
this.providerName = split[0];
this.apiName = split[1];
this.version = split[2];
} else {
throw new Exception("Invalid API ID : " + apiId);
}
}
public String getProviderName() {
return providerName;
}
public String getApiName() {
return apiName;
}
public String getVersion() {
return version;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
APIIdentifier that = (APIIdentifier) o;
return apiName.equals(that.apiName) && providerName.equals(that.providerName) &&
version.equals(that.version);
}
@Override
public int hashCode() {
int result = providerName.hashCode();
result = 31 * result + apiName.hashCode();
result = 31 * result + version.hashCode();
return result;
}
@Override
public String toString() {
return this.getProviderName() + '-' + this.getName() + '-' + this.getVersion();
}
@Override
public String getName() {
return apiName;
}
@Override
public String getUUID() {
return uuid;
}
@Override
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}

View File

@ -1,126 +0,0 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
import java.util.Objects;
/**
* API Product identifier.
*
*/
public class APIProductIdentifier implements Serializable, Identifier {
private static final long serialVersionUID = 1L;
private final String providerName;
private final String apiProductName;
//In this initial api product implementation versioning is not supported, we are setting a default version to all api products
//however we will create these models in such a way so that versioning can be easily introduced later.
private final String version;
private String tier;
private String applicationId;
private String uuid;
private int productId;
public APIProductIdentifier(String providerName, String apiProductName, String version){
this.apiProductName = apiProductName;
this.providerName = providerName;
this.version = "1.0.0";
}
public String getTier() {
return tier;
}
public void setTier(String tier) {
this.tier = tier;
}
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public void setUUID(String uuid) {
this.uuid = uuid;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof APIProductIdentifier)) {
return false;
}
APIProductIdentifier that = (APIProductIdentifier) o;
return Objects.equals(apiProductName, that.apiProductName) &&
Objects.equals(providerName, that.providerName) &&
Objects.equals(version, that.version);
}
@Override
public int hashCode() {
return Objects.hash(providerName, apiProductName, version);
}
@Override
public String toString() {
return this.getProviderName() + '-' + this.getName();
}
@Override
public String getName() {
// API name of the product is the product name
return apiProductName;
}
@Override
public String getVersion() {
return version;
}
@Override
public String getUUID() {
return uuid;
}
@Override
public String getProviderName() {
return providerName;
}
@Override
public int getId() {
return productId;
}
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
/**
* Status of an API can be anyone from following list.
*/
public enum APIStatus {
CREATED("CREATED"), PUBLISHED("PUBLISHED"),
DEPRECATED("DEPRECATED"), RETIRED("RETIRED"), BLOCKED("BLOCKED"), PROTOTYPED("PROTOTYPED");
private String status;
APIStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
}

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
/**
* Authorization Policy associated with a given API.
*/
@SuppressWarnings("unused")
public class AuthorizationPolicy implements Serializable{
private static final long serialVersionUID = 1L;
private String policyURL;
public AuthorizationPolicy(String policyURL) {
this.policyURL = policyURL;
}
public String getPolicyURL() {
return policyURL;
}
}

View File

@ -1,83 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.util.List;
import java.util.List;
/**
* API CORS Configuration
*/
public class CORSConfiguration {
private boolean corsConfigurationEnabled;
private List<String> accessControlAllowOrigins;
private boolean accessControlAllowCredentials;
private List<String> accessControlAllowHeaders;
private List<String> accessControlAllowMethods;
public CORSConfiguration(boolean corsConfigurationEnabled, List<String> accessControlAllowOrigins,
boolean accessControlAllowCredentials,
List<String> accessControlAllowHeaders, List<String> accessControlAllowMethods) {
this.corsConfigurationEnabled = corsConfigurationEnabled;
this.accessControlAllowOrigins = accessControlAllowOrigins;
this.accessControlAllowCredentials = accessControlAllowCredentials;
this.accessControlAllowHeaders = accessControlAllowHeaders;
this.accessControlAllowMethods = accessControlAllowMethods;
}
public boolean isCorsConfigurationEnabled() {
return corsConfigurationEnabled;
}
public void setCorsConfigurationEnabled(boolean corsConfigurationEnabled) {
this.corsConfigurationEnabled = corsConfigurationEnabled;
}
public List<String> getAccessControlAllowOrigins() {
return accessControlAllowOrigins;
}
public void setAccessControlAllowOrigins(List<String> accessControlAllowOrigins) {
this.accessControlAllowOrigins = accessControlAllowOrigins;
}
public boolean isAccessControlAllowCredentials() {
return accessControlAllowCredentials;
}
public void setAccessControlAllowCredentials(boolean accessControlAllowCredentials) {
this.accessControlAllowCredentials = accessControlAllowCredentials;
}
public List<String> getAccessControlAllowHeaders() {
return accessControlAllowHeaders;
}
public void setAccessControlAllowHeaders(List<String> accessControlAllowHeaders) {
this.accessControlAllowHeaders = accessControlAllowHeaders;
}
public List<String> getAccessControlAllowMethods() {
return accessControlAllowMethods;
}
public void setAccessControlAllowMethods(List<String> accessControlAllowMethods) {
this.accessControlAllowMethods = accessControlAllowMethods;
}
}

View File

@ -1,69 +0,0 @@
/*
*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* /
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
/**
* This DTO used to represent a specific condition inside a Condition Group. This is analogous to {@code Condition}
* object.
*/
public class ConditionDTO implements Serializable{
private static final long serialVersionUID = 1L;
private String conditionType;
private String conditionName;
private String conditionValue;
private boolean isInverted;
public String getConditionType() {
return conditionType;
}
public String getConditionName() {
return conditionName;
}
public void setConditionName(String conditionName) {
this.conditionName = conditionName;
}
public String getConditionValue() {
return conditionValue;
}
public void setConditionValue(String conditionValue) {
this.conditionValue = conditionValue;
}
public boolean isInverted() {
return isInverted;
}
public void setConditionType(String conditionType) {
this.conditionType = conditionType;
}
public void isInverted(boolean invertCondition) {
this.isInverted = invertCondition;
}
}

View File

@ -1,51 +0,0 @@
/*
*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* /
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
/**
* DTO used to represent a ConditionGroup. This is analogous to {@code Pipeline} class and has a subset of attributes
* defined in that.
*/
public class ConditionGroupDTO implements Serializable{
private static final long serialVersionUID = 1L;
private String conditionGroupId;
private ConditionDTO [] conditions;
public String getConditionGroupId() {
return conditionGroupId;
}
public void setConditionGroupId(String conditionGroupId) {
this.conditionGroupId = conditionGroupId;
}
public ConditionDTO[] getConditions() {
return conditions;
}
public void setConditions(ConditionDTO[] conditions) {
this.conditions = conditions;
}
}

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.util.List;
import java.util.Map;
public class DeploymentEnvironments {
//use this class to build the model for selected deployment environments
private String type;
private List<String> clusterNames;
public DeploymentEnvironments(String type, List<String> clusterNames) {
this.type = type;
this.clusterNames = clusterNames;
}
public DeploymentEnvironments() {
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<String> getClusterNames() {
return clusterNames;
}
public void setClusterNames(List<String> clusterNames) {
this.clusterNames = clusterNames;
}
}

View File

@ -1,171 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
import java.util.Date;
/**
* Documentation for API. There can be several types of documentation. Refer {@link DocumentationType}.
*
* @see DocumentationType
*/
@SuppressWarnings("unused")
public class Documentation implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private DocumentationType type;
private String name;
private String summary;
private DocumentSourceType sourceType;
private String sourceUrl;
private DocumentVisibility visibility;
private Date lastUpdated;
private String filePath;
private Date createdDate;
public String getOtherTypeName() {
return otherTypeName;
}
public void setOtherTypeName(String otherTypeName) {
this.otherTypeName = otherTypeName;
}
private String otherTypeName;
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getSourceUrl() {
return sourceUrl;
}
public void setSourceUrl(String sourceUrl) {
this.sourceUrl = sourceUrl;
}
public Documentation(DocumentationType type, String name) {
this.type = type;
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Documentation that = (Documentation) o;
return name.equals(that.name) && type == that.type;
}
public DocumentationType getType() {
return type;
}
public String getName() {
return name;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public DocumentVisibility getVisibility() {
return visibility;
}
public void setVisibility(DocumentVisibility visibility) {
this.visibility = visibility;
}
public DocumentSourceType getSourceType() {
return sourceType;
}
public void setSourceType(DocumentSourceType sourceType) {
this.sourceType = sourceType;
}
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + name.hashCode();
return result;
}
public Date getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
public enum DocumentSourceType {
INLINE("In line"), MARKDOWN("Markdown"), URL("URL"), FILE("File");
private String type;
private DocumentSourceType(String type) {
this.type = type;
}
}
public enum DocumentVisibility {
OWNER_ONLY("owner_only"), PRIVATE("private"), API_LEVEL("api_level");
private String visibility;
private DocumentVisibility(String visibility) {
this.visibility = visibility;
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
/**
* Types of Documentation that can exist for an API.
*/
@SuppressWarnings("unused")
public enum DocumentationType {
HOWTO("How To"),
SAMPLES("Samples"),
PUBLIC_FORUM("Public Forum"),
SUPPORT_FORUM("Support Forum"),
API_MESSAGE_FORMAT("API Message Format"),
SWAGGER_DOC("Swagger API Definition"),
OTHER("Other");
private String type;
private DocumentationType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}

View File

@ -1,106 +0,0 @@
/*
*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
public class Endpoint {
private String id = null;
private String name = null;
private EndpointEndpointConfig endpointConfig = null;
private EndpointSecurity endpointSecurity = null;
private Long maxTps = null;
private String type = null;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public EndpointEndpointConfig getEndpointConfig() {
return endpointConfig;
}
public void setEndpointConfig(EndpointEndpointConfig endpointConfig) {
this.endpointConfig = endpointConfig;
}
public EndpointSecurity getEndpointSecurity() {
return endpointSecurity;
}
public void setEndpointSecurity(EndpointSecurity endpointSecurity) {
this.endpointSecurity = endpointSecurity;
}
public Long getMaxTps() {
return maxTps;
}
public void setMaxTps(Long maxTps) {
this.maxTps = maxTps;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "Endpoint{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", endpointConfig=" + endpointConfig +
", endpointSecurity=" + endpointSecurity +
", maxTps=" + maxTps +
", type='" + type + '\'' +
'}';
}
}

View File

@ -1,87 +0,0 @@
/*
*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
import java.util.ArrayList;
import java.util.List;
public class EndpointConfig {
private String url = null;
private String timeout = null;
private Boolean isPrimary = null;
private List<EndpointConfigAttributes> attributes = new ArrayList<EndpointConfigAttributes>();
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTimeout() {
return timeout;
}
public void setTimeout(String timeout) {
this.timeout = timeout;
}
public Boolean getPrimary() {
return isPrimary;
}
public void setPrimary(Boolean primary) {
isPrimary = primary;
}
public List<EndpointConfigAttributes> getAttributes() {
return attributes;
}
public void setAttributes(List<EndpointConfigAttributes> attributes) {
this.attributes = attributes;
}
@Override
public String toString() {
return "EndpointConfig{" +
"url='" + url + '\'' +
", timeout='" + timeout + '\'' +
", isPrimary=" + isPrimary +
", attributes=" + attributes +
'}';
}
}

View File

@ -1,55 +0,0 @@
/*
*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
public class EndpointConfigAttributes {
private String name = null;
private String value = null;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "EndpointConfigAttributes{" +
"name='" + name + '\'' +
", value='" + value + '\'' +
'}';
}
}

View File

@ -1,63 +0,0 @@
/*
*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
import java.util.ArrayList;
import java.util.List;
public class EndpointEndpointConfig {
public enum EndpointTypeEnum {
SINGLE, LOAD_BALANCED, FAIL_OVER,
};
private EndpointTypeEnum endpointType = null;
private List<EndpointConfig> list = new ArrayList<EndpointConfig>();
public EndpointTypeEnum getEndpointType() {
return endpointType;
}
public void setEndpointType(EndpointTypeEnum endpointType) {
this.endpointType = endpointType;
}
public List<EndpointConfig> getList() {
return list;
}
public void setList(List<EndpointConfig> list) {
this.list = list;
}
@Override
public String toString() {
return "EndpointEndpointConfig{" +
"endpointType=" + endpointType +
", list=" + list +
'}';
}
}

View File

@ -1,152 +0,0 @@
/*
*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package cz.trask.migration.model.v32;
import java.util.HashMap;
import java.util.Map;
public class EndpointSecurity {
private String uniqueIdentifier = null;
private String password = null;
private String type = null;
private boolean enabled = false;
private String username = null;
private String grantType = null;
private String tokenUrl = null;
private String clientId = null;
private String clientSecret = null;
private String customParameters = null;
private Map additionalProperties = new HashMap();
public String getUniqueIdentifier() {
return uniqueIdentifier;
}
public void setUniqueIdentifier(String uniqueIdentifier) {
this.uniqueIdentifier = uniqueIdentifier;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getGrantType() {
return grantType;
}
public void setGrantType(String grantType) {
this.grantType = grantType;
}
public String getTokenUrl() {
return tokenUrl;
}
public void setTokenUrl(String tokenUrl) {
this.tokenUrl = tokenUrl;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getCustomParameters() {
return customParameters;
}
public void setCustomParameters(String customParameters) {
this.customParameters = customParameters;
}
public Map getAdditionalProperties() {
return additionalProperties;
}
public void setAdditionalProperties(Map additionalProperties) {
this.additionalProperties = additionalProperties;
}
@Override public String toString() {
return "EndpointSecurity{" + "uniqueIdentifier='" + uniqueIdentifier + '\'' + ", password='" + password + '\''
+ ", type='" + type + '\'' + ", enabled=" + enabled + ", username='" + username + '\'' + ", grantType='"
+ grantType + '\'' + ", tokenUrl='" + tokenUrl + '\'' + ", clientId='" + clientId + '\''
+ ", clientSecret='" + clientSecret + '\'' + ", customParameters='" + customParameters + '\''
+ ", additionalProperties=" + additionalProperties + '}';
}
}

View File

@ -1,66 +0,0 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
/**
* Interface for All Identifiers
*/
public interface Identifier {
/**
* Name of provider
* @return name
*/
String getProviderName();
/**
* Tier related to the identifier
* @return Tier
*/
String getTier();
/**
* Set tier related to the identifier
* @param tier
* @return
*/
void setTier(String tier);
/**
* Name of the identifier
* @return name
*/
String getName();
/**
* Version of the identifier
* @return version
*/
String getVersion();
/**
* UUID of the identifier
* @return uuid
*/
String getUUID();
/**
* Internal API Id
* @return id
*/
int getId();
}

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* This class represent the Label
*/
public class Label {
private String labelId;
private String name;
private String tenantId;
private String description;
private List<String> accessUrls = new ArrayList<>();
public Label() {
}
public String getLabelId() {
return labelId;
}
public void setLabelId(String labelId) {
this.labelId = labelId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public List<String> getAccessUrls() {
return accessUrls;
}
public void setAccessUrls(List<String> accessUrls) {
this.accessUrls = accessUrls;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (this == obj) return true;
Label other = (Label) obj;
if (!Objects.equals(this.name, other.name)) return false;
if (!Objects.equals(this.labelId, other.labelId)) return false;
if (!Objects.equals(this.description, other.description)) return false;
if (!Objects.equals(this.tenantId, other.tenantId)) return false;
if (!Objects.equals(this.accessUrls, other.accessUrls)) return false;
return true;
}
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
public class Limit {
private String timeUnit;
private int unitTime;
public String getTimeUnit() {
return timeUnit;
}
public void setTimeUnit(String timeUnit) {
this.timeUnit = timeUnit;
}
public int getUnitTime() {
return unitTime;
}
public void setUnitTime(int unitTime) {
this.unitTime = unitTime;
}
@Override
public String toString() {
return "Limit [timeUnit=" + timeUnit + ", unitTime=" + unitTime + "]";
}
}

View File

@ -1,128 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Policy implements Serializable {
private static final long serialVersionUID = 1L;
private int policyId;
private String uuid;
private String policyName;
private String displayName;
private String description;
private QuotaPolicy defaultQuotaPolicy;
private int tenantId;
private String tenantDomain;
private boolean isDeployed;
public Policy(String name){
this.policyName = name;
this.policyId = -1;
this.tenantId = -1;
this.isDeployed = false;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPolicyName() {
return policyName;
}
public void setPolicyName(String policyName) {
this.policyName = policyName;
}
public String getUUID() {
return uuid;
}
public void setUUID(String uuid) {
this.uuid = uuid;
}
public void setDefaultQuotaPolicy(QuotaPolicy defaultQuotaPolicy) {
this.defaultQuotaPolicy = defaultQuotaPolicy;
}
public QuotaPolicy getDefaultQuotaPolicy() {
return defaultQuotaPolicy;
}
public int getPolicyId() {
return policyId;
}
public void setPolicyId(int policyId) {
this.policyId = policyId;
}
public boolean isDeployed() {
return isDeployed;
}
public void setDeployed(boolean deployed) {
isDeployed = deployed;
}
@Override
public String toString() {
return "Policy{" +
"defaultQuotaPolicy=" + defaultQuotaPolicy +
", policyName='" + policyName + '\'' +
", description='" + description + '\'' +
", tenantId=" + tenantId +
'}';
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getTenantDomain() {
return tenantDomain;
}
public void setTenantDomain(String tenantDomain) {
this.tenantDomain = tenantDomain;
}
}

View File

@ -1,121 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
public class PolicyConstants {
public static final String IP_RANGE_TYPE = "IPRange";
public static final String IP_SPECIFIC_TYPE ="IPSpecific";
public static final String HEADER_TYPE = "Header";
public static final String DATE_RANGE_TYPE = "DateRage";
public static final String DATE_SPECIFIC_TYPE = "DateSpecific";
public static final String JWT_CLAIMS_TYPE = "JWTClaims";
public static final String HTTP_VERB_TYPE = "HTTPVerb";
public static final String QUERY_PARAMETER_TYPE = "QueryParameterType";
public static final String BANDWIDTH_TYPE = "bandwidthVolume";
public static final String REQUEST_COUNT_TYPE = "requestCount";
public static final String DATE_QUERY = "date";
public static final String IP_QUERY = "ip";
public static final String IPv6_QUERY = "ipv6";
public static final String HTTP_VERB_QUERY = "verb";
public static final String OPEN_BRACKET = "(";
public static final String CLOSE_BRACKET = ")";
public static final String INVERT_CONDITION = "NOT";
public static final String EQUAL = "==";
public static final String AND = " AND ";
public static final String GREATER_THAN = ">=";
public static final String LESS_THAN = "<=";
public static final String QUOTE = "'";
public static final String COMMA = ",";
public static final String NULL_CHECK = "null";
public static final String START_QUERY = "cast(map:get(propertiesMap,'";
public static final String REGEX_PREFIX_QUERY = "regex:find(";
public static final String REGEX_SUFFIX_QUERY = ")";
public static final String NULL_START_QUERY = "map:get(propertiesMap,'";
public static final String END_QUERY = "'),'string')";
public static final String NULL_END_QUERY = "') is null";
public static final String END_QUERY_LONG = "'),'Long')";
public static final String END_LONG = "l";
public static final String PER_USER = "userLevel";
public static final String ACROSS_ALL = "apiLevel";
public static final String POLICY_LEVEL_API = "api";
public static final String POLICY_LEVEL_RESOURCE = "resource";
public static final String POLICY_LEVEL_SUB = "sub";
public static final String POLICY_LEVEL_GLOBAL = "global";
public static final String POLICY_LEVEL_APP = "app";
public static final String API_THROTTLE_POLICY_TABLE = "AM_API_THROTTLE_POLICY";
public static final String POLICY_GLOBAL_TABLE = "AM_POLICY_GLOBAL";
public static final String POLICY_SUBSCRIPTION_TABLE = "AM_POLICY_SUBSCRIPTION";
public static final String POLICY_APPLICATION_TABLE = "AM_POLICY_APPLICATION";
public static final String POLICY_ID = "POLICY_ID";
public static final String POLICY_IS_DEPLOYED = "IS_DEPLOYED";
public static final String MB = "MB";
public static final String KB = "KB";
public static final String MEDIATION_NAME_ATTRIBUTE = "name";
public static final String THROTTLING_TIER_CONTENT_AWARE_SEPERATOR = ">";
}

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
public class QuotaPolicy {
private String type;
private Limit limit;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Limit getLimit() {
return limit;
}
public void setLimit(Limit limit) {
this.limit = limit;
}
@Override
public String toString() {
return "QuotaPolicy [type=" + type + ", limit=" + limit + "]";
}
}

View File

@ -1,38 +0,0 @@
/*
* Copyright WSO2 Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cz.trask.migration.model.v32;
import java.io.InputStream;
public class ResourceFile {
private InputStream content;
private String contentType;
public ResourceFile(InputStream content, String contentType) {
this.content = content;
this.contentType = contentType;
}
public InputStream getContent() {
return content;
}
public String getContentType() {
return contentType;
}
}

View File

@ -1,100 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
import java.util.Objects;
public class Scope implements Serializable{
private static final long serialVersionUID = 1L;
String key;
String name;
String roles;
String description;
String id;
int usageCount;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRoles() {
return roles;
}
public void setRoles(String roles) {
this.roles = roles;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getUsageCount() {
return usageCount;
}
public void setUsageCount(int usageCount) {
this.usageCount = usageCount;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Scope scope = (Scope) o;
if (id != null ? !id.equals(scope.id) : scope.id != null) return false;
if (!key.equals(scope.key)) return false;
if (!name.equals(scope.name)) return false;
if (roles != null ? !roles.equals(scope.roles) : scope.roles != null) return false;
return description != null ? description.equals(scope.description) : scope.description == null;
}
@Override
public int hashCode() {
return Objects.hash(key, name, roles, description, id);
}
}

View File

@ -1,176 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
import java.util.Map;
/**
* This class represent the Tier
*/
@SuppressWarnings("unused")
public class Tier implements Serializable, Comparable<Tier>{
private static final long serialVersionUID = 1L;
private String name;
private String displayName;
private String description;
private byte[] policyContent;
private Map<String,Object> tierAttributes;
private long requestsPerMin = 0;
private long requestCount = 0;
private long unitTime = 0;
private String timeUnit = "ms";
private String tierPlan;
// The default value would be "true" since the default behavior is to stop when the quota is reached
private boolean stopOnQuotaReached = true;
private TierPermission tierPermission;
private Map<String,String> monetizationAttributes;
public Map<String, String> getMonetizationAttributes() {
return monetizationAttributes;
}
public void setMonetizationAttributes(Map<String, String> monetizationAttributes) {
this.monetizationAttributes = monetizationAttributes;
}
public Tier(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public byte[] getPolicyContent() {
return policyContent;
}
public void setPolicyContent(byte[] policyContent) {
this.policyContent = policyContent;
}
public Map<String,Object> getTierAttributes() {
return tierAttributes;
}
public void setTierAttributes(Map<String,Object> tierAttributes) {
this.tierAttributes = tierAttributes;
}
public long getRequestsPerMin() {
return requestsPerMin;
}
public void setRequestsPerMin(long requestsPerMin) {
this.requestsPerMin = requestsPerMin;
}
public long getRequestCount() {
return requestCount;
}
public void setRequestCount(long requestCount) {
this.requestCount = requestCount;
}
public long getUnitTime() {
return unitTime;
}
public void setUnitTime(long unitTime) {
this.unitTime = unitTime;
}
public String getTimeUnit() {
return timeUnit;
}
public void setTimeUnit(String timeUnit) {
this.timeUnit = timeUnit;
}
public String getTierPlan() {
return tierPlan;
}
public void setTierPlan(String tierPlan) {
this.tierPlan = tierPlan;
}
public boolean isStopOnQuotaReached() {
return stopOnQuotaReached;
}
public void setStopOnQuotaReached(boolean stopOnQuotaReached) {
this.stopOnQuotaReached = stopOnQuotaReached;
}
public TierPermission getTierPermission() {
return tierPermission;
}
public void setTierPermission(TierPermission tierPermission) {
this.tierPermission = tierPermission;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Tier tier = (Tier) o;
return !(name != null ? !name.equals(tier.name) : tier.name != null);
}
@Override
public int hashCode() {
return name != null ? name.hashCode() : 0;
}
@Override
public int compareTo(Tier tier) {
if(tier.getRequestsPerMin() == Long.MAX_VALUE || tier.getRequestsPerMin() == Integer.MAX_VALUE){
return 1;
}
else if(this.getRequestsPerMin() == Long.MAX_VALUE || this.getRequestsPerMin() == Integer.MAX_VALUE){
return -1;
}
return new Long(tier.getRequestsPerMin() - this.getRequestsPerMin()).intValue();
}
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cz.trask.migration.model.v32;
/**
* This class represents Tier Permissions
*/
public class TierPermission {
private String tierName;
private String permissionType;
private String[] roles;
public TierPermission(String name) {
this.tierName = name;
}
public String getTierName() {
return tierName;
}
public void setTierName(String tierName) {
this.tierName = tierName;
}
public String getPermissionType() {
return permissionType;
}
public void setPermissionType(String permissionType) {
this.permissionType = permissionType;
}
public String[] getRoles() {
return roles;
}
public void setRoles(String[] roles) {
this.roles = roles;
}
}

View File

@ -1,442 +0,0 @@
/*
* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package cz.trask.migration.model.v32;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.simple.JSONValue;
public class URITemplate implements Serializable{
private static final long serialVersionUID = 1L;
private String uriTemplate;
private String resourceURI;
private String resourceSandboxURI;
private String httpVerb;
private String authType;
private LinkedHashSet<String> httpVerbs = new LinkedHashSet<String>();
private List<String> authTypes = new ArrayList<String>();
private List<String> throttlingConditions = new ArrayList<String>();
private String applicableLevel;
private String throttlingTier;
private List<String> throttlingTiers = new ArrayList<String>();
private Scope scope;
private String mediationScript;
private List<Scope> scopes = new ArrayList<Scope>();
private Map<String, String> mediationScripts = new HashMap<String, String>();
private ConditionGroupDTO[] conditionGroups;
private int id;
private Set<APIProductIdentifier> usedByProducts = new HashSet<>();
private String amznResourceName;
private int amznResourceTimeout;
public ConditionGroupDTO[] getConditionGroups() {
return conditionGroups;
}
public void setConditionGroups(ConditionGroupDTO[] conditionGroups) {
this.conditionGroups = conditionGroups;
}
public String getMediationScript() {
return mediationScript;
}
public List<String> getThrottlingConditions() {
return throttlingConditions;
}
public void setThrottlingConditions(List<String> throttlingConditions) {
this.throttlingConditions = throttlingConditions;
}
public void setMediationScript(String mediationScript) {
this.mediationScript = mediationScript;
}
/**
* Set mediation script for a given http method
* @param method http method name
* @param mediationScript mediation script content
*/
public void setMediationScripts(String method, String mediationScript){
if (mediationScript != null && !mediationScript.trim().equals("") && !mediationScript.trim().equals("null")){
mediationScripts.put(method, mediationScript);
}
}
/**
* Generating the script by aggregating scripts of each http method to form a single script in to be
* used when generating synapse configuration file.
*
* @return aggregated script in the following format,
* if (http-method = 'GET'){
* //script for GET
* }
* ....
* ....
* if (http-method = 'POST'){
* //script for POST
* }
*/
public String getAggregatedMediationScript(){
if (mediationScripts.isEmpty()){
return "null";
}else if (mediationScripts.size() == 1 && httpVerbs.size() == 1){
return mediationScript;
}else{
StringBuilder aggregatedScript = new StringBuilder();
for (Map.Entry<String, String> entry : mediationScripts.entrySet()){
String httpMethod = entry.getKey();
String mediationScript = entry.getValue();
aggregatedScript.append("if (mc.getProperty('REST_METHOD') == '").append(httpMethod).append("'){");
aggregatedScript.append(mediationScript);
aggregatedScript.append("}");
}
return aggregatedScript.toString();
}
}
public String getThrottlingTier() {
return throttlingTier;
}
public void setThrottlingTier(String throttlingTier) {
this.throttlingTier = throttlingTier;
}
public List<String> getThrottlingTiers(){
return throttlingTiers;
}
public void setThrottlingTiers(List<String> throttlingTiers) {
this.throttlingTiers = throttlingTiers;
}
public String getHTTPVerb() {
return httpVerb;
}
public void setHTTPVerb(String httpVerb) {
this.httpVerb = httpVerb;
}
public String getAuthType() {
return authType;
}
public void setAuthType(String authType) {
this.authType = authType;
}
public String getResourceURI() {
return resourceURI;
}
public void setResourceURI(String resourceURI) {
this.resourceURI = resourceURI;
}
public boolean isResourceURIExist(){
return this.resourceURI != null;
}
public String getResourceSandboxURI() {
return resourceSandboxURI;
}
public void setResourceSandboxURI(String resourceSandboxURI) {
this.resourceSandboxURI = resourceSandboxURI;
}
public boolean isResourceSandboxURIExist(){
return this.resourceSandboxURI != null;
}
public String getUriTemplate() {
return uriTemplate;
}
public void setUriTemplate(String template) {
this.uriTemplate = template;
}
public void setHttpVerbs(String httpVerb) {
httpVerbs.add(httpVerb);
}
public String getHttpVerbs() {
return httpVerb;
}
public void setAuthTypes(String authType) {
authTypes.add(authType);
}
public String getAuthTypes() {
return authType;
}
public String getMethodsAsString() {
StringBuilder stringBuilder = new StringBuilder();
for (String method : httpVerbs) {
stringBuilder.append(method).append(" ");
}
return stringBuilder.toString().trim();
}
public String getAuthTypeAsString() {
StringBuilder stringBuilder = new StringBuilder();
for (String authType : authTypes) {
stringBuilder.append(authType).append(" ");
}
return stringBuilder.toString().trim();
}
public String getThrottlingConditionsAsString() {
StringBuilder stringBuilder = new StringBuilder();
for (String authType : throttlingConditions) {
stringBuilder.append(authType).append(" ");
}
return stringBuilder.toString().trim();
}
public void setThrottlingTiers(String tier) {
throttlingTiers.add(tier);
}
public String getThrottlingTiersAsString() {
StringBuilder stringBuilder = new StringBuilder();
for (String tier : throttlingTiers) {
if (tier.contains(PolicyConstants.THROTTLING_TIER_CONTENT_AWARE_SEPERATOR)) {
stringBuilder.append(tier.substring(0,
tier.indexOf(PolicyConstants.THROTTLING_TIER_CONTENT_AWARE_SEPERATOR)).trim()).append(" ");
} else {
stringBuilder.append(tier.trim()).append(" ");
}
}
return stringBuilder.toString().trim();
}
public boolean checkContentAwareFromThrottlingTiers() {
// use the content aware property appended to throttling tiers
if (!throttlingTiers.isEmpty()) {
String throttlingTierWithContentAware = throttlingTiers.get(0);
if (throttlingTierWithContentAware != null &&
throttlingTierWithContentAware.contains(PolicyConstants.THROTTLING_TIER_CONTENT_AWARE_SEPERATOR)) {
String[] splitThrottlingTiers =
throttlingTierWithContentAware.split(PolicyConstants.THROTTLING_TIER_CONTENT_AWARE_SEPERATOR);
return Boolean.valueOf(splitThrottlingTiers[splitThrottlingTiers.length - 1]);
}
}
return false;
}
public Scope getScope() {
return scope;
}
public Scope getScopes() {
return scope;
}
public void setScope(Scope scope) {
this.scope = scope;
}
public void setScopes(Scope scope){
this.scopes.add(scope);
}
public String getResourceMap(){
Map verbs = new LinkedHashMap();
int i = 0;
for (String method : httpVerbs) {
Map verb = new LinkedHashMap();
verb.put("auth_type",authTypes.get(i));
verb.put("throttling_tier",throttlingTiers.get(i));
//Following parameter is not required as it not need to reflect UI level. If need please enable it.
// /verb.put("throttling_conditions", throttlingConditions.get(i));
try{
Scope tmpScope = scopes.get(i);
if(tmpScope != null){
verb.put("scope",tmpScope.getKey());
}
}catch(IndexOutOfBoundsException e){
//todo need to rewrite to prevent this type of exceptions
}
verbs.put(method,verb);
i++;
}
//todo this is a hack to make key validation service stub from braking need to rewrite.
return JSONValue.toJSONString(verbs);
}
public String getApplicableLevel() {
return applicableLevel;
}
public void setApplicableLevel(String applicableLevel) {
this.applicableLevel = applicableLevel;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
URITemplate that = (URITemplate) o;
if (!uriTemplate.equals(that.uriTemplate)) {
return false;
}
if (resourceURI != null ? !resourceURI.equals(that.resourceURI) : that.resourceURI != null) {
return false;
}
if (resourceSandboxURI != null ? !resourceSandboxURI.equals(that.resourceSandboxURI) : that
.resourceSandboxURI != null) {
return false;
}
if (!httpVerb.equals(that.httpVerb)) {
return false;
}
if (!authType.equals(that.authType)) {
return false;
}
if (!httpVerbs.equals(that.httpVerbs)) {
return false;
}
if (!authTypes.equals(that.authTypes)) {
return false;
}
if (throttlingConditions != null ? !throttlingConditions.equals(that.throttlingConditions) : that
.throttlingConditions != null) {
return false;
}
if (applicableLevel != null ? !applicableLevel.equals(that.applicableLevel) : that.applicableLevel != null) {
return false;
}
if (!throttlingTier.equals(that.throttlingTier)) {
return false;
}
if (!throttlingTiers.equals(that.throttlingTiers)) {
return false;
}
if (scope != null ? !scope.equals(that.scope) : that.scope != null) {
return false;
}
if (mediationScript != null ? !mediationScript.equals(that.mediationScript) : that.mediationScript != null) {
return false;
}
if (scopes != null ? !scopes.equals(that.scopes) : that.scopes != null) {
return false;
}
if (mediationScripts != null ? !mediationScripts.equals(that.mediationScripts) : that.mediationScripts !=
null) {
return false;
}
// Probably incorrect - comparing Object[] arrays with Arrays.equals
return Arrays.equals(conditionGroups, that.conditionGroups);
}
@Override
public int hashCode() {
int result = uriTemplate.hashCode();
result = 31 * result + (resourceURI != null ? resourceURI.hashCode() : 0);
result = 31 * result + (resourceSandboxURI != null ? resourceSandboxURI.hashCode() : 0);
result = 31 * result + (httpVerb != null ? httpVerb.hashCode() : 0);
result = 31 * result + (authType != null ? authType.hashCode() : 0);
result = 31 * result + (httpVerbs != null ? httpVerbs.hashCode() : 0);
result = 31 * result + (authTypes != null ? authTypes.hashCode() : 0);
result = 31 * result + (throttlingConditions != null ? throttlingConditions.hashCode() : 0);
result = 31 * result + (applicableLevel != null ? applicableLevel.hashCode() : 0);
result = 31 * result + (throttlingTier != null ? throttlingTier.hashCode() : 0);
result = 31 * result + (throttlingTiers != null ? throttlingTiers.hashCode() : 0);
result = 31 * result + (scope != null ? scope.hashCode() : 0);
result = 31 * result + (mediationScript != null ? mediationScript.hashCode() : 0);
result = 31 * result + (scopes != null ? scopes.hashCode() : 0);
result = 31 * result + (mediationScripts != null ? mediationScripts.hashCode() : 0);
result = 31 * result + Arrays.hashCode(conditionGroups);
return result;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<Scope> retrieveAllScopes() {
return this.scopes;
}
public void addAllScopes(List<Scope> scopes) {
this.scopes = scopes;
}
public Set<APIProductIdentifier> retrieveUsedByProducts() {
return usedByProducts;
}
public void addUsedByProduct(APIProductIdentifier usedByProduct) {
usedByProducts.add(usedByProduct);
}
public void setAmznResourceName(String amznResourceName) {
this.amznResourceName = amznResourceName;
}
public String getAmznResourceName() {
return amznResourceName;
}
public void setAmznResourceTimeout(int amznResourceTimeout) {
this.amznResourceTimeout = amznResourceTimeout;
}
public int getAmznResourceTimeout() {
return amznResourceTimeout;
}
}