2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.appc.sdc.artifacts.impl;
25 import java.net.MalformedURLException;
27 import org.onap.appc.srvcomm.messaging.event.EventSender;
28 import org.onap.appc.exceptions.APPCException;
29 import org.onap.appc.sdc.artifacts.object.SDCArtifact;
30 import org.onap.appc.sdc.listener.ProviderOperations;
31 import org.onap.appc.sdc.listener.ProviderResponse;
32 import org.onap.appc.sdc.listener.Util;
33 import org.onap.sdc.api.IDistributionClient;
34 import org.onap.sdc.api.notification.IArtifactInfo;
35 import org.onap.sdc.api.notification.INotificationData;
36 import org.onap.sdc.api.notification.IResourceInstance;
37 import com.att.eelf.configuration.EELFLogger;
38 import com.att.eelf.configuration.EELFManager;
41 * Artifact processor for config artifact type
43 public class ConfigArtifactProcessor extends AbstractArtifactProcessor {
45 private final EELFLogger logger = EELFManager.getInstance().getLogger(ConfigArtifactProcessor.class);
48 * returns an instance of ConfigArtifactProcessor
50 * @param client an instance of IDistributionClient
51 * @param eventSender an instance of EventSender
52 * @param notification an instance of INotificationData
53 * @param resource an instance of IResourceInstance
54 * @param artifact an instance of IArtifactInfo
55 * @param storeUri an instance of URI
57 public ConfigArtifactProcessor(IDistributionClient client, EventSender eventSender, INotificationData notification,
58 IResourceInstance resource, IArtifactInfo artifact, URI storeUri) {
59 super(client, eventSender, notification, resource, artifact, storeUri);
63 public void processArtifact(SDCArtifact artifact) throws APPCException {
65 Util.toSdcStoreDocumentInput(notification, resource, super.artifact, artifact.getArtifactContent());
66 logger.debug("ConfigArtifactProcessor::processArtifact::postData=" + postData);
68 if (null != storeUri) {
69 logger.debug("ConfigArtifactProcessor::processArtifact::URI is" + storeUri.toString());
70 ProviderResponse result = ProviderOperations.post(storeUri.toURL(), postData, null);
71 if (result.getStatus() == 200) {
72 logger.debug("ConfigArtifactProcessor::processArtifact::post request success!!");
73 Util.parseResponse(result.getBody());
75 logger.debug("ConfigArtifactProcessor::processArtifact()::post request failed!! Returned :"
76 + result.getStatus() + "-Result body- " + result.getBody());
77 throw new APPCException(
78 "ConfigArtifactProcessor::processArtifact: Invalid status retrurned from post "
79 + result.getStatus());
82 logger.error("ConfigArtifactProcessor::processArtifact, storeURI is null");
84 } catch (MalformedURLException | APPCException e) {
85 logger.error("Error processing artifact : " + this.artifact.toString(), e);
86 throw new APPCException(e.getMessage(), e);