TSK-311 fixed checkstyle

This commit is contained in:
Mustapha Zorgati 2018-02-27 15:32:01 +01:00 committed by Holger Hagen
parent 54c9b538f8
commit eaf15fd19c
25 changed files with 124 additions and 52 deletions

View File

@ -177,10 +177,6 @@
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>

View File

@ -28,6 +28,9 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.mapper.ClassificationMapper;
/**
* TODO.
*/
@RestController
@RequestMapping(path = "/v1/classifications", produces = {MediaType.APPLICATION_JSON_VALUE})
public class ClassificationController {

View File

@ -28,6 +28,9 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.mapper.ClassificationMapper;
/**
* TODO.
*/
@RestController
@RequestMapping(path = "/v1/classificationdefinitions", produces = {MediaType.APPLICATION_JSON_VALUE})
public class ClassificationDefinitionController {
@ -69,10 +72,12 @@ public class ClassificationDefinitionController {
for (ClassificationResource classificationResource : classificationResources) {
Classification classification = classificationMapper.toModel(classificationResource);
if (systemIds.containsKey(classificationResource.key + "|||" + classificationResource.domain))
if (systemIds.containsKey(classificationResource.key + "|||" + classificationResource.domain)) {
classificationService.updateClassification(classification);
else
} else {
classificationService.createClassification(classification);
}
}
return new ResponseEntity<>(HttpStatus.OK);

View File

@ -12,6 +12,9 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.TaskState;
/**
* TODO.
*/
@RestController
@RequestMapping(path = "/v1/monitor", produces = {MediaType.APPLICATION_JSON_VALUE})
public class MonitorController {

View File

@ -29,6 +29,9 @@ import pro.taskana.WorkbasketService;
import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.configuration.TaskanaEngineConfiguration;
/**
* TODO.
*/
@Configuration
@ComponentScan
@EnableTransactionManagement

View File

@ -33,11 +33,14 @@ import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.rest.query.TaskFilter;
/**
* TODO.
*/
@RestController
@RequestMapping(path = "/v1/tasks", produces = {MediaType.APPLICATION_JSON_VALUE})
public class TaskController {
private static final Logger logger = LoggerFactory.getLogger(TaskController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TaskController.class);
@Autowired
private TaskService taskService;
@ -56,7 +59,7 @@ public class TaskController {
}
return ResponseEntity.status(HttpStatus.OK).body(taskLogic.inspectPrams(params));
} catch (NotAuthorizedException e) {
logger.error("Something went wrong with the Authorisation, while getting all Tasks.", e);
LOGGER.error("Something went wrong with the Authorisation, while getting all Tasks.", e);
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
}
@ -69,7 +72,7 @@ public class TaskController {
Task task = taskService.getTask(taskId);
return ResponseEntity.status(HttpStatus.OK).body(task);
} catch (TaskNotFoundException e) {
logger.error("The searched Task couldn´t be found or does not exist.", e);
LOGGER.error("The searched Task couldn´t be found or does not exist.", e);
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
@ -103,11 +106,11 @@ public class TaskController {
Task updatedTask = taskService.getTask(taskId);
return ResponseEntity.status(HttpStatus.OK).body(updatedTask);
} catch (TaskNotFoundException e) {
logger.error("The given Task coundn´t be found/claimd or does not Exist.", e);
LOGGER.error("The given Task coundn´t be found/claimd or does not Exist.", e);
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
} catch (InvalidStateException | InvalidOwnerException e) {
logger.error("The given Task could not be claimed. Reason: {}", e);
LOGGER.error("The given Task could not be claimed. Reason: {}", e);
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return ResponseEntity.status(HttpStatus.CONFLICT).build();
}
@ -136,7 +139,7 @@ public class TaskController {
Task createdTask = taskService.createTask(task);
return ResponseEntity.status(HttpStatus.CREATED).body(createdTask);
} catch (Exception e) {
logger.error("Something went wrong: ", e);
LOGGER.error("Something went wrong: ", e);
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
@ -149,7 +152,7 @@ public class TaskController {
Task updatedTask = taskService.transfer(taskId, workbasketKey);
return ResponseEntity.status(HttpStatus.CREATED).body(updatedTask);
} catch (Exception e) {
logger.error("Something went wrong: ", e);
LOGGER.error("Something went wrong: ", e);
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}

View File

@ -41,6 +41,9 @@ import pro.taskana.rest.resource.mapper.WorkbasketAccessItemMapper;
import pro.taskana.rest.resource.mapper.WorkbasketMapper;
import pro.taskana.rest.resource.mapper.WorkbasketSummaryMapper;
/**
* TODO.
*/
@RestController
@RequestMapping(path = "/v1/workbaskets", produces = {MediaType.APPLICATION_JSON_VALUE})
public class WorkbasketController {
@ -343,6 +346,8 @@ public class WorkbasketController {
case "CUSTOM_12":
query.callerHasPermission(WorkbasketPermission.CUSTOM_12);
break;
default:
throw new RuntimeException("should never occur");
}
} catch (InvalidArgumentException e) {
e.printStackTrace();
@ -369,6 +374,8 @@ public class WorkbasketController {
case TYPE:
query.orderByType(sortDirection);
break;
default:
throw new RuntimeException("should never occur");
}
}
@ -384,20 +391,27 @@ public class WorkbasketController {
String key, String keyLike,
String descLike, String owner,
String ownerLike, String type) {
if (name != null)
if (name != null) {
query.nameIn(name);
if (nameLike != null)
}
if (nameLike != null) {
query.nameLike(LIKE + nameLike + LIKE);
if (key != null)
}
if (key != null) {
query.keyIn(key);
if (keyLike != null)
}
if (keyLike != null) {
query.keyLike(LIKE + keyLike + LIKE);
if (owner != null)
}
if (owner != null) {
query.ownerIn(owner);
if (ownerLike != null)
}
if (ownerLike != null) {
query.ownerLike(LIKE + ownerLike + LIKE);
if (descLike != null)
}
if (descLike != null) {
query.descriptionLike(LIKE + descLike + LIKE);
}
if (type != null) {
switch (type) {
case "PERSONAL":
@ -412,6 +426,8 @@ public class WorkbasketController {
case "TOPIC":
query.typeIn(WorkbasketType.TOPIC);
break;
default:
throw new RuntimeException("should never occur");
}
}
}

View File

@ -34,6 +34,9 @@ import pro.taskana.rest.resource.mapper.WorkbasketAccessItemMapper;
import pro.taskana.rest.resource.mapper.WorkbasketDefinitionMapper;
import pro.taskana.rest.resource.mapper.WorkbasketMapper;
/**
* TODO.
*/
@RestController
@RequestMapping(path = "/v1/workbasketdefinitions", produces = {MediaType.APPLICATION_JSON_VALUE})
public class WorkbasketDefinitionController {

View File

@ -15,6 +15,9 @@ import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* TODO.
*/
@Component
public class TaskFilter {
@ -131,18 +134,14 @@ public class TaskFilter {
private String[] extractCommaSeperatedFields(List<String> list) {
List<String> values = new ArrayList<>();
list.stream().forEach(item -> {
Arrays.asList(item.split(COMMA)).stream().forEach(subItem -> {
values.add(subItem);
});
});
list.forEach(item -> values.addAll(Arrays.asList(item.split(COMMA))));
return values.toArray(new String[0]);
}
private TaskState[] extractStates(MultiValueMap<String, String> params) {
List<TaskState> states = new ArrayList<>();
params.get(STATE).stream().forEach(item -> {
Arrays.asList(item.split(COMMA)).stream().forEach(state -> {
params.get(STATE).forEach(item -> {
Arrays.asList(item.split(COMMA)).forEach(state -> {
switch (state) {
case READY:
states.add(TaskState.READY);
@ -153,6 +152,8 @@ public class TaskFilter {
case CLAIMED:
states.add(TaskState.CLAIMED);
break;
default:
throw new RuntimeException("should never occur");
}
});
});

View File

@ -2,6 +2,9 @@ package pro.taskana.rest.resource;
import org.springframework.hateoas.ResourceSupport;
/**
* TODO.
*/
public class ClassificationResource extends ResourceSupport {
public String classificationId;

View File

@ -4,6 +4,9 @@ import javax.validation.constraints.NotNull;
import org.springframework.hateoas.ResourceSupport;
/**
* TODO.
*/
public class WorkbasketAccessItemResource extends ResourceSupport {
public String accessItemId;

View File

@ -6,6 +6,9 @@ import org.springframework.hateoas.ResourceSupport;
import pro.taskana.impl.WorkbasketType;
/**
* TODO.
*/
public class WorkbasketResource extends ResourceSupport {
public String workbasketId;

View File

@ -6,6 +6,9 @@ import org.springframework.hateoas.ResourceSupport;
import pro.taskana.impl.WorkbasketType;
/**
* TODO.
*/
public class WorkbasketSummaryResource extends ResourceSupport {
public String workbasketId;

View File

@ -16,6 +16,9 @@ import pro.taskana.impl.ClassificationImpl;
import pro.taskana.rest.ClassificationController;
import pro.taskana.rest.resource.ClassificationResource;
/**
* TODO.
*/
@Component
public class ClassificationMapper {

View File

@ -16,6 +16,9 @@ import pro.taskana.impl.WorkbasketAccessItemImpl;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
/**
* TODO.
*/
@Component
public class WorkbasketAccessItemMapper {

View File

@ -21,6 +21,9 @@ import pro.taskana.rest.WorkbasketDefinitionController;
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
import pro.taskana.rest.resource.WorkbasketDefinition;
/**
* TODO.
*/
@Component
public class WorkbasketDefinitionMapper {

View File

@ -16,6 +16,9 @@ import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.WorkbasketResource;
/**
* TODO.
*/
@Component
public class WorkbasketMapper {

View File

@ -10,6 +10,9 @@ import pro.taskana.WorkbasketSummary;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.WorkbasketSummaryResource;
/**
* TODO.
*/
@Component
public class WorkbasketSummaryMapper {

View File

@ -21,13 +21,13 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
/**
* This class deserializes the string list to real workbaskets
* This class deserializes the string list to real workbaskets.
*/
public class DistributionTargetDeserializer extends StdDeserializer<List<Workbasket>> {
private static final long serialVersionUID = 4226950057149602129L;
private static final Logger logger = LoggerFactory.getLogger(DistributionTargetDeserializer.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DistributionTargetDeserializer.class);
@Autowired
private WorkbasketService workbasketService;
@ -50,9 +50,9 @@ public class DistributionTargetDeserializer extends StdDeserializer<List<Workbas
try {
distributionTargets.add(workbasketService.getWorkbasket(id));
} catch (WorkbasketNotFoundException e) {
logger.error("The workbasket with the id '" + id + "' is not found in database.");
LOGGER.error("The workbasket with the id '" + id + "' is not found in database.");
} catch (NotAuthorizedException e) {
logger.error(
LOGGER.error(
"The user misses some required permissions for the workbasket with ID '" + id
+ "'. Exception = {}.",
e);

View File

@ -11,28 +11,28 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import pro.taskana.Workbasket;
/**
* This class serializes the distribution targets to an string array with ids
* This class serializes the distribution targets to an string array with ids.
*/
public class DistributionTargetSerializer extends StdSerializer<List<Workbasket>> {
private static final long serialVersionUID = -4655804943794734821L;
private static final long serialVersionUID = -4655804943794734821L;
public DistributionTargetSerializer() {
this(null);
}
public DistributionTargetSerializer() {
this(null);
}
public DistributionTargetSerializer(Class<List<Workbasket>> t) {
super(t);
}
public DistributionTargetSerializer(Class<List<Workbasket>> t) {
super(t);
}
@Override
public void serialize(List<Workbasket> workbaskets, JsonGenerator gen, SerializerProvider provider)
throws IOException {
List<String> ids = new ArrayList<>();
@Override
public void serialize(List<Workbasket> workbaskets, JsonGenerator gen, SerializerProvider provider)
throws IOException {
List<String> ids = new ArrayList<>();
for (Workbasket item : workbaskets) {
ids.add(item.getId());
}
gen.writeObject(ids);
}
for (Workbasket item : workbaskets) {
ids.add(item.getId());
}
gen.writeObject(ids);
}
}

View File

@ -9,12 +9,12 @@ import pro.taskana.Workbasket;
/**
* This class is used to override the distributiontargets with non standard
* serialization classes
* serialization classes.
*/
public abstract class WorkbasketMixIn {
@JsonSerialize(using = DistributionTargetSerializer.class)
@JsonDeserialize(using = DistributionTargetDeserializer.class)
abstract List<Workbasket> getDistributionTargets();
@JsonSerialize(using = DistributionTargetSerializer.class)
@JsonDeserialize(using = DistributionTargetDeserializer.class)
abstract List<Workbasket> getDistributionTargets();
}

View File

@ -17,6 +17,9 @@ import pro.taskana.impl.ClassificationImpl;
import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.ClassificationResource;
/**
* TODO.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {RestConfiguration.class})
@WebAppConfiguration

View File

@ -14,6 +14,9 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
/**
* TODO.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {RestConfiguration.class})
@WebAppConfiguration

View File

@ -18,6 +18,9 @@ import pro.taskana.impl.WorkbasketType;
import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.WorkbasketResource;
/**
* TODO.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {RestConfiguration.class})
@WebAppConfiguration

View File

@ -14,6 +14,9 @@ import pro.taskana.impl.WorkbasketType;
import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.WorkbasketSummaryResource;
/**
* TODO.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {RestConfiguration.class})
@WebAppConfiguration