import java.util.Map;\r
import java.util.Map.Entry;\r
import java.util.UUID;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
import javax.xml.parsers.DocumentBuilder;\r
import javax.xml.parsers.DocumentBuilderFactory;\r
import org.apache.commons.text.StringEscapeUtils;\r
import org.onap.aai.modelloader.config.ModelLoaderConfig;\r
import org.onap.aai.modelloader.entity.Artifact;\r
import org.onap.aai.modelloader.entity.ArtifactHandler;\r
+import org.onap.aai.modelloader.entity.vnf.VnfImages;\r
import org.onap.aai.modelloader.restclient.AaiRestClient;\r
import org.onap.aai.modelloader.service.ModelLoaderMsgs;\r
-import org.onap.aai.restclient.client.OperationResult;\r
+import org.springframework.http.HttpStatus;\r
+import org.springframework.http.MediaType;\r
+import org.springframework.http.ResponseEntity;\r
import org.springframework.stereotype.Component;\r
+import org.springframework.web.client.RestTemplate;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
import org.w3c.dom.Node;\r
String imageId = imageIdBuilder.toString();\r
int resultCode = getVnfImage(restClient, distributionId, imageId, dataItem);\r
\r
- if (resultCode == Response.Status.NOT_FOUND.getStatusCode()) {\r
+ if (resultCode == HttpStatus.NOT_FOUND.value()) {\r
// This vnf-image is missing, so add it\r
boolean success = putVnfImage(restClient, dataItem, distributionId);\r
if (success) {\r
} else {\r
throw new VnfImageException(imageId);\r
}\r
- } else if (resultCode == Response.Status.OK.getStatusCode()) {\r
+ } else if (resultCode == HttpStatus.OK.value()) {\r
logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, imageId + " already exists. Skipping ingestion.");\r
} else {\r
// if other than 404 or 200, something went wrong\r
for (Entry<String, String> entry : dataItem.entrySet()) {\r
b.addParameter(entry.getKey(), entry.getValue());\r
}\r
- OperationResult tryGet =\r
- restClient.getResource(b.build().toString(), distributionId, MediaType.APPLICATION_JSON_TYPE);\r
+ ResponseEntity<VnfImages> tryGet =\r
+ restClient.getResource(b.build().toString(), distributionId, MediaType.APPLICATION_JSON, VnfImages.class);\r
if (tryGet == null) {\r
throw new VnfImageException(imageId);\r
}\r
- return tryGet.getResultCode();\r
+ return tryGet.getStatusCodeValue();\r
} catch (URISyntaxException ex) {\r
throw new VnfImageException(ex);\r
}\r
String uuid = UUID.randomUUID().toString();\r
dataItem.put(ATTR_UUID, uuid);\r
\r
+ // TODO: Get rid of the dataItem map and replace it with the VnfImage object\r
String payload = new Gson().toJson(dataItem);\r
String putUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" + uuid;\r
- OperationResult putResp =\r
- restClient.putResource(putUrl, payload, distributionId, MediaType.APPLICATION_JSON_TYPE);\r
- return putResp != null && putResp.getResultCode() == Response.Status.CREATED.getStatusCode();\r
+ ResponseEntity<String> putResp =\r
+ restClient.putResource(putUrl, payload, distributionId, MediaType.APPLICATION_JSON, String.class);\r
+ return putResp != null && putResp.getStatusCode() == HttpStatus.CREATED;\r
}\r
\r
private List<Map<String, String>> unmarshallVnfcData(Artifact vnfcArtifact) {\r