2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.crud.dao.champ;
23 import java.nio.charset.Charset;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
31 import javax.ws.rs.core.MediaType;
32 import javax.ws.rs.core.Response;
33 import org.apache.http.NameValuePair;
34 import org.apache.http.client.utils.URLEncodedUtils;
35 import org.apache.http.message.BasicNameValuePair;
36 import org.eclipse.jetty.util.security.Password;
37 import org.onap.aai.cl.mdc.MdcContext;
38 import org.onap.aai.logging.LoggingContext;
39 import org.onap.aai.restclient.client.OperationResult;
40 import org.onap.aai.restclient.client.RestClient;
41 import org.onap.aai.restclient.enums.RestAuthenticationMode;
42 import org.onap.crud.dao.GraphDao;
43 import org.onap.crud.entity.Edge;
44 import org.onap.crud.entity.Vertex;
45 import org.onap.crud.exception.CrudException;
46 import org.onap.crud.util.CrudServiceConstants;
48 import com.google.gson.Gson;
49 import com.google.gson.GsonBuilder;
50 import com.google.gson.reflect.TypeToken;
51 import net.dongliu.gson.GsonJava8TypeAdapterFactory;
53 public class ChampDao implements GraphDao {
54 protected RestClient client;
55 protected String baseObjectUrl;
56 protected String baseRelationshipUrl;
57 protected String baseTransactionUrl;
59 protected static final String HEADER_FROM_APP = "X-FromAppId";
60 protected static final String HEADER_TRANS_ID = "X-TransactionId";
61 protected static final String FROM_APP_NAME = "Gizmo";
62 protected static final String OBJECT_SUB_URL = "objects";
63 protected static final String RELATIONSHIP_SUB_URL = "relationships";
64 protected static final String TRANSACTION_SUB_URL = "transaction";
66 // We use a custom vertex serializer for champ because it expects "key"
68 protected static final Gson champGson = new GsonBuilder()
69 .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
70 .registerTypeAdapter(Vertex.class, new ChampVertexSerializer())
71 .registerTypeAdapter(Edge.class, new ChampEdgeSerializer()).create();
76 public ChampDao(String champUrl, String certPassword) {
78 client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
79 .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
80 .clientCertPassword(Password.deobfuscate(certPassword));
82 baseObjectUrl = champUrl + OBJECT_SUB_URL;
83 baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
84 baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
85 } catch (Exception e) {
86 System.out.println("Error setting up Champ configuration");
92 public ChampDao(RestClient client, String baseObjectUrl, String baseRelationshipUrl, String baseTransactionUrl) {
94 this.baseObjectUrl = baseObjectUrl;
95 this.baseRelationshipUrl = baseRelationshipUrl;
96 this.baseTransactionUrl = baseTransactionUrl;
100 public Vertex getVertex(String id, String version) throws CrudException {
101 String url = baseObjectUrl + "/" + id;
102 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
104 if (getResult.getResultCode() == 200) {
105 return Vertex.fromJson(getResult.getResult(), version);
107 // We didn't find a vertex with the supplied id, so just throw an
109 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
114 public OperationResult getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException {
115 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
116 strBuild.append("/");
118 if(queryParams != null && !queryParams.isEmpty())
120 strBuild.append("?");
121 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
124 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
126 if (getResult.getResultCode() == 200) {
127 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
129 if (!vert.getType().equalsIgnoreCase(type)) {
130 // We didn't find a vertex with the supplied type, so just throw an
132 throw new CrudException("No vertex with id " + id + " and type " + type + " found in graph",
133 javax.ws.rs.core.Response.Status.NOT_FOUND);
137 // We didn't find a vertex with the supplied id, so just throw an
139 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
144 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException {
145 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
146 strBuild.append("/relationships/");
148 if(queryParams != null && !queryParams.isEmpty())
150 strBuild.append("?");
151 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
154 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
156 if (getResult.getResultCode() == 200) {
157 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
160 // We didn't find a vertex with the supplied id, so just throw an
162 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
167 public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
168 return getVertices(type, filter, new HashSet<String>(), version);
172 public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException {
173 filter.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
175 List<NameValuePair> queryParams = convertToNameValuePair(filter);
176 queryParams.addAll(convertToNameValuePair("properties", properties));
177 String url = baseObjectUrl + "/filter" + "?"
178 + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
180 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
182 if (getResult.getResultCode() == 200) {
185 // We didn't find a vertex with the supplied id, so just throw an
187 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertices found in graph for given filters");
192 public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
193 StringBuilder strBuild = new StringBuilder(baseRelationshipUrl);
194 strBuild.append("/");
196 if(queryParams != null && !queryParams.isEmpty())
198 strBuild.append("?");
199 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
201 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
203 if (getResult.getResultCode() == 200) {
204 Edge edge = Edge.fromJson(getResult.getResult());
206 if (!edge.getType().equalsIgnoreCase(type)) {
207 // We didn't find an edge with the supplied type, so just throw an
209 throw new CrudException("No edge with id " + id + " and type " + type + " found in graph",
210 javax.ws.rs.core.Response.Status.NOT_FOUND);
214 // We didn't find a edge with the supplied type, so just throw an
216 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
221 public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException {
222 String url = baseRelationshipUrl + "/filter" + "?"
223 + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
225 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
227 if (getResult.getResultCode() == 200) {
230 // We didn't find a vertex with the supplied id, so just throw an
232 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edges found in graph for given filters");
237 public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
238 String url = baseObjectUrl;
240 // Add the aai_node_type so that AAI can read the data created by gizmo
241 // TODO: This probably shouldn't be here
242 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
244 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
245 properties.forEach(insertVertexBuilder::property);
246 Vertex insertVertex = insertVertexBuilder.build();
248 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
249 MediaType.APPLICATION_JSON_TYPE);
251 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
254 // We didn't create a vertex with the supplied type, so just throw an
256 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
261 public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
262 String url = baseObjectUrl + "/" + id;
264 // Add the aai_node_type so that AAI can read the data created by gizmo
265 // TODO: This probably shouldn't be here
266 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
268 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
269 insertVertexBuilder.id(id);
270 properties.forEach(insertVertexBuilder::property);
271 Vertex insertVertex = insertVertexBuilder.build();
273 String payload = insertVertex.toJson(champGson);
274 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
275 MediaType.APPLICATION_JSON_TYPE);
277 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
280 // We didn't create a vertex with the supplied type, so just throw an
282 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
287 public void deleteVertex(String id, String type) throws CrudException {
288 String url = baseObjectUrl + "/" + id;
289 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
291 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
292 // We didn't delete a vertex with the supplied id, so just throw an
294 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
299 public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
300 String url = baseRelationshipUrl;
302 // Try requests to ensure source and target exist in Champ
303 OperationResult dbSourceOpResult = getVertex(source.getId().get(), source.getType(), version, new HashMap<String, String>());
304 Vertex dbSource = Vertex.fromJson(dbSourceOpResult.getResult(), version);
305 OperationResult dbTargetOpResult = getVertex(target.getId().get(), target.getType(), version, new HashMap<String, String>());
306 Vertex dbTarget = Vertex.fromJson(dbTargetOpResult.getResult(), version);
308 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
309 properties.forEach(insertEdgeBuilder::property);
310 Edge insertEdge = insertEdgeBuilder.build();
312 String edgeJson = insertEdge.toJson(champGson);
313 OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
314 MediaType.APPLICATION_JSON_TYPE);
316 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
319 // We didn't create an edge with the supplied type, so just throw an
321 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
326 public OperationResult updateEdge(Edge edge) throws CrudException {
327 if (!edge.getId().isPresent()) {
328 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
330 String url = baseRelationshipUrl + "/" + edge.getId().get();
332 String edgeJson = edge.toJson(champGson);
333 OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
334 MediaType.APPLICATION_JSON_TYPE);
336 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
339 // We didn't create an edge with the supplied type, so just throw an
341 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
346 public void deleteEdge(String id, String type) throws CrudException {
347 String url = baseRelationshipUrl + "/" + id;
348 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
350 if (getResult.getResultCode() != 200) {
351 // We didn't find an edge with the supplied type, so just throw an
353 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
358 public String openTransaction() {
359 String url = baseTransactionUrl;
361 OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
363 if (getResult.getResultCode() == 200) {
364 return getResult.getResult();
371 public void commitTransaction(String id) throws CrudException {
372 String url = baseTransactionUrl + "/" + id;
374 OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
375 MediaType.TEXT_PLAIN_TYPE);
377 if (getResult.getResultCode() != 200) {
378 throw new CrudException("Unable to commit transaction",
379 Response.Status.fromStatusCode(getResult.getResultCode()));
384 public void rollbackTransaction(String id) throws CrudException {
385 String url = baseTransactionUrl + "/" + id;
387 OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
388 MediaType.TEXT_PLAIN_TYPE);
390 if (getResult.getResultCode() != 200) {
391 throw new CrudException("Unable to rollback transaction",
392 Response.Status.fromStatusCode(getResult.getResultCode()));
397 public boolean transactionExists(String id) throws CrudException {
398 String url = baseTransactionUrl + "/" + id;
399 Map<String, List<String>> headers = new HashMap<>();
400 headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
401 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
403 OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
405 return getResult.getResultCode() == 200;
409 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
410 String url = baseObjectUrl + "?transactionId=" + txId;
412 // Add the aai_node_type so that AAI can read the data created by gizmo
413 // TODO: This probably shouldn't be here
414 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
416 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
417 properties.forEach(insertVertexBuilder::property);
418 Vertex insertVertex = insertVertexBuilder.build();
420 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
421 MediaType.APPLICATION_JSON_TYPE);
423 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
424 return Vertex.fromJson(getResult.getResult(), version);
426 // We didn't create a vertex with the supplied type, so just throw an
428 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
433 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
434 throws CrudException {
435 String url = baseRelationshipUrl + "?transactionId=" + txId;
437 // Try requests to ensure source and target exist in Champ
438 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
439 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
441 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
442 properties.forEach(insertEdgeBuilder::property);
443 Edge insertEdge = insertEdgeBuilder.build();
445 OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
446 MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
448 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
449 return Edge.fromJson(getResult.getResult());
451 // We didn't create an edge with the supplied type, so just throw an
453 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
458 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
459 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
461 // Add the aai_node_type so that AAI can read the data created by gizmo
462 // TODO: This probably shouldn't be here
463 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
465 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
466 insertVertexBuilder.id(id);
467 properties.forEach(insertVertexBuilder::property);
468 Vertex insertVertex = insertVertexBuilder.build();
470 String payload = insertVertex.toJson(champGson);
471 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
472 MediaType.APPLICATION_JSON_TYPE);
474 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
475 return Vertex.fromJson(getResult.getResult(), version);
477 // We didn't create a vertex with the supplied type, so just throw an
479 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
484 public void deleteVertex(String id, String type, String txId) throws CrudException {
485 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
486 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
488 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
489 // We didn't delete a vertex with the supplied id, so just throw an
491 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
496 public Edge updateEdge(Edge edge, String txId) throws CrudException {
497 if (!edge.getId().isPresent()) {
498 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
500 String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
501 OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
502 MediaType.APPLICATION_JSON_TYPE);
504 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
505 return Edge.fromJson(getResult.getResult());
507 // We didn't create an edge with the supplied type, so just throw an
509 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
510 Response.Status.fromStatusCode(getResult.getResultCode()));
515 public void deleteEdge(String id, String type, String txId) throws CrudException {
516 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
517 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
519 if (getResult.getResultCode() != 200) {
520 // We didn't find an edge with the supplied type, so just throw an
522 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
527 public Edge getEdge(String id, String type, String txId) throws CrudException {
528 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
529 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
531 if (getResult.getResultCode() == 200) {
532 Edge edge = Edge.fromJson(getResult.getResult());
534 if (!edge.getType().equalsIgnoreCase(type)) {
535 // We didn't find an edge with the supplied type, so just throw an
537 throw new CrudException("No edge with id " + id + " and type " + type + " found in graph",
538 javax.ws.rs.core.Response.Status.NOT_FOUND);
542 // We didn't find an edge with the supplied id, so just throw an
544 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
548 public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
549 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
550 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
552 if (getResult.getResultCode() == 200) {
553 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
555 if (!vert.getType().equalsIgnoreCase(type)) {
556 // We didn't find a vertex with the supplied type, so just throw an
558 throw new CrudException("No vertex with id " + id + " and type " + type + " found in graph",
559 javax.ws.rs.core.Response.Status.NOT_FOUND);
563 // We didn't find a vertex with the supplied id, so just throw an
565 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
569 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
570 private List<NameValuePair> convertToNameValuePair(Map<String, ? super String> pairs) {
571 List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
573 pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
578 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
579 private List<NameValuePair> convertToNameValuePair(String k, Set<String> values) {
580 List<NameValuePair> nvpList = new ArrayList<>(values.size());
582 values.forEach((v) -> nvpList.add(new BasicNameValuePair(k, v)));
587 private Map<String, List<String>> createHeader() {
588 Map<String, List<String>> headers = new HashMap<>();
589 headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
590 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
594 private CrudException createErrorException(OperationResult result, javax.ws.rs.core.Response.Status defaultErrorCode , String defaultErrorMsg)
596 CrudException ce = null;
598 ce = new CrudException(result.getFailureCause(), Response.Status.fromStatusCode(result.getResultCode()));
600 ce = new CrudException(defaultErrorMsg, defaultErrorCode);