* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
private final String appName = "ArtifactsHandler";
private final ExecutorService executor;
protected DataBroker dataBroker;
- protected NotificationProviderService notificationService;
+ protected NotificationPublishService notificationService;
protected RpcProviderRegistry rpcRegistry;
private ListenerRegistration<DataChangeListener> dclServices;
protected BindingAwareBroker.RpcRegistration<ArtifactHandlerService> rpcRegistration;
public ArtifactHandlerProvider(DataBroker dataBroker2,
- NotificationProviderService notificationProviderService,
+ NotificationPublishService notificationProviderService,
RpcProviderRegistry rpcProviderRegistry) {
this.log.info("Creating provider for " + appName);
executor = Executors.newFixedThreadPool(10);
}
// Listener for changes to Services tree
- rpcRegistration = rpcRegistry.addRpcImplementation(
- ArtifactHandlerService.class, this);
-
log.info("Initialization complete for " + appName);
}
private void createContainers() {
checkedFuture.get();
log.info("Create containers succeeded!");
- } catch (InterruptedException | ExecutionException e) {
+ } catch (InterruptedException e) {
+ log.error("Create containers failed", e);
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
log.error("Create containers failed", e);
}
}
String finalInd) {
UploadartifactOutputBuilder responseBuilder = new UploadartifactOutputBuilder();
- ConfigDocumentResponseBuilder configResponseBuilder=new ConfigDocumentResponseBuilder();
- configResponseBuilder.setRequestId(svcRequestId);
- configResponseBuilder.setStatus(code);
- configResponseBuilder.setErrorReason(message);
+ ConfigDocumentResponseBuilder configResponseBuilder=new ConfigDocumentResponseBuilder();
+ configResponseBuilder.setRequestId(svcRequestId);
+ configResponseBuilder.setStatus(code);
+ configResponseBuilder.setErrorReason(message);
RpcResult<UploadartifactOutput> rpcResult = RpcResultBuilder.<UploadartifactOutput> status(true)
.withResult(responseBuilder.build()).build();
- return rpcResult;
+ return rpcResult;
}
@Override
public Future<RpcResult<UploadartifactOutput>> uploadartifact(UploadartifactInput input) {
- if (input == null || input.getDocumentParameters() == null || input.getDocumentParameters().getArtifactContents() == null ) {
+ if (input == null || input.getDocumentParameters() == null || input.getDocumentParameters().getArtifactContents() == null ) {
RpcResult<UploadartifactOutput> rpcResult =
buildResponse1("N/A", "N/A", "INVALID_INPUT", "Invalid input, null or empty document information" , "Y");
return Futures.immediateFuture(rpcResult);
ConfigDocumentResponseBuilder configResponseBuilder = new ConfigDocumentResponseBuilder();
UploadartifactOutputBuilder responseBuilder = new UploadartifactOutputBuilder();
log.info("Received input = " + input );
- ArtifactHandlerProviderUtil designUtil = new ArtifactHandlerProviderUtil(input);
+ ArtifactHandlerProviderUtil designUtil = getArtifactHandlerProviderUtil(input);
configResponseBuilder.setRequestId(input.getRequestInformation().getRequestId());
try{
-
if(input.getRequestInformation().getSource() !=null){
if(input.getRequestInformation().getSource().equalsIgnoreCase(SdcArtifactHandlerConstants.DESIGN_TOOL)){
designUtil.processTemplate(designUtil.createDummyRequestData());
else
{
designUtil.processTemplate(designUtil.createRequestData());
- configResponseBuilder.setStatus(ArtifactHandlerProviderUtil.DistributionStatusEnum.DEPLOY_OK.toString());
+ configResponseBuilder.setStatus(ArtifactHandlerProviderUtil.DistributionStatusEnum.DEPLOY_OK.toString());
}
}
else
{
- throw new Exception("No Tempalte data found");
+ throw new Exception("No Template data found");
}
-
-
}
catch (Exception e) {
- configResponseBuilder.setErrorReason(e.getMessage());
+ configResponseBuilder.setErrorReason(e.getMessage());
configResponseBuilder.setStatus(ArtifactHandlerProviderUtil.DistributionStatusEnum.DEPLOY_ERROR.toString());
log.error("Caught exception looking for Artifact Handler", e);
log.info("Caught exception looking for Artifact Handler: ");
}
-
+
responseBuilder.setConfigDocumentResponse(configResponseBuilder.build());
RpcResult<UploadartifactOutput> rpcResult = RpcResultBuilder.<UploadartifactOutput> status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
+
+ protected ArtifactHandlerProviderUtil getArtifactHandlerProviderUtil(UploadartifactInput input) {
+ return new ArtifactHandlerProviderUtil(input);
+ }
}