import java.security.SecureRandom;
-import org.onap.aai.sparky.dal.cache.EntityCache;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.util.NodeUtils;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.sparky.logging.AaiUiMsgs;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
/**
* The Class RestfulDataAccessor.
+ *
+ * TODO: DELETE ME
+ *
*/
public class RestfulDataAccessor implements RestDataProvider {
protected RestClientBuilder clientBuilder;
- protected EntityCache entityCache;
- private boolean cacheEnabled;
private static final Logger LOG =
LoggerFactory.getInstance().getLogger(RestfulDataAccessor.class);
this.clientBuilder = clientBuilder;
txnIdGenerator = new SecureRandom();
resourceNotFoundErrorsSurpressed = false;
- cacheEnabled = false;
- entityCache = null;
- }
-
- protected boolean isCacheEnabled() {
- return cacheEnabled;
- }
-
- public void setCacheEnabled(boolean cacheEnabled) {
- this.cacheEnabled = cacheEnabled;
- }
-
- protected EntityCache getEntityCache() {
- return entityCache;
- }
-
- public void setEntityCache(EntityCache entityCache) {
- this.entityCache = entityCache;
- }
-
- /**
- * Cache result.
- *
- * @param result the result
- */
- private void cacheResult(OperationResult result) {
- if (cacheEnabled && entityCache != null) {
- final String id =
- NodeUtils.generateUniqueShaDigest(result.getRequestLink(), result.getRequestPayload());
- entityCache.put(id, result);
- }
}
/**
}
- /**
- * Gets the cached data.
- *
- * @param link the link
- * @param payload the payload
- * @return the cached data
- */
- private OperationResult getCachedData(String link, String payload) {
- if (cacheEnabled && entityCache != null) {
- final String id = NodeUtils.generateUniqueShaDigest(link, payload);
- return entityCache.get(id, link);
- }
- return null;
- }
-
/*
* (non-Javadoc)
*
* @see
- * org.onap.aai.sparky.dal.rest.RestDataProvider#doRestfulOperation(org.onap.aai.sparky.dal.rest.
- * HttpMethod, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ * org.openecomp.sparky.dal.rest.RestDataProvider#doRestfulOperation(org.openecomp.sparky.dal.rest
+ * .HttpMethod, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public OperationResult doRestfulOperation(HttpMethod method, String url, String payload,
Client client = null;
Builder builder = null;
- OperationResult operationResult = null;
-
- /*
- * Attempt to get cached data for the requested URL. We don't currently cache the other
- * operations.
- */
-
- operationResult = getCachedData(url, payload);
-
- if (operationResult != null) {
-
- /*
- * cache-hit, return what we found
- */
-
- // System.out.println("operationResult = " + operationResult.getResultCode());
- // System.out.println("opresult = " + operationResult.getResult());
- return operationResult;
- }
-
/*
* else cache miss / cache disabled (default operation)
*/
- operationResult = new OperationResult();
+ OperationResult operationResult = new OperationResult();
operationResult.setRequestLink(url);
try {
String.valueOf(operationResult.getResultCode()));
}
- cacheResult(operationResult);
-
return operationResult;
}
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#doGet(java.lang.String, java.lang.String)
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#doGet(java.lang.String, java.lang.String)
*/
@Override
public OperationResult doGet(String url, String acceptContentType) {
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#doDelete(java.lang.String, java.lang.String)
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#doDelete(java.lang.String,
+ * java.lang.String)
*/
@Override
public OperationResult doDelete(String url, String acceptContentType) {
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#doPost(java.lang.String, java.lang.String,
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#doPost(java.lang.String, java.lang.String,
* java.lang.String)
*/
@Override
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#doPut(java.lang.String, java.lang.String,
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#doPut(java.lang.String, java.lang.String,
* java.lang.String)
*/
@Override
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#doPatch(java.lang.String, java.lang.String,
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#doPatch(java.lang.String, java.lang.String,
* java.lang.String)
*/
@Override
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#doHead(java.lang.String, java.lang.String)
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#doHead(java.lang.String, java.lang.String)
*/
@Override
public OperationResult doHead(String url, String acceptContentType) {
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#shutdown()
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#shutdown()
*/
@Override
public void shutdown() {
- if (entityCache != null) {
- entityCache.shutdown();
- }
-
}
/*
* (non-Javadoc)
*
- * @see org.onap.aai.sparky.dal.rest.RestDataProvider#clearCache()
+ * @see org.openecomp.sparky.dal.rest.RestDataProvider#clearCache()
*/
@Override
public void clearCache() {
- if (cacheEnabled) {
- entityCache.clear();
- }
}