use of io.automatiko.engine.workflow.file.ByteArrayFile in project automatiko-engine by automatiko-io.
the class FileSystemFileVariableAugmentor method augmentOnUpdate.
@Override
public Object augmentOnUpdate(String processId, String processVersion, String processInstanceId, Variable variable, Object value) {
Object originalValue = value;
value = retrieveValue(value);
if (value == null) {
return value;
}
StringBuilder url = new StringBuilder(serviceUrl);
url.append(processId).append("/");
if (processVersion != null && !processVersion.isEmpty()) {
url.append(processVersion).append("/");
}
url.append(processInstanceId).append("/").append(variable.getName());
if (value instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) value;
if (file.content() != null) {
FileSystemFile fsFile = new FileSystemFile(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// replace file on file system
store.replace(file.content(), processId, processVersion, processInstanceId, variable.getName(), file.name());
value = updateValue(originalValue, fsFile);
}
} else if (value instanceof Collection) {
Collection<ByteArrayFile> fsFiles = new ArrayList<>();
for (Object potentialFile : (Collection<?>) value) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
if (file.content() != null) {
FileSystemFile fsFile = new FileSystemFile(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// replace file on file system
store.replace(file.content(), processId, processVersion, processInstanceId, variable.getName(), file.name());
fsFiles.add(fsFile);
} else {
fsFiles.add(file);
}
}
}
return updateValue(originalValue, fsFiles);
}
return value;
}
use of io.automatiko.engine.workflow.file.ByteArrayFile in project automatiko-engine by automatiko-io.
the class FileSystemFileVariableAugmentor method augmentOnCreate.
@Override
public Object augmentOnCreate(String processId, String processVersion, String processInstanceId, Variable variable, Object value) {
Object originalValue = value;
value = retrieveValue(value);
if (value == null) {
return value;
}
StringBuilder url = new StringBuilder(serviceUrl);
url.append(processId).append("/");
if (processVersion != null && !processVersion.isEmpty()) {
url.append(processVersion).append("/");
}
url.append(processInstanceId).append("/").append(variable.getName());
if (value instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) value;
if (file.content() != null) {
FileSystemFile fsFile = new FileSystemFile(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// store file on file system
store.save(file.content(), processId, processVersion, processInstanceId, variable.getName(), file.name());
value = updateValue(originalValue, fsFile);
}
} else if (value instanceof Collection) {
Collection<ByteArrayFile> fsFiles = new ArrayList<>();
for (Object potentialFile : (Collection<?>) value) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
if (file.content() != null) {
FileSystemFile fsFile = new FileSystemFile(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// store file on file system
store.save(file.content(), processId, processVersion, processInstanceId, variable.getName(), file.name());
fsFiles.add(fsFile);
} else {
fsFiles.add(file);
}
}
}
return updateValue(originalValue, fsFiles);
}
return value;
}
use of io.automatiko.engine.workflow.file.ByteArrayFile in project automatiko-engine by automatiko-io.
the class FileSystemFileVariableAugmentor method augmentOnDelete.
@Override
public void augmentOnDelete(String processId, String processVersion, String processInstanceId, Variable variable, Object value) {
value = retrieveValue(value);
if (value instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) value;
store.remove(processId, processVersion, processInstanceId, variable.getName(), file.name());
} else if (value instanceof Collection) {
for (Object potentialFile : (Collection<?>) value) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
store.remove(processId, processVersion, processInstanceId, variable.getName(), file.name());
}
}
}
}
use of io.automatiko.engine.workflow.file.ByteArrayFile in project automatiko-engine by automatiko-io.
the class S3FileVariableAugmentor method augmentOnUpdate.
@Override
public Object augmentOnUpdate(String processId, String processVersion, String processInstanceId, Variable variable, Object value) {
Object originalValue = value;
value = retrieveValue(value);
if (value == null) {
return value;
}
StringBuilder url = new StringBuilder(serviceUrl);
url.append(processId).append("/");
if (processVersion != null && !processVersion.isEmpty()) {
url.append(processVersion).append("/");
}
url.append(processInstanceId).append("/").append(variable.getName());
if (value instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) value;
if (file.content() != null) {
S3File fsFile = new S3File(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// replace file on file system
store.replace(file, processId, processVersion, processInstanceId, variable.getName(), file.name());
value = updateValue(originalValue, fsFile);
}
} else if (value instanceof Collection) {
Collection<ByteArrayFile> fsFiles = new ArrayList<>();
for (Object potentialFile : (Collection<?>) value) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
if (file.content() != null) {
S3File fsFile = new S3File(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// replace file on file system
store.replace(file, processId, processVersion, processInstanceId, variable.getName(), file.name());
fsFiles.add(fsFile);
} else {
fsFiles.add(file);
}
}
}
return updateValue(originalValue, fsFiles);
}
return value;
}
use of io.automatiko.engine.workflow.file.ByteArrayFile in project automatiko-engine by automatiko-io.
the class S3FileVariableAugmentor method augmentOnCreate.
@Override
public Object augmentOnCreate(String processId, String processVersion, String processInstanceId, Variable variable, Object value) {
Object originalValue = value;
value = retrieveValue(value);
if (value == null) {
return value;
}
StringBuilder url = new StringBuilder(serviceUrl);
url.append(processId).append("/");
if (processVersion != null && !processVersion.isEmpty()) {
url.append(processVersion).append("/");
}
url.append(processInstanceId).append("/").append(variable.getName());
if (value instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) value;
if (file.content() != null) {
S3File fsFile = new S3File(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// store file on file system
store.save(file, processId, processVersion, processInstanceId, variable.getName(), file.name());
value = updateValue(originalValue, fsFile);
}
} else if (value instanceof Collection) {
Collection<ByteArrayFile> fsFiles = new ArrayList<>();
for (Object potentialFile : (Collection<?>) value) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
if (file.content() != null) {
S3File fsFile = new S3File(file.name(), null, file.attributes());
fsFile.url(url.toString() + "/" + file.name());
// store file on file system
store.save(file, processId, processVersion, processInstanceId, variable.getName(), file.name());
fsFiles.add(fsFile);
} else {
fsFiles.add(file);
}
}
}
return updateValue(originalValue, fsFiles);
}
return value;
}
Aggregations