Skip to content

Commit

Permalink
Minor changes #321
Browse files Browse the repository at this point in the history
- removed auto wire annotation where not necessary
- made some fields final
- fixed typos
- removed unnecessary log output
  • Loading branch information
de-jcup committed Dec 5, 2024
1 parent de70eb3 commit 7203934
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -44,27 +43,20 @@ public class AssetService {

private static final Logger LOG = LoggerFactory.getLogger(AssetService.class);

private AssetFileRepository repository;
private final AssetFileRepository repository;

private UserInputAssertion inputAssertion;
private final UserInputAssertion inputAssertion;

private CheckSumSupport checkSumSupport;
private final CheckSumSupport checkSumSupport;

private StorageService storageService;
private final StorageService storageService;

/* @formatter:off */
AssetService(
@Autowired AssetFileRepository repository,
@Autowired UserInputAssertion inputAssertion,
@Autowired CheckSumSupport checkSumSupport,
@Autowired StorageService storageService
) {
this.repository=repository;
this.inputAssertion=inputAssertion;
this.checkSumSupport=checkSumSupport;
this.storageService=storageService;
AssetService(AssetFileRepository repository, UserInputAssertion inputAssertion, CheckSumSupport checkSumSupport, StorageService storageService) {
this.repository = repository;
this.inputAssertion = inputAssertion;
this.checkSumSupport = checkSumSupport;
this.storageService = storageService;
}
/* @formatter:on */

@UseCaseAdminDeletesAssetCompletely(@Step(number = 2, name = "Services deletes all asset parts"))
@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mercedesbenz.sechub.commons.model.template.TemplateDefinition;
Expand All @@ -33,26 +32,21 @@ public class TemplateService {

private static final Logger LOG = LoggerFactory.getLogger(TemplateService.class);

private TemplateRepository repository;
private final TemplateRepository repository;

private ScanProjectConfigService configService;
private final ScanProjectConfigService configService;

private TemplateTypeScanConfigIdResolver resolver;
private final TemplateTypeScanConfigIdResolver resolver;

private UserInputAssertion inputAssertion;
private final UserInputAssertion inputAssertion;

/* @formatter:off */
TemplateService(
@Autowired TemplateRepository repository,
@Autowired ScanProjectConfigService configService,
@Autowired UserInputAssertion inputAssertion,
@Autowired TemplateTypeScanConfigIdResolver resolver) {
this.repository=repository;
this.configService=configService;
this.resolver=resolver;
this.inputAssertion=inputAssertion;
TemplateService(TemplateRepository repository, ScanProjectConfigService configService, UserInputAssertion inputAssertion,
TemplateTypeScanConfigIdResolver resolver) {
this.repository = repository;
this.configService = configService;
this.resolver = resolver;
this.inputAssertion = inputAssertion;
}
/* @formatter:on */

@UseCaseAdminCreatesOrUpdatesTemplate(@Step(number = 2, name = "Service creates or updates template"))
public void createOrUpdateTemplate(String templateId, TemplateDefinition newTemplateDefinition) {
Expand All @@ -69,9 +63,9 @@ public void createOrUpdateTemplate(String templateId, TemplateDefinition newTemp

Optional<Template> templateOpt = repository.findById(templateId);
Template template = null;
;

if (templateOpt.isEmpty()) {
// we found an existing template
// we did not find an existing template, so we create one
template = new Template(templateId);
} else {
template = templateOpt.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void equals_returns_false_when_filenames_are_NOT_same() {
info1.setFileName("filename1");

AssetFileData info2 = new AssetFileData();
info1.setChecksum(sameChecksum);
info2.setFileName("filename1");
info2.setChecksum(sameChecksum);
info2.setFileName("filename2");

/* execute + test */
assertThat(info1).isNotEqualTo(info2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
group=UseCaseGroup.CONFIGURATION,
apiName="adminUploadsAssetFile",
title="Admin uploads an asset file",
description="An administrator uploads a file for an asset. If the file already exits, it will be overriden.")
description="An administrator uploads a file for an asset. If the file already exists, it will be overriden.")
public @interface UseCaseAdminUploadsAssetFile {

Step value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public AbstractSharedVolumeStorage(Path rootLocation, String rootStoragePath, Ob
if (additionalStoragePathParts != null) {
for (Object additionalStoragePathPart : additionalStoragePathParts) {
if (additionalStoragePathPart == null) {
LOG.warn("Additional part was null at position: ");
continue;
}
this.volumePath = volumePath.resolve(additionalStoragePathPart.toString());
Expand Down

0 comments on commit 7203934

Please sign in to comment.