Commit 6fd68996 authored by Matt Wise's avatar Matt Wise
Browse files

code review cleanup

parent 1e3004d9
......@@ -14,21 +14,15 @@
package org.opengroup.osdu.datasetregistry.api;
import java.util.List;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.storage.Record;
import org.opengroup.osdu.core.common.model.storage.StorageRole;
import org.opengroup.osdu.core.common.model.storage.validation.ValidationDoc;
import org.opengroup.osdu.datasetregistry.model.CreateDatasetRegistryRequest;
import org.opengroup.osdu.datasetregistry.response.CreateUpdateDatasetRegistryResponse;
import org.opengroup.osdu.datasetregistry.service.DatasetRegistryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -46,10 +40,10 @@ import org.springframework.web.context.annotation.RequestScope;
@Validated
public class DatasetRegistryApi {
@Autowired
@Inject
private DpsHeaders headers;
@Autowired
@Inject
private DatasetRegistryService dataRegistryService;
@PutMapping()
......
......@@ -17,19 +17,15 @@ package org.opengroup.osdu.datasetregistry.service;
import java.util.List;
import java.util.Map;
import com.google.api.client.http.HttpResponse;
import javax.inject.Inject;
import org.apache.commons.lang3.NotImplementedException;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsAndCacheService;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.storage.MultiRecordIds;
import org.opengroup.osdu.core.common.model.storage.MultiRecordInfo;
import org.opengroup.osdu.core.common.model.storage.Record;
import org.opengroup.osdu.core.common.model.storage.RecordData;
import org.opengroup.osdu.core.common.model.storage.Schema;
import org.opengroup.osdu.core.common.model.storage.SchemaItem;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.datasetregistry.model.DatasetRegistryValidationDoc;
import org.opengroup.osdu.datasetregistry.response.CreateUpdateDatasetRegistryResponse;
import org.opengroup.osdu.datasetregistry.storage.CreateUpdateRecordsResponse;
......@@ -37,27 +33,22 @@ import org.opengroup.osdu.datasetregistry.storage.GetRecordsResponse;
import org.opengroup.osdu.datasetregistry.storage.IStorageFactory;
import org.opengroup.osdu.datasetregistry.storage.IStorageProvider;
import org.opengroup.osdu.datasetregistry.storage.StorageException;
import org.opengroup.osdu.datasetregistry.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
@Service
public class DatasetRegistryServiceImpl implements DatasetRegistryService {
@Autowired
private IEntitlementsAndCacheService entitlementsAndCacheService;
// @Autowired
// private ILegalService legalService;
final String DATASET_REGISTRY_DATASET_PROPERTIES_NAME = "DatasetProperties";
final String DATASET_REGISTRY_SCHEMA_FORMAT = "%s:osdu:dataset-registry:0.0.1";
@Autowired
@Inject
private DpsHeaders headers;
@Autowired
@Inject
IStorageFactory storageFactory;
@Override
public void deleteDatasetRegistry(String datasetRegistryId) {
// todo: implement
......@@ -92,17 +83,11 @@ public class DatasetRegistryServiceImpl implements DatasetRegistryService {
HttpStatus.valueOf(e.getHttpResponse().getResponseCode()).getReasonPhrase(), e.getMessage());
}
CreateUpdateDatasetRegistryResponse response = new CreateUpdateDatasetRegistryResponse(getRecordsResponse.getRecords());
CreateUpdateDatasetRegistryResponse response = new CreateUpdateDatasetRegistryResponse(getRecordsResponse.getRecords());
return response;
}
final String DATASET_REGISTRY_DATASET_PROPERTIES_NAME = "DatasetProperties";
final String DATASET_REGISTRY_SCHEMA_FORMAT = "%s:osdu:dataset-registry:0.0.1";
/**
* Return a 400 Bad Request if any validation fails (one bad property on a single dataset registry fails all input dataset registries)
* in the event of bad input, nothing gets persisted (sent to storage service)
......
......@@ -15,41 +15,42 @@
package org.opengroup.osdu.datasetregistry.service;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.model.entitlements.Acl;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.model.storage.RecordMetadata;
import org.opengroup.osdu.core.common.util.Crc32c;
import org.opengroup.osdu.core.common.model.entitlements.EntitlementsException;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsAndCacheService;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsService;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsAndCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.opengroup.osdu.core.common.model.entitlements.Acl;
import org.opengroup.osdu.core.common.model.entitlements.EntitlementsException;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.storage.RecordMetadata;
import org.opengroup.osdu.core.common.util.Crc32c;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Service
public class EntitlementsAndCacheServiceImpl implements IEntitlementsAndCacheService {
private static final String ERROR_REASON = "Access denied";
private static final String ERROR_MSG = "The user is not authorized to perform this action";
@Autowired
@Inject
private IEntitlementsFactory factory;
@Autowired
@Inject
private ICache<String, Groups> cache;
@Autowired
@Inject
private JaxRsDpsLog logger;
@Override
......
......@@ -19,7 +19,6 @@ package org.opengroup.osdu.datasetregistry.storage;
import java.util.List;
import org.opengroup.osdu.core.common.model.storage.MultiRecordIds;
import org.opengroup.osdu.core.common.model.storage.MultiRecordInfo;
import org.opengroup.osdu.core.common.model.storage.Record;
import org.opengroup.osdu.core.common.model.storage.Schema;
......@@ -31,6 +30,4 @@ public interface IStorageProvider {
Schema getSchema(String kind) throws StorageException;
}
\ No newline at end of file
......@@ -39,7 +39,4 @@ public class StorageFactory implements IStorageFactory {
}
return new StorageService(this.config, new HttpClient(), headers);
}
}
......@@ -15,19 +15,21 @@
package org.opengroup.osdu.datasetregistry.util;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsAndCacheService;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Component("authorizationFilter")
@RequestScope
public class AuthorizationFilter {
@Autowired
@Inject
private IEntitlementsAndCacheService entitlementsAndCacheService;
@Autowired
@Inject
private DpsHeaders headers;
public boolean hasRole(String... requiredRoles) {
......
......@@ -19,6 +19,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
......@@ -28,12 +29,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.common.base.Strings;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.http.ResponseHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.stereotype.Component;
@Component
public class DatasetRegistryFilter implements Filter {
......@@ -43,7 +43,7 @@ public class DatasetRegistryFilter implements Filter {
private static final String FOR_HEADER_NAME = "frame-of-reference";
@Autowired
@Inject
private DpsHeaders dpsHeaders;
@Override
......
......@@ -15,13 +15,14 @@
package org.opengroup.osdu.datasetregistry.util;
import javax.inject.Inject;
import javax.validation.ValidationException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import javassist.NotFoundException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders;
......@@ -34,13 +35,14 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.opengroup.osdu.core.common.model.http.AppException;
import javassist.NotFoundException;
@Order(Ordered.HIGHEST_PRECEDENCE)
@ControllerAdvice
public class GlobalExceptionMapper extends ResponseEntityExceptionHandler {
@Autowired
@Inject
private JaxRsDpsLog logger;
@ExceptionHandler(AppException.class)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment