draft - apim 3.2 import
This commit is contained in:
parent
0bda9455ca
commit
67a5b59d00
@ -4,15 +4,13 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import cz.trask.migration.impl.ExportToWso2;
|
import cz.trask.migration.impl.ExportToWso2;
|
||||||
import cz.trask.migration.impl.ImportToApicurio;
|
import cz.trask.migration.impl.import32.ImportToApicurio;
|
||||||
import cz.trask.migration.model.StartParameters;
|
import cz.trask.migration.model.StartParameters;
|
||||||
|
|
||||||
public class ApiSync {
|
public class ApiSync {
|
||||||
|
|
||||||
private static Logger log = LogManager.getLogger(ApiSync.class);
|
private static Logger log = LogManager.getLogger(ApiSync.class);
|
||||||
|
|
||||||
protected final static String resourceName = "api-operator.properties";
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
log.info("API Operator started.");
|
log.info("API Operator started.");
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public final class ConfigManager {
|
|||||||
|
|
||||||
private static final Logger log = LogManager.getLogger(ConfigManager.class);
|
private static final Logger log = LogManager.getLogger(ConfigManager.class);
|
||||||
|
|
||||||
private static final String PROPERTY_FILENAME = "api-operator.properties";
|
private static final String PROPERTY_FILENAME = "apicurio-migrator.properties";
|
||||||
|
|
||||||
// SOURCE
|
// SOURCE
|
||||||
public static final String PROP_SOURCE_REGISTRATION_API_URL = "SOURCE_REGISTRATION_API_URL";
|
public static final String PROP_SOURCE_REGISTRATION_API_URL = "SOURCE_REGISTRATION_API_URL";
|
||||||
|
|||||||
@ -101,7 +101,7 @@ public class ExportToWso2 extends AbstractProcess {
|
|||||||
api.getId(), ver.getVersion());
|
api.getId(), ver.getVersion());
|
||||||
if (ref != null && !ref.isEmpty()) {
|
if (ref != null && !ref.isEmpty()) {
|
||||||
log.info("Artifact has {} references", ref.size());
|
log.info("Artifact has {} references", ref.size());
|
||||||
byte[] data = ZipUtils.prepareApiZipFile(client, ver, ref);
|
byte[] data = ZipUtils.prepareApiZipFile32to45(client, ver, ref);
|
||||||
String fileName = api.getName() + "-" + ver.getVersion() + ".zip";
|
String fileName = api.getName() + "-" + ver.getVersion() + ".zip";
|
||||||
if (data != null && data.length > 0 && fileName != null && !fileName.isEmpty()) {
|
if (data != null && data.length > 0 && fileName != null && !fileName.isEmpty()) {
|
||||||
int responseCode = publishApiToWso2(fileName, data, tokenResponse);
|
int responseCode = publishApiToWso2(fileName, data, tokenResponse);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package cz.trask.migration.impl;
|
package cz.trask.migration.impl.import32;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -1,5 +1,5 @@
|
|||||||
package cz.trask.migration.model;
|
package cz.trask.migration.model;
|
||||||
|
|
||||||
public enum FileType {
|
public enum FileType {
|
||||||
APIDEF, OPENAPI, WSDL, POLICY, UNKNOWN
|
APIDEF, OPENAPI, WSDL, POLICY_IN, POLICY_OUT, POLICY_FAULT, CERTIFICATE, UNKNOWN
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,14 +48,20 @@ public class ZipUtils {
|
|||||||
|
|
||||||
private static FileType determineFileType(String fileName) {
|
private static FileType determineFileType(String fileName) {
|
||||||
String lowerFileName = fileName.toLowerCase();
|
String lowerFileName = fileName.toLowerCase();
|
||||||
if (lowerFileName.endsWith("api.yaml")) {
|
if (lowerFileName.endsWith("/meta-information/api.yaml")) {
|
||||||
return FileType.APIDEF;
|
return FileType.APIDEF;
|
||||||
} else if (lowerFileName.contains("/definitions/swagger.yaml")) {
|
} else if (lowerFileName.endsWith("/meta-information/swagger.yaml")) {
|
||||||
return FileType.OPENAPI;
|
return FileType.OPENAPI;
|
||||||
} else if (lowerFileName.endsWith(".wsdl")) {
|
} else if (lowerFileName.endsWith(".wsdl")) {
|
||||||
return FileType.WSDL;
|
return FileType.WSDL;
|
||||||
} else if (lowerFileName.contains("/policies/")) {
|
} else if (lowerFileName.contains("/sequences/in-sequence")) {
|
||||||
return FileType.POLICY;
|
return FileType.POLICY_IN;
|
||||||
|
} else if (lowerFileName.contains("/sequences/out-sequence")) {
|
||||||
|
return FileType.POLICY_OUT;
|
||||||
|
} else if (lowerFileName.contains("/sequences/fault-sequence")) {
|
||||||
|
return FileType.POLICY_FAULT;
|
||||||
|
} else if (lowerFileName.endsWith("/meta-information/endpoint_certificates.yaml")) {
|
||||||
|
return FileType.CERTIFICATE;
|
||||||
}
|
}
|
||||||
return FileType.UNKNOWN;
|
return FileType.UNKNOWN;
|
||||||
}
|
}
|
||||||
@ -71,7 +77,7 @@ public class ZipUtils {
|
|||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] prepareApiZipFile(RegistryClient client, SearchedVersion ver, List<ArtifactReference> ref)
|
public static byte[] prepareApiZipFile32to45(RegistryClient client, SearchedVersion ver, List<ArtifactReference> ref)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
String baseDir = ver.getName() + "-" + ver.getVersion() + "/";
|
String baseDir = ver.getName() + "-" + ver.getVersion() + "/";
|
||||||
@ -88,7 +94,7 @@ public class ZipUtils {
|
|||||||
|
|
||||||
if (FileType.OPENAPI.toString().equals(amd.getGroupId())) {
|
if (FileType.OPENAPI.toString().equals(amd.getGroupId())) {
|
||||||
subDir = "Definitions/";
|
subDir = "Definitions/";
|
||||||
} else if (FileType.POLICY.toString().equals(amd.getGroupId())) {
|
} else if (FileType.POLICY_IN.toString().equals(amd.getGroupId())) {
|
||||||
subDir = "Policies/";
|
subDir = "Policies/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
SOURCE_REGISTRATION_API_URL = https://localhost:9443/client-registration/v0.17/register
|
SOURCE_REGISTRATION_API_URL = https://localhost:9443/client-registration/v0.17/register
|
||||||
SOURCE_PUBLISHER_API_URL = https://localhost:9443/api/am/publisher
|
SOURCE_PUBLISHER_API_URL = https://localhost:9443/api/am/publisher
|
||||||
SOURCE_DEVPORTAL_API_URL = https://localhost:9443/api/am/devportal
|
SOURCE_DEVPORTAL_API_URL = https://localhost:9443/api/am/store
|
||||||
SOURCE_PUBLISHER_TOKEN_URL = https://localhost:9443/oauth2/token
|
SOURCE_PUBLISHER_TOKEN_URL = https://localhost:9443/oauth2/token
|
||||||
SOURCE_WSO2_USER = YWRtaW46YWRtaW4=
|
SOURCE_WSO2_USER = YWRtaW46YWRtaW4=
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user