Skip to content

Commit

Permalink
1729 - Add missing @nonnull, annottaions remove validations
Browse files Browse the repository at this point in the history
  • Loading branch information
ivicac committed Nov 14, 2024
1 parent 2d8e192 commit 1a89ddc
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public interface ApiConnectorFileStorage {

void deleteApiConnectorDefinition(FileEntry componentFile);
void deleteApiConnectorDefinition(@NonNull FileEntry componentFile);

void deleteApiConnectorSpecification(@NonNull FileEntry specificationFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.bytechef.file.storage.domain.FileEntry;
import com.bytechef.file.storage.service.FileStorageService;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.Validate;
import org.springframework.lang.NonNull;

/**
Expand All @@ -39,7 +38,7 @@ public ApiConnectorFileStorageImpl(FileStorageService fileStorageService) {
}

@Override
public void deleteApiConnectorDefinition(FileEntry componentFile) {
public void deleteApiConnectorDefinition(@NonNull FileEntry componentFile) {
fileStorageService.deleteFile(API_CONNECTORS_DEFINITIONS_DIR, componentFile);
}

Expand All @@ -62,18 +61,12 @@ public String readApiConnectorSpecification(@NonNull FileEntry specificationFile

@Override
public FileEntry storeApiConnectorDefinition(String filename, @NonNull String definition) {
Validate.notNull(filename, "'filename' must not be null");
Validate.notNull(definition, "'bytes' must not be null");

return fileStorageService.storeFileContent(
API_CONNECTORS_DEFINITIONS_DIR, filename, CompressionUtils.compress(definition));
}

@Override
public FileEntry storeApiConnectorSpecification(@NonNull String filename, @NonNull String definition) {
Validate.notNull(filename, "'filename' must not be null");
Validate.notNull(definition, "'definition' must not be null");

return fileStorageService.storeFileContent(
API_CONNECTORS_SPECIFICATIONS_DIR, filename, CompressionUtils.compress(definition));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.fasterxml.jackson.core.type.TypeReference;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
import org.apache.commons.lang3.Validate;
import org.springframework.lang.NonNull;

/**
Expand Down Expand Up @@ -52,17 +51,13 @@ public TaskFileStorageImpl(FileStorageService fileStorageService) {

@Override
public Map<String, ?> readJobOutputs(@NonNull FileEntry fileEntry) {
Validate.notNull(fileEntry, "'fileEntry' must not be null");

return JsonUtils.read(
CompressionUtils.decompressToString(fileStorageService.readFileToBytes(JOB_FILES_DIR, fileEntry)),
new TypeReference<>() {});
}

@Override
public Object readTaskExecutionOutput(@NonNull FileEntry fileEntry) {
Validate.notNull(fileEntry, "'fileEntry' must not be null");

return JsonUtils.read(
CompressionUtils.decompressToString(
fileStorageService.readFileToBytes(TASK_EXECUTION_FILES_DIR, fileEntry)),
Expand All @@ -73,9 +68,6 @@ public Object readTaskExecutionOutput(@NonNull FileEntry fileEntry) {
public FileEntry storeContextValue(
long stackId, @NonNull Context.Classname classname, @NonNull Map<String, ?> value) {

Validate.notNull(classname, "'classname' must not be null");
Validate.notNull(value, "'value' must not be null");

return fileStorageService.storeFileContent(
CONTEXT_FILES_DIR, classname + "_" + stackId + ".json", CompressionUtils.compress(JsonUtils.write(value)));
}
Expand All @@ -84,26 +76,19 @@ public FileEntry storeContextValue(
public FileEntry storeContextValue(
long stackId, int subStackId, @NonNull Context.Classname classname, @NonNull Map<String, ?> value) {

Validate.notNull(classname, "'classname' must not be null");
Validate.notNull(value, "'value' must not be null");

return fileStorageService.storeFileContent(
CONTEXT_FILES_DIR, classname + "_" + stackId + "_" + subStackId + ".json",
CompressionUtils.compress(JsonUtils.write(value)));
}

@Override
public FileEntry storeJobOutputs(long jobId, @NonNull Map<String, ?> outputs) {
Validate.notNull(outputs, "'outputs' must not be null");

return fileStorageService.storeFileContent(
JOB_FILES_DIR, jobId + ".json", CompressionUtils.compress(JsonUtils.write(outputs)));
}

@Override
public FileEntry storeTaskExecutionOutput(long taskExecutionId, @NonNull Object output) {
Validate.notNull(output, "'output' must not be null");

return fileStorageService.storeFileContent(
TASK_EXECUTION_FILES_DIR, taskExecutionId + ".json",
CompressionUtils.compress(JsonUtils.write(output)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public interface CodeWorkflowFileStorage {

FileEntry storeCodeWorkflowDefinition(@NonNull String filename, @NonNull String definition);

FileEntry storeCodeWorkflowFile(String filename, @NonNull byte[] bytes);
FileEntry storeCodeWorkflowFile(@NonNull String filename, @NonNull byte[] bytes);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.bytechef.file.storage.service.FileStorageService;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URL;
import org.apache.commons.lang3.Validate;
import org.springframework.lang.NonNull;

/**
Expand Down Expand Up @@ -67,10 +66,7 @@ public FileEntry storeCodeWorkflowDefinition(@NonNull String filename, @NonNull
}

@Override
public FileEntry storeCodeWorkflowFile(String filename, @NonNull byte[] bytes) {
Validate.notNull(filename, "'filename' must not be null");
Validate.notNull(bytes, "'bytes' must not be null");

public FileEntry storeCodeWorkflowFile(@NonNull String filename, @NonNull byte[] bytes) {
return fileStorageService.storeFileContent(CODE_WORKFLOWS_FILES_DIR, filename, bytes, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.bytechef.platform.file.storage.FilesFileStorage;
import com.bytechef.platform.file.storage.FilesFileStorageImpl;
import java.io.InputStream;
import org.springframework.lang.NonNull;

/**
* @author Ivica Cardic
Expand All @@ -30,22 +31,22 @@ public class InMemoryFilesFileStorage implements FilesFileStorage {
private final FilesFileStorage filesFileStorage = new FilesFileStorageImpl(new Base64FileStorageService());

@Override
public InputStream getFileStream(FileEntry fileEntry) {
public InputStream getFileStream(@NonNull FileEntry fileEntry) {
return filesFileStorage.getFileStream(fileEntry);
}

@Override
public String readFileToString(FileEntry fileEntry) {
public String readFileToString(@NonNull FileEntry fileEntry) {
return filesFileStorage.readFileToString(fileEntry);
}

@Override
public FileEntry storeFileContent(String fileName, String data) {
public FileEntry storeFileContent(@NonNull String fileName, @NonNull String data) {
return filesFileStorage.storeFileContent(fileName, data);
}

@Override
public FileEntry storeFileContent(String submittedFileName, InputStream inputStream) {
public FileEntry storeFileContent(@NonNull String submittedFileName, @NonNull InputStream inputStream) {
return filesFileStorage.storeFileContent(submittedFileName, inputStream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.data.domain.Page;
import org.springframework.lang.NonNull;

/**
* @author Ivica Cardic
Expand All @@ -81,7 +82,7 @@ public class JobSyncExecutor {
private static final Executor executor = Executors.newCachedThreadPool();

@Override
public void execute(Runnable task) {
public void execute(@NonNull Runnable task) {
String tenantId = TenantContext.getCurrentTenantId();

executor.execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
*/
public interface CustomComponentFileStorage {

void deleteCustomComponentFile(FileEntry componentFile);
void deleteCustomComponentFile(@NonNull FileEntry componentFile);

URL getCustomComponentFileURL(@NonNull FileEntry componentFile);

FileEntry storeCustomComponentFile(String filename, @NonNull byte[] bytes);
FileEntry storeCustomComponentFile(@NonNull String filename, @NonNull byte[] bytes);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.bytechef.file.storage.service.FileStorageService;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URL;
import org.apache.commons.lang3.Validate;
import org.springframework.lang.NonNull;

/**
Expand All @@ -38,7 +37,7 @@ public CustomComponentFileStorageImpl(FileStorageService fileStorageService) {
}

@Override
public void deleteCustomComponentFile(FileEntry componentFile) {
public void deleteCustomComponentFile(@NonNull FileEntry componentFile) {
fileStorageService.deleteFile(CUSTOM_COMPONENTS_FILES_DIR, componentFile);
}

Expand All @@ -48,10 +47,7 @@ public URL getCustomComponentFileURL(@NonNull FileEntry componentFile) {
}

@Override
public FileEntry storeCustomComponentFile(String filename, @NonNull byte[] bytes) {
Validate.notNull(filename, "'filename' must not be null");
Validate.notNull(bytes, "'bytes' must not be null");

public FileEntry storeCustomComponentFile(@NonNull String filename, @NonNull byte[] bytes) {
return fileStorageService.storeFileContent(CUSTOM_COMPONENTS_FILES_DIR, filename, bytes, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@

import com.bytechef.file.storage.domain.FileEntry;
import java.io.InputStream;
import org.springframework.lang.NonNull;

/**
* @author Ivica Cardic
*/
public interface FilesFileStorage {

InputStream getFileStream(FileEntry fileEntry);
InputStream getFileStream(@NonNull FileEntry fileEntry);

String readFileToString(FileEntry fileEntry);
String readFileToString(@NonNull FileEntry fileEntry);

FileEntry storeFileContent(String fileName, String data);
FileEntry storeFileContent(@NonNull String fileName, @NonNull String data);

FileEntry storeFileContent(String submittedFileName, InputStream inputStream);
FileEntry storeFileContent(@NonNull String submittedFileName, @NonNull InputStream inputStream);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.bytechef.file.storage.service.FileStorageService;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.InputStream;
import org.springframework.lang.NonNull;

/**
* @author Ivica Cardic
Expand All @@ -36,22 +37,22 @@ public FilesFileStorageImpl(FileStorageService fileStorageService) {
}

@Override
public InputStream getFileStream(FileEntry fileEntry) {
public InputStream getFileStream(@NonNull FileEntry fileEntry) {
return fileStorageService.getFileStream(FILES_DIR, fileEntry);
}

@Override
public String readFileToString(FileEntry fileEntry) {
public String readFileToString(@NonNull FileEntry fileEntry) {
return fileStorageService.readFileToString(FILES_DIR, fileEntry);
}

@Override
public FileEntry storeFileContent(String fileName, String data) {
public FileEntry storeFileContent(@NonNull String fileName, @NonNull String data) {
return fileStorageService.storeFileContent(FILES_DIR, fileName, data);
}

@Override
public FileEntry storeFileContent(String submittedFileName, InputStream inputStream) {
public FileEntry storeFileContent(@NonNull String submittedFileName, @NonNull InputStream inputStream) {
return fileStorageService.storeFileContent(FILES_DIR, submittedFileName, inputStream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.bytechef.file.storage.domain.FileEntry;
import com.bytechef.file.storage.service.FileStorageService;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.Validate;
import org.springframework.lang.NonNull;

/**
Expand All @@ -40,8 +39,6 @@ public TriggerFileStorageImpl(FileStorageService fileStorageService) {

@Override
public Object readTriggerExecutionOutput(@NonNull FileEntry fileEntry) {
Validate.notNull(fileEntry, "'fileEntry' must not be null");

return JsonUtils.read(
CompressionUtils.decompressToString(
fileStorageService.readFileToBytes(TRIGGER_EXECUTION_FILES_DIR, fileEntry)),
Expand All @@ -50,8 +47,6 @@ public Object readTriggerExecutionOutput(@NonNull FileEntry fileEntry) {

@Override
public FileEntry storeTriggerExecutionOutput(long triggerExecutionId, @NonNull Object output) {
Validate.notNull(output, "'output' must not be null");

return fileStorageService.storeFileContent(
TRIGGER_EXECUTION_FILES_DIR, triggerExecutionId + ".json",
CompressionUtils.compress(JsonUtils.write(output)));
Expand Down

0 comments on commit 1a89ddc

Please sign in to comment.