/bin/
/logs/
/target/
+/gateway/target/
+/gateway/logs/
--- /dev/null
+ACUMOS
+================================================================================
+Copyright © 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+================================================================================
+This Acumos software file is distributed by AT&T and Tech Mahindra
+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
+
+This file 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.
#Instance of this component could be gateway or adapter
#Based on the value configured, the behavior of this instance will vary.
-federated.instance=adapter
-federated.instance.name=ONAP
+federation.instance=adapter
+federation.instance.name=ONAP
#local config
-peersLocal.sourceUri=file:///home/jora/
+peersLocal.sourceUri=file:///{path_to_peers_local}
#Instance of this component could be gateway or adapter
#Based on the value configured, the behavior of this instance will vary.
-federated.instance=gateway
-federated.instance.name=ATT
-federated.peerGatewayOperator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
+federation.instance=gateway
+federation.instance.name=Acumos
+federation.operator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
-security.user.name=federated_client
-#security.user.password = ENC(CTQD7Xk5bOIuC4MaqRZtzjW1K4ArjCjr)
-security.user.password=federated_pass
-management.security.roles=SUPERUSER
-
-# CDmS REST endpoints are protected by HTTP Basic Authentication
+# CDMS REST endpoints are protected by HTTP Basic Authentication
#Common Data Source Configuration
cdms.client.url=http://localhost:8002/ccds
#cdms.client.url=http://localhost:8082/ccds
#Instance of this component could be gateway or adapter
#Based on the value configured, the behavior of this instance will vary.
-federated.instance=gateway
-federated.instance.name=ATT
+federation.instance=gateway
+federation.instance.name=ATT
#Task executor that run every x seconds
peer.jobchecker.interval=300
nexus.password=not4you
nexus.groupId=com.artifact
nexus.proxy=http://some.proxy.com:8080
-###################################################################
\ No newline at end of file
+###################################################################
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</authConfig>
<images>
<image>
- <name>federated-gateway:${project.version}</name>
+ <name>federation-gateway:${project.version}</name>
<build>
<!-- This is the same FROM used in a Dockerfile -->
<from>openjdk:8-jdk</from>
<!-- </execution> -->
<!-- </executions> -->
</plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.7.6.201602180812</version>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
<distributionManagement>
import org.acumos.federation.gateway.service.impl.Clients;
import org.acumos.federation.gateway.service.impl.FederationClient;
import org.acumos.federation.gateway.util.Utils;
+
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.BeanInitializationException;
//import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpStatusCodeException;
import org.acumos.cds.AccessTypeCode;
import org.acumos.cds.ValidationStatusCode;
import org.acumos.cds.client.ICommonDataServiceRestClient;
import org.acumos.cds.domain.MLPArtifact;
import org.acumos.cds.domain.MLPPeer;
+import org.acumos.cds.domain.MLPPeerSubscription;
import org.acumos.cds.domain.MLPSolution;
import org.acumos.cds.domain.MLPSolutionRevision;
@Component("peergateway")
//@Scope("singleton")
-@ConfigurationProperties(prefix="federated")
+@ConfigurationProperties(prefix="federation")
@Conditional(GatewayCondition.class)
public class PeerGateway {
private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerGateway.class);
- private String peerGatewayOperator = "testUser";
+ private String operator;
private TaskExecutor taskExecutor;
@Autowired
private Environment env;
public void initPeerGateway() {
logger.debug(EELFLoggerDelegate.debugLogger, "initPeerGateway");
- /*if (this.asdc.getUri() == null)
- throw new BeanInitializationException("Forgot to configure the SDC uri??");*/
+ /* make sure an operator was specified and that it is a declared user */
+ if (null == this.env.getProperty("federation.operator")) {
+ throw new BeanInitializationException("Missing 'federation.operator' configuration");
+ }
+ else {
+ try {
+ if (null == this.clients.getClient().getUser(
+ this.env.getProperty("federation.operator"))) {
+ logger.warn(EELFLoggerDelegate.errorLogger, "'federation.operator' does not point to an existing user");
+ }
+ }
+ catch (HttpStatusCodeException dx) {
+ logger.warn(EELFLoggerDelegate.errorLogger, "failed to verify 'federation.operator' value", dx);
+ }
+ }
this.taskExecutor = new ThreadPoolTaskExecutor();
((ThreadPoolTaskExecutor)this.taskExecutor).setCorePoolSize(1);
logger.debug(EELFLoggerDelegate.debugLogger, "PeerGateway destroyed");
}
+ protected String getOwnerId(MLPPeerSubscription theSubscription/*,
+ MLPSolution theSolution*/) {
+ // Need to get from c_user table . It has to be admin user
+ return this.env.getProperty("federation.operator");
+ }
+
@EventListener
public void handlePeerSubscriptionUpdate(PeerSubscriptionEvent theEvent) {
logger.info(EELFLoggerDelegate.debugLogger, "received peer subscription update event " + theEvent);
- taskExecutor.execute(new PeerGatewayUpdateTask(theEvent.getPeer(), theEvent.getSolutions()));
+ taskExecutor.execute(
+ new PeerGatewayUpdateTask(theEvent.getPeer(),
+ theEvent.getSubscription(),
+ theEvent.getSolutions()));
}
public class PeerGatewayUpdateTask implements Runnable {
- private MLPPeer peer;
- private List<MLPSolution> solutions;
+ private MLPPeer peer;
+ private MLPPeerSubscription sub;
+ private List<MLPSolution> solutions;
+
- public PeerGatewayUpdateTask(MLPPeer thePeer, List<MLPSolution> theSolutions) {
+ public PeerGatewayUpdateTask(MLPPeer thePeer,
+ MLPPeerSubscription theSub,
+ List<MLPSolution> theSolutions) {
this.peer = thePeer;
+ this.sub = theSub;
this.solutions = theSolutions;
}
}
}
- private MLPSolution createMLPSolution(MLPSolution peerMLPSolution, ICommonDataServiceRestClient cdsClient) {
+ private MLPSolution createMLPSolution(
+ MLPSolution peerMLPSolution,
+ ICommonDataServiceRestClient cdsClient) {
logger.info(EELFLoggerDelegate.debugLogger, "Creating Local MLP Solutino for peer solution " + peerMLPSolution);
MLPSolution mlpSolution = new MLPSolution();
mlpSolution.setSolutionId(peerMLPSolution.getSolutionId());
mlpSolution.setValidationStatusCode(ValidationStatusCode.PS.toString());
mlpSolution.setCreated(peerMLPSolution.getCreated());
mlpSolution.setModified(peerMLPSolution.getModified());
- mlpSolution.setOwnerId(env.getProperty("federated.peerGatewayOperator")); // Need to get from c_user table . It has to be admin user
+ mlpSolution.setOwnerId(getOwnerId(this.sub));
try {
cdsClient.createSolution(mlpSolution);
} catch (Exception e) {
return mlpSolution;
}
- private MLPSolutionRevision createMLPSolutionRevision(MLPSolutionRevision mlpSolutionRevision, ICommonDataServiceRestClient cdsClient) {
+ private MLPSolutionRevision createMLPSolutionRevision(
+ MLPSolutionRevision mlpSolutionRevision,
+ ICommonDataServiceRestClient cdsClient) {
MLPSolutionRevision solutionRevision = new MLPSolutionRevision();
solutionRevision.setSolutionId(mlpSolutionRevision.getSolutionId());
solutionRevision.setRevisionId(mlpSolutionRevision.getRevisionId());
solutionRevision.setVersion(mlpSolutionRevision.getVersion());
solutionRevision.setDescription(mlpSolutionRevision.getDescription());
- solutionRevision.setOwnerId(env.getProperty("federated.peerGatewayOperator"));//TODO
+ solutionRevision.setOwnerId(getOwnerId(this.sub));
solutionRevision.setMetadata(mlpSolutionRevision.getMetadata());
solutionRevision.setCreated(mlpSolutionRevision.getCreated());
solutionRevision.setModified(mlpSolutionRevision.getModified());
artifact.setMetadata(mlpArtifact.getMetadata());
artifact.setModified(mlpArtifact.getModified());
artifact.setName(mlpArtifact.getName());
- artifact.setOwnerId(env.getProperty("federated.peerGatewayOperator"));
+ artifact.setOwnerId(getOwnerId(this.sub));
artifact.setSize(mlpArtifact.getSize());;
artifact.setUri(mlpArtifact.getUri());
artifact.setVersion(mlpArtifact.getVersion());
localMLPArtifact.setMetadata(peerMLPArtifact.getMetadata());
localMLPArtifact.setModified(peerMLPArtifact.getModified());
localMLPArtifact.setName(peerMLPArtifact.getName());
- localMLPArtifact.setOwnerId(env.getProperty("federated.peerGatewayOperator"));
+ localMLPArtifact.setOwnerId(getOwnerId(this.sub));
localMLPArtifact.setSize(peerMLPArtifact.getSize());;
localMLPArtifact.setUri(peerMLPArtifact.getUri());
localMLPArtifact.setVersion(peerMLPArtifact.getVersion());
localMLPSolution.setActive(peerMLPSolution.isActive());
localMLPSolution.setToolkitTypeCode(peerMLPSolution.getToolkitTypeCode());
localMLPSolution.setValidationStatusCode(localMLPSolution.getValidationStatusCode());
- localMLPSolution.setOwnerId(env.getProperty("federated.peerGatewayOperator")); // Need to get from c_user table . It has to be admin user
+ localMLPSolution.setOwnerId(getOwnerId(this.sub));
+
try {
cdsClient.updateSolution(localMLPSolution);
} catch (Exception e) {
private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ONAP.class);
private ASDC asdc = new ASDC();
- private String asdcOperator = "admin";
+ private String asdcOperator;
private TaskExecutor taskExecutor;
@Autowired
private Clients clients;
logger.debug(EELFLoggerDelegate.debugLogger, "initOnap");
if (this.asdc.getUri() == null)
- throw new BeanInitializationException("Forgot to configure the SDC uri??");
+ throw new BeanInitializationException("Forgot to configure the SDC uri ('onap.sdcUri') ??");
+ if (this.asdcOperator == null)
+ throw new BeanInitializationException("Forgot to configure the SDC user ('onap.sdcOperator) ??");
this.taskExecutor = new ThreadPoolTaskExecutor();
((ThreadPoolTaskExecutor)this.taskExecutor).setCorePoolSize(1);
fedClient.getSolutionsRevisionListFromPeer(theSolution.getSolutionId(), null).getResponseBody();
}
catch (Exception x) {
- logger.warn(EELFLoggerDelegate.debugLogger, "Failed to retrieve acumos revisions: " + x);
+ logger.warn(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos revisions: " + x);
throw x;
}
Environment env = theContext.getEnvironment();
return super.matches(theContext, theMetadata) &&
null != env &&
- "ONAP".equals(env.getProperty("federated.instance.name"));
+ "ONAP".equals(env.getProperty("federation.instance.name"));
}
}
return theExecution.executeAsync(theRequest, theBody);
}
}
-
-//amdocs: "http://dcaedt:dcae123@135.16.121.89:8080#demo"));
- public static void main(String[] theArgs) throws Exception {
-
- CommandLineParser parser = new BasicParser();
-
- Options options = new Options();
- options.addOption(OptionBuilder
- .withArgName("target")
- .withLongOpt("target")
- .withDescription("target asdc system")
- .hasArg()
- .isRequired()
- .create('t') );
-
- options.addOption(OptionBuilder
- .withArgName("rootPath")
- .withLongOpt("rootpath")
- .withDescription("asdc rootpath")
- .hasArg()
- .isRequired()
- .create('r') );
-
- options.addOption(OptionBuilder
- .withArgName("action")
- .withLongOpt("action")
- .withDescription("one of: list, get, getartifact, checkin, checkout")
- .hasArg()
- .isRequired()
- .create('a') );
-
- options.addOption(OptionBuilder
- .withArgName("assetType")
- .withLongOpt("assetType")
- .withDescription("one of resource, service, product")
- .hasArg()
- .isRequired()
- .create('k') ); //k for 'kind' ..
-
- options.addOption(OptionBuilder
- .withArgName("assetId")
- .withLongOpt("assetId")
- .withDescription("asset uuid")
- .hasArg()
- .create('u') ); //u for 'uuid'
-
- options.addOption(OptionBuilder
- .withArgName("artifactId")
- .withLongOpt("artifactId")
- .withDescription("artifact uuid")
- .hasArg()
- .create('s') ); //s for 'stuff'
- options.addOption(OptionBuilder
- .withArgName("instance")
- .withLongOpt("instance")
- .withDescription("asset instance name")
- .hasArg()
- .create('i') );
- options.addOption(OptionBuilder
- .withArgName("listFilter")
- .withLongOpt("listFilter")
- .withDescription("filter for list operations")
- .hasArg()
- .create('f') ); //u for 'uuid'
-
- CommandLine line = null;
- try {
- line = parser.parse(options, theArgs);
- }
- catch(ParseException exp) {
- System.err.println(exp.getMessage());
- new HelpFormatter().printHelp("asdc", options);
- return;
- }
-
- ASDC asdc = new ASDC();
- asdc.setUri(new URI(line.getOptionValue("target")));
- asdc.setRootPath(line.getOptionValue("rootpath"));
-
- String instance = line.getOptionValue("instance");
- String action = line.getOptionValue("action");
- if (action.equals("list")) {
- JSONObject filterInfo = new JSONObject(
- line.hasOption("listFilter") ?
- line.getOptionValue("listFilter") : "{}");
- JSONArray assets =
- asdc.getAssets(ASDC.AssetType.valueOf(line.getOptionValue("assetType")), JSONArray.class,
- filterInfo.optString("category", null), filterInfo.optString("subCategory", null))
- .waitForResult();
- for (int i = 0; i < assets.length(); i++) {
- System.out.println("> " + assets.getJSONObject(i).toString(2));
- }
- }
- else if (action.equals("get")) {
- System.out.println(
- asdc.getAsset(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
- UUID.fromString(line.getOptionValue("assetId")),
- JSONObject.class)
- .waitForResult()
- .toString(2)
- );
- }
- else if (action.equals("getartifact")) {
- if (instance == null) {
- System.out.println(
- asdc.getAssetArtifact(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
- UUID.fromString(line.getOptionValue("assetId")),
- UUID.fromString(line.getOptionValue("artifactId")),
- String.class)
- .waitForResult()
- );
- }
- else {
- System.out.println(
- asdc.getAssetInstanceArtifact(
- ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
- UUID.fromString(line.getOptionValue("assetId")),
- instance,
- UUID.fromString(line.getOptionValue("artifactId")),
- String.class)
- .waitForResult()
- );
- }
- }
- else if (action.equals("checkin")) {
- System.out.println(
- asdc.cycleAsset(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
- UUID.fromString(line.getOptionValue("assetId")),
- ASDC.LifecycleState.Checkin,
- "Admin",
- "cli op")
- .waitForResult()
- );
- }
- else if (action.equals("checkout")) {
- System.out.println(
- asdc.cycleAsset(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
- UUID.fromString(line.getOptionValue("assetId")),
- ASDC.LifecycleState.Checkout,
- "Admin",
- "cli op")
- .waitForResult()
- );
- }
- else if (action.equals("cleanup")) {
- JSONArray resources = asdc.getResources()
- .waitForResult();
- System.out.println("Got " + resources.length() + " resources");
-
-
- // vfcmt cleanup
- for (int i = 0; i < resources.length(); i++) {
-
- JSONObject resource = resources.getJSONObject(i);
-
- if (resource.getString("resourceType").equals("VFCMT") &&
- resource.getString("name").contains("test")) {
-
- System.out.println("undocheckout for " + resource.getString("uuid"));
-
- try {
- asdc.cycleAsset(AssetType.resource, UUID.fromString(resource.getString("uuid")), LifecycleState.undocheckout, "sj2381", null)
- .waitForResult();
- }
- catch (Exception x) {
- System.out.println("** " + x);
- }
- }
- }
-
- }
- else {
- try {
- System.out.println(
- asdc.createVF()
- .withInfo(new JSONObject()
- .put("category", "Generic")
- .put("subcategory", "Abstract"))
- .withName("Cognitor")
- .withDescription("Acumos import 07262017")
- .withVendorName("AcumosInc")
- .withVendorRelease("1.0")
- .withTags("acumos")
- .withOperator("sj2381")
- .execute()
- .waitForResult());
- }
- catch(Exception x) {
- System.out.println("Failed to create VF: " + x);
- }
- }
-/*
- else {
- UUID cid = UUID.fromString(line.getOptionValue("assetId"));
- JSONObject jsonObj = asdc.getResource(cid).waitForResult();
- System.out.println(jsonObj);
-
- JSONObject artifactObj = null;
- boolean flag = false;
-
- JSONArray resObj = jsonObj.optJSONArray("artifacts");
- if(resObj != null) {
- for(int i=0; i< resObj.length(); i++) {
- artifactObj = (JSONObject) resObj.get(i);
- System.out.println(artifactObj);
- if(artifactObj.get("artifactName").equals("superposition.yml")) {
- asdc.updateResourceArtifact(cid, artifactObj)
- .withContent("{}".getBytes())
- .withOperator("sj2381")
- // .withLabel("Superposition")
- // .withType(ArtifactType.DCAE_TOSCA)
- // .withGroupType(ArtifactGroupType.DEPLOYMENT)
- .withDescription(" serban asdc api test")
- .execute()
- .waitForResult();
- flag = true;
- }
- }
- }
-
- if(!flag) {
- asdc.createResourceArtifact(cid)
- .withName("superposition.yml")
- .withDisplayName("composition")
- .withContent("{}".getBytes())
- .withOperator("sj2381")
- .withLabel("Superposition")
- .withType(ArtifactType.DCAE_TOSCA)
- .withGroupType(ArtifactGroupType.DEPLOYMENT)
- .withDescription(" serban asdc api test")
- .execute()
- .waitForResult();
- }
-
- System.out.println(">>> " +
- asdc.checkinResource(cid, "sj2381", "done")
- .waitForResult());
-
-
- }
-*/
-/*
- System.out.println(
- asdc.deleteServiceInstanceArtifact(UUID.fromString("b8c40b18-a295-4f7d-905f-4ce18f939f9c"),
- "vMOG_for_DCAEDT 1",
- UUID.fromString("0992b5a9-75e0-4f0f-994c-8c7be6616e13"))
- .withOperator("sj2381")
- .execute()
- .waitForResult());
-*/
-
-/*
- JSONArray services = asdc.getServices()
-//("DCAE Component", null)
-// .waitForResult();
-// System.out.println("Got " + services.length() + " services");
-// System.out.println(services.toString(2));
-
- for (int i = 0; i < services.length(); i++) {
-// if (services.getJSONObject(i).getString("name").equals("DCAEDT_vMOG_Srvc3")) {
-// if (services.getJSONObject(i).getString("name").equals("MonicaforBP")) {
- UUID serviceId = UUID.fromString(services.getJSONObject(i).getString("uuid"));
-
- System.out.println("Service " + serviceId);
-
- if (theArgs.length > 1 && !theArgs[1].equals(serviceId.toString()))
- continue;
-
- JSONObject service = null;
- try {
- service = asdc.getService(serviceId)
- .waitForResult();
- }
- catch(Exception x) {
- System.out.println(x);
- continue;
- }
- System.out.println("Service details: " + service);
-
- asdc.checkinService(serviceId, "sj2381", "ready for update")
- .waitForResult();
-
-
- JSONArray instances = service.optJSONArray("resources");
- if (instances != null) {
- JSONObject instance = instances.getJSONObject(0);
- try {
-*/
- //System.out.println("Found instances, processing artifact for " + instance);
-
-/*
- System.out.println(
- asdc.createServiceInstanceArtifact(UUID.fromString(services.getJSONObject(i).getString("uuid")),
- instance.getString("resourceInstanceName"))
- .withName("test.yaml")
- .withDisplayName("artificial")
- .withLabel("artificial")
- .withDescription("serban asdc api test")
- .withContent(new File(theArgs[theArgs.length-1]))
- //.withType(ArtifactType.DCAE_TOSCA)
- //.withType(ArtifactType.HEAT_ARTIFACT)
- .withType(ArtifactType.DCAE_INVENTORY_BLUEPRINT)
- .withGroupType(ArtifactGroupType.DEPLOYMENT)
- .withOperator("sj2381")
- .execute()
- .waitForResult());
- asdc.deleteServiceInstanceArtifact(UUID.fromString(services.getJSONObject(i).getString("uuid")),
- instance.getString("resourceInstanceName"),
- UUID.fromString(
- instance.getJSONArray("artifacts").getJSONObject(0).getString("artifactUUID")))
- .withOperator("sj2381")
- .execute()
- .waitForResult());
-*/
-
-/*
- }
- catch(Exception x) {
- System.out.println("Failed to create resource instance artifact" + x);
- return;
- }
-// }
- }
- }
-*/
-
-
-
-// List resources = asdc.getResources(List.class, "DCAE Component", "Database")
-// .waitForResult();
-// System.out.println(resources.toString());
-
-
-// String artifact = asdc.getResourceArtifact(UUID.fromString(theArgs[1]),UUID.fromString(theArgs[2]),String.class)
-// .waitForResult();
-// System.out.println(artifact);
-
-// System.out.println(
-// asdc.checkinService(UUID.fromString(theArgs[1]), "sj2381", "testing")
-// .waitForResult());
-
-// System.out.println(
-// asdc.checkinService(UUID.fromString(theArgs[1]), "sj2381", "tested")
-// .waitForResult());
-
-/*
- try {
- System.out.println(
- asdc.createResourceArtifact(UUID.fromString(theArgs[1]))
- .withName("test.yml")
- .withDisplayName("test")
- .withLabel("test")
- .withDescription("serban asdc api test")
- .withContent(new File(theArgs[2]))
- .withType(ArtifactType.DCAE_TOSCA)
- .withGroupType(ArtifactGroupType.DEPLOYMENT)
- .withOperator("sj2381")
- .execute()
- .waitForResult());
- }
- catch(Exception x) {
- System.out.println("Failed to create asset " + x);
- return;
- }
-*/
-
-/*
- JSONObject resource = asdc.getResource(UUID.fromString(theArgs[1]), JSONObject.class)
- .waitForResult();
- System.out.println(resource.toString(2));
- JSONArray artifacts = resource.getJSONArray("artifacts");
- JSONObject artifact = artifacts.getJSONObject(0);
-*/
-
-
-/*
- byte[] archive = asdc.getResourceArchive(UUID.fromString(theArgs[1]))
- .waitForResult();
- FileUtils.writeByteArrayToFile(new File("archive.jar"), archive);
-*/
-/*
- String artifactInfo = asdc.getResourceArtifact(
- UUID.fromString(theArgs[1]),
- UUID.fromString(artifacts.getJSONObject(0).getString("artifactUUID")),
- String.class)
- .waitForResult();
- System.out.println(artifactInfo);
-*/
-
-/*
- System.out.println(
- asdc.fetch(
- asdc.refAssetArtifact(AssetType.resource, UUID.fromString(theArgs[1]), UUID.fromString(artifact.getString("artifactUUID"))), JSONObject.class)
- .waitForResult()
- .toString(2));
-*/
-
-/*
- try {
- System.out.println(
- asdc.updateResourceArtifact(UUID.fromString(theArgs[1]), artifact)
- .withDescription("serban asdc api test update")
- .withContent(new File(theArgs[3]))
- .withLabel("test")
- .withOperator("sj2381")
- .execute()
- .waitForResult());
- }
- catch(Exception x) {
- System.out.println("Failed to update asset " + x);
- return;
- }
-*/
-
-
-/*
- try {
- asdc.deleteResourceArtifact(UUID.fromString(theArgs[1]),
- UUID.fromString(artifacts.getJSONObject(0).getString("artifactUUID")))
- .withOperator("sj2381")
- .execute()
- .waitForResult();
- }
- catch(Exception x) {
- System.out.println("Failed to delete asset artifact " + x);
- }
-*/
-
-/*
- try {
- JSONObject artifact = artifacts.getJSONObject(0);
-
- System.out.println(
- asdc.updateResourceArtifact(UUID.fromString(theArgs[1]),
- UUID.fromString(artifacts.getJSONObject(0).getString("artifactUUID")))
- .withName(artifact.getString("artifactName"))
- .withDescription("serban asdc api test update")
- .withContent(new File(theArgs[2]))
- .withGroupType(ArtifactGroupType.DEPLOYMENT)
- .withLabel("test")
- .withType(ArtifactType.valueOf(artifact.getString("artifactType")))
- .withATTContact("sj2381")
- .post()
- .waitForResult());
- }
- catch(Exception x) {
- System.out.println("Failed to update asset artifact " + x);
- }
-*/
-/*
- try {
- System.out.println(
- asdc.createVFCMT()
- .withName("SB4.5")
- .withDescription("All mountain")
- .withVendorName("Yeti")
- .withVendorRelease("1.0")
- .withTags("MTB", "FS")
- .withOperator("sj2381")
- .execute()
- .waitForResult());
- }
- catch(Exception x) {
- System.out.println("Failed to create VFCMT: " + x);
- }
-*/
-/*
- asdc.updateAssetArtifact(AssetType.resource, UUID.fromString(theArgs[1]), UUID.fromString(theArgs[2]))
- .withDescription("serban asdc api test")
- .post();
-*/
- }
-}
+}
Environment env = theContext.getEnvironment();
return null != env &&
- "adapter".equals(env.getProperty("federated.instance"));
+ "adapter".equals(env.getProperty("federation.instance"));
}
}
AnnotatedTypeMetadata theMetadata) {
Environment env = theContext.getEnvironment();
- return null != env && "gateway".equals(env.getProperty("federated.instance"));
+ return null != env && "gateway".equals(env.getProperty("federation.instance"));
}
}
Environment env = theContext.getEnvironment();
return super.matches(theContext, theMetadata) &&
null != env &&
- "ghost".equals(env.getProperty("federated.instance.name"));
+ "ghost".equals(env.getProperty("federation.instance.name"));
}
}
import org.acumos.federation.gateway.common.JsonResponse;
import org.acumos.federation.gateway.config.APINames;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederatedCatalogService;
+import org.acumos.federation.gateway.service.FederationService;
import io.swagger.annotations.ApiOperation;
*/
@Controller
@RequestMapping("/")
-public class FederatedCatalogController extends AbstractController {
+public class FederationController extends AbstractController {
- private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederatedCatalogController.class);
+ private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederationController.class);
@Autowired
- FederatedCatalogService federationGatewayService;
+ FederationService federationService;
// /**
try {
data = new JsonResponse<List<MLPSolution>>();
logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: model types " + mlpModelTypes);
- peerCatalogSolutions = federationGatewayService.getPeerCatalogSolutionsList(mlpModelTypes);
+ peerCatalogSolutions = federationService.getPeerCatalogSolutionsList(mlpModelTypes);
if(peerCatalogSolutions != null) {
data.setResponseBody(peerCatalogSolutions);
data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
List<MLPSolutionRevision> peerCatalogSolutionRevisions= null;
try {
data = new JsonResponse<List<MLPSolutionRevision>>();
- peerCatalogSolutionRevisions = federationGatewayService.getPeerCatalogSolutionRevision(solutionId);
+ peerCatalogSolutionRevisions = federationService.getPeerCatalogSolutionRevision(solutionId);
if(peerCatalogSolutionRevisions != null) {
data.setResponseBody(peerCatalogSolutionRevisions);
data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
List<MLPArtifact> peerSolutionArtifacts= null;
try {
data = new JsonResponse<List<MLPArtifact>>();
- peerSolutionArtifacts = federationGatewayService.getPeerSolutionArtifacts(solutionId, revisionId);
+ peerSolutionArtifacts = federationService.getPeerSolutionArtifacts(solutionId, revisionId);
if(peerSolutionArtifacts != null) {
//re-encode the artifact uri
{
HttpServletRequest request, HttpServletResponse response) {
InputStreamResource inputStreamResource = null;
try {
- inputStreamResource = federationGatewayService.getPeerSolutionArtifactFile(artifactId);
+ inputStreamResource = federationService.getPeerSolutionArtifactFile(artifactId);
//TODO : Need to Implement a logic to download a Artifact or Docker Image from Nexus
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache");
import com.google.common.collect.HashBasedTable;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
+import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.PeerSubscriptionService;
import org.acumos.federation.gateway.task.PeerCommunicationTask;
import org.acumos.federation.gateway.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
private Environment env;
@Autowired
- private PeerAcumosConfigService peerAcumosConfigService;
+ private PeerService peerService;
@Autowired
- private PeerAcumosSubscriptionService peerAcumosSubscriptionService;
+ private PeerSubscriptionService peerSubscriptionService;
private ApplicationContext appCtx;
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
- String name = env.getProperty("federated.instance.name") + "-" + env.getProperty("federated.instance") + "-taskscheduler";
+ String name = env.getProperty("federation.instance.name") + "-" + env.getProperty("federation.instance") + "-taskscheduler";
ThreadPoolTaskScheduler threadPoolTaskScheduler = null;
try {
threadPoolTaskScheduler = (ThreadPoolTaskScheduler)this.appCtx.getBean(name);
public void checkPeerJobs() {
//Get the List of MLP Peers
- List<MLPPeer> mlpPeers = peerAcumosConfigService.getPeers();
+ List<MLPPeer> mlpPeers = peerService.getPeers();
if(Utils.isEmptyList(mlpPeers)) {
- logger.info(EELFLoggerDelegate.debugLogger, "checkPeer : no peers from " + peerAcumosConfigService);
+ logger.info(EELFLoggerDelegate.debugLogger, "checkPeer : no peers from " + peerService);
return;
}
continue;
}
- List<MLPPeerSubscription> mlpSubs = peerAcumosSubscriptionService.getPeerSubscriptions(mlpPeer.getPeerId());
+ List<MLPPeerSubscription> mlpSubs = peerSubscriptionService.getPeerSubscriptions(mlpPeer.getPeerId());
if(Utils.isEmptyList(mlpSubs)) {
//the peer is still there but has no subscriptions: cancel any ongoing tasks
import org.acumos.cds.domain.MLPPeer;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
+import org.acumos.federation.gateway.service.PeerService;
import org.acumos.federation.gateway.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
@Autowired
- private PeerAcumosConfigService peerConfigService;
+ private PeerService peerService;
private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
public UserDetailsService userDetailsService() {
return (username -> {
log.info(EELFLoggerDelegate.debugLogger, " X509 subject : " + username);
- List<MLPPeer> mlpPeers = peerConfigService.getPeer(username);
+ List<MLPPeer> mlpPeers = peerService.getPeer(username);
log.info(EELFLoggerDelegate.debugLogger, " Peers matching X509 subject : " + mlpPeers);
if(!Utils.isEmptyList(mlpPeers)) {
log.info(EELFLoggerDelegate.debugLogger, " We are providing a matching Use ");
import org.acumos.cds.transport.RestPageResponse;
/**
- *
- *
+ * Handles the business behind the Acumos federation interface
*/
-public interface FederatedCatalogService {
+public interface FederationService {
/**
*
*
*/
-public interface PeerAcumosConfigService {
+public interface PeerService {
/**
* @return List of Peers configured in the Local Acumos Instance
*
*
*/
-public interface PeerAcumosSubscriptionService {
+public interface PeerSubscriptionService {
/**
* @return List of PeerSubscription configured in the Local Acumos Instance
import org.apache.commons.io.FileUtils;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederatedCatalogService;
+import org.acumos.federation.gateway.service.FederationService;
import org.acumos.federation.gateway.util.Utils;
import org.acumos.federation.gateway.common.GatewayCondition;
import org.springframework.beans.factory.annotation.Autowired;
*/
@Service
@Conditional(GatewayCondition.class)
-public class FederatedCatalogServiceImpl extends AbstractServiceImpl implements FederatedCatalogService {
+public class FederationServiceImpl extends AbstractServiceImpl implements FederationService {
- private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(FederatedCatalogServiceImpl.class);
+ private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(FederationServiceImpl.class);
@Autowired
private Environment env;
import org.apache.commons.io.FileUtils;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederatedCatalogService;
+import org.acumos.federation.gateway.service.FederationService;
import org.acumos.federation.gateway.util.Utils;
import org.acumos.federation.gateway.util.LocalWatchService;
import org.acumos.federation.gateway.common.AdapterCondition;
@Service
@ConfigurationProperties(prefix="catalogLocal")
@Conditional(AdapterCondition.class)
-public class FederatedCatalogServiceLocalImpl extends AbstractServiceImpl
- implements FederatedCatalogService {
+public class FederationServiceLocalImpl extends AbstractServiceImpl
+ implements FederationService {
private URI catalogUri;
private List<FLPSolution> solutions;
import org.acumos.federation.gateway.common.GatewayCondition;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
+import org.acumos.federation.gateway.service.PeerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
*/
@Service
@Conditional(GatewayCondition.class)
-public class PeerAcumosConfigServiceImpl extends AbstractServiceImpl implements PeerAcumosConfigService {
+public class PeerServiceImpl extends AbstractServiceImpl implements PeerService {
/**
*
*/
- public PeerAcumosConfigServiceImpl() {
+ public PeerServiceImpl() {
// TODO Auto-generated constructor stub
}
import org.acumos.federation.gateway.util.LocalWatchService;
import org.acumos.federation.gateway.common.AdapterCondition;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
+import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.PeerSubscriptionService;
import org.acumos.cds.domain.MLPPeer;
import org.acumos.cds.domain.MLPPeerSubscription;
@Service
@ConfigurationProperties(prefix="peersLocal")
@Conditional(AdapterCondition.class)
-public class PeerAcumosServiceLocalImpl
- implements PeerAcumosConfigService,
- PeerAcumosSubscriptionService {
+public class PeerServiceLocalImpl
+ implements PeerService,
+ PeerSubscriptionService {
private List<FLPPeer> peers;
private URI sourceUri;
private WatchService sourceWatcher = null;
- private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerAcumosServiceLocalImpl.class);
+ private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerServiceLocalImpl.class);
@Autowired
private LocalWatchService watcher;
import org.acumos.federation.gateway.common.GatewayCondition;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
+import org.acumos.federation.gateway.service.PeerSubscriptionService;
import org.acumos.federation.gateway.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
*/
@Service
@Conditional(GatewayCondition.class)
-public class PeerAcumosSubscriptionServiceImpl extends AbstractServiceImpl implements PeerAcumosSubscriptionService {
-
- private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(PeerAcumosSubscriptionServiceImpl.class);
+public class PeerSubscriptionServiceImpl extends AbstractServiceImpl implements PeerSubscriptionService {
@Autowired
private Environment env;
/**
*
*/
- public PeerAcumosSubscriptionServiceImpl() {
+ public PeerSubscriptionServiceImpl() {
// TODO Auto-generated constructor stub
}
* See the License for the specific language governing permissions and
* limitations under the License.
* ===============LICENSE_END=========================================================
- */
-
-/**
- *
- */
-/**
- *
*
+ * Contains the specifications of federation gateway/adapter services (used through the gateway implementation)
*/
-package org.acumos.federated.gateway.service;
+
+package org.acumos.federation.gateway.service;
import org.acumos.federation.gateway.common.JsonResponse;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
import org.acumos.federation.gateway.service.impl.Clients;
import org.acumos.federation.gateway.service.impl.FederationClient;
import org.acumos.federation.gateway.util.Utils;
try {
logger.info(EELFLoggerDelegate.debugLogger, "Peer task: " + mlpPeer);
- //} else if(env.getProperty("federated.instance") != null && env.getProperty("federated.instance").equalsIgnoreCase("adapter")) {
- //TODO: X509 Verification and Send Principa verified in the request certificates
logger.info(EELFLoggerDelegate.debugLogger, "Peer task: invoking getSolutions from Remote instance " + mlpPeer.getApiUrl());
FederationClient fedClient =
clients.getFederationClient(this.mlpPeer.getApiUrl());
- //Map<String, Object> queryParameters = new HashMap<String, Object>();
- //queryParameters.put("modelTypeCode", mlpSubscription.getSelector()); // Subscriptions
+ //Map<String, Object> queryParameters = new HashMap<String, Object>();
+ //queryParameters.put("modelTypeCode", mlpSubscription.getSelector()); // Subscriptions
logger.info(EELFLoggerDelegate.debugLogger, "Peer Task: filter " + mlpSubscription.getSelector());
JsonResponse<List<MLPSolution>> jsonResponse =
* See the License for the specific language governing permissions and
* limitations under the License.
* ===============LICENSE_END=========================================================
- */
-
-/**
- *
- */
-/**
- *
*
+ * Jobs performed within the federation gateway/adapter, such as peer subscription processing
*/
+
package org.acumos.federation.gateway.task;
import java.util.Map;
import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.controller.FederatedCatalogController;
import org.acumos.cds.domain.MLPAccessType;
public class Utils {
- private final static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederatedCatalogController.class);
+ private final static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Utils.class);
public static ObjectMapper objectMapper = new ObjectMapper();
#Instance of this component could be gateway or adapter
#Based on the value configured, the behavior of this instance will vary.
-federated.instance=gateway
-federated.instance.name=ATT
-#federated.peerGatewayOperator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
+federation.instance=gateway
+federation.instance.name=ATT
+#federation.operator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
security.user.name=federated_client
#security.user.password = ENC(CTQD7Xk5bOIuC4MaqRZtzjW1K4ArjCjr)
server.ssl.trust-store-password = acumos
server.ssl.client-auth = want
-client.ssl.key-store = file:///home/src/acumos/federation/gateway/src/test/resources/acumosa.pkcs12
+client.ssl.key-store = file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa.pkcs12
client.ssl.key-store-password = acumosa
client.ssl.key-store-type = PKCS12
client.ssl.key-password = acumosa
#pretend we are an adapter so that we can use local peer config
-federated.instance=adapter
-federated.instance.name=ghost
+federation.instance=adapter
+federation.instance.name=ghost
-#peersLocal.sourceUri=classpath:acumosa-peers.json
-#peersLocal.catalogUri=classpath:acumosa-catalog.json
-peersLocal.sourceUri=file:///home/src/acumos/federation/gateway/src/test/resources/acumosa-peers.json
-catalogLocal.catalogUri=file:///home/src/acumos/federation/gateway/src/test/resources/acumosa-catalog.json
+#replace
+peersLocal.sourceUri=file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa-peers.json
+catalogLocal.catalogUri=file:///{path_to_src}acumos/federation/gateway/src/test/resources/acumosa-catalog.json
server.ssl.trust-store-password = acumos
server.ssl.client-auth = want
-client.ssl.key-store = file:///home/jora/src/acumos/federation/gateway/src/test/resources/acumosb.pkcs12
+client.ssl.key-store = file:///#{systemProperties['user.dir']}/gateway/src/test/resources/acumosb.pkcs12
client.ssl.key-store-password = acumosb
client.ssl.key-store-type = PKCS12
client.ssl.key-password = acumosb
#pretend we are an adapter so that we can use local peer config
-federated.instance=adapter
-federated.instance.name=ghost
+federation.instance=adapter
+federation.instance.name=ghost
-peersLocal.sourceUri=file:///home/jora/src/acumos/federation/gateway/src/test/resources/acumosb-peers.json
-catalogLocal.catalogUri=file:///home/jora/src/acumos/federation/gateway/src/test/resources/acumosb-catalog.json
+peersLocal.sourceUri=file:///#{systemProperties['user.dir']}/gateway/src/test/resources/acumosb-peers.json
+catalogLocal.catalogUri=file:///#{systemProperties['user.dir']}/gateway/src/test/resources/acumosb-catalog.json