* @author
* @version ONAP Amsterdam Release 2017-08-28
*/
-public class AaiAdapter {
+public class AaiUtil {
public static RestfulResponse addRelation(String serviceInstanceID, String resourceInstanceID)
{
LOGGER.info("create ns -> end");
LOGGER.info("save segment and operaton info -> begin");
// Step 5: add relation between service and NS
- AaiAdapter.addRelation(segInput.getNsOperationKey().getServiceId(), nsInstanceId);
+ AaiUtil.addRelation(segInput.getNsOperationKey().getServiceId(), nsInstanceId);
// Step 6: save resource operation information
ResourceOperationStatus nsOperInfo = RequestsDatabase.getResourceOperationStatus(
}
// Step3: remove relation info between service and ns
- AaiAdapter.removeRelation(nsOperationKey.getServiceId(), nsInstanceId);
+ AaiUtil.removeRelation(nsOperationKey.getServiceId(), nsInstanceId);
LOGGER.info("delete segment information -> end");
// Step4: update service segment operation status
public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) {
ValidateUtil.assertObjectNotNull(jobId);
+ // Step 1: query the current resource operation status
ResourceOperationStatus nsOperInfo = RequestsDatabase.getResourceOperationStatus(nsOperationKey.getServiceId(),
nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId());
ValidateUtil.assertObjectNotNull(rsp);
LOGGER.info("query ns progress response status is : {}", rsp.getStatus());
LOGGER.info("query ns progress response content is : {}", rsp.getResponseContent());
+ //Step 3:check the response staus
if(!HttpCode.isSucess(rsp.getStatus())) {
LOGGER.info("fail to query job status");
nsOperInfo.setErrorCode(String.valueOf(rsp.getStatus()));
RequestsDatabase.updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.JOB_STATUS_ERROR);
} else {
- // do nothing
+ LOGGER.error("unexcepted response status");
}
LOGGER.info("query ns status -> end");
public static final String STR_EMPTY = "";
- public static final String CATALOGUE_QUERY_SVC_TMPL_NODETYPE_URL = "/openoapi/catalog/v1/servicetemplates/nesting";
-
- public static final String SDNO_CREATE_URL = "/openoapi/sdnonslcm/v1/ns";
-
- public static final String SDNO_INSTANTIATE_URL = "/openoapi/sdnonslcm/v1/ns/%s/instantiate";
-
- public static final String SDNO_TERMINATE_URL = "/openoapi/sdnonslcm/v1/ns/%s/terminate";
-
- public static final String SDNO_DELETE_URL = "/openoapi/sdnonslcm/v1/ns/%s";
-
- public static final String SDNO_QUERY_URL = "/openoapi/sdnonslcm/v1/jobs/%s";
-
public static final String NFVO_CREATE_URL = "/openoapi/nslcm/v1/ns";
public static final String NFVO_INSTANTIATE_URL = "/openoapi/nslcm/v1/ns/%s/instantiate";
public static final String NFVO_QUERY_URL = "/openoapi/nslcm/v1/jobs/%s";
- public static final String GSO_CREATE_URL = "/openoapi/gso/v1/services";
-
- public static final String GSO_DELETE_URL = "/openoapi/gso/v1/services/%s";
-
- public static final String GSO_QUERY_URL = "/openoapi/gso/v1/services/%s/operations/%s";
public static final String LEFT_QUOTE_LEFT_BRACE = "\"\\{";
* identification of adapter exception
*
* @author
- * @version GSO 0.5 2016/9/3
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class DriverExceptionID {
public static final String FAIL_TO_CREATE_NS = "Fail to create ns";
- public static final String FAIL_TO_CREATE_GSO_NS = "Fail to create gso ns";
-
public static final String INVALID_RESPONSEE_FROM_DELETE_OPERATION = "Invalid response from delete operation";
public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION = "Invalid response from terminate operation";
- public static final String FAIL_TO_DELETE_GSO_NS = "Fail to delete gso ns";
-
public static final String FAIL_TO_DELETE_NS = "Fail to delete ns";
public static final String FAIL_TO_TERMINATE_NS = "Fail to terminate ns";
* <p>
* </p>
*
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
private HttpCode() {
*
* @param httpCode response code
* @return true or false
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
public static boolean isSucess(int httpCode) {
return httpCode / 100 == 2;
*
* @param errorCode error status
* @param errorDetail error detail
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
public ApplicationException(int errorCode, Object errorDetail) {
super(Response.status(errorCode).entity(errorDetail).type(MediaType.APPLICATION_JSON).build());
* </p>
*
* @author
- * @version GSO 0.5 2017/2/21
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class LocationConstraint {
* request model for instatiate
*
* @author
- * @version GSO 0.5 2016/9/3
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class NsInstantiateReq extends NsParameters {
* </p>
*
* @author
- * @version GSO 0.5 2017/2/21
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class NsParameters {
* response model of query operation status
*
* @author
- * @version GSO 0.5 2016/9/3
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class NsProgressStatus {
\r
import java.util.Map;\r
\r
+/**\r
+ * The Unified Restful Reponse Class\r
+ * <br>\r
+ * <p>\r
+ * </p>\r
+ * \r
+ * @author\r
+ * @version ONAP Amsterdam Release 2017-09-06\r
+ */\r
public class RestfulResponse {\r
\r
+ // the response content\r
private String responseContent;\r
\r
+ //the response status\r
private int status;\r
\r
+ //the response header\r
private Map<String, String> respHeaderMap;\r
\r
public RestfulResponse() {\r
* </p>
*
* @author
- * @version GSO 0.5 2016/9/1
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class JsonUtil {
* <p>
* </p>
*
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
private JsonUtil() {
* @param jsonstr json string.
* @param type that convert json string to
* @return model object
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
public static <T> T unMarshal(String jsonstr, Class<T> type) {
try {
* @param jsonstr json string.
* @param type that convert json string to
* @return model object
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
public static <T> T unMarshal(String jsonstr, TypeReference<T> type) {
try {
*
* @param srcObj data object
* @return json string
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
public static String marshal(Object srcObj) {
try {
* Get mapper.<br/>
*
* @return mapper
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
public static ObjectMapper getMapper() {
return MAPPER;
* utility to invoke restclient
*
* @author
- * @version GSO 0.5 2016/9/3
+ * @version ONAP Amsterdam Release 2017-9-6
*/
public class RestfulUtil {
* <p>\r
* </p>\r
* \r
- * @since GSO 0.5\r
+ * @since ONAP Amsterdam Release 2017-9-6\r
*/\r
private ValidateUtil() {\r
\r
* \r
* @param paramValue parameter data\r
* @param name of parameter\r
- * @since GSO 0.5\r
+ * @since ONAP Amsterdam Release 2017-9-6\r
*/\r
public static void assertStringNotNull(String paramValue, String paramName) {\r
if(null != paramValue && !paramValue.isEmpty()) {\r
* Assert object is null.<br/>\r
* \r
* @param object data object\r
- * @since GSO 0.5\r
+ * @since ONAP Amsterdam Release 2017-9-6\r
*/\r
public static void assertObjectNotNull(Object object) {\r
if(null == object) {\r
* Mock to get request body.<br/>
*
* @param file json file path.
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
private void mockGetRequestBody(final String file) {
new MockUp<RestfulUtil>() {
* @param file the path of file
* @return json string
* @throws IOException when fail to read
- * @since GSO 0.5
+ * @since ONAP Amsterdam Release 2017-9-6
*/
private String getJsonString(final String file) {
if(ValidateUtil.isStrEmpty(file)) {