import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
import org.acumos.federation.gateway.service.impl.Clients;
import org.acumos.federation.gateway.service.impl.FederationClient;
+import org.acumos.federation.gateway.util.Errors;
import org.acumos.federation.gateway.util.Utils;
import org.acumos.nexus.client.data.UploadArtifactInfo;
//list with category and subcategory currently used for onap
//more dynamic mapping to come: based on solution information it will provide sdc assettype, categoty and subcategoty
- ICommonDataServiceRestClient cdsClient =
- new CommonDataServiceRestClientImpl(
- env.getProperty("cdms.client.url"),
- env.getProperty("cdms.client.username"),
- env.getProperty("cdms.client.password"));
+ ICommonDataServiceRestClient cdsClient = PeerGateway.this.clients.getClient();
logger.info(EELFLoggerDelegate.debugLogger, "Received peer " + this.peer + " solutions: " + this.solutions);
peerRevisions.get(peerRevisions.size()-1).getRevisionId());
}
catch (HttpStatusCodeException restx) {
- if (restx.getStatusCode() != HttpStatus.NOT_FOUND) {
+ if (!Errors.isCDSNotFound(restx)) {
logger.error(EELFLoggerDelegate.debugLogger, "getSolutionRevision CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
throw restx;
}
cdsClient.getArtifact(peerArtifact.getArtifactId());
}
catch (HttpStatusCodeException restx) {
- if (restx.getStatusCode() != HttpStatus.NOT_FOUND) {
+ if (!Errors.isCDSNotFound(restx)) {
logger.error(EELFLoggerDelegate.debugLogger, "getArtifact CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
throw restx;
}
--- /dev/null
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 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.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.federation.gateway.util;
+
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.client.HttpStatusCodeException;
+
+
+/** */
+public class Errors {
+
+ private Errors() {
+ }
+
+
+ /**
+ * CDS provides a 400 error with a particular error message
+ */
+ public static boolean isCDSNotFound(HttpStatusCodeException theError) {
+
+ if (theError.getStatusCode() == HttpStatus.BAD_REQUEST) {
+ String msg = theError.getResponseBodyAsString();
+ return (msg != null &&
+ msg.startsWith("No entry for ID"));
+ }
+ return false;
+ }
+
+}