diff --git a/.github/workflows/release-backend.yml b/.github/workflows/release-backend.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/release-frontend.yml b/.github/workflows/release-frontend.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 2ab3a41e5a..ca7c7ad78f --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .gradle build/ +.history/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/assets/ap-logo.png b/assets/ap-logo.png old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml old mode 100644 new mode 100755 diff --git a/src/backend/.gitignore b/src/backend/.gitignore deleted file mode 100644 index b9ca9ab0cd..0000000000 --- a/src/backend/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.classpath -.project -.settings/ -target/ -/code-build/ -*.iml -/code -/.idea/ diff --git a/src/backend/Dockerfile b/src/backend/Dockerfile deleted file mode 100644 index 11b9989c8e..0000000000 --- a/src/backend/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM debian:bullseye - -RUN apt-get update -RUN apt-get install -y default-jre -RUN apt-get install -y curl \ - && apt-get update && curl -sL https://deb.nodesource.com/setup_16.x | bash - \ - && apt-get install -y nodejs \ - && curl -L https://www.npmjs.com/install.sh | sh - -# Set the locale -RUN apt-get update && apt-get install -y --no-install-recommends \ - locales \ - locales-all -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 - -RUN apt-get install -y libcap-dev -COPY backend-loader/default.cf /usr/local/etc/isolate -COPY backend-loader/isolate /isolate - -RUN npm install --global --unsafe-perm webpack@5.74.0 -RUN npm install --global --unsafe-perm webpack-cli@^4.10.0 -RUN npm install --global --unsafe-perm webpack-node-externals@^3.0.0 - -COPY backend-loader/target/backend-loader-*.jar /usr/local/lib/app.jar - -EXPOSE 8000 - -ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /usr/local/lib/app.jar"] diff --git a/src/backend/actions-service/actions-client/pom.xml b/src/backend/actions-service/actions-client/pom.xml deleted file mode 100644 index 207de012bb..0000000000 --- a/src/backend/actions-service/actions-client/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - actions-client - - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - variable-client - 1.0 - compile - - - com.activepieces - store-client - 1.0 - compile - - - Actions Client - 4.0.0 - actions-client - - actions-service - com.activepieces - 1.0 - - 1.0 - - \ No newline at end of file diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/mapper/ActionMapper.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/mapper/ActionMapper.java deleted file mode 100644 index 7c4a1843ba..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/mapper/ActionMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.activepieces.actions.mapper; - -import com.activepieces.actions.model.action.*; -import com.activepieces.actions.model.action.settings.CodeSettingsView; -import com.activepieces.entity.subdocuments.action.*; -import com.activepieces.entity.subdocuments.action.settings.CodeSettings; -import com.github.ksuid.Ksuid; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.SubclassMapping; -import org.mapstruct.SubclassMappings; - -import java.util.Objects; - -import static org.mapstruct.SubclassExhaustiveStrategy.RUNTIME_EXCEPTION; - -@Mapper(subclassExhaustiveStrategy = RUNTIME_EXCEPTION, componentModel = "spring") -public abstract class ActionMapper { - - @SubclassMappings({ - @SubclassMapping(source = CodeActionMetadata.class, target = CodeActionMetadataView.class), - @SubclassMapping( - source = StorageActionMetadata.class, - target = StorageActionMetadataView.class), - @SubclassMapping( - source = ResponseActionMetadata.class, - target = ResponseActionMetadataView.class), - @SubclassMapping( - source = LoopOnItemsActionMetadata.class, - target = LoopOnItemsActionMetadataView.class), - @SubclassMapping( - source = ComponentActionMetadata.class, - target = ComponentActionMetadataView.class) - }) - @Mappings(value = {}) - public abstract ActionMetadataView map(ActionMetadata entity); - - @SubclassMappings({ - @SubclassMapping(source = CodeActionMetadataView.class, target = CodeActionMetadata.class), - @SubclassMapping( - source = StorageActionMetadataView.class, - target = StorageActionMetadata.class), - @SubclassMapping( - source = ResponseActionMetadataView.class, - target = ResponseActionMetadata.class), - @SubclassMapping( - source = LoopOnItemsActionMetadataView.class, - target = LoopOnItemsActionMetadata.class), - @SubclassMapping( - source = ComponentActionMetadataView.class, - target = ComponentActionMetadata.class) - }) - @Mappings(value = {}) - public abstract ActionMetadata map(ActionMetadataView entity); - - @Mappings(value = {}) - public abstract CodeSettings map(CodeSettingsView entity); - - @Mappings(value = {}) - public abstract CodeSettingsView map(CodeSettings entity); - - @Mappings({}) - public String map(Ksuid ksuid){ - if(Objects.isNull(ksuid)){ - return null; - } - return ksuid.toString(); - } - - @Mappings({}) - public Ksuid map(String ksuid){ - if(Objects.isNull(ksuid)){ - return null; - } - return Ksuid.fromString(ksuid); - } - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ActionMetadataView.java deleted file mode 100644 index 6ec61898c8..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ActionMetadataView.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.activepieces.actions.model.action; - -import com.activepieces.common.validation.CodeNameConstraints; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import java.io.Serializable; - -@Getter -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type", - defaultImpl = EmptyActionMetadataView.class, - visible = true) -@JsonSubTypes({ - @JsonSubTypes.Type(value = CodeActionMetadataView.class, name = "CODE"), - @JsonSubTypes.Type(value = StorageActionMetadataView.class, name = "STORAGE"), - @JsonSubTypes.Type(value = ResponseActionMetadataView.class, name = "RESPONSE"), - @JsonSubTypes.Type(value = LoopOnItemsActionMetadataView.class, name = "LOOP_ON_ITEMS"), - @JsonSubTypes.Type(value = ComponentActionMetadataView.class, name = "COMPONENT") -}) -public abstract class ActionMetadataView implements Serializable { - - @Pattern(regexp = "CODE|STORAGE|RESPONSE|LOOP_ON_ITEMS|COMPONENT") - @JsonProperty - private String type; - - @JsonProperty - @NotEmpty - @NotNull - private String displayName; - - @JsonProperty - @CodeNameConstraints - private String name; - ; - - @JsonProperty - private ActionMetadataView nextAction; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private boolean valid; - - public abstract ActionMetadataViewBuilder toBuilder(); - - public void setValid(boolean valid) { - this.valid = valid; - } -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/CodeActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/CodeActionMetadataView.java deleted file mode 100644 index eab5cc7246..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/CodeActionMetadataView.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.actions.model.action; - -import com.activepieces.actions.model.action.settings.CodeSettingsView; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@Getter -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -public class CodeActionMetadataView extends ActionMetadataView { - - @JsonProperty - @NotNull - @Valid - private CodeSettingsView settings; - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ComponentActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ComponentActionMetadataView.java deleted file mode 100644 index 3cb58c7398..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ComponentActionMetadataView.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.actions.model.action; - -import com.activepieces.actions.model.action.settings.ComponentSettingsView; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; -import org.apache.commons.io.FilenameUtils; -import org.springframework.data.annotation.Transient; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@Getter -@Setter -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -public class ComponentActionMetadataView extends ActionMetadataView { - - @JsonProperty - @NotNull - @Valid - private ComponentSettingsView settings; - - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/EmptyActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/EmptyActionMetadataView.java deleted file mode 100644 index e935ac6a34..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/EmptyActionMetadataView.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.actions.model.action; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@Getter -@Setter -@AllArgsConstructor -@SuperBuilder(toBuilder = true) -public class EmptyActionMetadataView extends ActionMetadataView { - - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/LoopOnItemsActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/LoopOnItemsActionMetadataView.java deleted file mode 100644 index 9af5c0419d..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/LoopOnItemsActionMetadataView.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.activepieces.actions.model.action; - -import com.activepieces.actions.model.action.settings.LoopOnItemsActionSettingsView; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; - -@Getter -@Setter -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -public class LoopOnItemsActionMetadataView extends ActionMetadataView { - - @JsonProperty - @Valid - private ActionMetadataView firstLoopAction; - - @JsonProperty - @Valid - private LoopOnItemsActionSettingsView settings; - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ResponseActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ResponseActionMetadataView.java deleted file mode 100644 index d292f898b0..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/ResponseActionMetadataView.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.actions.model.action; - -import com.activepieces.entity.subdocuments.action.settings.ResponseSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class ResponseActionMetadataView extends ActionMetadataView { - - @JsonProperty - @Valid - private ResponseSettings settings; - - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/StorageActionMetadataView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/StorageActionMetadataView.java deleted file mode 100644 index 18c4fe5e50..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/StorageActionMetadataView.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.actions.model.action; - -import com.activepieces.entity.subdocuments.action.settings.StoreSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class StorageActionMetadataView extends ActionMetadataView { - - @JsonProperty - @Valid - private StoreSettings settings; - - -} \ No newline at end of file diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/CodeSettingsView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/CodeSettingsView.java deleted file mode 100644 index b4a5c168ad..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/CodeSettingsView.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.activepieces.actions.model.action.settings; - -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.common.model.ArtifactMetadataSettings; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class CodeSettingsView implements ArtifactMetadataSettings { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid artifactSourceId; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid artifactPackagedId; - - @JsonIgnore - private ArtifactFile newArtifactToUploadFile; - - @NotNull @JsonProperty @Valid private Map input; - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/ComponentSettingsView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/ComponentSettingsView.java deleted file mode 100644 index 3d53a4aeae..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/ComponentSettingsView.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.actions.model.action.settings; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ComponentSettingsView { - - @NotNull @JsonProperty @Valid private Map input; - - @JsonProperty @NotNull private String componentName; - - @JsonProperty @NotNull private String actionName; - -} diff --git a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/LoopOnItemsActionSettingsView.java b/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/LoopOnItemsActionSettingsView.java deleted file mode 100644 index e626ba7e53..0000000000 --- a/src/backend/actions-service/actions-client/src/main/java/com/activepieces/actions/model/action/settings/LoopOnItemsActionSettingsView.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.actions.model.action.settings; - -import com.activepieces.common.validation.NotEmptyIfString; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class LoopOnItemsActionSettingsView { - - @JsonProperty - @NotNull - @NotEmptyIfString - private Object items; - -} - diff --git a/src/backend/actions-service/pom.xml b/src/backend/actions-service/pom.xml deleted file mode 100644 index 7e66e5a061..0000000000 --- a/src/backend/actions-service/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - actions-service - 4.0.0 - - actions-client - store-service - - pom - - backend - com.activepieces - 1.0 - - 1.0 - - - - entities - com.activepieces - compile - 1.0 - - - diff --git a/src/backend/actions-service/store-service/pom.xml b/src/backend/actions-service/store-service/pom.xml deleted file mode 100644 index 77ff5f621e..0000000000 --- a/src/backend/actions-service/store-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - actions-service - com.activepieces - 1.0 - - 4.0.0 - - store-service - pom - - store-server - store-client - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/actions-service/store-service/store-client/pom.xml b/src/backend/actions-service/store-service/store-client/pom.xml deleted file mode 100644 index a088afcc75..0000000000 --- a/src/backend/actions-service/store-service/store-client/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - store-service - com.activepieces - 1.0 - - 4.0.0 - - store-client - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/GetStorageRequest.java b/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/GetStorageRequest.java deleted file mode 100644 index 162a752f30..0000000000 --- a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/GetStorageRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.actions.store; - -import com.activepieces.entity.enums.StoreScope; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -@SuperBuilder -public class GetStorageRequest { - - @JsonProperty - @NotNull - private StoreScope scope; - - @JsonProperty - @NotNull - private List storePath; -} diff --git a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/PutStorageRequest.java b/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/PutStorageRequest.java deleted file mode 100644 index c50b63a2c3..0000000000 --- a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/PutStorageRequest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.actions.store; - -import com.activepieces.entity.enums.StoreScope; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -@SuperBuilder -public class PutStorageRequest { - - @JsonProperty - @NotNull - private StoreScope scope; - - @JsonProperty - @NotNull - private List storePath; - - @JsonProperty - @NotNull - private Object value; -} diff --git a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/StorageService.java b/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/StorageService.java deleted file mode 100644 index 43cb20654f..0000000000 --- a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/StorageService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.actions.store; - - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.actions.store.model.StoreValueView; - -import java.util.Optional; - -public interface StorageService { - - StoreValueView put(StorePath storePath, Object value); - - Optional get(StorePath storePath); - -} diff --git a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/model/StorePath.java b/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/model/StorePath.java deleted file mode 100644 index 17da4c6d5e..0000000000 --- a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/model/StorePath.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.activepieces.actions.store.model; - -import com.activepieces.common.identity.WorkerIdentity; -import com.activepieces.entity.enums.StoreScope; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.UUID; - -@Builder -@AllArgsConstructor -@Setter -@Getter -public class StorePath { - - @JsonProperty private List paths; - - public StorePath() { - this.paths = new ArrayList<>(); - } - - public static StorePath collection(@NonNull Ksuid collectionId) { - return new StorePath() - .scope("collection") - .scope(collectionId.toString()); - } - - public static StorePath testScope( - @NonNull Ksuid collectionId) { - return new StorePath() - .scope("collection") - .scope(collectionId.toString()) - .scope("test"); - } - - public StorePath paths(List morePaths) { - List paths = new ArrayList<>(this.paths); - paths.addAll(morePaths); - return new StorePath(paths); - } - - private StorePath scope(String path) { - List paths = new ArrayList<>(this.paths); - paths.add(path); - return new StorePath(paths); - } - - public static StorePath fromIdentity(StoreScope scope, WorkerIdentity workerIdentity){ - switch (scope){ - case COLLECTION: - return StorePath.collection(workerIdentity.getCollectionId()); - } - throw new RuntimeException("Unsupported Store scope " + scope.toString()); - } -} diff --git a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/model/StoreValueView.java b/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/model/StoreValueView.java deleted file mode 100644 index 67726e7f2a..0000000000 --- a/src/backend/actions-service/store-service/store-client/src/main/java/com/activepieces/actions/store/model/StoreValueView.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.actions.store.model; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import javax.validation.constraints.NotNull; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class StoreValueView { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private String id; - - @JsonProperty - @NotNull - private String key; - - @JsonProperty - @NotNull - private Object value; - - @JsonIgnore private long created; - - @JsonIgnore private long updated; -} diff --git a/src/backend/actions-service/store-service/store-server/pom.xml b/src/backend/actions-service/store-service/store-server/pom.xml deleted file mode 100644 index 607825b534..0000000000 --- a/src/backend/actions-service/store-service/store-server/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - store-service - com.activepieces - 1.0 - - 4.0.0 - - store-server - - - com.activepieces - store-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/StorageServiceImpl.java b/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/StorageServiceImpl.java deleted file mode 100644 index 2bb8b6bf44..0000000000 --- a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/StorageServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.activepieces.actions.store.server; - -import com.activepieces.actions.store.StorageService; -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.actions.store.model.StoreValueView; -import com.activepieces.actions.store.server.mapper.StoreMapper; -import com.activepieces.actions.store.server.repository.StoreRepository; -import com.activepieces.common.utils.HashUtils; -import com.activepieces.entity.sql.StoreValue; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.time.Instant; -import java.util.List; -import java.util.Optional; - -@Service -public class StorageServiceImpl implements StorageService { - - private final StoreMapper storeMapper; - private final StoreRepository storeRepository; - - @Autowired - public StorageServiceImpl(StoreRepository storeRepository, StoreMapper storeMapper) { - this.storeRepository = storeRepository; - this.storeMapper = storeMapper; - } - - @Override - public StoreValueView put(StorePath storePath, Object value) { - final String path = buildPath(storePath.getPaths()); - String storeId = HashUtils.calculateHash(path); - StoreValueView storeValueView = - StoreValueView.builder() - .value(value) - .key(path) - .id(storeId) - .build(); - return storeMapper.toView(storeRepository.save(storeMapper.fromView(storeValueView))); - } - - @Override - public Optional get(StorePath storePath) { - final String path = buildPath(storePath.getPaths()); - Optional storeValueOptional = - storeRepository.findById(HashUtils.calculateHash(path)); - if (storeValueOptional.isEmpty()) { - return Optional.empty(); - } - return Optional.of(storeMapper.toView(storeValueOptional.get())); - } - - private String buildPath(List storePath){ - return String.join("/", storePath); - } -} diff --git a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/controller/StorageController.java b/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/controller/StorageController.java deleted file mode 100644 index dfcef5a795..0000000000 --- a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/controller/StorageController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.activepieces.actions.store.server.controller; - -import com.activepieces.actions.store.GetStorageRequest; -import com.activepieces.actions.store.PutStorageRequest; -import com.activepieces.actions.store.StorageService; -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.actions.store.model.StoreValueView; -import com.activepieces.common.identity.WorkerIdentity; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.annotation.Secured; -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.Optional; - -@CrossOrigin -@RestController -@Hidden -@RequestMapping -public class StorageController { - - private final StorageService storageService; - - @Autowired - public StorageController(@NonNull final StorageService storageService) { - this.storageService = storageService; - } - - @Secured("ROLE_WORKER") - @PostMapping("/storage") - public ResponseEntity put( - @AuthenticationPrincipal WorkerIdentity workerIdentity, - @RequestBody @Valid PutStorageRequest storageRequest) { - final StorePath storePath = StorePath.fromIdentity(storageRequest.getScope(), workerIdentity).paths(storageRequest.getStorePath()); - StoreValueView storeValueView = storageService.put(storePath, storageRequest.getValue()); - return ResponseEntity.ok(storeValueView.getValue()); - } - - @Secured("ROLE_WORKER") - @GetMapping("/storage") - public ResponseEntity get( - @AuthenticationPrincipal WorkerIdentity workerIdentity, - @RequestBody @Valid GetStorageRequest storageRequest) { - final StorePath storePath = StorePath.fromIdentity(storageRequest.getScope(), workerIdentity).paths(storageRequest.getStorePath()); - Optional storeValueView = storageService.get(storePath); - if(storeValueView.isEmpty()){ - return ResponseEntity.ok(null); - } - return ResponseEntity.ok(storeValueView.get().getValue()); - } -} diff --git a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/mapper/StoreMapper.java b/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/mapper/StoreMapper.java deleted file mode 100644 index d1c8410e81..0000000000 --- a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/mapper/StoreMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.actions.store.server.mapper; - -import com.activepieces.actions.store.model.StoreValueView; -import com.activepieces.entity.sql.StoreValue; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; - -import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR; - -@Mapper(subclassExhaustiveStrategy = COMPILE_ERROR, componentModel = "spring") -public abstract class StoreMapper { - - @Mappings({}) - public abstract StoreValue fromView(StoreValueView entity); - - @Mappings({}) - public abstract StoreValueView toView(StoreValue entity); - -} diff --git a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/repository/StoreRepository.java b/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/repository/StoreRepository.java deleted file mode 100644 index 28bf30107d..0000000000 --- a/src/backend/actions-service/store-service/store-server/src/main/java/com/activepieces/actions/store/server/repository/StoreRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.activepieces.actions.store.server.repository; - -import com.activepieces.entity.sql.StoreValue; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface StoreRepository extends CrudRepository { - -} diff --git a/src/backend/authentication-service/authentication-client/pom.xml b/src/backend/authentication-service/authentication-client/pom.xml deleted file mode 100644 index 9b84398c6e..0000000000 --- a/src/backend/authentication-service/authentication-client/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - authentication-client - 1.0 - - - entities - com.activepieces - compile - 1.0 - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - feature-service - 1.0 - compile - - - 4.0.0 - - - authentication-service - com.activepieces - 1.0 - - - - 11 - 11 - - - diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/JWTService.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/JWTService.java deleted file mode 100644 index ab368afa80..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/JWTService.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.activepieces.authentication.client; - -import com.activepieces.common.identity.*; -import com.activepieces.flag.service.FlagService; -import com.auth0.jwt.JWT; -import com.auth0.jwt.algorithms.Algorithm; -import com.auth0.jwt.exceptions.JWTDecodeException; -import com.auth0.jwt.exceptions.SignatureVerificationException; -import com.auth0.jwt.exceptions.TokenExpiredException; -import com.auth0.jwt.interfaces.Claim; -import com.auth0.jwt.interfaces.DecodedJWT; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.stereotype.Service; - -import java.time.Duration; -import java.util.Date; -import java.util.Objects; -import java.util.Optional; - -import static com.auth0.jwt.algorithms.Algorithm.HMAC512; - -@Service -public class JWTService { - - public static final String AUTHORIZATION_HEADER_NAME = "Authorization"; - public static final String TOKEN_PREFIX = "Bearer "; - public static final Duration DEFAULT_EXPIRATION_DURATION = Duration.ofDays(7); - private static final String RESOURCE_ROLE = "role"; - private static final String COLLECTION_ID = "collection_id"; - private static final String FLOW_ID = "flow_id"; - - private String secretKey; - - public JWTService(@NonNull final FlagService flagService){ - if(!flagService.exists(FlagService.BEARER_ENCRYPTION_KEY)){ - secretKey = RandomStringUtils.randomAlphanumeric(35); - flagService.save(FlagService.BEARER_ENCRYPTION_KEY, secretKey); - }else{ - secretKey = flagService.getValue(FlagService.BEARER_ENCRYPTION_KEY).get(); - } - } - - public String createTokenWithExpirationPeriod( - @NonNull final UserIdentity userIdentity, final Duration duration) { - return JWT.create() - .withSubject(userIdentity.getId().toString()) - .withClaim(RESOURCE_ROLE, userIdentity.getPrincipleType().toString()) - .withExpiresAt(new Date(System.currentTimeMillis() + duration.getSeconds() * 1000L)) - .sign(HMAC512(secretKey.getBytes())); - } - - - public String createTokenWithDefaultExpiration( - @NonNull final WorkerIdentity workerIdentity) { - return JWT.create() - .withSubject(workerIdentity.getId().toString()) - .withClaim(RESOURCE_ROLE, workerIdentity.getPrincipleType().toString()) - .withClaim(COLLECTION_ID, workerIdentity.getCollectionId().toString()) - .withClaim(FLOW_ID, workerIdentity.getFlowId().toString()) - .withExpiresAt( - new Date(System.currentTimeMillis() + DEFAULT_EXPIRATION_DURATION.getSeconds() * 1000L)) - .sign(HMAC512(secretKey.getBytes())); - } - - public String createTokenWithDefaultExpiration(@NonNull final UserIdentity userIdentity) { - return createTokenWithExpirationPeriod(userIdentity, DEFAULT_EXPIRATION_DURATION); - } - - public Optional decodeIdentityFromToken( - @NonNull final String rawToken) { - try { - final String strippedToken = rawToken.replace(TOKEN_PREFIX, ""); - final DecodedJWT decodedJWT = JWT.decode(strippedToken); - final Claim resourceType = decodedJWT.getClaim(RESOURCE_ROLE); - if (!resourceType.isNull()) { - final String resourceIdString = - JWT.require(Algorithm.HMAC512(secretKey.getBytes())) - .build() - .verify(strippedToken) - .getSubject(); - final Ksuid resourceId = Ksuid.fromString(resourceIdString); - final PrincipleType principleType = PrincipleType.valueOf(resourceType.asString()); - if (principleType.equals(PrincipleType.USER)) { - return Optional.of(UserIdentity.builder().resourceId(resourceId).build()); - } else if (principleType.equals(PrincipleType.WORKER)) { - WorkerIdentity.WorkerIdentityBuilder builder = - WorkerIdentity.builder() - .flowId(Ksuid.fromString(decodedJWT.getClaim(FLOW_ID).asString())) - .collectionId(Ksuid.fromString(decodedJWT.getClaim(COLLECTION_ID).asString())); - return Optional.of(builder.build()); - } - } - } catch (TokenExpiredException - | JWTDecodeException - |IllegalArgumentException - | SignatureVerificationException ignored) { - } - return Optional.empty(); - } -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/UserAuthenticationService.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/UserAuthenticationService.java deleted file mode 100644 index 792cd128cb..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/UserAuthenticationService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.authentication.client; - -import com.activepieces.authentication.client.exception.UserNotFoundException; -import com.activepieces.authentication.client.model.UserInformationView; -import com.activepieces.authentication.client.request.SignUpRequest; -import com.github.ksuid.Ksuid; -import lombok.NonNull; - -import java.util.Optional; -import java.util.UUID; - -public interface UserAuthenticationService { - - Optional getOptional(@NonNull final Ksuid userId); - - Optional getOptional(@NonNull final String name); - - UserInformationView getById(@NonNull final Ksuid userId) throws UserNotFoundException; - - Optional getByCredentials( - @NonNull final String email, @NonNull final String password); - - UserInformationView create(@NonNull final String email, @NonNull final SignUpRequest request); - - UserInformationView update( - @NonNull final Ksuid userId, - @NonNull final UserInformationView userInformationRequest) - throws UserNotFoundException; - -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/InvalidTokenException.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/InvalidTokenException.java deleted file mode 100644 index 2722d5f5bf..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/InvalidTokenException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.authentication.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class InvalidTokenException extends Exception implements ErrorResponseException { - - public InvalidTokenException() { - super("Token is invalid"); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.INVALID_TOKEN; - } -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UnAuthenticationException.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UnAuthenticationException.java deleted file mode 100644 index 4b245c0e74..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UnAuthenticationException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.authentication.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class UnAuthenticationException extends Exception implements ErrorResponseException { - - public UnAuthenticationException() { - super("Wrong credentials is provided"); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.UNAUTHENTICATED; - } -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UnAuthorizedException.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UnAuthorizedException.java deleted file mode 100644 index ea32765a05..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UnAuthorizedException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.authentication.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class UnAuthorizedException extends Exception implements ErrorResponseException { - - public UnAuthorizedException() { - super("Unauthorized operation"); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.UNAUTHORIZED; - } -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UserNotFoundException.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UserNotFoundException.java deleted file mode 100644 index 62fbc6624e..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/exception/UserNotFoundException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.authentication.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class UserNotFoundException extends Exception implements ErrorResponseException { - - public UserNotFoundException(Ksuid id) { - super(String.format("User with id=%s is not found", id.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.USER_NOT_FOUND; - } -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/mapper/UserInformationMapper.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/mapper/UserInformationMapper.java deleted file mode 100644 index de2a1f2097..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/mapper/UserInformationMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.authentication.client.mapper; - -import com.activepieces.authentication.client.model.UserInformationView; -import com.activepieces.entity.sql.UserInformation; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; - -@Mapper(componentModel = "spring") -public interface UserInformationMapper { - - @Mappings({}) - UserInformation fromView(UserInformationView entity); - - @Mappings({}) - UserInformationView toView(UserInformation entity); - - - -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/model/UserInformationView.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/model/UserInformationView.java deleted file mode 100644 index b95ed3c504..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/model/UserInformationView.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.activepieces.authentication.client.model; - -import com.activepieces.entity.enums.UserStatus; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.UUID; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -@Setter -public class UserInformationView { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private String email; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) private Long created; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) private Long updated; - - @JsonProperty @NotNull @NotEmpty private String firstName; - - @JsonProperty @NotNull @NotEmpty private String lastName; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private UserStatus status; - -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/request/SignInRequest.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/request/SignInRequest.java deleted file mode 100644 index 113bb6d5fa..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/request/SignInRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.authentication.client.request; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -@Setter -public class SignInRequest { - - @JsonProperty(required = true) - @Email - @NotEmpty - private String email; - - @JsonProperty(required = true) - @NotEmpty - private String password; -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/request/SignUpRequest.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/request/SignUpRequest.java deleted file mode 100644 index 0b78ed797b..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/request/SignUpRequest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.activepieces.authentication.client.request; - -import com.activepieces.authentication.client.validation.ValidPassword; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -@Setter -@Builder -public class SignUpRequest { - - @JsonProperty @NotEmpty private String firstName; - - @JsonProperty @NotEmpty private String lastName; - - @JsonProperty @NotNull - @ValidPassword private String password; -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/validation/PasswordConstraintValidator.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/validation/PasswordConstraintValidator.java deleted file mode 100644 index bbe7a10182..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/validation/PasswordConstraintValidator.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.activepieces.authentication.client.validation; - -import org.passay.*; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -public class PasswordConstraintValidator implements ConstraintValidator { - - @Override - public void initialize(ValidPassword arg0) {} - - @Override - public boolean isValid(String password, ConstraintValidatorContext context) { - if (Objects.isNull(password)) { - context - .buildConstraintViolationWithTemplate("Password is null") - .addConstraintViolation() - .disableDefaultConstraintViolation(); - return false; - } - PasswordValidator validator = - new PasswordValidator( - Arrays.asList( - new LengthRule(8, 64), - new DigitCharacterRule(1), - new SpecialCharacterRule(1), - new AlphabeticalCharacterRule(1), - new WhitespaceRule())); - - RuleResult result = validator.validate(new PasswordData(password)); - if (result.isValid()) { - return true; - } - List messages = validator.getMessages(result); - String messageTemplate = String.join(",", messages); - context - .buildConstraintViolationWithTemplate(messageTemplate) - .addConstraintViolation() - .disableDefaultConstraintViolation(); - return false; - } -} diff --git a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/validation/ValidPassword.java b/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/validation/ValidPassword.java deleted file mode 100644 index 7e88964c59..0000000000 --- a/src/backend/authentication-service/authentication-client/src/main/java/com/activepieces/authentication/client/validation/ValidPassword.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.authentication.client.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Documented -@Constraint(validatedBy = PasswordConstraintValidator.class) -@Target({FIELD, ANNOTATION_TYPE}) -@Retention(RUNTIME) -public @interface ValidPassword { - - String message() default "Invalid Password"; - - Class[] groups() default {}; - - Class[] payload() default {}; -} diff --git a/src/backend/authentication-service/authentication-server/pom.xml b/src/backend/authentication-service/authentication-server/pom.xml deleted file mode 100644 index 45b3fbbe17..0000000000 --- a/src/backend/authentication-service/authentication-server/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - authentication-server - - - - authentication-client - com.activepieces - compile - 1.0 - - - org.springframework.security - spring-security-web - - - com.activepieces - guardian-client - 1.0 - compile - - - 4.0.0 - - authentication-service - com.activepieces - 1.0 - - - - diff --git a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/controller/AuthenticationController.java b/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/controller/AuthenticationController.java deleted file mode 100644 index f6dde54f1d..0000000000 --- a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/controller/AuthenticationController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.activepieces.authentication.server.controller; - -import com.activepieces.authentication.client.UserAuthenticationService; -import com.activepieces.authentication.client.exception.UnAuthenticationException; -import com.activepieces.authentication.client.exception.UnAuthorizedException; -import com.activepieces.authentication.client.model.UserInformationView; -import com.activepieces.authentication.client.request.SignInRequest; -import com.activepieces.authentication.client.JWTService; -import com.activepieces.common.identity.UserIdentity; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.Optional; - -@CrossOrigin -@Log4j2 -@RestController -@Hidden -@RequestMapping(path = "/authentication") -public class AuthenticationController { - - private final UserAuthenticationService userAuthenticationService; - private final JWTService jwtService; - - @Autowired - public AuthenticationController( - @NonNull final UserAuthenticationService userAuthenticationService, - @NonNull final JWTService jwtService) { - this.jwtService = jwtService; - this.userAuthenticationService = userAuthenticationService; - } - - @ResponseBody - @PostMapping(value = "/sign-in") - public ResponseEntity signIn(@RequestBody @Valid final SignInRequest request) - throws UnAuthorizedException, UnAuthenticationException { - final Optional userInformation = - userAuthenticationService.getByCredentials(request.getEmail(), request.getPassword()); - if(userInformation.isEmpty()){ - throw new UnAuthenticationException(); - } - return ResponseEntity.ok() - .header( - JWTService.AUTHORIZATION_HEADER_NAME, - jwtService.createTokenWithDefaultExpiration( - UserIdentity.builder().resourceId(userInformation.get().getId()).build())) - .body(userInformation.get()); - } - -} diff --git a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/controller/UserController.java b/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/controller/UserController.java deleted file mode 100644 index bb2e37d2b6..0000000000 --- a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/controller/UserController.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.activepieces.authentication.server.controller; - - -import com.activepieces.authentication.client.UserAuthenticationService; -import com.activepieces.authentication.client.exception.UserNotFoundException; -import com.activepieces.authentication.client.model.UserInformationView; -import com.activepieces.common.identity.UserIdentity; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.*; - -import java.util.UUID; - -@CrossOrigin -@RestController -@Hidden -@RequestMapping(path = "/users") -public class UserController { - - private final UserAuthenticationService userAuthenticationService; - - @Autowired - public UserController( - @NonNull final UserAuthenticationService userAuthenticationService) { - this.userAuthenticationService = userAuthenticationService; - } - - @PutMapping("/{userId}") - public ResponseEntity update( - @AuthenticationPrincipal UserIdentity userIdentity, - @PathVariable("userId") Ksuid userId, - @RequestBody UserInformationView requestBody) - throws UserNotFoundException { - if(!userIdentity.getId().equals(userId)) - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - return ResponseEntity.ok(userAuthenticationService.update(userId, requestBody)); - } - - @GetMapping("/{userId}") - public ResponseEntity get( - @PathVariable("userId") Ksuid userId) - throws UserNotFoundException { - return ResponseEntity.ok(userAuthenticationService.getById(userId)); - } - - -} diff --git a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/repository/UserInformationRepository.java b/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/repository/UserInformationRepository.java deleted file mode 100644 index 8a0de0169b..0000000000 --- a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/repository/UserInformationRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.authentication.server.repository; - -import com.activepieces.entity.sql.UserInformation; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; -import java.util.UUID; - -@Repository() -public interface UserInformationRepository - extends CrudRepository { - - Optional findByEmailIgnoreCase(String email); -} diff --git a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/security/JWTAuthorizationFilter.java b/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/security/JWTAuthorizationFilter.java deleted file mode 100644 index ee4ca204a4..0000000000 --- a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/security/JWTAuthorizationFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.activepieces.authentication.server.security; - -import com.activepieces.authentication.client.JWTService; -import com.activepieces.common.identity.PrincipleIdentity; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Collections; -import java.util.Optional; - -public class JWTAuthorizationFilter extends BasicAuthenticationFilter { - - - private final JWTService jwtService; - - public JWTAuthorizationFilter( - JWTService jwtService, - AuthenticationManager authenticationManager) { - super(authenticationManager); - this.jwtService = jwtService; - } - - @Override - protected void doFilterInternal( - HttpServletRequest req, HttpServletResponse res, FilterChain chain) - throws IOException, ServletException { - - String token = req.getHeader(JWTService.AUTHORIZATION_HEADER_NAME); - UsernamePasswordAuthenticationToken authentication = getAuthentication(token); - if (authentication == null) { - chain.doFilter(req, res); - return; - } - - SecurityContextHolder.getContext().setAuthentication(authentication); - chain.doFilter(req, res); - } - - private UsernamePasswordAuthenticationToken getAuthentication(final String token) { - if (token == null) { - return null; - } - Optional resourceToken = - jwtService.decodeIdentityFromToken( - token); - - return resourceToken - .map( - identity -> - new UsernamePasswordAuthenticationToken( - identity, - null, - Collections.singletonList( - new SimpleGrantedAuthority(identity.getPrincipleType().getType())))) - .orElse(null); - } -} diff --git a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/service/UserAuthenticationServiceImpl.java b/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/service/UserAuthenticationServiceImpl.java deleted file mode 100644 index 59b7326de1..0000000000 --- a/src/backend/authentication-service/authentication-server/src/main/java/com/activepieces/authentication/server/service/UserAuthenticationServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.activepieces.authentication.server.service; - -import com.activepieces.authentication.client.UserAuthenticationService; -import com.activepieces.authentication.client.exception.UserNotFoundException; -import com.activepieces.authentication.client.mapper.UserInformationMapper; -import com.activepieces.authentication.client.model.UserInformationView; -import com.activepieces.authentication.client.request.SignUpRequest; -import com.activepieces.authentication.server.repository.UserInformationRepository; -import com.activepieces.entity.enums.UserStatus; -import com.activepieces.entity.sql.UserInformation; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import java.time.Duration; -import java.time.Instant; -import java.util.Optional; -import java.util.UUID; - -@Service -@Log4j2 -public class UserAuthenticationServiceImpl implements UserAuthenticationService { - - private final UserInformationRepository userInformationRepository; - private final PasswordEncoder passwordEncoder; - private final UserInformationMapper userInformationMapper; - @Autowired - public UserAuthenticationServiceImpl( - @NonNull final UserInformationRepository userInformationRepository, - @NonNull final PasswordEncoder passwordEncoder, - @NonNull final UserInformationMapper userInformationMapper) { - this.passwordEncoder = passwordEncoder; - this.userInformationMapper = userInformationMapper; - this.userInformationRepository = userInformationRepository; - } - - @Override - public Optional getOptional(@NonNull final Ksuid userId) { - Optional optional = userInformationRepository.findById(userId); - if (optional.isEmpty()) { - return Optional.empty(); - } - return Optional.of(userInformationMapper.toView(optional.get())); - } - - @Override - public Optional getOptional(@NonNull String name) { - Optional optional = userInformationRepository.findByEmailIgnoreCase(name); - if (optional.isEmpty()) { - return Optional.empty(); - } - return Optional.of(userInformationMapper.toView(optional.get())); - } - - @Override - public UserInformationView getById(@NonNull final Ksuid userId) throws UserNotFoundException { - Optional optional = getOptional(userId); - if (optional.isEmpty()) { - throw new UserNotFoundException(userId); - } - return optional.get(); - } - - @Override - public Optional getByCredentials( - @NonNull final String email, @NonNull final String password) { - Optional userInformation = - userInformationRepository.findByEmailIgnoreCase(email); - if (userInformation.isEmpty()) { - return Optional.empty(); - } - if (!passwordEncoder.matches(password, userInformation.get().getPassword())) { - return Optional.empty(); - } - return Optional.of(userInformationMapper.toView(userInformation.get())); - } - - @Override - public UserInformationView create(@NonNull String email, @NonNull SignUpRequest request) { - final String encryptedPassword = passwordEncoder.encode(request.getPassword()); - final UserInformation userInformation = - userInformationRepository - .findByEmailIgnoreCase(email) - .orElse( - UserInformation.builder() - .id(Ksuid.newKsuid()) - .email(email) - .build()); - userInformation.setFirstName(request.getFirstName()); - userInformation.setLastName(request.getLastName()); - userInformation.setPassword(encryptedPassword); - userInformation.setStatus(UserStatus.VERIFIED); - return userInformationMapper.toView(userInformationRepository.save(userInformation)); - } - - @Override - public UserInformationView update( - @NonNull final Ksuid userId, @NonNull final UserInformationView request) - throws UserNotFoundException { - Optional userInformationOptional = userInformationRepository.findById(userId); - if (userInformationOptional.isEmpty()) { - throw new UserNotFoundException(userId); - } - final UserInformation userInformation = userInformationOptional.get(); - userInformation.setFirstName(request.getFirstName()); - userInformation.setLastName(request.getLastName()); - return userInformationMapper.toView(userInformationRepository.save(userInformation)); - } - -} diff --git a/src/backend/authentication-service/pom.xml b/src/backend/authentication-service/pom.xml deleted file mode 100644 index 16b3a97326..0000000000 --- a/src/backend/authentication-service/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - authentication-service - 4.0.0 - - - authentication-client - authentication-server - - pom - - backend - com.activepieces - 1.0 - - - - diff --git a/src/backend/backend-loader/default.cf b/src/backend/backend-loader/default.cf deleted file mode 100644 index eebd421995..0000000000 --- a/src/backend/backend-loader/default.cf +++ /dev/null @@ -1,24 +0,0 @@ -# This is a configuration file for Isolate - -# All sandboxes are created under this directory. -# To avoid symlink attacks, this directory and all its ancestors -# must be writeable only to root. -box_root = /var/local/lib/isolate - -# Root of the control group hierarchy -cg_root = /sys/fs/cgroup - -# If the following variable is defined, the per-box cgroups -# are created as sub-groups of the named cgroup -#cg_parent = boxes - -# Block of UIDs and GIDs reserved for sandboxes -first_uid = 60000 -first_gid = 60000 -num_boxes = 1000 - -# Per-box settings of the set of allowed CPUs and NUMA nodes -# (see linux/Documentation/cgroups/cpusets.txt for precise syntax) - -#box0.cpus = 4-7 -#box0.mems = 1 diff --git a/src/backend/backend-loader/isolate b/src/backend/backend-loader/isolate deleted file mode 100755 index fdf04fc103..0000000000 Binary files a/src/backend/backend-loader/isolate and /dev/null differ diff --git a/src/backend/backend-loader/onboard.txt b/src/backend/backend-loader/onboard.txt deleted file mode 100644 index 51139ef3b8..0000000000 --- a/src/backend/backend-loader/onboard.txt +++ /dev/null @@ -1,7 +0,0 @@ -Install Isolate (run) - -cp backend-loader/default.cf /usr/local/etc/isolate - -Install Webpack globally - -Check Docker Image \ No newline at end of file diff --git a/src/backend/backend-loader/pom.xml b/src/backend/backend-loader/pom.xml deleted file mode 100644 index 06956b505b..0000000000 --- a/src/backend/backend-loader/pom.xml +++ /dev/null @@ -1,267 +0,0 @@ - - - 4.0.0 - - - backend - com.activepieces - 1.0 - - - backend-loader - 0.0.28 - - - - component-service - com.activepieces - compile - 1.0 - - - project-server - com.activepieces - compile - 1.0 - - - instance-client - com.activepieces - compile - 1.0 - - - instance-server - com.activepieces - compile - 1.0 - - - project-client - com.activepieces - compile - 1.0 - - - guardian-server - com.activepieces - compile - 1.0 - - - guardian-client - com.activepieces - compile - 1.0 - - - - trigger-client - com.activepieces - compile - 1.0 - - - - - authentication-client - com.activepieces - compile - 1.0 - - - authentication-server - com.activepieces - compile - 1.0 - - - - - com.activepieces - scheduler-server - 1.0 - compile - - - com.activepieces - scheduler-client - 1.0 - compile - - - - - com.activepieces - actions-client - 1.0 - compile - - - - com.activepieces - worker-server - 1.0 - compile - - - com.activepieces - worker-client - 1.0 - compile - - - - com.activepieces - flow-server - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - - junit - junit - test - - - - com.activepieces - collection-client - 1.0 - compile - - - com.activepieces - collection-server - 1.0 - compile - - - com.activepieces - store-client - 1.0 - compile - - - com.activepieces - store-server - 1.0 - compile - - - - com.activepieces - variable-client - 1.0 - compile - - - com.activepieces - variable-server - 1.0 - compile - - - - com.activepieces - file-client - 1.0 - compile - - - com.activepieces - file-server - 1.0 - compile - - - - com.activepieces - logging-client - 1.0 - compile - - - com.activepieces - logging-server - 1.0 - compile - - - com.activepieces - executor-client - 1.0 - compile - - - com.activepieces - executor-server - 1.0 - compile - - - com.activepieces - feature-service - 1.0 - compile - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.1 - - 11 - 11 - - - org.projectlombok - lombok - 1.18.22 - - - - org.projectlombok - lombok-mapstruct-binding - 0.2.0 - - - - org.mapstruct - mapstruct - 1.5.0.Beta2 - - - - - - - spring-boot-maven-plugin - org.springframework.boot - - - - lombok - org.projectlombok - - - - - - - - diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/BackendApplication.java b/src/backend/backend-loader/src/main/java/com/activepieces/BackendApplication.java deleted file mode 100644 index aae9992e41..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/BackendApplication.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.activepieces; - -import com.activepieces.common.CascadeDeleteHandler; -import com.activepieces.common.pagination.impl.PaginationRepositoryImpl; -import com.activepieces.guardian.server.ResourcePublisher; -import com.activepieces.instance.client.InstancePublisher; -import lombok.extern.log4j.Log4j2; -import org.apache.commons.io.IOUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.http.HttpInputMessage; -import org.springframework.http.HttpOutputMessage; -import org.springframework.http.MediaType; -import org.springframework.http.converter.AbstractHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.http.converter.HttpMessageNotWritableException; -import org.springframework.integration.config.EnableIntegration; -import org.springframework.integration.jdbc.lock.DefaultLockRepository; -import org.springframework.integration.jdbc.lock.JdbcLockRegistry; -import org.springframework.integration.jdbc.lock.LockRepository; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; - -import javax.sql.DataSource; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -@SpringBootApplication(scanBasePackages = "com.activepieces") -@EnableJpaRepositories(basePackages = "com.activepieces", repositoryBaseClass = PaginationRepositoryImpl.class) -@EntityScan(basePackages = "com.activepieces") -@EnableScheduling -@EnableAsync -@Log4j2 -@EnableIntegration -public class BackendApplication implements CommandLineRunner { - - private final JdbcTemplate jdbcTemplate; - - @Autowired - public BackendApplication(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } - - public static void main(String[] args) { - SpringApplication.run(BackendApplication.class, args); - } - - @Override - public void run(String... strings) throws IOException { - - } - - @Bean - public PasswordEncoder encoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public InstancePublisher instancePublisher() { - return new InstancePublisher(); - } - - @Bean - public ResourcePublisher resourcePublisher(CascadeDeleteHandler cascadeDeleteHandler) { - return new ResourcePublisher(List.of(cascadeDeleteHandler)); - } - - @Bean - public DefaultLockRepository DefaultLockRepository(DataSource dataSource){ - return new DefaultLockRepository(dataSource); - } - - @Bean - public JdbcLockRegistry jdbcLockRegistry(LockRepository lockRepository){ - return new JdbcLockRegistry(lockRepository); - } - @Bean - public Validator validator() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - return factory.getValidator(); - } -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/common/CascadeDeleteHandler.java b/src/backend/backend-loader/src/main/java/com/activepieces/common/CascadeDeleteHandler.java deleted file mode 100644 index e5489329a4..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/common/CascadeDeleteHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.activepieces.common; - -import com.activepieces.entity.sql.Instance; -import com.activepieces.entity.sql.Resource; -import com.activepieces.flow.repository.FlowRepository; -import com.activepieces.flow.repository.FlowVersionRepository; -import com.activepieces.guardian.client.ResourceSubscriber; -import com.activepieces.guardian.client.model.ResourceEventType; -import com.activepieces.instance.repository.InstanceRepository; -import com.activepieces.piece.server.repository.CollectionRepository; -import com.activepieces.piece.server.repository.CollectionVersionRepository; -import com.activepieces.project.server.repository.ProjectRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class CascadeDeleteHandler implements ResourceSubscriber { - - private final ProjectRepository projectRepository; - private final InstanceRepository instanceRepository; - private final FlowRepository flowRepository; - private final CollectionRepository collectionRepository; - private final FlowVersionRepository flowVersionRepository; - private final CollectionVersionRepository collectionVersionRepository; - - @Autowired - public CascadeDeleteHandler(CollectionVersionRepository collectionVersionRepository, FlowVersionRepository flowVersionRepository, ProjectRepository projectRepository, InstanceRepository instanceRepository, FlowRepository flowRepository, CollectionRepository collectionRepository) { - this.collectionVersionRepository = collectionVersionRepository; - this.flowVersionRepository = flowVersionRepository; - this.projectRepository = projectRepository; - this.instanceRepository = instanceRepository; - this.flowRepository = flowRepository; - this.collectionRepository = collectionRepository; - } - - @Override - public void onListen(ResourceEventType type, Resource entity) { - if(type.equals(ResourceEventType.DELETE)) { - switch (entity.getResourceType()) { - case PROJECT: - projectRepository.deleteById(entity.getResourceId()); - break; - case INSTANCE: - Instance instance = instanceRepository.findById(entity.getResourceId()).orElseThrow(); - instanceRepository.deleteById(instance.getId()); - break; - case FLOW: - flowRepository.deleteById(entity.getResourceId()); - break; - case COLLECTION: - collectionRepository.deleteById(entity.getResourceId()); - break; - case FLOW_VERSION: - flowVersionRepository.deleteById(entity.getResourceId()); - break; - case COLLECTION_VERSION: - collectionVersionRepository.deleteById(entity.getResourceId()); - break; - } - } - } -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/common/ExceptionHandlerController.java b/src/backend/backend-loader/src/main/java/com/activepieces/common/ExceptionHandlerController.java deleted file mode 100644 index 21efaae76e..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/common/ExceptionHandlerController.java +++ /dev/null @@ -1,239 +0,0 @@ -package com.activepieces.common; - -import com.activepieces.authentication.client.exception.InvalidTokenException; -import com.activepieces.authentication.client.exception.UnAuthenticationException; -import com.activepieces.authentication.client.exception.UnAuthorizedException; -import com.activepieces.authentication.client.exception.UserNotFoundException; -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponse; -import com.activepieces.common.error.exception.*; -import com.activepieces.common.error.exception.collection.*; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionAlreadyLockedException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.utils.StringUtils; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.logging.client.exception.InstanceRunNotFoundException; -import com.activepieces.project.client.exception.ProjectNotFoundException; -import com.activepieces.security.Slf4jMDCFilterConfiguration; -import com.activepieces.variable.model.exception.MissingConfigsException; -import io.swagger.v3.oas.annotations.Hidden; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.WebRequest; -import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -@Hidden -@RestControllerAdvice -public class ExceptionHandlerController { - - @Autowired - public ExceptionHandlerController() { - } - @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) - public ResponseEntity exception(HttpRequestMethodNotSupportedException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = CollectionInvalidStateException.class) - public ResponseEntity exception(CollectionInvalidStateException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = HttpMediaTypeNotSupportedException.class) - public ResponseEntity exception(HttpMediaTypeNotSupportedException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST); - } - - - @ExceptionHandler(value = ConfigInvalidTypeException.class) - public ResponseEntity exception(ConfigInvalidTypeException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler({MethodArgumentTypeMismatchException.class}) - public ResponseEntity handleMethodArgumentTypeMismatch( - MethodArgumentTypeMismatchException ex, WebRequest request) { - String error = ex.getName() + " should be of type " + ex.getRequiredType().getName(); - return new ResponseEntity(error, new HttpHeaders(), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = ConfigNotFoundException.class) - public ResponseEntity exception(ConfigNotFoundException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = IllegalArgumentException.class) - public ResponseEntity exception(IllegalArgumentException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(HttpMessageNotReadableException.class) - public ResponseEntity handleAllOtherErrors(HttpMessageNotReadableException formatException) { - String error = formatException.getMessage(); - return new ResponseEntity(error, HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = InstantiationException.class) - public ResponseEntity exception(InstantiationException exception) { - return new ResponseEntity<>( - new ErrorResponse("Internal Server error :(", ErrorCode.INTERNAL_SERVER_ERROR), - HttpStatus.INTERNAL_SERVER_ERROR); - } - - @ExceptionHandler(value = CodeArtifactBuildFailure.class) - public ResponseEntity exception(CodeArtifactBuildFailure exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.BAD_REQUEST); - } - @ExceptionHandler(value = ConstraintsException.class) - public ResponseEntity> exception(ConstraintsException exception) { - return new ResponseEntity<>(exception.getErrorResponse(), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = CollectionVersionAlreadyLockedException.class) - public ResponseEntity exception( - CollectionVersionAlreadyLockedException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = InvalidTokenException.class) - public ResponseEntity exception(InvalidTokenException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.UNAUTHORIZED); - } - - @ExceptionHandler(value = MissingConfigsException.class) - public ResponseEntity exception(MissingConfigsException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = InstanceRunNotFoundException.class) - public ResponseEntity exception(InstanceRunNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = CollectionVersionNotFoundException.class) - public ResponseEntity exception(CollectionVersionNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = ManifestNotFoundException.class) - public ResponseEntity exception(ManifestNotFoundException exception) { - return new ResponseEntity<>(exception.getMessage(), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = InstanceNotFoundException.class) - public ResponseEntity exception(InstanceNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = FlowVersionNotFoundException.class) - public ResponseEntity exception(FlowVersionNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = FlowNotFoundException.class) - public ResponseEntity exception(FlowNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = CollectionNotFoundException.class) - public ResponseEntity exception(CollectionNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = ProjectNotFoundException.class) - public ResponseEntity exception(ProjectNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = UserNotFoundException.class) - public ResponseEntity exception(UserNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - @ExceptionHandler(value = FlowVersionAlreadyLockedException.class) - public ResponseEntity exception(FlowVersionAlreadyLockedException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = InvalidCodeArtifactException.class) - public ResponseEntity exception(InvalidCodeArtifactException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = FlowNotEnabledException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - public ResponseEntity exception(FlowNotEnabledException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(value = PermissionDeniedException.class) - public ResponseEntity exception(PermissionDeniedException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.FORBIDDEN); - } - - @ExceptionHandler(value = UnAuthenticationException.class) - public ResponseEntity exception(UnAuthenticationException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.UNAUTHORIZED); - } - - @ExceptionHandler(value = UnAuthorizedException.class) - public ResponseEntity exception(UnAuthorizedException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.UNAUTHORIZED); - } - - @ExceptionHandler(Exception.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity handleAllUncaughtException( - Exception exception, WebRequest request) { - exception.printStackTrace(); - return new ResponseEntity<>( - ErrorResponse.builder() - .errorCode(ErrorCode.INTERNAL_SERVER_ERROR) - .message( - "Unknown error occurred Request-id: " - + request.getHeader(Slf4jMDCFilterConfiguration.DEFAULT_RESPONSE_TOKEN_HEADER) - + ", " - + exception.getMessage()) - .build(), - HttpStatus.INTERNAL_SERVER_ERROR); - } - - @ExceptionHandler(value = CollectionInstanceNotFoundException.class) - public ResponseEntity exception(CollectionInstanceNotFoundException exception) { - return new ResponseEntity<>(new ErrorResponse(exception), HttpStatus.NOT_FOUND); - } - - - @ExceptionHandler(MethodArgumentNotValidException.class) - public ResponseEntity handleValidationExceptions(MethodArgumentNotValidException ex) { - Map errors = new HashMap<>(); - ex.getBindingResult() - .getFieldErrors() - .forEach( - error -> { - if (errors.containsKey(error.getField())) { - errors.put( - StringUtils.camelCaseToSnakeCase(error.getField()), - String.format( - "%s, %s", errors.get(error.getField()), error.getDefaultMessage())); - } else { - errors.put(StringUtils.camelCaseToSnakeCase(error.getField()), error.getDefaultMessage()); - } - }); - return ResponseEntity.badRequest().body(errors); - } -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/common/HealthController.java b/src/backend/backend-loader/src/main/java/com/activepieces/common/HealthController.java deleted file mode 100644 index 0e19667b19..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/common/HealthController.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.activepieces.common; - -import io.swagger.v3.oas.annotations.Hidden; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Hidden -public class HealthController { - - - @GetMapping("/health") - public ResponseEntity up() { - return ResponseEntity.ok("UP"); - } - -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/config/MethodSecurityConfig.java b/src/backend/backend-loader/src/main/java/com/activepieces/config/MethodSecurityConfig.java deleted file mode 100644 index cf2ffbfe20..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/config/MethodSecurityConfig.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.activepieces.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; - -@Configuration -@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) -public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/config/MultiPartConfigure.java b/src/backend/backend-loader/src/main/java/com/activepieces/config/MultiPartConfigure.java deleted file mode 100644 index c2f7fdd25d..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/config/MultiPartConfigure.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.config; - -import org.springframework.boot.web.servlet.MultipartConfigFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.unit.DataSize; - -import javax.servlet.MultipartConfigElement; - -@Configuration -public class MultiPartConfigure { - @Bean - public MultipartConfigElement multipartConfigElement() { - MultipartConfigFactory factory = new MultipartConfigFactory(); - factory.setMaxFileSize(DataSize.ofMegabytes(25)); - factory.setMaxRequestSize(DataSize.ofMegabytes(30)); - return factory.createMultipartConfig(); - } -} \ No newline at end of file diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/config/RestTemplateConfig.java b/src/backend/backend-loader/src/main/java/com/activepieces/config/RestTemplateConfig.java deleted file mode 100644 index 322ddebb81..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/config/RestTemplateConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.config; - -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; - -@Configuration -public class RestTemplateConfig { - - @Bean - public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { - return restTemplateBuilder - .build(); - } -} \ No newline at end of file diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/config/StartupHousekeeper.java b/src/backend/backend-loader/src/main/java/com/activepieces/config/StartupHousekeeper.java deleted file mode 100644 index 776c8739e4..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/config/StartupHousekeeper.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.activepieces.config; - -import com.activepieces.authentication.client.UserAuthenticationService; -import com.activepieces.authentication.client.model.UserInformationView; -import com.activepieces.authentication.client.request.SignUpRequest; -import com.activepieces.project.client.ProjectService; -import com.activepieces.project.client.model.CreateProjectRequest; -import com.activepieces.project.client.model.ProjectView; -import com.activepieces.common.Constants; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.context.event.EventListener; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.stereotype.Component; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.List; - -@Component -@Log4j2 -public class StartupHousekeeper { - - - private final UserAuthenticationService authenticationService; - private final ProjectService projectService; - private final Scheduler scheduler; - - @Autowired - public StartupHousekeeper(@NonNull final UserAuthenticationService authenticationService, - @NonNull final Scheduler scheduleService, - @NonNull final ProjectService projectService) { - this.authenticationService = authenticationService; - this.projectService = projectService; - this.scheduler = scheduleService; - } - - @EventListener(ContextRefreshedEvent.class) - public void contextRefreshedEvent() throws SchedulerException, IOException { - log.info("Running Startup configuration"); - final UserInformationView user = authenticationService.getOptional("admin@activepieces.com") - .orElse(authenticationService.create("admin@activepieces.com", - SignUpRequest.builder().firstName("Activepieces") - .lastName("Admin") - .password("password") - .build())); - final List projectViewList = projectService.listByOwnerId(user.getId()); - if (projectViewList.isEmpty()) { - final ProjectView projectView = projectService.create(user.getId(), CreateProjectRequest.builder() - .displayName("Project") - .build()); - scheduler.clear(); - } - // Place worker js - final Resource workerExecutor = new ClassPathResource(Constants.ACTIVEPIECES_WORKER_JS); - final File temp = new File(Constants.ACTIVEPIECES_WORKER_ABS_PATH_JS); - temp.getParentFile().mkdirs(); - Files.copy( - workerExecutor.getInputStream(), - temp.toPath(), - StandardCopyOption.REPLACE_EXISTING); - log.info("Copied worker js file to {}", temp.getAbsolutePath()); - } - -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/config/WebConfigConverter.java b/src/backend/backend-loader/src/main/java/com/activepieces/config/WebConfigConverter.java deleted file mode 100644 index 8a81c4e904..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/config/WebConfigConverter.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.activepieces.config; - -import com.activepieces.common.utils.APIdSerializer; -import com.activepieces.common.pagination.Cursor; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.github.ksuid.Ksuid; -import lombok.extern.log4j.Log4j2; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.core.convert.converter.Converter; -import org.springframework.format.FormatterRegistry; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.security.web.method.annotation.AuthenticationPrincipalArgumentResolver; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.util.List; -import java.util.Objects; - -@Configuration -@Log4j2 -public class WebConfigConverter extends WebMvcConfigurationSupport { - - @Override - protected void addArgumentResolvers(List argumentResolvers) { - super.addArgumentResolvers(argumentResolvers); - argumentResolvers.add(new AuthenticationPrincipalArgumentResolver()); - } - - @Bean(name = "jsonMapper") - @Primary - public ObjectMapper jsonMapper() { - SimpleModule simpleModule = new SimpleModule("SimpleModule"); - simpleModule.addSerializer(Ksuid.class, new APIdSerializer()); - return new ObjectMapper().registerModule(simpleModule) - .setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE) - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - } - - @Override - protected void configureMessageConverters(List> converters) { - super.configureMessageConverters(converters); - converters.add(new MappingJackson2HttpMessageConverter(jsonMapper())); - } - - @Override - protected void addFormatters(FormatterRegistry registry) { - super.addFormatters(registry); - log.info("Added formatter packages"); - registry.addConverter(new StringToCursorConverter()); - registry.addConverter(new StringToKsuidConvertor()); - } -} - -class StringToKsuidConvertor implements Converter { - - @Override - public Ksuid convert(String param) { - if(Objects.isNull(param)){ - return null; - } - return Ksuid.fromString(param); - } -} - - -class StringToCursorConverter implements Converter { - @Override - public Cursor convert(String param) { - if(Objects.isNull(param)){ - return null; - } - return new Cursor(param); - } -} - - diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/security/Slf4jMDCFilter.java b/src/backend/backend-loader/src/main/java/com/activepieces/security/Slf4jMDCFilter.java deleted file mode 100644 index b733c174a7..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/security/Slf4jMDCFilter.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.activepieces.security; - -/* - * #%L - * Summer - * %% - * Copyright (C) 2018 GreenEyed (Daniel Lopez) - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ - - -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.UUID; - -/** - * A servlet that adds a key to the Mapped Diagnostic Context (MDC) to each request so you can print a unique id in the logg messages of each request. - * It also add the key as a header in the response so the caller of the request can provide you the id to browse the logs. - * - **/ -@Data -@EqualsAndHashCode(callSuper = false) -@Component -public class Slf4jMDCFilter extends OncePerRequestFilter { - - private final String responseHeader; - private final String mdcTokenKey; - private final String requestHeader; - private final String apiRunPattern; - - @Autowired - public Slf4jMDCFilter(@Value("${logging.request-id-header}") String mdcTokenKey, - @Value("${logging.api-pattern}") String apiRunPattern){ - responseHeader = Slf4jMDCFilterConfiguration.DEFAULT_RESPONSE_TOKEN_HEADER; - this.mdcTokenKey = mdcTokenKey; - this.apiRunPattern = apiRunPattern; - requestHeader = null; - } - - public Slf4jMDCFilter(final String responseHeader, final String mdcTokenKey, final String apiRunPattern, final String requestHeader) { - this.responseHeader = responseHeader; - this.mdcTokenKey = mdcTokenKey; - this.requestHeader = requestHeader; - this.apiRunPattern = apiRunPattern; - } - - @Override - protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) - throws java.io.IOException, ServletException { - try { - final String token = extractToken(request); - MDC.put(mdcTokenKey, String.format(apiRunPattern,token)); - if (StringUtils.hasText(responseHeader)) { - response.addHeader(responseHeader, token); - } - chain.doFilter(request, response); - } finally { - MDC.remove(mdcTokenKey); - } - } - - private String extractToken(final HttpServletRequest request) { - final String token; - if (StringUtils.hasText(requestHeader) && StringUtils.hasText(request.getHeader(requestHeader))) { - token = request.getHeader(requestHeader); - } else { - token = UUID.randomUUID().toString().toUpperCase(); - } - return token; - } - - - - @Override - protected boolean isAsyncDispatch(final HttpServletRequest request) { - return false; - } - - @Override - protected boolean shouldNotFilterErrorDispatch() { - return false; - } -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/security/Slf4jMDCFilterConfiguration.java b/src/backend/backend-loader/src/main/java/com/activepieces/security/Slf4jMDCFilterConfiguration.java deleted file mode 100644 index a20e055a6b..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/security/Slf4jMDCFilterConfiguration.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.activepieces.security;/* - * #%L - * Summer - * %% - * Copyright (C) 2018 GreenEyed (Daniel Lopez) - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ - - -import lombok.Data; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * The class that configures a servlet that adds a key to the Mapped Diagnostic Context (MDC) to each request so you can print a unique id in the logg - * messages of each request. It also add the key as a header in the response so the caller of the request can provide you the id to browse the logs. - * Set the response header name to null/blank if you want the response to NOT include such header. - * - * If you provide a request header name, the filter will check first if the request contains a header with that name and will use the ID it provides. - * This is useful if your application chain has already assigned an id to the "transaction". (Microservices, apps behind a proxy/gateway service...) - * - * The MDC key and the header names are configurable. - * - * Here's a configuration sample with the default values: - * - *
- * summer:
- *   slf4jfilter:
- *     response_header: Response_Token
- *     mdc_token_key: Slf4jMDCFilter.UUID
- *     mdc_client_ip_key: Slf4jMDCFilter.ClientIP
- *     request_header:
- * 
- **/ -@Data -@Configuration -@ConfigurationProperties(prefix = "summer.slf4jfilter") -public class Slf4jMDCFilterConfiguration { - - public static final String DEFAULT_RESPONSE_TOKEN_HEADER = "Request-id"; - - private String responseHeader = DEFAULT_RESPONSE_TOKEN_HEADER; - private String requestHeader = null; - private String mdcTokenKey; - private String mcTokenPrefix; - - @Autowired - public Slf4jMDCFilterConfiguration(@Value("${logging.request-id-header}") String mdcTokenKey, - @Value("${logging.api-pattern}") String mcTokenPrefix){ - this.mdcTokenKey = mdcTokenKey; - this.mcTokenPrefix = mcTokenPrefix; - } - - @Bean - public FilterRegistrationBean servletRegistrationBean() { - final FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - final Slf4jMDCFilter log4jMDCFilterFilter = new Slf4jMDCFilter(responseHeader, mdcTokenKey, mcTokenPrefix, requestHeader); - registrationBean.setFilter(log4jMDCFilterFilter); - registrationBean.setOrder(2); - return registrationBean; - } -} diff --git a/src/backend/backend-loader/src/main/java/com/activepieces/security/WebSecurity.java b/src/backend/backend-loader/src/main/java/com/activepieces/security/WebSecurity.java deleted file mode 100644 index cea6a5da15..0000000000 --- a/src/backend/backend-loader/src/main/java/com/activepieces/security/WebSecurity.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.activepieces.security; - -import com.activepieces.authentication.client.JWTService; -import com.activepieces.authentication.server.security.JWTAuthorizationFilter; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpMethod; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.CorsConfigurationSource; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.servlet.HandlerExceptionResolver; - -@Configuration -@EnableWebSecurity -public class WebSecurity extends WebSecurityConfigurerAdapter { - - public static final String AUTHORIZATION_HEADER_NAME = "Authorization"; - - private final HandlerExceptionResolver resolver; - private final JWTService jwtService; - - @Autowired - public WebSecurity( - @Qualifier("handlerExceptionResolver") HandlerExceptionResolver resolver, - @NonNull final JWTService jwtService) { - this.resolver = resolver; - this.jwtService = jwtService; - } - - @Override - protected void configure(HttpSecurity httpSecurity) throws Exception { - httpSecurity.httpBasic(); - httpSecurity - .cors() - .and() - .csrf() - .disable() - .authorizeRequests() - .antMatchers(HttpMethod.GET, "/files/*") - .permitAll() - .antMatchers(HttpMethod.GET, "/api-docs") - .permitAll() - .antMatchers(HttpMethod.GET, "/health") - .permitAll() - .antMatchers(HttpMethod.POST, "/webhook") - .permitAll() - .antMatchers(HttpMethod.POST, "/authentication/*") - .permitAll() - .antMatchers(HttpMethod.GET, "/components") - .permitAll() - .antMatchers(HttpMethod.POST, "/components/*/actions/*/configs/*/options") - .permitAll() - .antMatchers(HttpMethod.POST, "/instances/*/flows/*/runs") - .permitAll() - .anyRequest() - .authenticated() - .and() - .addFilter( - new JWTAuthorizationFilter( - jwtService, - authenticationManager())) - .sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS); - } - - - @Bean - CorsConfigurationSource corsConfigurationSource() { - CorsConfiguration configuration = new CorsConfiguration().applyPermitDefaultValues(); - configuration.addExposedHeader(AUTHORIZATION_HEADER_NAME); - configuration.addAllowedOrigin("*"); - configuration.addAllowedHeader("*"); - configuration.addAllowedMethod("*"); - final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", configuration); - return source; - } -} diff --git a/src/backend/backend-loader/src/main/resources/application-default.properties b/src/backend/backend-loader/src/main/resources/application-default.properties deleted file mode 100644 index 6ce605791a..0000000000 --- a/src/backend/backend-loader/src/main/resources/application-default.properties +++ /dev/null @@ -1,18 +0,0 @@ - -spring.datasource.hikari.idle-timeout=600000 -spring.datasource.hikari.validationTimeout=300000 -spring.datasource.hikari.connectionTimeout=30000 -spring.datasource.hikari.idleTimeout=600000 -spring.datasource.hikari.maxLifetime=1800000 - -spring.jpa.hibernate.ddl-auto=update -spring.datasource.initialization-mode=always -spring.datasource.platform=postgres -spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:7432/activepieces} -spring.datasource.username=postgres -spring.datasource.password=A79Vm5D4p2VQHOp2gd5 -spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true - -## General -com.activepieces.api-prefix=http://localhost:8000 -com.activepieces.redirect-url=http://localhost:8080/redirect diff --git a/src/backend/backend-loader/src/main/resources/application.properties b/src/backend/backend-loader/src/main/resources/application.properties deleted file mode 100644 index 2015fe4cc5..0000000000 --- a/src/backend/backend-loader/src/main/resources/application.properties +++ /dev/null @@ -1,22 +0,0 @@ -server.port=8000 -spring.output.ansi.enabled=ALWAYS -logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} |%X{Slf4jMDCFilter.UUID}| %highlight(%-5level) %yellow(%C{1.}): %msg%n%throwable -logging.request-id-header=Slf4jMDCFilter.UUID -logging.run-pattern=RUN_%S -logging.api-pattern=API_%S -logging.level.root=INFO - -## QuartzProperties -spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate -spring.quartz.job-store-type=jdbc -spring.quartz.jdbc.schema=classpath:schema.sql -spring.quartz.jdbc.initialize-schema=always -spring.quartz.jdbc.comment-prefix=QRTZ -spring.quartz.properties.org.quartz.threadPool.threadCount=10 -spring.servlet.multipart.max-file-size=25MB -spring.servlet.multipart.max-request-size=25MB - -springdoc.api-docs.path=/api-docs -spring.flyway.baseline-on-migrate=true -spring.flyway.locations=classpath:sql -spring.flyway.sql-migration-prefix=v diff --git a/src/backend/backend-loader/src/main/resources/artifact.zip b/src/backend/backend-loader/src/main/resources/artifact.zip deleted file mode 100644 index 9293ac4196..0000000000 Binary files a/src/backend/backend-loader/src/main/resources/artifact.zip and /dev/null differ diff --git a/src/backend/backend-loader/src/main/resources/code-executor.js b/src/backend/backend-loader/src/main/resources/code-executor.js deleted file mode 100644 index 0e5d7b993f..0000000000 --- a/src/backend/backend-loader/src/main/resources/code-executor.js +++ /dev/null @@ -1,15 +0,0 @@ -const handler = require("./index"); -const fs = require('fs'); - -async function main(){ - let rawdata = fs.readFileSync('_input.txt'); - let input = JSON.parse(rawdata); - try{ - let output = await handler.code(input); - fs.writeFileSync('_functionOutput.txt', output == undefined ? "" : JSON.stringify(output)); - }catch (exception){ - throw exception - } -} - -main(); diff --git a/src/backend/backend-loader/src/main/resources/invalid-code.js b/src/backend/backend-loader/src/main/resources/invalid-code.js deleted file mode 100644 index 3a2cbacc85..0000000000 --- a/src/backend/backend-loader/src/main/resources/invalid-code.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.code = async (params) => { - throw new Error("${ERROR_MESSAGE}"); -}; diff --git a/src/backend/backend-loader/src/main/resources/schema.sql b/src/backend/backend-loader/src/main/resources/schema.sql deleted file mode 100644 index d28633a8b8..0000000000 --- a/src/backend/backend-loader/src/main/resources/schema.sql +++ /dev/null @@ -1,190 +0,0 @@ - -CREATE TABLE IF NOT EXISTS QRTZ_JOB_DETAILS -( - SCHED_NAME VARCHAR(120) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - JOB_CLASS_NAME VARCHAR(250) NOT NULL, - IS_DURABLE BOOL NOT NULL, - IS_NONCONCURRENT BOOL NOT NULL, - IS_UPDATE_DATA BOOL NOT NULL, - REQUESTS_RECOVERY BOOL NOT NULL, - JOB_DATA BYTEA NULL, - PRIMARY KEY (SCHED_NAME, JOB_NAME, JOB_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - NEXT_FIRE_TIME BIGINT NULL, - PREV_FIRE_TIME BIGINT NULL, - PRIORITY INTEGER NULL, - TRIGGER_STATE VARCHAR(16) NOT NULL, - TRIGGER_TYPE VARCHAR(8) NOT NULL, - START_TIME BIGINT NOT NULL, - END_TIME BIGINT NULL, - CALENDAR_NAME VARCHAR(200) NULL, - MISFIRE_INSTR SMALLINT NULL, - JOB_DATA BYTEA NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, JOB_NAME, JOB_GROUP) - REFERENCES QRTZ_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_SIMPLE_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - REPEAT_COUNT BIGINT NOT NULL, - REPEAT_INTERVAL BIGINT NOT NULL, - TIMES_TRIGGERED BIGINT NOT NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_CRON_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - CRON_EXPRESSION VARCHAR(120) NOT NULL, - TIME_ZONE_ID VARCHAR(80), - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_SIMPROP_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - STR_PROP_1 VARCHAR(512) NULL, - STR_PROP_2 VARCHAR(512) NULL, - STR_PROP_3 VARCHAR(512) NULL, - INT_PROP_1 INT NULL, - INT_PROP_2 INT NULL, - LONG_PROP_1 BIGINT NULL, - LONG_PROP_2 BIGINT NULL, - DEC_PROP_1 NUMERIC(13, 4) NULL, - DEC_PROP_2 NUMERIC(13, 4) NULL, - BOOL_PROP_1 BOOL NULL, - BOOL_PROP_2 BOOL NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_BLOB_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - BLOB_DATA BYTEA NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_CALENDARS -( - SCHED_NAME VARCHAR(120) NOT NULL, - CALENDAR_NAME VARCHAR(200) NOT NULL, - CALENDAR BYTEA NOT NULL, - PRIMARY KEY (SCHED_NAME, CALENDAR_NAME) - ); - - -CREATE TABLE IF NOT EXISTS QRTZ_PAUSED_TRIGGER_GRPS -( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - PRIMARY KEY (SCHED_NAME, TRIGGER_GROUP) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_FIRED_TRIGGERS -( - SCHED_NAME VARCHAR(120) NOT NULL, - ENTRY_ID VARCHAR(95) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - FIRED_TIME BIGINT NOT NULL, - SCHED_TIME BIGINT NOT NULL, - PRIORITY INTEGER NOT NULL, - STATE VARCHAR(16) NOT NULL, - JOB_NAME VARCHAR(200) NULL, - JOB_GROUP VARCHAR(200) NULL, - IS_NONCONCURRENT BOOL NULL, - REQUESTS_RECOVERY BOOL NULL, - PRIMARY KEY (SCHED_NAME, ENTRY_ID) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_SCHEDULER_STATE -( - SCHED_NAME VARCHAR(120) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - LAST_CHECKIN_TIME BIGINT NOT NULL, - CHECKIN_INTERVAL BIGINT NOT NULL, - PRIMARY KEY (SCHED_NAME, INSTANCE_NAME) - ); - -CREATE TABLE IF NOT EXISTS QRTZ_LOCKS -( - SCHED_NAME VARCHAR(120) NOT NULL, - LOCK_NAME VARCHAR(40) NOT NULL, - PRIMARY KEY (SCHED_NAME, LOCK_NAME) - ); - -CREATE INDEX IF NOT EXISTS IDX_QRTZ_J_REQ_RECOVERY - ON QRTZ_JOB_DETAILS (SCHED_NAME, REQUESTS_RECOVERY); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_J_GRP - ON QRTZ_JOB_DETAILS (SCHED_NAME, JOB_GROUP); - -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_J - ON QRTZ_TRIGGERS (SCHED_NAME, JOB_NAME, JOB_GROUP); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_JG - ON QRTZ_TRIGGERS (SCHED_NAME, JOB_GROUP); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_C - ON QRTZ_TRIGGERS (SCHED_NAME, CALENDAR_NAME); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_G - ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_GROUP); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_STATE - ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_STATE); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_N_STATE - ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP, TRIGGER_STATE); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_N_G_STATE - ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_GROUP, TRIGGER_STATE); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_NEXT_FIRE_TIME - ON QRTZ_TRIGGERS (SCHED_NAME, NEXT_FIRE_TIME); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_NFT_ST - ON QRTZ_TRIGGERS (SCHED_NAME, TRIGGER_STATE, NEXT_FIRE_TIME); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_NFT_MISFIRE - ON QRTZ_TRIGGERS (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_NFT_ST_MISFIRE - ON QRTZ_TRIGGERS (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_STATE); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_T_NFT_ST_MISFIRE_GRP - ON QRTZ_TRIGGERS (SCHED_NAME, MISFIRE_INSTR, NEXT_FIRE_TIME, TRIGGER_GROUP, TRIGGER_STATE); - -CREATE INDEX IF NOT EXISTS IDX_QRTZ_FT_TRIG_INST_NAME - ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, INSTANCE_NAME); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_FT_INST_JOB_REQ_RCVRY - ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, INSTANCE_NAME, REQUESTS_RECOVERY); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_FT_J_G - ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, JOB_NAME, JOB_GROUP); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_FT_JG - ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, JOB_GROUP); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_FT_T_G - ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, TRIGGER_NAME, TRIGGER_GROUP); -CREATE INDEX IF NOT EXISTS IDX_QRTZ_FT_TG - ON QRTZ_FIRED_TRIGGERS (SCHED_NAME, TRIGGER_GROUP); - - diff --git a/src/backend/backend-loader/src/main/resources/sql/v2__init.sql b/src/backend/backend-loader/src/main/resources/sql/v2__init.sql deleted file mode 100644 index bfac7c6d2c..0000000000 --- a/src/backend/backend-loader/src/main/resources/sql/v2__init.sql +++ /dev/null @@ -1,60 +0,0 @@ -CREATE TABLE INT_MESSAGE ( - MESSAGE_ID CHAR(36) NOT NULL, - REGION VARCHAR(100) NOT NULL, - CREATED_DATE TIMESTAMP NOT NULL, - MESSAGE_BYTES BYTEA, - constraint INT_MESSAGE_PK primary key (MESSAGE_ID, REGION) -); - -CREATE INDEX INT_MESSAGE_IX1 ON INT_MESSAGE (CREATED_DATE); - -CREATE TABLE INT_GROUP_TO_MESSAGE ( - GROUP_KEY CHAR(36) NOT NULL, - MESSAGE_ID CHAR(36) NOT NULL, - REGION VARCHAR(100), - constraint INT_GROUP_TO_MESSAGE_PK primary key (GROUP_KEY, MESSAGE_ID, REGION) -); - -CREATE TABLE INT_MESSAGE_GROUP ( - GROUP_KEY CHAR(36) NOT NULL, - REGION VARCHAR(100) NOT NULL, - MARKED BIGINT, - COMPLETE BIGINT, - LAST_RELEASED_SEQUENCE BIGINT, - CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP DEFAULT NULL, - constraint INT_MESSAGE_GROUP_PK primary key (GROUP_KEY, REGION) -); - -CREATE TABLE INT_LOCK ( - LOCK_KEY CHAR(36) NOT NULL, - REGION VARCHAR(100) NOT NULL, - CLIENT_ID CHAR(36), - CREATED_DATE TIMESTAMP NOT NULL, - constraint INT_LOCK_PK primary key (LOCK_KEY, REGION) -); - -CREATE SEQUENCE INT_MESSAGE_SEQ START WITH 1 INCREMENT BY 1 NO CYCLE; - -CREATE TABLE INT_CHANNEL_MESSAGE ( - MESSAGE_ID CHAR(36) NOT NULL, - GROUP_KEY CHAR(36) NOT NULL, - CREATED_DATE BIGINT NOT NULL, - MESSAGE_PRIORITY BIGINT, - MESSAGE_SEQUENCE BIGINT NOT NULL DEFAULT nextval('INT_MESSAGE_SEQ'), - MESSAGE_BYTES BYTEA, - REGION VARCHAR(100) NOT NULL, - constraint INT_CHANNEL_MESSAGE_PK primary key (REGION, GROUP_KEY, CREATED_DATE, MESSAGE_SEQUENCE) -); - -CREATE INDEX INT_CHANNEL_MSG_DELETE_IDX ON INT_CHANNEL_MESSAGE (REGION, GROUP_KEY, MESSAGE_ID); --- This is only needed if the message group store property 'priorityEnabled' is true --- CREATE UNIQUE INDEX INT_CHANNEL_MSG_PRIORITY_IDX ON INT_CHANNEL_MESSAGE (REGION, GROUP_KEY, MESSAGE_PRIORITY DESC, CREATED_DATE, MESSAGE_SEQUENCE); - - -CREATE TABLE INT_METADATA_STORE ( - METADATA_KEY VARCHAR(255) NOT NULL, - METADATA_VALUE VARCHAR(4000), - REGION VARCHAR(100) NOT NULL, - constraint INT_METADATA_STORE_PK primary key (METADATA_KEY, REGION) -); \ No newline at end of file diff --git a/src/backend/collection-service/collection-client/pom.xml b/src/backend/collection-service/collection-client/pom.xml deleted file mode 100644 index b60744dbbf..0000000000 --- a/src/backend/collection-service/collection-client/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - collection-client - - - authentication-client - com.activepieces - compile - 1.0 - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - 4.0.0 - - - collection-service - com.activepieces - 1.0 - - - - diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/CollectionService.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/CollectionService.java deleted file mode 100644 index 91d7e1492e..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/CollectionService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.activepieces.piece.client; - -import com.activepieces.common.error.exception.InvalidCodeArtifactException; -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionAlreadyLockedException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.piece.client.model.CollectionView; -import com.activepieces.piece.client.model.CreatePieceRequest; -import com.github.ksuid.Ksuid; - -import java.io.IOException; -import java.util.Optional; - -public interface CollectionService { - - SeekPage listByProjectId(Ksuid projectId, SeekPageRequest pageRequest) throws CollectionNotFoundException, PermissionDeniedException; - - CollectionView create(Ksuid projectId, CreatePieceRequest view) throws PermissionDeniedException, ResourceNotFoundException, IOException, CollectionVersionNotFoundException, InvalidCodeArtifactException; - - Optional getOptional(Ksuid id) throws PermissionDeniedException; - - CollectionView get(Ksuid id) throws CollectionNotFoundException, PermissionDeniedException; - - CollectionView update(Ksuid id, CollectionVersionView view) - throws CollectionNotFoundException, PermissionDeniedException, ResourceNotFoundException, IOException, CollectionVersionNotFoundException, InvalidCodeArtifactException, CollectionVersionAlreadyLockedException; - - void delete(Ksuid id) throws CollectionNotFoundException, PermissionDeniedException, ResourceNotFoundException; -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/CollectionVersionService.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/CollectionVersionService.java deleted file mode 100644 index 63d0879f6f..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/CollectionVersionService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.activepieces.piece.client; - - -import com.activepieces.common.error.exception.collection.CollectionInvalidStateException; -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionAlreadyLockedException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.piece.client.model.CollectionMetaVersionView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.github.ksuid.Ksuid; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -public interface CollectionVersionService { - - CollectionVersionView create(Ksuid collectionId, CollectionVersionView view) throws ResourceNotFoundException, PermissionDeniedException, CollectionVersionNotFoundException; - - CollectionVersionView getLatest(Ksuid collectionId) throws PermissionDeniedException; - - CollectionVersionView get(Ksuid id) throws CollectionVersionNotFoundException, PermissionDeniedException; - - Map commit(Ksuid id) throws PermissionDeniedException, CollectionVersionNotFoundException, CollectionVersionAlreadyLockedException, FlowNotFoundException, CollectionInvalidStateException; - - CollectionVersionView update(Ksuid id, CollectionVersionView view) throws PermissionDeniedException, CollectionVersionNotFoundException, CollectionVersionAlreadyLockedException, CollectionVersionAlreadyLockedException; - - List listByCollectionId(Ksuid collectionId) throws CollectionNotFoundException, PermissionDeniedException; - - Optional getOptional(Ksuid id) throws PermissionDeniedException; - -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/mapper/CollectionMapper.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/mapper/CollectionMapper.java deleted file mode 100644 index 9e06d9bffa..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/mapper/CollectionMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.activepieces.piece.client.mapper; - -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.entity.sql.Collection; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.piece.client.model.CollectionView; -import com.github.ksuid.Ksuid; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.UUID; - -import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR; - -@Mapper(subclassExhaustiveStrategy = COMPILE_ERROR, componentModel = "spring") -public abstract class CollectionMapper { - - @Autowired - private CollectionVersionService collectionVersionService; - - @Mappings({}) - public abstract Collection fromView(CollectionView entity); - - @Mappings({ - @Mapping(target = "lastVersion", expression = "java(map(entity.getId()))"), - }) - public abstract CollectionView toView(Collection entity); - - public CollectionVersionView map(Ksuid collectionId) { - try { - return collectionVersionService.getLatest(collectionId); - } catch (PermissionDeniedException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/mapper/CollectionVersionMapper.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/mapper/CollectionVersionMapper.java deleted file mode 100644 index f8138ca79b..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/mapper/CollectionVersionMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.piece.client.mapper; - -import com.activepieces.entity.sql.CollectionVersion; -import com.activepieces.entity.subdocuments.field.Variable; -import com.activepieces.piece.client.model.CollectionMetaVersionView; -import com.activepieces.piece.client.model.CollectionVersionView; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; - -import java.util.List; - -import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR; - -@Mapper(subclassExhaustiveStrategy = COMPILE_ERROR, componentModel = "spring") -public abstract class CollectionVersionMapper { - - @Mappings({}) - public abstract CollectionMetaVersionView toMeta(CollectionVersionView entity); - @Mappings({}) - public abstract CollectionVersion fromView(CollectionVersionView entity); - - @Mappings({}) - public abstract CollectionVersionView toView(CollectionVersion entity); -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionMetaVersionView.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionMetaVersionView.java deleted file mode 100644 index bbdeaff138..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionMetaVersionView.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.activepieces.piece.client.model; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.EditState; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.UUID; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@Builder(toBuilder = true) -public class CollectionMetaVersionView implements EntityMetadata { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty @NotEmpty @NotNull private String displayName; - - @JsonIgnore private Ksuid collectionId; - - @JsonProperty @NotEmpty private String description; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long created; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long updated; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private EditState state; -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionVersionView.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionVersionView.java deleted file mode 100644 index a887bb92db..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionVersionView.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.activepieces.piece.client.model; - -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.subdocuments.field.Variable; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@Builder(toBuilder = true) -public class CollectionVersionView { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty @NotEmpty private String displayName; - - @JsonProperty @NotNull private List<@Valid Variable> configs; - - @JsonIgnore private Ksuid collectionId; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long created; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long updated; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) - private EditState state; - -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionView.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionView.java deleted file mode 100644 index 5160604f67..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CollectionView.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.activepieces.piece.client.model; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.EditState; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import java.time.Instant; -import java.util.List; -import java.util.UUID; - -@NoArgsConstructor -@Getter -@Setter -@AllArgsConstructor -@SuperBuilder(toBuilder = true) -public class CollectionView implements EntityMetadata { - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) private Ksuid id; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) - private Ksuid projectId; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private CollectionVersionView lastVersion; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) private long created; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) private long updated; - - public void updateOrCreateDraft(CollectionVersionView newDraft) { - lastVersion = newDraft; - } - -} diff --git a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CreatePieceRequest.java b/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CreatePieceRequest.java deleted file mode 100644 index df99b45337..0000000000 --- a/src/backend/collection-service/collection-client/src/main/java/com/activepieces/piece/client/model/CreatePieceRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.piece.client.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@Builder(toBuilder = true) -public class CreatePieceRequest { - - @JsonProperty @NotEmpty - private String displayName; - - -} diff --git a/src/backend/collection-service/collection-server/pom.xml b/src/backend/collection-service/collection-server/pom.xml deleted file mode 100644 index ff67f21580..0000000000 --- a/src/backend/collection-service/collection-server/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - collection-server - - - guardian-client - com.activepieces - compile - 1.0 - - - authentication-client - com.activepieces - compile - 1.0 - - - com.activepieces - project-client - 1.0 - compile - - - junit - junit - test - - - com.activepieces - flow-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - 4.0.0 - - collection-service - com.activepieces - 1.0 - - - - 11 - 11 - - - - diff --git a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/controller/CollectionController.java b/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/controller/CollectionController.java deleted file mode 100644 index 1ed7d2511f..0000000000 --- a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/controller/CollectionController.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.activepieces.piece.server.controller; - -import com.activepieces.common.error.exception.InvalidCodeArtifactException; -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionAlreadyLockedException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.pagination.Cursor; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.piece.client.CollectionService; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.piece.client.model.CollectionView; -import com.activepieces.piece.client.model.CreatePieceRequest; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.annotation.Secured; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.io.IOException; - -@RestController -@RequestMapping -@Hidden -public class CollectionController { - - private final CollectionService collectionService; - private final CollectionVersionService collectionVersionService; - - @Autowired - public CollectionController( - @NonNull final CollectionService collectionService, - @NonNull final CollectionVersionService collectionVersionService) { - this.collectionService = collectionService; - this.collectionVersionService = collectionVersionService; - } - - @Secured(value = {"ROLE_API_KEY", "ROLE_USER"}) - @GetMapping("/collections/{collectionId}") - public ResponseEntity get(@PathVariable("collectionId") Ksuid collectionId) - throws CollectionNotFoundException, PermissionDeniedException { - CollectionView collectionView = collectionService.get(collectionId); - return ResponseEntity.ok(collectionView); - } - - @Secured(value = {"ROLE_API_KEY", "ROLE_USER"}) - @GetMapping({"/projects/{projectId}/collections"}) - public ResponseEntity> list( - @PathVariable("projectId") Ksuid projectId, - @RequestParam(value = "cursor", required = false) Cursor cursor, - @RequestParam(value = "limit", defaultValue = "10", required = false) int limit) - throws PermissionDeniedException, CollectionNotFoundException { - return ResponseEntity.ok( - collectionService.listByProjectId( - projectId, new SeekPageRequest(cursor, limit))); - } - - @PostMapping("/projects/{projectId}/collections") - public ResponseEntity create( - @PathVariable("projectId") Ksuid projectId, - @RequestBody @Valid CreatePieceRequest request) - throws PermissionDeniedException, ResourceNotFoundException, - IOException, CollectionVersionNotFoundException, InvalidCodeArtifactException { - return ResponseEntity.ok(collectionService.create(projectId, request)); - } - - @PutMapping("/collections/{collectionId}") - public ResponseEntity update( - @PathVariable("collectionId") Ksuid collectionId, - @RequestBody @Valid CollectionVersionView request) - throws PermissionDeniedException, CollectionNotFoundException, ResourceNotFoundException, - IOException, CollectionVersionNotFoundException, - CollectionVersionAlreadyLockedException, InvalidCodeArtifactException { - return ResponseEntity.ok(collectionService.update(collectionId, request)); - } - - @DeleteMapping("/collections/{collectionId}") - public void delete(@PathVariable("collectionId") Ksuid collectionId) - throws PermissionDeniedException, CollectionNotFoundException, ResourceNotFoundException { - collectionService.delete(collectionId); - } -} diff --git a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/controller/CollectionVersionController.java b/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/controller/CollectionVersionController.java deleted file mode 100644 index 4a04e3438e..0000000000 --- a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/controller/CollectionVersionController.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.activepieces.piece.server.controller; - -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionMetaVersionView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.annotation.Secured; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.UUID; - -@RestController -@Hidden -@RequestMapping -public class CollectionVersionController { - - private final CollectionVersionService collectionVersionService; - - @Autowired - public CollectionVersionController( - @NonNull final CollectionVersionService collectionVersionService) { - this.collectionVersionService = collectionVersionService; - } - - @GetMapping( "/collection-versions/{versionId}") - public ResponseEntity get(@PathVariable("versionId") Ksuid versionId) - throws PermissionDeniedException, CollectionVersionNotFoundException { - CollectionVersionView pieceView = collectionVersionService.get(versionId); - return ResponseEntity.ok(pieceView); - } - - @Secured(value = {"ROLE_API_KEY", "ROLE_USER"}) - @GetMapping( "/collections/{collectionId}/versions") - public ResponseEntity> list(@PathVariable("collectionId") Ksuid collectionId) - throws PermissionDeniedException, CollectionNotFoundException { - return ResponseEntity.ok(collectionVersionService.listByCollectionId(collectionId)); - } - - -} diff --git a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/repository/CollectionRepository.java b/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/repository/CollectionRepository.java deleted file mode 100644 index b871d124c9..0000000000 --- a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/repository/CollectionRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.piece.server.repository; - -import com.activepieces.common.pagination.PaginationRepository; -import com.activepieces.entity.sql.Collection; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.UUID; - -@Repository("CollectionRepository") -public interface CollectionRepository extends CrudRepository, PaginationRepository { - - -} diff --git a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/repository/CollectionVersionRepository.java b/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/repository/CollectionVersionRepository.java deleted file mode 100644 index aa1017688b..0000000000 --- a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/repository/CollectionVersionRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.piece.server.repository; - -import com.activepieces.entity.sql.CollectionVersion; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface CollectionVersionRepository extends CrudRepository { - - List findAllByCollectionId(Ksuid collectionId); - - CollectionVersion findFirstByCollectionIdOrderByIdDesc(Ksuid collectionId); - -} diff --git a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/service/CollectionServiceImpl.java b/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/service/CollectionServiceImpl.java deleted file mode 100644 index 9943d7e2e0..0000000000 --- a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/service/CollectionServiceImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.activepieces.piece.server.service; - - -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionAlreadyLockedException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.pagination.PageFilter; -import com.activepieces.common.pagination.PageOperator; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.sql.Collection; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.piece.client.CollectionService; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.mapper.CollectionMapper; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.piece.client.model.CollectionView; -import com.activepieces.piece.client.model.CreatePieceRequest; -import com.activepieces.piece.server.repository.CollectionRepository; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -@Service -public class CollectionServiceImpl implements CollectionService { - - private final CollectionRepository collectionRepository; - private final CollectionVersionService collectionVersionService; - private final CollectionMapper collectionMapper; - private final PermissionService permissionService; - - @Autowired - public CollectionServiceImpl( - @NonNull final CollectionRepository collectionRepository, - @NonNull final CollectionMapper collectionMapper, - @NonNull final CollectionVersionService collectionVersionService, - @NonNull final PermissionService permissionService) { - this.collectionRepository = collectionRepository; - this.collectionVersionService = collectionVersionService; - this.permissionService = permissionService; - this.collectionMapper = collectionMapper; - } - - @Override - public SeekPage listByProjectId(Ksuid projectId, SeekPageRequest request) - throws PermissionDeniedException { - permissionService.requiresPermission(projectId, Permission.READ_COLLECTION); - final List filters = List.of(new PageFilter(Collection.PROJECT_ID, PageOperator.EQUAL, projectId)); - return collectionRepository.findPageAsc( filters, request).convert(collectionMapper::toView); - } - - - @Override - public CollectionView create(Ksuid projectId, CreatePieceRequest view) - throws PermissionDeniedException, ResourceNotFoundException, CollectionVersionNotFoundException { - permissionService.requiresPermission(projectId, Permission.WRITE_COLLECTION); - Ksuid collectionId = Ksuid.newKsuid(); - - Collection metadata = Collection.builder().id(collectionId).projectId(projectId).build(); - Collection result = collectionRepository.save(metadata); - permissionService.createResourceWithParent(result.getId(), projectId, ResourceType.COLLECTION); - - CollectionVersionView collectionVersionView = - collectionVersionService.create( - collectionId, - CollectionVersionView.builder() - .configs(Collections.emptyList()) - .displayName(view.getDisplayName()) - .build()); - return collectionMapper.toView(result); - } - - @Override - public Optional getOptional(Ksuid id) throws PermissionDeniedException { - Optional optional = collectionRepository.findById(id); - if (optional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(optional.get().getId(), Permission.READ_COLLECTION); - CollectionView collectionView = collectionMapper.toView(optional.get()); - return Optional.of(collectionView); - } - - @Override - public CollectionView get(Ksuid id) throws CollectionNotFoundException, PermissionDeniedException { - Optional optional = getOptional(id); - if (optional.isEmpty()) { - throw new CollectionNotFoundException(id); - } - return optional.get(); - } - - @Override - public CollectionView update(Ksuid id, CollectionVersionView view) - throws CollectionNotFoundException, PermissionDeniedException, ResourceNotFoundException, CollectionVersionNotFoundException, CollectionVersionAlreadyLockedException { - Optional optional = collectionRepository.findById(id); - if (optional.isEmpty()) { - throw new CollectionNotFoundException(id); - } - permissionService.requiresPermission(id, Permission.WRITE_COLLECTION); - CollectionView collectionView = get(id); - CollectionVersionView draft; - if (collectionView.getLastVersion().getState().equals(EditState.LOCKED)) { - draft = collectionVersionService.create(id, view); - } else { - draft = collectionVersionService.update(collectionView.getLastVersion().getId(), view); - } - collectionView.updateOrCreateDraft(draft); - return collectionMapper.toView(collectionRepository.save(collectionMapper.fromView(collectionView))); - } - - - public void delete(Ksuid id) - throws CollectionNotFoundException, PermissionDeniedException { - Optional pieceOptional = collectionRepository.findById(id); - if (pieceOptional.isEmpty()) { - throw new CollectionNotFoundException(id); - } - permissionService.requiresPermission(id, Permission.WRITE_COLLECTION); - collectionRepository.delete(pieceOptional.get()); - } -} diff --git a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/service/CollectionVersionServiceImpl.java b/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/service/CollectionVersionServiceImpl.java deleted file mode 100644 index 0db2e68112..0000000000 --- a/src/backend/collection-service/collection-server/src/main/java/com/activepieces/piece/server/service/CollectionVersionServiceImpl.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.activepieces.piece.server.service; - -import com.activepieces.cache.ConditionalCache; -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.collection.CollectionInvalidStateException; -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionAlreadyLockedException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionAlreadyLockedException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.sql.Collection; -import com.activepieces.entity.sql.CollectionVersion; -import com.activepieces.flow.FlowService; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.model.FlowView; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.mapper.CollectionVersionMapper; -import com.activepieces.piece.client.model.CollectionMetaVersionView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.piece.server.repository.CollectionRepository; -import com.activepieces.piece.server.repository.CollectionVersionRepository; -import com.github.ksuid.Ksuid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Service -public class CollectionVersionServiceImpl implements CollectionVersionService { - - private final CollectionVersionRepository collectionVersionRepository; - private final CollectionVersionMapper collectionVersionMapper; - private final FlowVersionService flowVersionService; - private final PermissionService permissionService; - private final FlowService flowService; - private final CollectionRepository collectionRepository; - private final ErrorServiceHandler errorServiceHandler; - private final ConditionalCache> conditionalCache; - - @Autowired - public CollectionVersionServiceImpl( - final CollectionVersionRepository collectionVersionRepository, - final FlowVersionService flowVersionService, - final PermissionService permissionService, - final ErrorServiceHandler errorServiceHandler, - final CollectionRepository collectionRepository, - final FlowService flowService, - final CollectionVersionMapper collectionVersionMapper) { - Function> generatorFunction = - collectionVersionRepository::findById; - Function, Boolean> cacheCondition = - pieceVersionOptional -> - pieceVersionOptional.isPresent() - && pieceVersionOptional.get().getState().equals(EditState.LOCKED); - this.conditionalCache = new ConditionalCache<>(generatorFunction, cacheCondition); - - this.collectionVersionMapper = collectionVersionMapper; - this.permissionService = permissionService; - this.collectionRepository = collectionRepository; - this.errorServiceHandler = errorServiceHandler; - this.flowService = flowService; - this.flowVersionService = flowVersionService; - this.collectionVersionRepository = collectionVersionRepository; - } - - @Override - public CollectionVersionView create( - Ksuid collectionId, - CollectionVersionView view) - throws ResourceNotFoundException, - PermissionDeniedException { - permissionService.requiresPermission(collectionId, Permission.WRITE_COLLECTION); - Ksuid newVersionIUd = Ksuid.newKsuid(); - CollectionVersionView savedView = - saveFromView( - view.toBuilder() - .collectionId(collectionId) - .id(newVersionIUd) - .state(EditState.DRAFT) - .build()); - permissionService.createResourceWithParent( - savedView.getId(), savedView.getCollectionId(), ResourceType.COLLECTION_VERSION); - return savedView; - } - - @Override - public CollectionVersionView getLatest(Ksuid collectionId) throws PermissionDeniedException { - permissionService.requiresPermission(collectionId, Permission.READ_COLLECTION); - return collectionVersionMapper.toView(collectionVersionRepository.findFirstByCollectionIdOrderByIdDesc(collectionId)); - } - - @Override - public Optional getOptional(Ksuid id) throws PermissionDeniedException { - Optional optional = conditionalCache.get(id); - if (optional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(optional.get().getId(), Permission.READ_COLLECTION); - return optional.map(collectionVersionMapper::toView); - } - - @Override - public CollectionVersionView get(Ksuid id) - throws CollectionVersionNotFoundException, PermissionDeniedException { - return getOptional(id).orElseThrow(() -> new CollectionVersionNotFoundException(id)); - } - - @Override - public CollectionVersionView update( - Ksuid id, CollectionVersionView view) - throws PermissionDeniedException, CollectionVersionNotFoundException, CollectionVersionAlreadyLockedException { - permissionService.requiresPermission(id, Permission.WRITE_COLLECTION); - CollectionVersionView currentVersion = get(id); - if (currentVersion.getState().equals(EditState.LOCKED)) { - throw new CollectionVersionAlreadyLockedException(id); - } - CollectionVersionView savedView = - saveFromView( - currentVersion.toBuilder() - .displayName(view.getDisplayName()) - .configs(view.getConfigs()) - .build()); - return saveFromView(savedView); - } - - @Override - public List listByCollectionId(Ksuid collectionId) - throws CollectionNotFoundException, PermissionDeniedException { - permissionService.requiresPermission(collectionId, Permission.READ_COLLECTION); - Optional collection = collectionRepository.findById(collectionId); - if (collection.isEmpty()) { - throw new CollectionNotFoundException(collectionId); - } - return collectionVersionRepository.findAllByCollectionId(collectionId).stream() - .map(version -> collectionVersionMapper.toMeta(collectionVersionMapper.toView(version))) - .collect(Collectors.toList()); - } - - @Override - public Map commit(Ksuid collectionVersionId) - throws PermissionDeniedException, CollectionVersionNotFoundException, FlowNotFoundException, - CollectionInvalidStateException { - permissionService.requiresPermission(collectionVersionId, Permission.WRITE_COLLECTION); - CollectionVersionView currentVersion = get(collectionVersionId); - List flowViews = flowService.listByCollectionId(currentVersion.getCollectionId(), new SeekPageRequest(null, Integer.MAX_VALUE)).getData(); - for (FlowView flowView : flowViews) { - if (!flowView.getLastVersion().isValid()) { - throw new CollectionInvalidStateException(currentVersion.getDisplayName()); - } - } - Map flowVersionIds = flowViews.stream() - .map(f -> Map.entry( f.getId(), f.getLastVersion().getId())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - commitFlows(new ArrayList<>(flowVersionIds.values())); - saveFromView( - currentVersion.toBuilder().state(EditState.LOCKED).build()); - return flowVersionIds; - } - - private void commitFlows(List versionsList) { - versionsList.forEach( - f -> { - try { - FlowVersionView flowVersionView = flowVersionService.get(f); - try { - flowVersionService.lock(flowVersionView.getId()); - } catch (FlowVersionAlreadyLockedException ignored) { - } - } catch (FlowVersionNotFoundException | PermissionDeniedException e) { - throw errorServiceHandler.createInternalError(CollectionVersionServiceImpl.class, e); - } - }); - } - - private CollectionVersionView saveFromView(CollectionVersionView versionView) { - return collectionVersionMapper.toView( - collectionVersionRepository.save(collectionVersionMapper.fromView(versionView))); - } -} diff --git a/src/backend/collection-service/pom.xml b/src/backend/collection-service/pom.xml deleted file mode 100644 index 8d1bade3a7..0000000000 --- a/src/backend/collection-service/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - collection-service - 4.0.0 - pom - - backend - com.activepieces - 1.0 - - - - collection-client - collection-server - - diff --git a/src/backend/component-service/pom.xml b/src/backend/component-service/pom.xml deleted file mode 100644 index 9923fbde5d..0000000000 --- a/src/backend/component-service/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - component-service - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/component-service/src/main/java/com/activepieces/component/ComponentService.java b/src/backend/component-service/src/main/java/com/activepieces/component/ComponentService.java deleted file mode 100644 index f52a2b5b42..0000000000 --- a/src/backend/component-service/src/main/java/com/activepieces/component/ComponentService.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.activepieces.component; - -import com.activepieces.common.Constants; -import com.activepieces.common.utils.ArtifactUtils; -import com.activepieces.entity.enums.ComponentTriggerHook; -import com.activepieces.entity.enums.ComponentTriggerType; -import com.activepieces.flow.model.FlowVersionView; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@Service -public class ComponentService { - - private final ObjectMapper objectMapper; - private final String apiPrefix; - - @Autowired - public ComponentService(@Value("${com.activepieces.api-prefix}") final String apiPrefix, - @NonNull final ObjectMapper objectMapper) { - this.objectMapper = objectMapper.copy().setPropertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE); - this.apiPrefix = apiPrefix; - } - - public List getApps() throws IOException, InterruptedException { - final String result = runJs(Constants.WORKER_APPS_ARG, null); - return objectMapper.readValue(result, new TypeReference<>() { - }); - } - - public boolean validateConfig( - @NonNull final String componentName, - final String actionName, - final String triggerName, - @NonNull final Map input) { - try { - final ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("componentName", componentName); - objectNode.put("actionName", actionName); - objectNode.put("triggerName", triggerName); - objectNode.put("input", objectMapper.convertValue(input, ObjectNode.class)); - final String result = runJs(Constants.WORKER_VALIDATE_CONFIGS_ARG, objectMapper.writeValueAsString(objectNode)).trim(); - return Boolean.parseBoolean(result); - }catch (IOException | InterruptedException e){ - throw new RuntimeException(e); - } - } - - public void executeTriggerHook( - @NonNull final ComponentTriggerHook componentTriggerHook, - @NonNull final FlowVersionView flowVersion, - @NonNull final Map configs) throws IOException, InterruptedException { - final ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("flowVersion", objectMapper.convertValue(flowVersion, ObjectNode.class)); - objectNode.put("method", componentTriggerHook.equals(ComponentTriggerHook.ENABLED) ? "on-enable" : "on-disable"); - objectNode.put("configs", objectMapper.convertValue(configs, ObjectNode.class)); - objectNode.put("webhookUrl", String.format("%s/flows/%s/webhook", apiPrefix, flowVersion.getFlowId())); - runJs(Constants.WORKER_EXECUTE_TRIGGER_ARG, objectMapper.writeValueAsString(objectNode)); - } - - public List getTriggersPayload( - @NonNull final Object payload, - @NonNull final FlowVersionView flowVersion, - @NonNull final Map configs) throws IOException, InterruptedException { - final ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("payload", objectMapper.convertValue(payload, ObjectNode.class)); - objectNode.put("method", "run"); - objectNode.put("flowVersion", objectMapper.convertValue(flowVersion, ObjectNode.class)); - objectNode.put("configs", objectMapper.convertValue(configs, ObjectNode.class)); - objectNode.put("webhookUrl", String.format("%s/flows/%s/webhook", apiPrefix, flowVersion.getFlowId())); - final String result = runJs(Constants.WORKER_EXECUTE_TRIGGER_ARG, objectMapper.writeValueAsString(objectNode)); - return objectMapper.readValue(result, new TypeReference<>() { - }); - } - - public ComponentTriggerType getTriggerType(@NonNull final String componentName, - @NonNull final String triggerName) throws IOException, InterruptedException { - final ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("componentName", componentName); - objectNode.put("triggerName", triggerName); - final String result = runJs(Constants.WORKER_TRIGGER_TYPE_ARG, objectMapper.writeValueAsString(objectNode)).trim(); - return ComponentTriggerType.valueOf(result); - } - - public List getOptions(final String componentName, final String actionName, final String configName, - final Map configs) - throws IOException, InterruptedException { - final ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("componentName", componentName); - objectNode.put("actionName", actionName); - objectNode.put("configName", configName); - objectNode.put("configs", objectMapper.convertValue(configs, ObjectNode.class)); - final String result = runJs(Constants.WORKER_OPTIONS_ARG, objectMapper.writeValueAsString(objectNode)); - return objectMapper.readValue(result, new TypeReference<>() { - }); - } - - private String runJs(final String args, final String secondArgs) throws IOException, InterruptedException { - if (Objects.isNull(secondArgs)) { - return ArtifactUtils.runCommandAsRoot(String.format("node %s %s", Constants.ACTIVEPIECES_WORKER_ABS_PATH_JS, args)); - } - return ArtifactUtils.runCommandAsRoot(String.format("node %s %s %s", Constants.ACTIVEPIECES_WORKER_ABS_PATH_JS, - args, ArtifactUtils.escapeShellDoubleQuoteString(secondArgs, true))); - } - -} diff --git a/src/backend/component-service/src/main/java/com/activepieces/component/controller/ComponentController.java b/src/backend/component-service/src/main/java/com/activepieces/component/controller/ComponentController.java deleted file mode 100644 index 28534063a3..0000000000 --- a/src/backend/component-service/src/main/java/com/activepieces/component/controller/ComponentController.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.activepieces.component.controller; - -import com.activepieces.component.ComponentService; -import com.activepieces.component.model.ConfigOptionsRequest; -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; - -@CrossOrigin -@RestController -@Hidden -@RequestMapping() -public class ComponentController { - - - private final ComponentService componentService; - - - @Autowired - public ComponentController(@NonNull final ComponentService componentService) { - this.componentService = componentService; - } - - @GetMapping("/components") - public ResponseEntity getApps() - throws Exception { - return ResponseEntity.ok(componentService.getApps()); - } - - @PostMapping("/components/{componentName}/options") - public ResponseEntity> getOptions(@PathVariable("componentName") String componentName, - @RequestBody @Valid ConfigOptionsRequest configs) - throws Exception { - return ResponseEntity.ok(componentService.getOptions(componentName, configs.getActionName(), configs.getConfigName(), configs.getConfig())); - } - -} diff --git a/src/backend/component-service/src/main/java/com/activepieces/component/model/ConfigOptionsRequest.java b/src/backend/component-service/src/main/java/com/activepieces/component/model/ConfigOptionsRequest.java deleted file mode 100644 index 4d3d70df5e..0000000000 --- a/src/backend/component-service/src/main/java/com/activepieces/component/model/ConfigOptionsRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.component.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.Map; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -public class ConfigOptionsRequest { - - @JsonProperty - @NotNull - private String configName; - - @NotNull - @JsonProperty - private String actionName; - - @NotNull - @JsonProperty - private Map config; -} diff --git a/src/backend/entities/pom.xml b/src/backend/entities/pom.xml deleted file mode 100644 index 47e40f0707..0000000000 --- a/src/backend/entities/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - entities - 4.0.0 - 1.0 - - backend - com.activepieces - 1.0 - - - - diff --git a/src/backend/entities/src/main/java/com/activepieces/cache/ConditionalCache.java b/src/backend/entities/src/main/java/com/activepieces/cache/ConditionalCache.java deleted file mode 100644 index d205065626..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/cache/ConditionalCache.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.cache; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; - -public class ConditionalCache { - - private final ConcurrentHashMap cache = new ConcurrentHashMap(); - private final Function generator; - private final Function condition; - - public ConditionalCache(Function generator, Function condition) { - this.generator = generator; - this.condition = condition; - } - - public V get(K key) { - if (cache.contains(key)) { - return cache.get(key); - } - V value = generator.apply(key); - if (this.condition.apply(value)) { - cache.put(key, value); - } - return value; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/Constants.java b/src/backend/entities/src/main/java/com/activepieces/common/Constants.java deleted file mode 100644 index e57011a75f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/Constants.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.common; - -import java.io.File; - -public class Constants { - - public static final String HOME_PATH = (new File(System.getProperty("user.home")).exists() ? System.getProperty("user.home") : "/root") + File.separator + "activepieces"; - public static String ACTIVEPIECES_WORKER_ABS_PATH_JS = HOME_PATH + File.separator + "activepieces-worker.js"; - public static String WORKER_OUTPUT_FILE = "output.json"; - public static String WORKER_EXECUTE_FLOW_ARG = "execute-flow"; - public static String WORKER_VALIDATE_CONFIGS_ARG = "validate-configs"; - public static String WORKER_EXECUTE_TRIGGER_ARG = "execute-trigger"; - public static String WORKER_APPS_ARG = "components"; - public static String WORKER_OPTIONS_ARG = "options"; - public static String WORKER_TRIGGER_TYPE_ARG = "trigger-type"; - - public static String ACTIVEPIECES_WORKER_JS = "activepieces-worker.js"; - public static String WORKER_RESULT_IN_MAP = "result"; - public static String RUN_RESULT_IN_MAP = "run"; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/EntityMetadata.java b/src/backend/entities/src/main/java/com/activepieces/common/EntityMetadata.java deleted file mode 100644 index 88a22b040f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/EntityMetadata.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.common; - -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public interface EntityMetadata { - - Ksuid getId(); - - long getCreated(); - - long getUpdated(); - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/Publisher.java b/src/backend/entities/src/main/java/com/activepieces/common/Publisher.java deleted file mode 100644 index 7af7508928..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/Publisher.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.common; - -import lombok.extern.log4j.Log4j2; - -import java.util.ArrayList; -import java.util.List; - -@Log4j2 -public abstract class Publisher, T>{ - - private final List> subscriberList = new ArrayList<>(); - - public void addSubscriber(Subscriber subscriber){ - subscriberList.add(subscriber); - } - - public void notify(E type, T entity){ - log.info("Notify subscribers"); - for(Subscriber subscriber: subscriberList){ - subscriber.onListen(type,entity); - } - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/Subscriber.java b/src/backend/entities/src/main/java/com/activepieces/common/Subscriber.java deleted file mode 100644 index a3d39680c7..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/Subscriber.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.activepieces.common; - -public interface Subscriber, T>{ - - void onListen(E type, T entity); - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorCode.java b/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorCode.java deleted file mode 100644 index b0ab3a19de..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorCode.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.activepieces.common.error; - -public enum ErrorCode { - COLLECTION_NOT_FOUND, - INSTANCE_NOT_FOUND, - EMAIL_EXISTS, - FLOW_VERSION_NOT_FOUND, - FLOW_NOT_FOUND, - PROJECT_NOT_FOUND, - PERMISSION_DENIED, - USER_NOT_FOUND, - INVALID_INPUT_FORMAT, - UNAUTHORIZED, - UNAUTHENTICATED, - API_KEY_NOT_FOUND, - INVALID_CODE_ARTIFACT, - MISSING_CODE_ARTIFACTS, - INSTANCE_RUN_LOG_NOT_FOUND, - MISSING_CONFIGS, - INVALID_TOKEN, - INVALID_IMAGE_FORMAT, - DUPLICATED_STEP_NAME, - PROJECT_NAME_EXISTS, - FLOW_VERSION_LOCKED, - COLLECTION_VERSION_LOCKED, - DEPENDENCY_NOT_FOUND, - FLOW_NAME_EXISTS, - ARTIFACT_BUILD_FAILED, - INTERNAL_SERVER_ERROR, - COLLECTION_INVALID_STATE, - EMPTY_TRIGGER, - CONFIG_NOT_FOUND, - INVALID_CONFIG, - FLOW_NOT_ENABLED, - CONFIG_NOT_DYNAMIC, - MANIFEST_NOT_FOUND, - COLLECTION_INSTANCE_NOT_FOUND -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorResponse.java b/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorResponse.java deleted file mode 100644 index 8dc0e12f04..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorResponse.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.common.error; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.io.Serializable; - -@Setter -@Getter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class ErrorResponse implements Serializable { - - @JsonProperty - private String message; - - @JsonProperty - private ErrorCode errorCode; - - public ErrorResponse(ErrorResponseException errorResponse){ - this.message = errorResponse.getMessage(); - this.errorCode = errorResponse.getErrorCode(); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorResponseException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorResponseException.java deleted file mode 100644 index fb5ab05c69..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorResponseException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.activepieces.common.error; - - -public interface ErrorResponseException { - - ErrorCode getErrorCode(); - String getMessage(); - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorServiceHandler.java b/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorServiceHandler.java deleted file mode 100644 index 5106899fed..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/ErrorServiceHandler.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.common.error; - - -import org.springframework.social.InternalServerErrorException; -import org.springframework.stereotype.Service; - -@Service -public class ErrorServiceHandler { - public InternalServerErrorException createInternalError(Exception e) throws InternalServerErrorException{ - return new InternalServerErrorException("ErrorServiceHandler", e.getMessage()); - } - - public InternalServerErrorException createInternalError(Class cl, Exception e) throws InternalServerErrorException{ - e.printStackTrace(); - return new InternalServerErrorException(cl.getName(), e.getMessage()); - } - - public InternalServerErrorException createInternalError(Class cl, String e) throws InternalServerErrorException{ - return new InternalServerErrorException(cl.getName(), e); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionExecutionException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionExecutionException.java deleted file mode 100644 index d5a0cce87e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionExecutionException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.activepieces.common.error.exception; - -public class ActionExecutionException extends Exception { - - public ActionExecutionException(Exception e) { - super("ActionExecutionException",e); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionNotFoundException.java deleted file mode 100644 index aec816dfcd..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionNotFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.activepieces.common.error.exception; - -import java.util.UUID; - -public class ActionNotFoundException extends Exception { - - public ActionNotFoundException(UUID id) { - super(String.format("ActionNotFoundException is not found with id=%s", id.toString())); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionTypeNotFound.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionTypeNotFound.java deleted file mode 100644 index 0cf61caab9..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ActionTypeNotFound.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.activepieces.common.error.exception; - -public class ActionTypeNotFound extends RuntimeException { - - public ActionTypeNotFound() { - super(); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/CodeArtifactBuildFailure.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/CodeArtifactBuildFailure.java deleted file mode 100644 index c30cc758f9..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/CodeArtifactBuildFailure.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class CodeArtifactBuildFailure extends Exception implements ErrorResponseException { - - public CodeArtifactBuildFailure(String fileName, Exception e) { - super(String.format("Artifact with path %s building failed with exception", fileName, e)); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.ARTIFACT_BUILD_FAILED; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConfigInvalidTypeException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConfigInvalidTypeException.java deleted file mode 100644 index eb358bdcb1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConfigInvalidTypeException.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -import java.util.UUID; - -public class ConfigInvalidTypeException extends Exception implements ErrorResponseException { - - public ConfigInvalidTypeException(UUID id, String key) { - super(String.format("Version id=%s with key=%s type is not auth", id.toString(), key)); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.INVALID_CONFIG; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConfigNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConfigNotFoundException.java deleted file mode 100644 index 16672f3f0a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConfigNotFoundException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -import java.util.UUID; - -public class ConfigNotFoundException extends Exception implements ErrorResponseException { - - public ConfigNotFoundException(UUID id, String key) { - super(String.format("Version id=%s with key=%s is not found", id.toString(), key)); - } - - public ConfigNotFoundException(String key) { - super(String.format("Variable with key=%s is not found and its used, make sure its not deleted", key)); - } - @Override - public ErrorCode getErrorCode() { - return ErrorCode.CONFIG_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConstraintsException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConstraintsException.java deleted file mode 100644 index 1b6f62db8f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ConstraintsException.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorResponse; - -import java.util.Set; - -public class ConstraintsException extends RuntimeException { - - private final Set errorResponse; - public ConstraintsException(Set errorResponse) { - super(errorResponse.toString()); - this.errorResponse = errorResponse; - } - - public Set getErrorResponse(){ - return errorResponse; - } - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/FailedToObtainLockException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/FailedToObtainLockException.java deleted file mode 100644 index 494b824d4b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/FailedToObtainLockException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.activepieces.common.error.exception; - -public class FailedToObtainLockException extends Exception { - - public FailedToObtainLockException(Exception e) { - super("FailedToObtainLock",e); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/FlowNotEnabledException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/FlowNotEnabledException.java deleted file mode 100644 index 23234c963a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/FlowNotEnabledException.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -import java.util.UUID; - -public class FlowNotEnabledException extends Exception implements ErrorResponseException { - - public FlowNotEnabledException(UUID id, UUID instanceId) { - super( - String.format( - "Flow with id=%s not enabled in instanceId=%s", id.toString(), instanceId.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.FLOW_NOT_ENABLED; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/InstanceNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/InstanceNotFoundException.java deleted file mode 100644 index 49bef3e204..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/InstanceNotFoundException.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class InstanceNotFoundException extends Exception implements ErrorResponseException { - - private final Ksuid instanceId; - - public InstanceNotFoundException(Ksuid instanceId) { - super(String.format("Instance with id=%s not found", instanceId.toString())); - this.instanceId = instanceId; - } - - public Ksuid getInstanceId(){ - return instanceId; - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.INSTANCE_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/InvalidCodeArtifactException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/InvalidCodeArtifactException.java deleted file mode 100644 index 281f1a65c7..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/InvalidCodeArtifactException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class InvalidCodeArtifactException extends Exception implements ErrorResponseException { - - public InvalidCodeArtifactException(String filename) { - super(String.format("file with name=%s must be zip file, check content type", filename)); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.INVALID_CODE_ARTIFACT; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ManifestNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ManifestNotFoundException.java deleted file mode 100644 index b108d2007a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/ManifestNotFoundException.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.activepieces.common.error.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class ManifestNotFoundException extends Exception implements ErrorResponseException { - - - public ManifestNotFoundException(String componentName, String componentVersion, String message) { - super(String.format("Manifest not found for componentName=%s and componentVersion=%s, message=%s", componentName, componentVersion, message)); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.MANIFEST_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionInstanceNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionInstanceNotFoundException.java deleted file mode 100644 index f061da7f4e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionInstanceNotFoundException.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.common.error.exception.collection; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -public class CollectionInstanceNotFoundException extends Exception implements ErrorResponseException { - - private final Ksuid collectionId; - - public CollectionInstanceNotFoundException(Ksuid collectionId) { - super(String.format("Collection with id=%s has no instance", collectionId.toString())); - this.collectionId = collectionId; - } - - public Ksuid getCollectionId(){ - return collectionId; - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.COLLECTION_INSTANCE_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionInvalidStateException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionInvalidStateException.java deleted file mode 100644 index 26bd9def41..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionInvalidStateException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.common.error.exception.collection; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class CollectionInvalidStateException extends Exception implements ErrorResponseException { - - public CollectionInvalidStateException(String name) { - super(String.format("Collection name %s flows contains errors, please fix them first", name)); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.COLLECTION_INVALID_STATE; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionNotFoundException.java deleted file mode 100644 index 1b47f70cbb..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionNotFoundException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.error.exception.collection; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class CollectionNotFoundException extends Exception implements ErrorResponseException { - - public CollectionNotFoundException(Ksuid id) { - super(String.format("Collection with id=%s is not found", id.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.COLLECTION_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionVersionAlreadyLockedException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionVersionAlreadyLockedException.java deleted file mode 100644 index fa316f1620..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionVersionAlreadyLockedException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.error.exception.collection; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class CollectionVersionAlreadyLockedException extends Exception implements ErrorResponseException { - - public CollectionVersionAlreadyLockedException(Ksuid id) { - super(String.format("Collection version id=%s is locked, create new version", id.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.COLLECTION_VERSION_LOCKED; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionVersionNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionVersionNotFoundException.java deleted file mode 100644 index ba093822dc..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/collection/CollectionVersionNotFoundException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.common.error.exception.collection; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class CollectionVersionNotFoundException extends Exception implements ErrorResponseException { - - public CollectionVersionNotFoundException(Ksuid id) { - super(String.format("Collection version with id=%s is not found", id)); - } - public CollectionVersionNotFoundException(Ksuid collectionId, int version) { - super(String.format("Collection version with piece Id=%s and version=%d is not found", collectionId, version)); - } - @Override - public ErrorCode getErrorCode() { - return ErrorCode.COLLECTION_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowExecutionInternalError.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowExecutionInternalError.java deleted file mode 100644 index 6dd8919345..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowExecutionInternalError.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.activepieces.common.error.exception.flow; - -public class FlowExecutionInternalError extends Exception { - - public FlowExecutionInternalError(Exception exception) { - super(exception); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowNotFoundException.java deleted file mode 100644 index 2dccf51b93..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowNotFoundException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.common.error.exception.flow; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class FlowNotFoundException extends Exception implements ErrorResponseException { - - public FlowNotFoundException(Ksuid id) { - super(String.format("FlowNotFoundException is not found with id=%s", id.toString())); - } - public FlowNotFoundException(UUID pieceId, String flowName) { - super(String.format("FlowNotFoundException is not found with Piece id=%s and name=%s", pieceId.toString(), flowName)); - } - @Override - public ErrorCode getErrorCode() { - return ErrorCode.FLOW_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowVersionAlreadyLockedException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowVersionAlreadyLockedException.java deleted file mode 100644 index 92dbd5d6a0..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowVersionAlreadyLockedException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.error.exception.flow; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class FlowVersionAlreadyLockedException extends Exception implements ErrorResponseException { - - public FlowVersionAlreadyLockedException(Ksuid id) { - super(String.format("Flow version id=%s is locked, create new version", id.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.FLOW_VERSION_LOCKED; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowVersionNotFoundException.java b/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowVersionNotFoundException.java deleted file mode 100644 index 83be02794d..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/error/exception/flow/FlowVersionNotFoundException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.common.error.exception.flow; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class FlowVersionNotFoundException extends Exception implements ErrorResponseException { - - public FlowVersionNotFoundException(Ksuid id) { - super(String.format("Flow Version with id=%s is not found", id.toString())); - } - - public FlowVersionNotFoundException(Ksuid CollectionId, Ksuid flow) { - super(String.format("Flow Version for CollectionId=%s and flowName=%s is not found", CollectionId.toString(), flow.toString())); - } - - public FlowVersionNotFoundException(Ksuid instanceId, Ksuid flow, boolean instance) { - super(String.format("Flow Version for Instance=%s and flowId=%s is not found", instanceId.toString(), flow.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.FLOW_VERSION_NOT_FOUND; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/identity/PrincipleIdentity.java b/src/backend/entities/src/main/java/com/activepieces/common/identity/PrincipleIdentity.java deleted file mode 100644 index 54239e5c9b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/identity/PrincipleIdentity.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.activepieces.common.identity; - - -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.UUID; - -@Getter -@AllArgsConstructor -public class PrincipleIdentity { - - private Ksuid id; - - private PrincipleType principleType; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/identity/PrincipleType.java b/src/backend/entities/src/main/java/com/activepieces/common/identity/PrincipleType.java deleted file mode 100644 index bceb65b814..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/identity/PrincipleType.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.common.identity; - -public enum PrincipleType { - USER("ROLE_USER"), - WORKER("ROLE_WORKER"); - private final String type; - - PrincipleType(String type) { - this.type = type; - } - - public String getType() { - return type; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/identity/UserIdentity.java b/src/backend/entities/src/main/java/com/activepieces/common/identity/UserIdentity.java deleted file mode 100644 index a8c35dd66b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/identity/UserIdentity.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.common.identity; - -import com.github.ksuid.Ksuid; -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -@Getter -public class UserIdentity extends PrincipleIdentity { - - @Builder - public UserIdentity(Ksuid resourceId) { - super(resourceId, PrincipleType.USER); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/identity/WorkerIdentity.java b/src/backend/entities/src/main/java/com/activepieces/common/identity/WorkerIdentity.java deleted file mode 100644 index 762d0bb2b7..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/identity/WorkerIdentity.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.common.identity; - -import com.github.ksuid.Ksuid; -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -@Getter -public class WorkerIdentity extends PrincipleIdentity { - - private final Ksuid collectionId; - private final Ksuid flowId; - - @Builder - public WorkerIdentity(Ksuid collectionId, Ksuid flowId) { - super(Ksuid.newKsuid(), PrincipleType.WORKER); - this.collectionId = collectionId; - this.flowId = flowId; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/model/ArtifactFile.java b/src/backend/entities/src/main/java/com/activepieces/common/model/ArtifactFile.java deleted file mode 100644 index 5cce2b7a7e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/model/ArtifactFile.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.activepieces.common.model; - -import lombok.*; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.social.InternalServerErrorException; -import org.springframework.web.multipart.MultipartFile; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -@AllArgsConstructor -@NoArgsConstructor -@Getter -@Setter -@Builder -public class ArtifactFile { - - private String originalFileName; - private String contentType; - private InputStream inputStream; - private String hashWithExtension; - - public MultipartFile toMultiFile() throws IOException { - return new MockMultipartFile("file", originalFileName, contentType, getInputStream()); - } - - public InputStream getInputStream() { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - inputStream.transferTo(baos); - inputStream = new ByteArrayInputStream(baos.toByteArray()); - return new ByteArrayInputStream(baos.toByteArray()); - } catch (IOException e) { - throw new InternalServerErrorException("Artifact", Arrays.toString(e.getStackTrace())); - } - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/model/ArtifactMetadataSettings.java b/src/backend/entities/src/main/java/com/activepieces/common/model/ArtifactMetadataSettings.java deleted file mode 100644 index 04ab227dba..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/model/ArtifactMetadataSettings.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.model; - -import com.github.ksuid.Ksuid; - -public interface ArtifactMetadataSettings { - - Ksuid getArtifactSourceId(); - - void setArtifactSourceId(Ksuid artifact); - - Ksuid getArtifactPackagedId(); - - void setArtifactPackagedId(Ksuid artifactPackagedId); - - ArtifactFile getNewArtifactToUploadFile(); - - void setNewArtifactToUploadFile(ArtifactFile artifactToUploadFile); - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/Cursor.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/Cursor.java deleted file mode 100644 index c07762b7ba..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/Cursor.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.activepieces.common.pagination; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.Locale; - -@JsonSerialize(using = CursorSerializer.class) -@JsonDeserialize(using = CursorDeserializer.class) -@Getter -@AllArgsConstructor -public class Cursor { - - private final Ksuid id; - private final PagePrefix prefix; - - public Cursor(final PagePrefix prefix, final Ksuid id) { - this.id = id; - this.prefix = prefix; - } - - public Cursor(String base64){ - String decodedString = new String(Base64.getDecoder(). - decode(base64.getBytes(StandardCharsets.UTF_8))); - String[] split = decodedString.split("@"); - prefix = PagePrefix.valueOf(split[0]); - id = Ksuid.fromString(split[1]); - } - - @Override - public String toString() { - String finalString = String.format("%s@%s", - prefix.toString().toUpperCase(Locale.ROOT), - id.toString()); - return Base64.getEncoder().encodeToString(finalString.getBytes()); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/CursorDeserializer.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/CursorDeserializer.java deleted file mode 100644 index bde64dac64..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/CursorDeserializer.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.activepieces.common.pagination; - -import com.fasterxml.jackson.core.JacksonException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -import java.io.IOException; - -public class CursorDeserializer extends StdDeserializer { - - public CursorDeserializer() { - this(null); - } - - public CursorDeserializer(Class t) { - super(t); - } - - @Override - public Cursor deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException { - String id = jsonParser.readValueAs(String.class); - return new Cursor(id); - } - - -} - diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/CursorSerializer.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/CursorSerializer.java deleted file mode 100644 index 4db05711ff..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/CursorSerializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.common.pagination; - - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; - -import java.io.IOException; - -public class CursorSerializer extends StdSerializer { - - public CursorSerializer() { - this(null); - } - - public CursorSerializer(Class t) { - super(t); - } - - @Override - public void serialize(Cursor value, JsonGenerator jgen, SerializerProvider provider) - throws IOException { - jgen.writeString(value.toString()); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PageFilter.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/PageFilter.java deleted file mode 100644 index fbedb2eeae..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PageFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.pagination; - -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.UUID; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class PageFilter { - - private String key; - private PageOperator operator; - private Ksuid value; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PageOperator.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/PageOperator.java deleted file mode 100644 index 38180ff20e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PageOperator.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.common.pagination; - -public enum PageOperator { - EQUAL, - NOT_NULL -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PagePrefix.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/PagePrefix.java deleted file mode 100644 index 0a6fdc1c66..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PagePrefix.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.activepieces.common.pagination; - -public enum PagePrefix { - PREV, - NEXT - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PaginationRepository.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/PaginationRepository.java deleted file mode 100644 index 0dd66fac68..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/PaginationRepository.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.common.pagination; - -import lombok.NonNull; -import org.springframework.data.repository.NoRepositoryBean; -import org.springframework.data.repository.Repository; - -import java.util.List; - - -@NoRepositoryBean -public interface PaginationRepository extends Repository { - - SeekPage findPageDesc( - @NonNull final List filters, - @NonNull final SeekPageRequest maxResults); - - SeekPage findPageAsc( - @NonNull final List filters, - @NonNull final SeekPageRequest maxResults); - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/SeekPage.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/SeekPage.java deleted file mode 100644 index 4378e8fe06..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/SeekPage.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.activepieces.common.pagination; - -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Getter -@NoArgsConstructor -public class SeekPage { - - private Cursor previous; - private Cursor next; - private List data; - - public SeekPage(List data, Cursor previous,Cursor next) { - this.previous = previous; - this.next = next; - this.data = data; - } - - - public SeekPage convert(Function function) { - return new SeekPage<>( - data.stream() - .map(function) - .collect(Collectors.toCollection(CopyOnWriteArrayList::new)), - previous, next); - } - -} - diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/SeekPageRequest.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/SeekPageRequest.java deleted file mode 100644 index 1f0f0aa651..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/SeekPageRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.common.pagination; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.ToString; - -@Getter -@AllArgsConstructor -@ToString -public class SeekPageRequest{ - - private Cursor cursor; - private int limit; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/pagination/impl/PaginationRepositoryImpl.java b/src/backend/entities/src/main/java/com/activepieces/common/pagination/impl/PaginationRepositoryImpl.java deleted file mode 100644 index 68167e7181..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/pagination/impl/PaginationRepositoryImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.activepieces.common.pagination.impl; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.common.pagination.*; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import org.springframework.data.domain.Sort; -import org.springframework.data.jpa.repository.support.JpaEntityInformation; -import org.springframework.data.jpa.repository.support.SimpleJpaRepository; -import org.springframework.util.Assert; - -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Predicate; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import static org.springframework.data.jpa.repository.query.QueryUtils.toOrders; - - -public class PaginationRepositoryImpl extends SimpleJpaRepository - implements PaginationRepository { - - private static final String ID = "id"; - private final EntityManager entityManager; - - public PaginationRepositoryImpl(final JpaEntityInformation entityInformation, - final EntityManager entityManager) { - super(entityInformation, entityManager); - this.entityManager = entityManager; - } - - - private SeekPage findPage(@NonNull final Sort.Direction direction, - @NonNull final List filters, - @NonNull final SeekPageRequest request) { - var sort = Sort.by(direction, ID); - var domainClass = getDomainClass(); - var criteriaBuilder = entityManager.getCriteriaBuilder(); - var criteriaQuery = criteriaBuilder.createQuery(domainClass); - Assert.notNull(domainClass, "Domain class must not be null!"); - Assert.notNull(criteriaQuery, "CriteriaQuery must not be null!"); - var root = criteriaQuery.from(domainClass); - criteriaQuery.select(root); - for (PageFilter filter : filters) { - Predicate predicateCondition = null; - switch (filter.getOperator()) { - case EQUAL: - predicateCondition - = criteriaBuilder.equal(root.get(filter.getKey()), filter.getValue()); - break; - case NOT_NULL: - predicateCondition - = criteriaBuilder.isNotNull(root.get(filter.getKey())); - break; - } - criteriaQuery.where(predicateCondition); - } - - criteriaQuery.orderBy(toOrders(direction.equals(Sort.Direction.ASC) ? sort.descending() : sort.ascending(), root, criteriaBuilder)); - Optional lastResult = getFirstResult(criteriaQuery); - - criteriaQuery.orderBy(toOrders(sort, root, criteriaBuilder)); - Optional firstResult = getFirstResult(criteriaQuery); - - boolean reverse = false; - if (Objects.nonNull(request.getCursor())) { - Expression expression = root.get(ID).as(Ksuid.class); - if (direction.isDescending()) { - if (request.getCursor().getPrefix().equals(PagePrefix.PREV)) { - reverse = true; - criteriaQuery.where(criteriaBuilder.greaterThan(expression, request.getCursor().getId())); - criteriaQuery.orderBy(toOrders(sort.ascending(), root, criteriaBuilder)); - } else { - criteriaQuery.where(criteriaBuilder.lessThan(expression, request.getCursor().getId())); - criteriaQuery.orderBy(toOrders(sort, root, criteriaBuilder)); - } - } else { - if (request.getCursor().getPrefix().equals(PagePrefix.PREV)) { - reverse = true; - criteriaQuery.where(criteriaBuilder.lessThan(expression, request.getCursor().getId())); - criteriaQuery.orderBy(toOrders(sort.descending(), root, criteriaBuilder)); - } else { - criteriaQuery.where(criteriaBuilder.greaterThan(expression, request.getCursor().getId())); - criteriaQuery.orderBy(toOrders(sort, root, criteriaBuilder)); - } - } - } - TypedQuery typedQuery = entityManager.createQuery(criteriaQuery); - typedQuery.setMaxResults(request.getLimit()); - List results = typedQuery.getResultList(); - if (reverse) { - Collections.reverse(results); - } - Cursor nextId = null; - Cursor previousId = null; - if (results.size() > 0) { - if (firstResult.isPresent() && - !firstResult.get().getId().equals(results.get(0).getId())) { - previousId = new Cursor(PagePrefix.PREV, - results.get(0).getId()); - } - if (lastResult.isPresent() && !lastResult.get().getId().equals( - results.get(results.size() - 1).getId())) { - nextId = new Cursor(PagePrefix.NEXT, - results.get(results.size() - 1).getId()); - } - } - return new SeekPage(results, previousId, nextId); - } - - private Optional getFirstResult(CriteriaQuery q) { - TypedQuery firstQuery = entityManager.createQuery(q); - firstQuery.setMaxResults(1); - List firstQueryResultList = firstQuery.getResultList(); - return Optional.ofNullable(firstQueryResultList.size() > 0 ? firstQueryResultList.get(0) : null); - } - - - @Override - public SeekPage findPageDesc(@NonNull List filters, @NonNull SeekPageRequest request) { - return findPage(Sort.Direction.DESC, filters, request); - } - - @Override - public SeekPage findPageAsc(@NonNull List filters, @NonNull SeekPageRequest request) { - return findPage(Sort.Direction.ASC, filters, request); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/utils/APIdSerializer.java b/src/backend/entities/src/main/java/com/activepieces/common/utils/APIdSerializer.java deleted file mode 100644 index 888c315e53..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/utils/APIdSerializer.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.common.utils; - - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import com.github.ksuid.Ksuid; - -import java.io.IOException; - -public class APIdSerializer extends StdSerializer { - - public APIdSerializer() { - this(null); - } - - public APIdSerializer(Class t) { - super(t); - } - - @Override - public void serialize(Ksuid value, JsonGenerator jgen, SerializerProvider provider) - throws IOException { - jgen.writeString(value.toString()); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/utils/ArtifactUtils.java b/src/backend/entities/src/main/java/com/activepieces/common/utils/ArtifactUtils.java deleted file mode 100644 index 848152d58d..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/utils/ArtifactUtils.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.activepieces.common.utils; - -import com.activepieces.common.model.ArtifactFile; -import lombok.extern.log4j.Log4j2; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.io.IOUtils; -import org.springframework.web.multipart.MultipartFile; - -import java.io.*; -import java.nio.file.*; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipOutputStream; - -@Log4j2 -public class ArtifactUtils { - - public static List toArtifacts(List files) { - return files.stream() - .map( - f -> { - try { - ArtifactFile artifactFile = - ArtifactFile.builder() - .contentType(f.getContentType()) - .originalFileName(f.getOriginalFilename()) - .inputStream(f.getInputStream()) - .build(); - artifactFile.setHashWithExtension( - HashUtils.getFileNameAfterUpload( - artifactFile.getOriginalFileName(), artifactFile.getInputStream())); - return artifactFile; - } catch (IOException e) { - e.printStackTrace(); - } - return null; - }) - .collect(Collectors.toList()); - } - - public static String readOutputFromStream(Reader reader) throws IOException { - try (BufferedReader br = new BufferedReader(reader)) { - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null) { - sb.append(line); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - return sb.toString(); - } - } - - public static String escapeShellDoubleQuoteString(String s, boolean addOuterQuote) { - final List targets = Arrays.asList("\"", "$", "`"); - String escape = escape(s, "\\", targets); - return addOuterQuote ? '"' + escape + '"' : escape; - } - - private static String escape(String s, String escaper, List targets) { - s = s.replace(escaper, escaper + escaper); - for (String t : targets) { - s = s.replace(t, escaper + t); - } - return s; - } - - public static String bundledFileName(String artifact) { - return FilenameUtils.removeExtension(artifact) + ".js"; - } - - public static void extractArtifact(File artifact) throws IOException { - ArtifactUtils.extractFolder(artifact); - // Remove Single directory - File parentDirectory = artifact.getParentFile(); - if (containsSingleFolder(parentDirectory)) { - log.debug("Containing single directory, extracting content"); - extractContent(parentDirectory); - } - } - - private static void extractContent(File parentFile) throws IOException { - File child = - Arrays.stream(Objects.requireNonNull(parentFile.listFiles())) - .filter(File::isDirectory) - .findFirst() - .get(); - for (File file : Objects.requireNonNull(child.listFiles())) { - File destFile = new File(parentFile.getAbsolutePath() + File.separator + file.getName()); - Files.move(file.toPath(), destFile.toPath(), StandardCopyOption.ATOMIC_MOVE); - } - child.delete(); - } - - public static String runCommandAsRoot(String command) throws IOException, InterruptedException { - String[] commands = {"/bin/bash", "-c", command}; - ProcessBuilder ps = new ProcessBuilder(commands); - ps.redirectErrorStream(true); - Process pb = ps.start(); - String output = readOutputFromStream(new InputStreamReader(pb.getInputStream())); - pb.waitFor(); - return output; - } - - private static void extractFolder(File file) throws IOException { - int buffer = 2048; - - try (ZipFile zip = new ZipFile(file)) { - String newPath = file.getParentFile().getAbsolutePath(); - new File(newPath).mkdir(); - Enumeration zipFileEntries = zip.entries(); - - // Process each entry - while (zipFileEntries.hasMoreElements()) { - // grab a zip file entry - ZipEntry entry = zipFileEntries.nextElement(); - String currentEntry = entry.getName(); - - File destFile = new File(newPath, currentEntry); - File destinationParent = destFile.getParentFile(); - - // create the parent directory structure if needed - destinationParent.mkdirs(); - - if (!entry.isDirectory()) { - BufferedInputStream is = new BufferedInputStream(zip.getInputStream(entry)); - int currentByte; - // establish buffer for writing file - byte[] data = new byte[buffer]; - - // write the current file to disk - FileOutputStream fos = new FileOutputStream(destFile); - try (BufferedOutputStream dest = new BufferedOutputStream(fos, buffer)) { - - // read and write until last byte is encountered - while ((currentByte = is.read(data, 0, buffer)) != -1) { - dest.write(data, 0, currentByte); - } - dest.flush(); - is.close(); - } - } - } - } - } - - public static InputStream zipFolder(Path sourceFolderPath) throws Exception { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(baos); - Files.walkFileTree(sourceFolderPath, new SimpleFileVisitor() { - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - zos.putNextEntry(new ZipEntry(sourceFolderPath.relativize(file).toString())); - Files.copy(file, zos); - zos.closeEntry(); - return FileVisitResult.CONTINUE; - } - }); - zos.close(); - return new ByteArrayInputStream(baos.toByteArray()); - } - - private static boolean containsSingleFolder(File parent) { - return Arrays.stream(Objects.requireNonNull(parent.listFiles())) - .filter(File::isDirectory) - .count() - == 1; - } - - public static void writeToFile(File output, InputStream inputStream) throws IOException { - try (OutputStream outputStream = new FileOutputStream(output)) { - IOUtils.copy(inputStream, outputStream); - } catch (IOException e) { - throw e; - } - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/utils/HashUtils.java b/src/backend/entities/src/main/java/com/activepieces/common/utils/HashUtils.java deleted file mode 100644 index 1b90eef2c1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/utils/HashUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.activepieces.common.utils; - -import lombok.experimental.UtilityClass; -import org.apache.commons.io.FilenameUtils; -import org.springframework.social.InternalServerErrorException; - -import javax.xml.bind.annotation.adapters.HexBinaryAdapter; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; - -@UtilityClass -public class HashUtils { - - public static String calculateHash(String string) { - try { - MessageDigest sha1 = MessageDigest.getInstance("SHA-256"); - byte[] hash = sha1.digest(string.getBytes(StandardCharsets.UTF_8)); - return new HexBinaryAdapter().marshal(hash); - } catch (NoSuchAlgorithmException e) { - throw new InternalServerErrorException( - "CodeArtifactService", Arrays.toString(e.getStackTrace())); - } - } - - public static String calculateHash(InputStream file) { - try { - MessageDigest sha1 = MessageDigest.getInstance("SHA-256"); - try (InputStream input = file) { - byte[] buffer = new byte[8192]; - int len = input.read(buffer); - while (len != -1) { - sha1.update(buffer, 0, len); - len = input.read(buffer); - } - - return new HexBinaryAdapter().marshal(sha1.digest()); - } - } catch (NoSuchAlgorithmException | IOException e) { - throw new InternalServerErrorException( - "CodeArtifactService", Arrays.toString(e.getStackTrace())); - } - } - - public static String getFileNameAfterUpload(String originalFileName, InputStream file) { - String extension = FilenameUtils.getExtension(originalFileName); - return calculateHash(file) + "." + extension; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/utils/StringUtils.java b/src/backend/entities/src/main/java/com/activepieces/common/utils/StringUtils.java deleted file mode 100644 index 22f1438f5f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/utils/StringUtils.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.activepieces.common.utils; - -import com.google.common.base.CaseFormat; -import org.springframework.stereotype.Service; - -@Service -public final class StringUtils { - - public static String camelCaseToSnakeCase(final String camelCase) { - return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, camelCase); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/CodeNameConstraints.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/CodeNameConstraints.java deleted file mode 100644 index 51bd973ded..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/CodeNameConstraints.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.*; - -@Documented -@Constraint(validatedBy = CodeNameValidator.class) -@Target( { ElementType.METHOD, ElementType.FIELD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface CodeNameConstraints { - String message() default "name must consist only of a-z, 0-9, underscore"; - Class[] groups() default {}; - Class[] payload() default {}; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/CodeNameValidator.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/CodeNameValidator.java deleted file mode 100644 index 97bae3413e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/CodeNameValidator.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -public class CodeNameValidator implements - ConstraintValidator { - - @Override - public void initialize(CodeNameConstraints contactNumber) { - } - - @Override - public boolean isValid(String contactField, - ConstraintValidatorContext cxt) { - return contactField != null && contactField.matches("[a-z0-9_]*"); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/CronExpression.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/CronExpression.java deleted file mode 100644 index 800fe0e37f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/CronExpression.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Target({ FIELD }) -@Retention(RUNTIME) -@Constraint(validatedBy = CronExpressionValidator.class) -@Documented -public @interface CronExpression { - - String message() default "cronExpression is invalid"; - - Class[] groups() default { }; - - Class[] payload() default { }; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/CronExpressionValidator.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/CronExpressionValidator.java deleted file mode 100644 index 76f14657fe..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/CronExpressionValidator.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.common.validation; - -import lombok.NoArgsConstructor; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import java.util.Objects; - -@NoArgsConstructor -public class CronExpressionValidator implements ConstraintValidator { - - @Override - public boolean isValid(String value, ConstraintValidatorContext context) { - if (Objects.isNull(value)){ - return false; - } - return org.quartz.CronExpression.isValidExpression(value); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/EnumNamePattern.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/EnumNamePattern.java deleted file mode 100644 index 574279b7e1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/EnumNamePattern.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE}) -@Retention(RUNTIME) -@Documented -@Constraint(validatedBy = EnumNamePatternValidator.class) -public @interface EnumNamePattern { - String regexp(); - String message() default "must match \"{regexp}\""; - Class[] groups() default {}; - Class[] payload() default {}; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/EnumNamePatternValidator.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/EnumNamePatternValidator.java deleted file mode 100644 index f9c2d1ba5c..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/EnumNamePatternValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -public class EnumNamePatternValidator implements ConstraintValidator> { - private Pattern pattern; - - @Override - public void initialize(EnumNamePattern annotation) { - try { - pattern = Pattern.compile(annotation.regexp()); - } catch (PatternSyntaxException e) { - throw new IllegalArgumentException("Given regex is invalid", e); - } - } - - @Override - public boolean isValid(Enum value, ConstraintValidatorContext context) { - if (value == null) { - return true; - } - - Matcher m = pattern.matcher(value.name()); - return m.matches(); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/NotEmptyIfString.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/NotEmptyIfString.java deleted file mode 100644 index 4581b529d1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/NotEmptyIfString.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.*; - -@Documented -@Constraint(validatedBy = NotEmptyIfStringValidator.class) -@Target( { ElementType.METHOD, ElementType.FIELD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface NotEmptyIfString { - String message() default "string cannot be empty"; - Class[] groups() default {}; - Class[] payload() default {}; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/common/validation/NotEmptyIfStringValidator.java b/src/backend/entities/src/main/java/com/activepieces/common/validation/NotEmptyIfStringValidator.java deleted file mode 100644 index 645131c7a1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/common/validation/NotEmptyIfStringValidator.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.common.validation; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import java.util.Objects; - -public class NotEmptyIfStringValidator implements - ConstraintValidator { - - @Override - public void initialize(NotEmptyIfString contactNumber) { - } - - @Override - public boolean isValid(Object contactField, - ConstraintValidatorContext cxt) { - if( Objects.isNull(contactField)){ - return true; - } - if(!contactField.getClass().equals(String.class)){ - return true; - } - return ((String) contactField).length() > 0; - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/docs/OpenAPIConfiguration.java b/src/backend/entities/src/main/java/com/activepieces/docs/OpenAPIConfiguration.java deleted file mode 100644 index 5a4f374941..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/docs/OpenAPIConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.docs; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Contact; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.servers.Server; - -@OpenAPIDefinition( - info = - @Info( - title = "Activepieces API Reference", - description = "Complete reference documentation for the Activepieces API.\n", - contact = - @Contact( - name = "Activepieces Support", - url = "https://activepieces.com", - email = "support@activepieces.com")), - servers = @Server(url = "https://api.activepieces.com")) -public class OpenAPIConfiguration { - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/ComponentTriggerHook.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/ComponentTriggerHook.java deleted file mode 100644 index a452f5b5d5..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/ComponentTriggerHook.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.entity.enums; - -public enum ComponentTriggerHook { - ENABLED, - DISABLED -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/ComponentTriggerType.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/ComponentTriggerType.java deleted file mode 100644 index de1cf89789..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/ComponentTriggerType.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.entity.enums; - -public enum ComponentTriggerType { - POLLING, - WEBHOOK -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/EditState.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/EditState.java deleted file mode 100644 index 9cba2fd3b6..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/EditState.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.entity.enums; - -public enum EditState { - DRAFT, - LOCKED -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/FlowExecutionStatus.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/FlowExecutionStatus.java deleted file mode 100644 index 955090e64e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/FlowExecutionStatus.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.activepieces.entity.enums; - -public enum FlowExecutionStatus { - RUNNING, - SUCCEEDED, - FAILED -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/InputVariableType.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/InputVariableType.java deleted file mode 100644 index eb23ceae82..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/InputVariableType.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.activepieces.entity.enums; - -public enum InputVariableType { - CHECKBOX, - PASSWORD, - NUMBER, - DICTIONARY, - LONG_TEXT, - SHORT_TEXT, - API_KEY, - OAUTH2, - DROPDOWN -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/InstanceStatus.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/InstanceStatus.java deleted file mode 100644 index ff117f200f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/InstanceStatus.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.entity.enums; - -public enum InstanceStatus { - ENABLED, - DISABLED -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/Permission.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/Permission.java deleted file mode 100644 index a1bbf55866..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/Permission.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.activepieces.entity.enums; - -public enum Permission { - READ_INSTANCE_RUN, - WRITE_INSTANCE_RUN, - READ_PROJECT, - WRITE_PROJECT, - READ_COLLECTION, - WRITE_COLLECTION, - READ_FLOW, - WRITE_FLOW, - READ_API_KEY, - WRITE_API_KEY, - READ_INSTANCE, - WRITE_INSTANCE - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/ResourceType.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/ResourceType.java deleted file mode 100644 index acbf200c39..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/ResourceType.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.entity.enums; - -public enum ResourceType { - PROJECT("proj",true), - FLOW("flow",false), - FLOW_VERSION("flow_ver", false), - INSTANCE("inst",false), - COLLECTION_VERSION("coll_ver",false), - COLLECTION("coll",false), - INSTANCE_RUN("run",false); - - private final boolean mainResource; - private final String prefix; - - ResourceType(String prefix, - boolean mainResource){ - this.prefix = prefix; - this.mainResource = mainResource; - } - - public String getPrefix(){ - return prefix; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/Role.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/Role.java deleted file mode 100644 index 93fa9b6adb..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/Role.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.enums; - -import lombok.NonNull; - -import java.util.Arrays; -import java.util.List; - -public enum Role { - OWNER(Arrays.asList(Permission.values())), - API_KEY(Arrays.asList(Permission.values())); - - final List permissionList; - - Role(final List permissionList) { - this.permissionList = permissionList; - } - - public boolean hasPermission(@NonNull final Permission permission) { - return permissionList.contains(permission); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/StoreOperation.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/StoreOperation.java deleted file mode 100644 index 0a704987c6..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/StoreOperation.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.entity.enums; - -public enum StoreOperation { - GET, - PUT -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/StoreScope.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/StoreScope.java deleted file mode 100644 index 2d97038a2a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/StoreScope.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.activepieces.entity.enums; - -public enum StoreScope { - COLLECTION -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/enums/UserStatus.java b/src/backend/entities/src/main/java/com/activepieces/entity/enums/UserStatus.java deleted file mode 100644 index 26ac94adc1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/enums/UserStatus.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.activepieces.entity.enums; - -public enum UserStatus { - VERIFIED -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Collection.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/Collection.java deleted file mode 100644 index 5f5ec9db5d..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Collection.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.persistence.*; -import java.time.Instant; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@SuperBuilder -@Entity -@Table(name = "collection", indexes = {@Index(name = "project_id_index", columnList = "project_id", unique = false)}) -public class Collection implements EntityMetadata { - public static final String PROJECT_ID = "projectId"; - - @JsonProperty - @Id - private Ksuid id; - - @JsonProperty - @Column(name = "name") - private String name; - - @JsonProperty - @Column(name = "project_id") - private Ksuid projectId; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/CollectionVersion.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/CollectionVersion.java deleted file mode 100644 index 064788afd8..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/CollectionVersion.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.subdocuments.field.Variable; -import com.github.ksuid.Ksuid; -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; - -import javax.persistence.*; -import java.time.Instant; -import java.util.List; - -@NoArgsConstructor -@Getter -@Setter -@Entity -@Table(name = "collection_version", indexes = {@Index(name = "collection_id_index", columnList = "collection_id", unique = false)}) -@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) -public class CollectionVersion implements EntityMetadata { - - @Id private Ksuid id; - - @Column(name = "display_name") - private String displayName; - - @Column(name = "collection_id") - private Ksuid collectionId; - - @Type(type = "jsonb") - @Column(name = "configs", columnDefinition = "jsonb") - private List configs; - - @Column(name = "state") - @Enumerated(EnumType.STRING) - private EditState state; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/FileEntity.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/FileEntity.java deleted file mode 100644 index 2ce52c6226..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/FileEntity.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.activepieces.entity.sql; - - -import com.activepieces.common.EntityMetadata; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; -import org.springframework.transaction.annotation.Transactional; - -import javax.persistence.*; -import java.time.Instant; - -@Entity -@Getter -@AllArgsConstructor -@Builder(toBuilder = true) -@NoArgsConstructor -@Table(name = "FILES") -public class FileEntity implements EntityMetadata { - - @Id - private Ksuid id; - - @Column(name = "content_type") - private String contentType; - - @Column(name = "size") - private Long size; - - @Column(name = "data", columnDefinition = "bytea") - private byte[] data; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/FlagValue.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/FlagValue.java deleted file mode 100644 index 83967a2188..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/FlagValue.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.activepieces.entity.sql; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; -import lombok.*; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "flag") -public class FlagValue { - - @JsonProperty - @Id - @Column(name = "id") - private String key; - - @JsonProperty - @Column(name = "value") - private String value; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Flow.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/Flow.java deleted file mode 100644 index bc6e2e8fba..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Flow.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.persistence.*; -import java.time.Instant; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -@Entity -@Table(name = "flow", indexes = {@Index(name = "flow_collection_id_index", columnList = "collection_id", unique = false)}) -public class Flow implements EntityMetadata { - - public static final String COLLECTION_ID = "collectionId"; - - @Id private Ksuid id; - - @Column(name = "name") - private String name; - - @Column(name = "collection_id") - private Ksuid collectionId; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/FlowVersion.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/FlowVersion.java deleted file mode 100644 index 20a5ecda55..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/FlowVersion.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.common.error.ErrorResponse; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.subdocuments.trigger.TriggerMetadata; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; - -import javax.persistence.*; -import java.time.Instant; -import java.util.Set; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -@Entity -@Table(name = "flow_version") -@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) -public class FlowVersion implements EntityMetadata { - - @Id - private Ksuid id; - - @Column(name = "flow_id") - private Ksuid flowId; - - @Column(name = "display_name") - private String displayName; - - @Column(name = "trigger", columnDefinition = "jsonb") - @Type(type = "jsonb") - private TriggerMetadata trigger; - - - @Column(name = "errors", columnDefinition = "jsonb") - @Type(type = "jsonb") - private Set errors; - - @JsonProperty - private boolean valid; - - @JsonProperty - @Enumerated(EnumType.STRING) - private EditState state; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Instance.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/Instance.java deleted file mode 100644 index 83bf142918..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Instance.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.InstanceStatus; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; -import lombok.*; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; - -import javax.persistence.*; -import java.time.Instant; -import java.util.List; -import java.util.Map; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table( name = "instance") -@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) -public class Instance implements EntityMetadata { - - public static final String PROJECT_ID = "projectId"; - public static final String COLLECTION_ID = "collectionId"; - public static final String STATUS = "status"; - - @Id private Ksuid id; - - @Column(name = "collection_id") - private Ksuid collectionId; - - - @Column(name = "collection_version_id") - private Ksuid collectionVersionId; - - @Column(name = "flow_versions_id", columnDefinition = "jsonb") - @Type(type = "jsonb") - private Map flowVersionId; - - @Column(name = "project_id") - private Ksuid projectId; - - @Column(name = "status") - @Enumerated(EnumType.STRING) - private InstanceStatus status; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/InstanceRun.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/InstanceRun.java deleted file mode 100644 index 56c36e2b1f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/InstanceRun.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.FlowExecutionStatus; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.persistence.*; -import java.time.Instant; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "instance_run_log", indexes = {@Index(name = "run_project_id_index", columnList = "project_id, instance_id", unique = false), - @Index(name = "run_instance_id_index", columnList = "instance_id", unique = false)}) -public class InstanceRun implements EntityMetadata { - - public static final String INSTANCE_ID = "instanceId"; - - public static final String PROJECT_ID = "projectId"; - - @JsonProperty - @Id - private Ksuid id; - - @Column(name = "instance_id") - private Ksuid instanceId; - - @Column(name = "project_id") - private Ksuid projectId; - - @Column(name = "collection_id") - private Ksuid collectionId; - - @Column(name = "flow_version_id") - private Ksuid flowVersionId; - - @Column(name = "collection_version_id") - private Ksuid collectionVersionId; - - @Column(name = "status") - @Enumerated(EnumType.STRING) - private FlowExecutionStatus status; - - @Column(name = "flow_display_name") - private String flowDisplayName; - - @Column(name = "collection_display_name") - private String collectionDisplayName; - - @Column(name = "logs_file_id") - private Ksuid logsFileId; - - @Column(name = "finish_time") - private long finishTime; - - @Column(name = "start_time") - private long startTime; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Project.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/Project.java deleted file mode 100644 index 983a135c0c..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Project.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.persistence.*; -import java.time.Instant; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "project") -public class Project implements EntityMetadata { - @Id - @Column(name = "id") - private Ksuid id; - - @Column(name = "owner_id") - private Ksuid ownerId; - - @Column(name = "display_name") - private String displayName; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Resource.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/Resource.java deleted file mode 100644 index 2f8037514e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/Resource.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.entity.enums.ResourceType; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.persistence.*; -import java.util.HashSet; -import java.util.Set; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "resource") -public class Resource { - - @Column(name = "resource_id") @Id private Ksuid resourceId; - - @Column(name = "resource_type") - @Enumerated(EnumType.STRING) - private ResourceType resourceType; - - @Column(name = "parent_resource_id") private Ksuid parentResourceId; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name="parent_resource_id", insertable = false, updatable = false) - private Resource parent; - - @OneToMany(mappedBy="parent", fetch = FetchType.LAZY) - private Set children = new HashSet(); - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/ResourceAccess.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/ResourceAccess.java deleted file mode 100644 index 02667a725f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/ResourceAccess.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.entity.enums.Role; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.persistence.*; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "resource_access") -@IdClass(ResourceAccessId.class) -public class ResourceAccess { - - @Column(name = "resource_id") @Id private Ksuid resourceId; - - @Column(name = "principle_id") @Id private Ksuid principleId; - - @Column - @Enumerated(EnumType.STRING) - private Role role; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/ResourceAccessId.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/ResourceAccessId.java deleted file mode 100644 index 5c74ab866f..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/ResourceAccessId.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.entity.sql; - -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -@AllArgsConstructor -@NoArgsConstructor -public class ResourceAccessId implements Serializable { - - private Ksuid resourceId; - private Ksuid principleId; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/StoreValue.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/StoreValue.java deleted file mode 100644 index 82626e5dc8..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/StoreValue.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.activepieces.entity.sql; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; -import lombok.*; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "store") -@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) -public class StoreValue { - - @JsonProperty - @Id - @Column(name = "id") - private String id; - - @JsonProperty - @Column(name = "key") - private String key; - - @JsonProperty - @Type(type = "jsonb") - @Column(name = "value", columnDefinition = "jsonb") - private Object value; - - @JsonProperty private long created; - - @JsonProperty private long updated; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/sql/UserInformation.java b/src/backend/entities/src/main/java/com/activepieces/entity/sql/UserInformation.java deleted file mode 100644 index 48beb85081..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/sql/UserInformation.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.activepieces.entity.sql; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.UserStatus; -import com.github.ksuid.Ksuid; -import lombok.*; -import org.hibernate.annotations.GenericGenerator; - -import javax.persistence.*; -import java.time.Instant; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name = "user_information", indexes = @Index(columnList = "email")) -public class UserInformation implements EntityMetadata { - - @Id - @Column - private Ksuid id; - - @Column(name = "email", unique = true) - private String email; - - @Column(name = "full_name") - private String firstName; - - @Column(name = "last_name") - private String lastName; - - @Column(name = "password") - private String password; - - @Column(name = "user_status", nullable = false) - @Enumerated(EnumType.STRING) - private UserStatus status; - - @Column(name = "created", nullable = false) - private long created; - - @Column(name = "updated", nullable = false) - private long updated; - - - @PrePersist - protected void onCreate() { - long currentMs = Instant.now().toEpochMilli(); - created = currentMs; - updated = currentMs; - } - - @PreUpdate - protected void onUpdate() { - updated = Instant.now().toEpochMilli(); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ActionMetadata.java deleted file mode 100644 index 32c7a99e10..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ActionMetadata.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import java.io.Serializable; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type", - defaultImpl = EmptyActionMetadata.class, - visible = true) -@JsonSubTypes({ - @JsonSubTypes.Type(value = CodeActionMetadata.class, name = "CODE"), - @JsonSubTypes.Type(value = StorageActionMetadata.class, name = "STORAGE"), - @JsonSubTypes.Type(value = ResponseActionMetadata.class, name = "RESPONSE"), - @JsonSubTypes.Type(value = LoopOnItemsActionMetadata.class, name = "LOOP_ON_ITEMS"), - @JsonSubTypes.Type(value = ComponentActionMetadata.class, name = "COMPONENT") -}) -public abstract class ActionMetadata { - - @JsonProperty - private String type; - - @JsonProperty - private String displayName; - - @JsonProperty - private String name; - - @JsonProperty - private ActionMetadata nextAction; - - @JsonProperty - private boolean valid; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/CodeActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/CodeActionMetadata.java deleted file mode 100644 index dbc2330bff..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/CodeActionMetadata.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.activepieces.entity.subdocuments.action.settings.CodeSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class CodeActionMetadata extends ActionMetadata { - - @JsonProperty - private CodeSettings settings; - - -} \ No newline at end of file diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ComponentActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ComponentActionMetadata.java deleted file mode 100644 index 05751d8ca3..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ComponentActionMetadata.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.activepieces.entity.subdocuments.action.settings.ComponentSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ComponentActionMetadata extends ActionMetadata { - - @JsonProperty - private ComponentSettings settings; - -} \ No newline at end of file diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/EmptyActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/EmptyActionMetadata.java deleted file mode 100644 index d92b540e9c..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/EmptyActionMetadata.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.activepieces.entity.subdocuments.action.settings.CodeSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class EmptyActionMetadata extends ActionMetadata { - - -} \ No newline at end of file diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/LoopOnItemsActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/LoopOnItemsActionMetadata.java deleted file mode 100644 index 355aadd7e9..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/LoopOnItemsActionMetadata.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.activepieces.entity.subdocuments.action.settings.LoopOnItemsActionSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class LoopOnItemsActionMetadata extends ActionMetadata { - - @JsonProperty - private ActionMetadata firstLoopAction; - - @JsonProperty - private LoopOnItemsActionSettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ResponseActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ResponseActionMetadata.java deleted file mode 100644 index 41ceae7d24..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/ResponseActionMetadata.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.activepieces.entity.subdocuments.action.settings.ResponseSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ResponseActionMetadata extends ActionMetadata { - - @JsonProperty - private ResponseSettings settings; - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/StorageActionMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/StorageActionMetadata.java deleted file mode 100644 index 662927cf8b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/StorageActionMetadata.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.entity.subdocuments.action; - -import com.activepieces.entity.subdocuments.action.settings.StoreSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class StorageActionMetadata extends ActionMetadata { - - @JsonProperty - private StoreSettings settings; - - -} \ No newline at end of file diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/CodeSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/CodeSettings.java deleted file mode 100644 index 63447d9ec7..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/CodeSettings.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.entity.subdocuments.action.settings; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class CodeSettings { - - @JsonProperty - private String artifactSourceId; - - @JsonProperty - private String artifactPackagedId; - - @NotNull @JsonProperty @Valid private Map input; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/ComponentSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/ComponentSettings.java deleted file mode 100644 index 070ac6f52b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/ComponentSettings.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.entity.subdocuments.action.settings; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import java.util.Map; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ComponentSettings { - - private Map input; - - private String componentName; - - private String actionName; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/LoopOnItemsActionSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/LoopOnItemsActionSettings.java deleted file mode 100644 index a20772b11a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/LoopOnItemsActionSettings.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.entity.subdocuments.action.settings; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class LoopOnItemsActionSettings { - - @JsonProperty - private Object items; -} - diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/ResponseSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/ResponseSettings.java deleted file mode 100644 index d0b4a2cc4e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/ResponseSettings.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.entity.subdocuments.action.settings; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Map; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ResponseSettings { - - @NotNull - @JsonProperty - private Map output; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/StoreSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/StoreSettings.java deleted file mode 100644 index 738b0203f8..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/action/settings/StoreSettings.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.activepieces.entity.subdocuments.action.settings; - -import com.activepieces.entity.enums.StoreOperation; -import com.activepieces.entity.enums.StoreScope; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class StoreSettings { - - @NotNull - @JsonProperty - private StoreOperation operation; - - @NotNull - @JsonProperty - private StoreScope scope; - - @NotNull - @NotEmpty - @JsonProperty - private String key; - - @JsonProperty - private Object value; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/CheckboxVariable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/CheckboxVariable.java deleted file mode 100644 index 4c62001ae8..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/CheckboxVariable.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class CheckboxVariable extends Variable { - - @JsonProperty - private Object value; - - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue); - } - - public Object getValue() { - return value; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/EmptyField.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/EmptyField.java deleted file mode 100644 index 4fdef2dd85..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/EmptyField.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.experimental.SuperBuilder; - -@SuperBuilder -@Getter -@AllArgsConstructor -public class EmptyField extends Variable { - - - @Override - public Object getValue() { - return null; - } - - @Override - public boolean validate(Object finalValue) { - return true; - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/KeyValueVariable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/KeyValueVariable.java deleted file mode 100644 index 79fe42b49b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/KeyValueVariable.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class KeyValueVariable extends Variable { - - @JsonProperty - private Object value; - - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue); - } - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/MultilineVariable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/MultilineVariable.java deleted file mode 100644 index a365fd0746..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/MultilineVariable.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class MultilineVariable extends Variable { - - private Object value; - - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue) && finalValue instanceof String && ((String) finalValue).length() > 0; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/NumberVariable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/NumberVariable.java deleted file mode 100644 index e9ff976df1..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/NumberVariable.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class NumberVariable extends Variable { - - @JsonProperty - private Object value; - - public Object getValue() { - return value; - } - - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/PasswordVariable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/PasswordVariable.java deleted file mode 100644 index 8df093ac4e..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/PasswordVariable.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class PasswordVariable extends Variable { - - - @JsonProperty - private Object value; - - public Object getValue() { - return value; - } - - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue); - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/ShortTextVariable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/ShortTextVariable.java deleted file mode 100644 index f714a2313b..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/ShortTextVariable.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class ShortTextVariable extends Variable{ - - @JsonProperty - private Object value; - - public Object getValue() { - return value; - } - - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue) && ((String) finalValue).length() > 0; - } -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/ValueField.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/ValueField.java deleted file mode 100644 index 81c88fcaf0..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/ValueField.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -public interface ValueField { - - Object getValue(); - - boolean validate(Object finalValue); -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/Variable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/Variable.java deleted file mode 100644 index bbc930d721..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/Variable.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.activepieces.entity.subdocuments.field; - -import com.activepieces.common.validation.EnumNamePattern; -import com.activepieces.entity.enums.InputVariableType; -import com.activepieces.entity.subdocuments.field.connection.oauth2.OAuth2Variable; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -@Getter -@Setter -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true, defaultImpl = EmptyField.class) -@JsonSubTypes({ - @JsonSubTypes.Type(value = CheckboxVariable.class, name = "CHECKBOX"), - @JsonSubTypes.Type(value = PasswordVariable.class, name = "PASSWORD"), - @JsonSubTypes.Type(value = OAuth2Variable.class, name = "OAUTH2"), - @JsonSubTypes.Type(value = NumberVariable.class, name = "NUMBER"), - @JsonSubTypes.Type(value = KeyValueVariable.class, name = "DICTIONARY"), - @JsonSubTypes.Type(value = MultilineVariable.class, name = "LONG_TEXT"), - @JsonSubTypes.Type(value = ShortTextVariable.class, name = "SHORT_TEXT"),} -) -public abstract class Variable implements ValueField, Serializable { - - @JsonProperty - @NotNull - private String key; - - @EnumNamePattern(regexp = "CHECKBOX|PASSWORD|NUMBER|DICTIONARY|LONG_TEXT|SHORT_TEXT|OAUTH2") - @JsonProperty - private InputVariableType type; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/connection/oauth2/OAuth2Settings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/connection/oauth2/OAuth2Settings.java deleted file mode 100644 index 6f91976590..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/connection/oauth2/OAuth2Settings.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.activepieces.entity.subdocuments.field.connection.oauth2; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -@Setter -@SuperBuilder(toBuilder = true) -public class OAuth2Settings implements Serializable { - - @JsonProperty - @NotNull - private String scope; - - @JsonProperty - @NotNull - @NotEmpty - private String clientId; - - @JsonProperty - @NotNull - @NotEmpty - private String clientSecret; - - @JsonProperty - @NotNull - @NotEmpty - private String authUrl; - - @JsonProperty - @NotNull - @NotEmpty - private String tokenUrl; - - @JsonProperty - private String refreshUrl; - - @JsonProperty - @NotNull - @NotEmpty - private String responseType; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/connection/oauth2/OAuth2Variable.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/connection/oauth2/OAuth2Variable.java deleted file mode 100644 index bfac067de4..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/field/connection/oauth2/OAuth2Variable.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.activepieces.entity.subdocuments.field.connection.oauth2; - -import com.activepieces.entity.subdocuments.field.Variable; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.Objects; - -@SuperBuilder -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2Variable extends Variable { - - @NotNull @Valid @JsonProperty private OAuth2Settings settings; - - @JsonProperty private Object value; - - @Override - public boolean validate(Object finalValue) { - return Objects.nonNull(finalValue); - } - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/ActionExecutionStatus.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/ActionExecutionStatus.java deleted file mode 100644 index 69264f8f79..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/ActionExecutionStatus.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.entity.subdocuments.runs; - -public enum ActionExecutionStatus { - SUCCEEDED, - FAILED -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/ExecutionStateView.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/ExecutionStateView.java deleted file mode 100644 index d4fa9f67ec..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/ExecutionStateView.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.entity.subdocuments.runs; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.LinkedHashMap; -import java.util.Map; - -@Getter -@Builder(toBuilder = true) -@NoArgsConstructor -@AllArgsConstructor -@ToString -@JsonIgnoreProperties(ignoreUnknown = true) -public class ExecutionStateView { - - @JsonProperty private Map context; - - @JsonProperty - private Map configs; - - @JsonProperty private LinkedHashMap steps; - - - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/StepOutput.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/StepOutput.java deleted file mode 100644 index 6cfa8637ef..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/runs/StepOutput.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.activepieces.entity.subdocuments.runs; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.LinkedHashMap; -import java.util.List; - -@Getter -@Setter -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -public class StepOutput { - - public static final String OUTPUT_FIELD = "output"; - public static final String ERROR_FIELD = "errorMessage"; - - @NotNull - @JsonProperty - private Object output; - - @NotNull - @JsonProperty - private List> iterations; - - @NotNull - @JsonProperty - private Object input; - - @JsonProperty private long duration; - - @JsonProperty() - private ActionExecutionStatus status; - - @JsonInclude(JsonInclude.Include.NON_NULL) - @JsonProperty - private Object errorMessage; -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ComponentTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ComponentTriggerMetadata.java deleted file mode 100644 index d3d3cde494..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ComponentTriggerMetadata.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.trigger.settings.ComponentTriggerSettings; -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ComponentTriggerMetadata extends TriggerMetadata { - - @JsonProperty - private ComponentTriggerSettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/EmptyTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/EmptyTriggerMetadata.java deleted file mode 100644 index 1e25f35241..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/EmptyTriggerMetadata.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class EmptyTriggerMetadata extends TriggerMetadata { - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/InstanceStartedTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/InstanceStartedTriggerMetadata.java deleted file mode 100644 index c2dcd48e2c..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/InstanceStartedTriggerMetadata.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class InstanceStartedTriggerMetadata extends TriggerMetadata { - - @JsonProperty - private EmptySettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/InstanceStoppedTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/InstanceStoppedTriggerMetadata.java deleted file mode 100644 index 73341632ae..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/InstanceStoppedTriggerMetadata.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class InstanceStoppedTriggerMetadata extends TriggerMetadata { - - @JsonProperty - private EmptySettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ManualTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ManualTriggerMetadata.java deleted file mode 100644 index 39b2ac021a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ManualTriggerMetadata.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ManualTriggerMetadata extends TriggerMetadata { - - @JsonProperty - private EmptySettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ScheduleTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ScheduleTriggerMetadata.java deleted file mode 100644 index 366bece7e9..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/ScheduleTriggerMetadata.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.trigger.settings.ScheduleTriggerSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ScheduleTriggerMetadata extends TriggerMetadata { - - @JsonProperty - private ScheduleTriggerSettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/TriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/TriggerMetadata.java deleted file mode 100644 index 50192a6b94..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/TriggerMetadata.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.action.ActionMetadata; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true, defaultImpl = EmptyTriggerMetadata.class) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ScheduleTriggerMetadata.class, name = "SCHEDULE"), - @JsonSubTypes.Type(value = EmptyTriggerMetadata.class, name = "EMPTY"), - @JsonSubTypes.Type(value = InstanceStartedTriggerMetadata.class, name = "COLLECTION_ENABLED"), - @JsonSubTypes.Type(value = InstanceStoppedTriggerMetadata.class, name = "COLLECTION_DISABLED"), - @JsonSubTypes.Type(value = WebhookTriggerMetadata.class, name = "WEBHOOK"), - @JsonSubTypes.Type(value = ComponentTriggerMetadata.class, name = "COMPONENT_TRIGGER") -} -) -public abstract class TriggerMetadata { - - @JsonProperty - private String displayName; - - @JsonProperty - private String type; - - @JsonProperty - private String name; - - @JsonProperty - private boolean valid; - - @JsonProperty - private ActionMetadata nextAction; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/WebhookTriggerMetadata.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/WebhookTriggerMetadata.java deleted file mode 100644 index 461af95113..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/WebhookTriggerMetadata.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class WebhookTriggerMetadata extends TriggerMetadata { - - @JsonProperty - private EmptySettings settings; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/ComponentTriggerSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/ComponentTriggerSettings.java deleted file mode 100644 index 849eb00704..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/ComponentTriggerSettings.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger.settings; - -import com.activepieces.common.validation.CronExpression; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ComponentTriggerSettings { - - @JsonProperty - @NotEmpty - private String componentName; - - @JsonProperty - - private String triggerName; - - @JsonProperty - @NotNull - private Map input; - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/EmptySettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/EmptySettings.java deleted file mode 100644 index e19d3d340a..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/EmptySettings.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger.settings; - -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@Getter -@Setter -@SuperBuilder -@JsonSerialize -public class EmptySettings { - -} diff --git a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/ScheduleTriggerSettings.java b/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/ScheduleTriggerSettings.java deleted file mode 100644 index 5c62430bdd..0000000000 --- a/src/backend/entities/src/main/java/com/activepieces/entity/subdocuments/trigger/settings/ScheduleTriggerSettings.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.entity.subdocuments.trigger.settings; - -import com.activepieces.common.validation.CronExpression; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder -public class ScheduleTriggerSettings { - - @JsonProperty - @NotEmpty - @CronExpression - private String cronExpression; -} diff --git a/src/backend/executor-service/executor-client/pom.xml b/src/backend/executor-service/executor-client/pom.xml deleted file mode 100644 index d605bf3fd4..0000000000 --- a/src/backend/executor-service/executor-client/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - executor-service - com.activepieces - 1.0 - - 4.0.0 - - executor-client - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/executor-service/executor-client/src/main/java/com/activepieces/action/ExecutionRequest.java b/src/backend/executor-service/executor-client/src/main/java/com/activepieces/action/ExecutionRequest.java deleted file mode 100644 index d98d1b8bb3..0000000000 --- a/src/backend/executor-service/executor-client/src/main/java/com/activepieces/action/ExecutionRequest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.activepieces.action; - -import com.activepieces.actions.store.model.StorePath; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import java.util.Map; -import java.util.UUID; - -@Getter -@Builder(toBuilder = true) -@NoArgsConstructor -@AllArgsConstructor -@ToString -public class ExecutionRequest { - - @JsonProperty - private Ksuid runId; - - @JsonProperty - private Ksuid instanceId; - - @JsonProperty - private Ksuid collectionVersionId; - - @JsonProperty - private Ksuid flowVersionId; - - @JsonProperty - private StorePath storePath; - - @JsonProperty - private Map configs; - - @JsonProperty - private Map triggerPayload; - -} diff --git a/src/backend/executor-service/executor-client/src/main/java/com/activepieces/action/FlowPublisherService.java b/src/backend/executor-service/executor-client/src/main/java/com/activepieces/action/FlowPublisherService.java deleted file mode 100644 index d97341d4e4..0000000000 --- a/src/backend/executor-service/executor-client/src/main/java/com/activepieces/action/FlowPublisherService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.action; - -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.error.exception.flow.FlowExecutionInternalError; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.variable.model.exception.MissingConfigsException; -import com.github.ksuid.Ksuid; -import lombok.NonNull; - -import java.util.Map; -import java.util.UUID; - -public interface FlowPublisherService { - - InstanceRunView executeTest(@NonNull final Ksuid collectionVersionId, - @NonNull final Ksuid flowVersionID, - @NonNull Map triggerPayload) throws FlowExecutionInternalError, ResourceNotFoundException; - - InstanceRunView executeInstance(@NonNull final Ksuid instanceId, @NonNull Ksuid flowVersionId, @NonNull Map triggerPayload) throws FlowExecutionInternalError, MissingConfigsException, ResourceNotFoundException, InstanceNotFoundException, PermissionDeniedException; - - -} diff --git a/src/backend/executor-service/executor-client/src/main/java/com/activepieces/flow/ManualFlowExecutionRequest.java b/src/backend/executor-service/executor-client/src/main/java/com/activepieces/flow/ManualFlowExecutionRequest.java deleted file mode 100644 index 1cb16a6e73..0000000000 --- a/src/backend/executor-service/executor-client/src/main/java/com/activepieces/flow/ManualFlowExecutionRequest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.flow; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.validation.constraints.NotNull; -import java.util.Map; -import java.util.UUID; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class ManualFlowExecutionRequest { - - @JsonProperty - @NotNull - private Ksuid flowId; - - @JsonProperty - @NotNull - private Ksuid collectionId; - - @JsonProperty - @NotNull - Map payload; - -} diff --git a/src/backend/executor-service/executor-server/pom.xml b/src/backend/executor-service/executor-server/pom.xml deleted file mode 100644 index e4b836b1c7..0000000000 --- a/src/backend/executor-service/executor-server/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - executor-service - com.activepieces - 1.0 - - 4.0.0 - - executor-server - - - com.activepieces - executor-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - com.activepieces - worker-client - 1.0 - compile - - - com.activepieces - component-service - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/FlowPublisherServiceImpl.java b/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/FlowPublisherServiceImpl.java deleted file mode 100644 index b28dc4ace7..0000000000 --- a/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/FlowPublisherServiceImpl.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.activepieces.flow; - -import com.activepieces.action.ExecutionRequest; -import com.activepieces.action.FlowPublisherService; -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.error.exception.flow.FlowExecutionInternalError; -import com.activepieces.entity.enums.FlowExecutionStatus; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.subdocuments.runs.ActionExecutionStatus; -import com.activepieces.entity.subdocuments.runs.ExecutionStateView; -import com.activepieces.entity.subdocuments.runs.StepOutput; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.instance.client.InstanceService; -import com.activepieces.instance.client.model.InstanceView; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.trigger.model.TriggerMetadataView; -import com.activepieces.variable.model.VariableService; -import com.activepieces.worker.service.WorkerService; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.time.Instant; -import java.util.*; - -@Service -@Log4j2 -public class FlowPublisherServiceImpl implements FlowPublisherService { - - - private final InstanceService instanceService; - private final FlowVersionService flowVersionService; - private final CollectionVersionService collectionVersionService; - private final InstanceRunService instanceRunService; - private final VariableService variableService; - private final FlowScheduler flowScheduler; - private final PermissionService permissionService; - - @Autowired - FlowPublisherServiceImpl( - @NonNull final FlowVersionService flowVersionService, - @NonNull final PermissionService permissionService, - @NonNull final InstanceService instanceService, - @NonNull final FlowScheduler flowScheduler, - @NonNull final InstanceRunService instanceRunService, - @NonNull final VariableService variableService, - @NonNull final CollectionVersionService collectionVersionService) { - this.collectionVersionService = collectionVersionService; - this.instanceService = instanceService; - this.flowScheduler = flowScheduler; - this.variableService = variableService; - this.permissionService = permissionService; - this.instanceRunService = instanceRunService; - this.flowVersionService = flowVersionService; - } - - @Override - public InstanceRunView executeTest( - @NonNull Ksuid collectionVersionId, - @NonNull Ksuid flowVersionId, - @NonNull Map triggerPayload) - throws FlowExecutionInternalError { - return execute(null, collectionVersionId, flowVersionId, triggerPayload); - } - - @Override - public InstanceRunView executeInstance( - @NonNull Ksuid instanceId, - @NonNull Ksuid flowVersionId, - @NonNull Map triggerPayload) - throws FlowExecutionInternalError, InstanceNotFoundException, PermissionDeniedException { - final InstanceView instanceView = instanceService.get(instanceId); - return execute(instanceView, instanceView.getCollectionVersionId(), flowVersionId, triggerPayload); - } - - public InstanceRunView execute( - InstanceView instanceView, - @NonNull Ksuid collectionVersionId, - @NonNull Ksuid flowVersionId, - @NonNull Map triggerPayload) - throws FlowExecutionInternalError { - try { - FlowVersionView flowVersionView = flowVersionService.get(flowVersionId); - CollectionVersionView collectionVersionView = - collectionVersionService.get(collectionVersionId); - Map validatedInstanceConfigs = - variableService.flatConfigsValue(collectionVersionView.getConfigs()); - Ksuid runId = Ksuid.newKsuid(); - Optional request = - constructRun( - runId, - StorePath.testScope(collectionVersionId), - instanceView, - collectionVersionView, - flowVersionView, - validatedInstanceConfigs, - triggerPayload); - if (request.isPresent()) { - Ksuid projectID = permissionService.getFirstResourceParentWithType(collectionVersionView.getCollectionId(), ResourceType.PROJECT).getResourceId(); - InstanceRunView instanceRunView = - createInstanceRun(projectID, Objects.isNull(instanceView) ? null : instanceView.getId(), collectionVersionView, flowVersionView, request.get()); - flowScheduler.executeFlowAsync(request.get()); - return instanceRunView.toBuilder().build(); - } - return InstanceRunView.builder().id(runId).build(); - } catch (Exception e) { - e.printStackTrace(); - throw new FlowExecutionInternalError(e); - } - } - - private Optional constructRun( - Ksuid runId, - StorePath storePath, - InstanceView instanceView, - @NonNull CollectionVersionView collectionVersionView, - @NonNull FlowVersionView version, - @NonNull Map variables, - @NonNull Map triggerPayload) { - TriggerMetadataView trigger = version.getTrigger(); - if (Objects.nonNull(trigger)) { - Ksuid instanceId = Objects.nonNull(instanceView) ? instanceView.getId() : null; - ExecutionRequest request = - ExecutionRequest.builder() - .storePath(storePath) - .configs(variables) - .collectionVersionId(collectionVersionView.getId()) - .triggerPayload(triggerPayload) - .instanceId(instanceId) - .flowVersionId(version.getId()) - .runId(runId) - .build(); - return Optional.of(request); - } - return Optional.empty(); - } - - private InstanceRunView createInstanceRun( - @NonNull final Ksuid projectId, - final Ksuid instanceId, - @NonNull CollectionVersionView collectionVersionView, - @NonNull FlowVersionView flowVersion, - ExecutionRequest executionRequest) - throws PermissionDeniedException, InstanceNotFoundException, ResourceNotFoundException, IOException { - final StepOutput triggerOutput = StepOutput.builder().output(executionRequest.getTriggerPayload()).status(ActionExecutionStatus.SUCCEEDED).build(); - final LinkedHashMap steps = new LinkedHashMap<>(); - steps.put(flowVersion.getTrigger().getName(), triggerOutput); - - ExecutionStateView environmentView = - ExecutionStateView.builder().configs(executionRequest.getConfigs()) - .steps(steps) - .build(); - InstanceRunView instanceRunView = - InstanceRunView.builder() - .id(executionRequest.getRunId()) - .instanceId(instanceId) - .collectionId(collectionVersionView.getId()) - .flowDisplayName(flowVersion.getDisplayName()) - .collectionVersionId(collectionVersionView.getId()) - .collectionDisplayName(collectionVersionView.getDisplayName()) - .projectId(projectId) - .flowVersionId(flowVersion.getId()) - .startTime(Instant.now().toEpochMilli()) - .finishTime(Instant.now().toEpochMilli()) - .status( - Objects.isNull(flowVersion.getTrigger().getNextAction()) - ? FlowExecutionStatus.SUCCEEDED - : FlowExecutionStatus.RUNNING) - .build(); - return instanceRunService.createOrUpdate(instanceRunView, environmentView); - } - -} diff --git a/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/FlowScheduler.java b/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/FlowScheduler.java deleted file mode 100644 index 172a8e877a..0000000000 --- a/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/FlowScheduler.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.activepieces.flow; - -import com.activepieces.action.ExecutionRequest; -import com.activepieces.actions.model.action.settings.ComponentSettingsView; -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.component.ComponentService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.trigger.model.ComponentTriggerMetadataView; -import com.activepieces.trigger.model.ScheduleMetadataTriggerView; -import com.activepieces.trigger.model.TriggerMetadataView; -import com.activepieces.worker.service.WorkerService; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.jboss.logging.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@Service -@Log4j2 -public class FlowScheduler { - - private final ErrorServiceHandler errorServiceHandler; - private final FlowVersionService flowVersionService; - private final CollectionVersionService collectionVersionService; - private final WorkerService workerService; - private final InstanceRunService instanceRunService; - private final String mdcHeader; - private final String loggingRunPattern; - private final ComponentService componentService; - - @Autowired - FlowScheduler( - final ErrorServiceHandler errorServiceHandler, - final WorkerService workerService, - final CollectionVersionService collectionVersionService, - final InstanceRunService instanceRunService, - final FlowVersionService flowVersionService, - final ComponentService componentService, - @Value("${logging.request-id-header}") String mdcHeader, - @Value("${logging.run-pattern}") String loggingRunPattern) { - this.mdcHeader = mdcHeader; - this.workerService = workerService; - this.componentService = componentService; - this.instanceRunService = instanceRunService; - this.collectionVersionService = collectionVersionService; - this.flowVersionService = flowVersionService; - this.loggingRunPattern = loggingRunPattern; - this.errorServiceHandler = errorServiceHandler; - - } - - @Async - public void executeFlowAsync(ExecutionRequest request) { - try { - MDC.put(mdcHeader, String.format(loggingRunPattern, request.getRunId().toString())); - long startTime = System.currentTimeMillis(); - log.info("[Started] Executing Message " + request); - - FlowVersionView flowVersionView = flowVersionService.get(request.getFlowVersionId()); - CollectionVersionView collectionVersionView = collectionVersionService.get(request.getCollectionVersionId()); - InstanceRunView instanceRunView = instanceRunService.get(request.getRunId()); - - List triggers = getTriggersPayload(flowVersionView, request.getConfigs(), request.getTriggerPayload()); - log.info("There are {} events payload", triggers.size()); - for (Object trigger : triggers) { - workerService.executeFlow( - instanceRunView, - collectionVersionView, - flowVersionView, - request.getConfigs(), - trigger, - request.getStorePath()); - log.info( - "[Finished] Executing Message " - + request - + " " - + (System.currentTimeMillis() - startTime) - + "ms"); - } - } catch (Exception e) { - e.printStackTrace(); - throw errorServiceHandler.createInternalError(FlowScheduler.class, e); - } - } - - private List getTriggersPayload(@NonNull final FlowVersionView flowVersionView, - @NonNull final Map configs, - @NonNull final Object payload) throws IOException, InterruptedException { - final TriggerMetadataView triggerMetadataView = flowVersionView.getTrigger(); - if (Objects.isNull(triggerMetadataView)) { - return Collections.singletonList(payload); - } - if (triggerMetadataView instanceof ComponentTriggerMetadataView) { - return componentService.getTriggersPayload(payload, flowVersionView, configs); - } - return Collections.singletonList(payload); - } -} diff --git a/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/InstanceHooksListener.java b/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/InstanceHooksListener.java deleted file mode 100644 index 16ab9f8c41..0000000000 --- a/src/backend/executor-service/executor-server/src/main/java/com/activepieces/flow/InstanceHooksListener.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.activepieces.flow; - -import com.activepieces.action.FlowPublisherService; -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.error.exception.flow.FlowExecutionInternalError; -import com.activepieces.component.ComponentService; -import com.activepieces.entity.enums.ComponentTriggerHook; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.instance.client.InstancePublisher; -import com.activepieces.instance.client.InstanceSubscriber; -import com.activepieces.instance.client.model.InstanceEventType; -import com.activepieces.instance.client.model.InstanceView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.piece.client.model.CollectionView; -import com.activepieces.trigger.model.InstanceStartedTriggerMetadataView; -import com.activepieces.trigger.model.InstanceStoppedTriggerMetadataView; -import com.activepieces.variable.model.VariableService; -import com.activepieces.variable.model.exception.MissingConfigsException; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; - -@Service -@Log4j2 -public class InstanceHooksListener implements InstanceSubscriber { - - private final FlowVersionService flowVersionService; - private final CollectionVersionService collectionVersionService; - private final VariableService variableService; - private final ErrorServiceHandler errorServiceHandler; - private final FlowPublisherService flowPublisherService; - private final ComponentService componentService; - - @Autowired - public InstanceHooksListener( - @NonNull final FlowVersionService flowVersionService, - @NonNull final InstancePublisher instancePublisher, - @NonNull final VariableService variableService, - @NonNull final CollectionVersionService collectionVersionService, - @NonNull final ComponentService componentService, - @NonNull final FlowPublisherService flowPublisherService, - @NonNull final ErrorServiceHandler errorServiceHandler) { - instancePublisher.addSubscriber(this); - this.variableService = variableService; - this.collectionVersionService = collectionVersionService; - this.flowVersionService = flowVersionService; - this.componentService = componentService; - this.flowPublisherService = flowPublisherService; - this.errorServiceHandler = errorServiceHandler; - } - - private List toFlows(List flowVersionIds) { - return flowVersionIds.stream() - .map( - f -> { - try { - return flowVersionService.getOptional(f).orElseThrow(); - } catch (PermissionDeniedException e) { - throw errorServiceHandler.createInternalError(e); - } - }).collect(Collectors.toList()); - } - - private List filterFlows(List flowVersionIds, Class triggerType) { - return toFlows(flowVersionIds).stream() - .filter(f -> Objects.nonNull(f.getTrigger()) - && triggerType.isInstance(f.getTrigger())) - .collect(Collectors.toList()); - } - - public void runHooks(InstanceView instance, ComponentTriggerHook hook) { - try { - CollectionVersionView collectionVersionView = collectionVersionService.get(instance.getCollectionVersionId()); - List flowVersions = toFlows(new ArrayList<>(instance.getFlowVersionId().values())); - for (FlowVersionView flowVersionView : flowVersions) { - componentService.executeTriggerHook(hook, flowVersionView, variableService.flatConfigsValue(collectionVersionView.getConfigs())); - log.info("Running Trigger hook {} for flow {}", hook, flowVersionView.getId().toString()); - } - } catch (MissingConfigsException | PermissionDeniedException | CollectionVersionNotFoundException | IOException | InterruptedException e) { - throw errorServiceHandler.createInternalError(e); - } - } - - public void runFlows(InstanceView instance, Class triggerType) { - try { - List flowVersions = - filterFlows(new ArrayList<>(instance.getFlowVersionId().values()), triggerType); - for (FlowVersionView flowVersionView : flowVersions) { - InstanceRunView instanceRunView = flowPublisherService.executeInstance( - instance.getId(), - flowVersionView.getId(), - Collections.emptyMap()); - log.info("Running instance hook with run Id {}", instanceRunView.getId().toString()); - } - } catch (FlowExecutionInternalError | MissingConfigsException | ResourceNotFoundException | InstanceNotFoundException | PermissionDeniedException e) { - throw errorServiceHandler.createInternalError(e); - } - } - - public void onStop(InstanceView entity) { - runFlows(entity, InstanceStoppedTriggerMetadataView.class); - } - - public void onStart(InstanceView entity) { - runFlows(entity, InstanceStartedTriggerMetadataView.class); - } - - @Override - public void onListen(InstanceEventType type, InstanceView entity) { - log.info("Instance event type {} for Instance Id {}", type, entity.getId()); - switch (type) { - case UPDATE: - case CREATE: - switch (entity.getStatus()) { - case ENABLED: - runHooks(entity, ComponentTriggerHook.ENABLED); - onStart(entity); - break; - case DISABLED: - runHooks(entity, ComponentTriggerHook.DISABLED); - onStop(entity); - break; - } - break; - case DELETE: - runHooks(entity, ComponentTriggerHook.DISABLED); - onStop(entity); - break; - default: - throw errorServiceHandler.createInternalError( - new RuntimeException("Unexpected instance event type " + type)); - } - } -} diff --git a/src/backend/executor-service/pom.xml b/src/backend/executor-service/pom.xml deleted file mode 100644 index c9164fc891..0000000000 --- a/src/backend/executor-service/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - executor-service - pom - - executor-client - executor-server - - - - org.projectlombok - lombok - - - - - 11 - 11 - - - diff --git a/src/backend/feature-service/pom.xml b/src/backend/feature-service/pom.xml deleted file mode 100644 index e61194aab0..0000000000 --- a/src/backend/feature-service/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - feature-service - - - com.activepieces - entities - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/feature-service/src/main/java/com/activepieces/flag/repository/FlagRepository.java b/src/backend/feature-service/src/main/java/com/activepieces/flag/repository/FlagRepository.java deleted file mode 100644 index dbe3d32964..0000000000 --- a/src/backend/feature-service/src/main/java/com/activepieces/flag/repository/FlagRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.activepieces.flag.repository; - -import com.activepieces.entity.sql.FlagValue; -import org.springframework.data.repository.CrudRepository; - -public interface FlagRepository extends CrudRepository { - -} diff --git a/src/backend/feature-service/src/main/java/com/activepieces/flag/service/FlagService.java b/src/backend/feature-service/src/main/java/com/activepieces/flag/service/FlagService.java deleted file mode 100644 index ae18513130..0000000000 --- a/src/backend/feature-service/src/main/java/com/activepieces/flag/service/FlagService.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.activepieces.flag.service; - -import com.activepieces.entity.sql.FlagValue; -import com.activepieces.flag.repository.FlagRepository; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.swing.text.html.Option; -import java.util.Optional; - -@Service -public class FlagService { - - public static final String BEARER_ENCRYPTION_KEY = "BEARER_ENCRYPTION_KEY"; - - private final FlagRepository flagRepository; - - @Autowired - public FlagService(@NonNull final FlagRepository flagRepository){ - this.flagRepository = flagRepository; - } - - public Optional getValue(@NonNull final String key){ - Optional result = flagRepository.findById(key); - if(result.isEmpty()){ - return Optional.empty(); - } - return Optional.of(result.get().getValue()); - } - - public boolean exists(@NonNull final String key){ - return flagRepository.existsById(key); - } - - public void save(@NonNull final String key, - @NonNull final String value){ - flagRepository.save(FlagValue.builder().key(key).value(value).build()); - } -} diff --git a/src/backend/file-service/file-client/pom.xml b/src/backend/file-service/file-client/pom.xml deleted file mode 100644 index e56d4b3de0..0000000000 --- a/src/backend/file-service/file-client/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - backend - com.activepieces - 1.0 - ../../pom.xml - - 4.0.0 - - file-client - - - com.activepieces - entities - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/file-service/file-client/src/main/java/com/activepieces/file/service/FileService.java b/src/backend/file-service/file-client/src/main/java/com/activepieces/file/service/FileService.java deleted file mode 100644 index 0afbde23e3..0000000000 --- a/src/backend/file-service/file-client/src/main/java/com/activepieces/file/service/FileService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.file.service; - -import com.activepieces.entity.sql.FileEntity; -import com.github.ksuid.Ksuid; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.Optional; -import java.util.UUID; - -public interface FileService { - - FileEntity clone(Ksuid id); - - FileEntity save(Ksuid fileId, MultipartFile file) throws IOException; - - Optional getFileById(Ksuid id); - - void delete(Ksuid id); - -} diff --git a/src/backend/file-service/file-server/pom.xml b/src/backend/file-service/file-server/pom.xml deleted file mode 100644 index a4c461b996..0000000000 --- a/src/backend/file-service/file-server/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - backend - com.activepieces - 1.0 - ../../pom.xml - - 4.0.0 - - file-server - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - file-client - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/file-service/file-server/src/main/java/com/activepieces/file/controller/FileController.java b/src/backend/file-service/file-server/src/main/java/com/activepieces/file/controller/FileController.java deleted file mode 100644 index ed3cac2d7e..0000000000 --- a/src/backend/file-service/file-server/src/main/java/com/activepieces/file/controller/FileController.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.activepieces.file.controller; - - import com.activepieces.entity.sql.FileEntity; - import com.activepieces.file.service.FileService; - import com.github.ksuid.Ksuid; - import io.swagger.v3.oas.annotations.Hidden; - import jdk.jfr.ContentType; - import org.springframework.beans.factory.annotation.Autowired; - import org.springframework.core.io.ByteArrayResource; - import org.springframework.http.ContentDisposition; - import org.springframework.http.HttpHeaders; - import org.springframework.http.MediaType; - import org.springframework.http.ResponseEntity; - import org.springframework.stereotype.Controller; - import org.springframework.web.bind.annotation.GetMapping; - import org.springframework.web.bind.annotation.PathVariable; - import org.springframework.web.bind.annotation.ResponseBody; - import org.springframework.web.bind.annotation.RestController; - - import javax.servlet.http.HttpServletResponse; - import java.io.ByteArrayOutputStream; - import java.io.IOException; - import java.io.OutputStream; - import java.util.Optional; - -@Controller -@Hidden -public class FileController { - - - private final FileService fileService; - - @Autowired - public FileController(FileService fileService) { - this.fileService = fileService; - } - - - @GetMapping(value = "/files/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) - @ResponseBody - public void getFile(@PathVariable Ksuid id, HttpServletResponse response) throws IOException { - Optional fileEntityOptional = fileService.getFileById(id); - FileEntity fileEntity = fileEntityOptional.get(); - ByteArrayOutputStream out = new ByteArrayOutputStream(fileEntity.getData().length); - out.write(fileEntity.getData(), 0, fileEntity.getData().length); - response.addIntHeader("Content-Length", fileEntity.getData().length); - response.addHeader("Content-Disposition", "attachment; filename=artifact.zip"); - OutputStream outputStream = response.getOutputStream(); - out.writeTo(outputStream); - outputStream.close(); - out.close(); - } -} diff --git a/src/backend/file-service/file-server/src/main/java/com/activepieces/file/repository/FileRepository.java b/src/backend/file-service/file-server/src/main/java/com/activepieces/file/repository/FileRepository.java deleted file mode 100644 index ae71610da8..0000000000 --- a/src/backend/file-service/file-server/src/main/java/com/activepieces/file/repository/FileRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.file.repository; - -import com.activepieces.entity.sql.FileEntity; -import com.github.ksuid.Ksuid; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; -import java.util.UUID; - -@Repository -public interface FileRepository extends JpaRepository { - -} diff --git a/src/backend/file-service/file-server/src/main/java/com/activepieces/file/service/FileServiceImpl.java b/src/backend/file-service/file-server/src/main/java/com/activepieces/file/service/FileServiceImpl.java deleted file mode 100644 index 84674a878a..0000000000 --- a/src/backend/file-service/file-server/src/main/java/com/activepieces/file/service/FileServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.activepieces.file.service; - -import com.activepieces.entity.sql.FileEntity; -import com.activepieces.file.repository.FileRepository; -import com.github.ksuid.Ksuid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; - -@Service -public class FileServiceImpl implements FileService { - - private final FileRepository fileRepository; - - @Autowired - public FileServiceImpl(FileRepository fileRepository) { - this.fileRepository = fileRepository; - } - - @Override - public FileEntity clone(Ksuid id) { - Optional file = fileRepository.findById(id); - return file.map(fileEntity -> fileRepository.save(fileEntity.toBuilder().id(Ksuid.newKsuid()).build())).orElse(null); - } - - @Override - public FileEntity save(Ksuid fileId, MultipartFile file) throws IOException { - FileEntity.FileEntityBuilder fileEntity = FileEntity.builder().id(Ksuid.newKsuid()); - if(Objects.nonNull(fileId)) { - Optional fn = fileRepository.findById(fileId); - if (fn.isPresent()) { - fileEntity = fn.get().toBuilder(); - } - } - return fileRepository.save(fileEntity - .contentType(file.getContentType()) - .data(file.getBytes()) - .size(file.getSize()) - .build()); - } - - @Override - public Optional getFileById(Ksuid id) { - return fileRepository.findById(id); - } - - @Override - public void delete(Ksuid id) { - fileRepository.deleteById(id); - } - -} diff --git a/src/backend/file-service/pom.xml b/src/backend/file-service/pom.xml deleted file mode 100644 index dddc5a8854..0000000000 --- a/src/backend/file-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - file-service - - - 11 - 11 - - pom - - file-client - file-server - - - diff --git a/src/backend/flow-service/flow-client/pom.xml b/src/backend/flow-service/flow-client/pom.xml deleted file mode 100644 index 79da4e45b5..0000000000 --- a/src/backend/flow-service/flow-client/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - flow-service - com.activepieces - 1.0 - - 1.0 - 4.0.0 - - flow-client - - - com.activepieces - trigger-client - 1.0 - compile - - - com.activepieces - project-client - 1.0 - compile - - - com.activepieces - variable-client - 1.0 - compile - - - com.activepieces - logging-client - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/FlowService.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/FlowService.java deleted file mode 100644 index 165fcf95b8..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/FlowService.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.activepieces.flow; - - -import com.activepieces.common.error.exception.CodeArtifactBuildFailure; -import com.activepieces.common.error.exception.FailedToObtainLockException; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionAlreadyLockedException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.model.FlowView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.github.ksuid.Ksuid; - -import java.io.IOException; -import java.util.Optional; - -public interface FlowService { - - SeekPage listByCollectionId(Ksuid integrationId, SeekPageRequest pageRequest) throws FlowNotFoundException, PermissionDeniedException; - - FlowView create(Ksuid projectId, Ksuid integrationId, FlowVersionView view) throws FlowVersionNotFoundException, PermissionDeniedException, ResourceNotFoundException, CodeArtifactBuildFailure, IOException; - - Optional getOptional(Ksuid id) throws PermissionDeniedException; - - FlowView get(Ksuid id) throws FlowNotFoundException, PermissionDeniedException; - - FlowView updateDraft(Ksuid flowId, FlowVersionView view) - throws FlowNotFoundException, FlowVersionNotFoundException, PermissionDeniedException, ResourceNotFoundException, FlowVersionAlreadyLockedException, CodeArtifactBuildFailure, IOException, FailedToObtainLockException; - - void delete(Ksuid id) throws FlowNotFoundException, ResourceNotFoundException, PermissionDeniedException; -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/FlowVersionService.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/FlowVersionService.java deleted file mode 100644 index 3ae627ccac..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/FlowVersionService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.flow; - -import com.activepieces.common.error.exception.flow.FlowVersionAlreadyLockedException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.flow.model.FlowVersionMetaView; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.github.ksuid.Ksuid; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -public interface FlowVersionService { - - FlowVersionView getLatest(Ksuid flowId) throws PermissionDeniedException; - Optional getOptional(Ksuid id) throws PermissionDeniedException; - - List listByFlowId(Ksuid flowId) throws PermissionDeniedException; - - FlowVersionView get(Ksuid id) throws FlowVersionNotFoundException, PermissionDeniedException; - - FlowVersionView persistPackagedFlow(FlowVersionView id); - - void lock(Ksuid id) throws FlowVersionAlreadyLockedException, FlowVersionNotFoundException, PermissionDeniedException; - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowMapper.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowMapper.java deleted file mode 100644 index 9530b70d06..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.activepieces.flow.mapper; - -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.entity.sql.Flow; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.model.FlowView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.github.ksuid.Ksuid; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.SubclassExhaustiveStrategy; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.UUID; - -@Mapper(subclassExhaustiveStrategy = SubclassExhaustiveStrategy.RUNTIME_EXCEPTION - , componentModel = "spring") -public abstract class FlowMapper { - - @Autowired - private FlowVersionService flowVersionService; - - @Mappings({ - @Mapping(target = "lastVersion", expression = "java(map(entity.getId()))"), - }) - public abstract FlowView toView(Flow entity); - - @Mappings({}) - public abstract Flow fromView(FlowView entity); - - public FlowVersionView map(Ksuid flowId) { - try { - return flowVersionService.getLatest(flowId); - } catch (PermissionDeniedException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowVersionMapper.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowVersionMapper.java deleted file mode 100644 index 3517f1d01a..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowVersionMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.activepieces.flow.mapper; - -import com.activepieces.entity.sql.FlowVersion; -import com.activepieces.entity.subdocuments.trigger.TriggerMetadata; -import com.activepieces.flow.model.FlowVersionMetaView; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.trigger.mapper.TriggerMapper; -import com.activepieces.trigger.model.TriggerMetadataView; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.springframework.beans.factory.annotation.Autowired; - - -@Mapper(componentModel = "spring") -public abstract class FlowVersionMapper { - - @Autowired private TriggerMapper triggerMapper; - - @Mappings({ - @Mapping(target = "trigger", expression = "java(mapTrigger(entity))"), - }) - public abstract FlowVersion fromView(FlowVersionView entity); - - @Mappings({}) - public abstract FlowVersionMetaView toMeta(FlowVersionView entity); - - @FlowVersionToView - @Mappings({ - @Mapping(target = "trigger", expression = "java(mapTrigger(entity))"), - }) - public abstract FlowVersionView toView(FlowVersion entity); - - public TriggerMetadataView mapTrigger(FlowVersion flowVersion) { - return triggerMapper.toView(flowVersion.getTrigger()); - } - - public TriggerMetadata mapTrigger(FlowVersionView flowVersion) { - return triggerMapper.fromView(flowVersion.getTrigger()); - } - - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowVersionToView.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowVersionToView.java deleted file mode 100644 index 9c871d133f..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/mapper/FlowVersionToView.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.flow.mapper; - -import org.mapstruct.Qualifier; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Qualifier -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.CLASS) -public @interface FlowVersionToView { -} \ No newline at end of file diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/CreateFlowRequest.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/CreateFlowRequest.java deleted file mode 100644 index 8858e9df94..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/CreateFlowRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.flow.model; - -import com.activepieces.trigger.model.TriggerMetadataView; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Builder(toBuilder = true) -public class CreateFlowRequest { - - @JsonProperty - @NotEmpty - private String displayName; - - @JsonProperty - private TriggerMetadataView trigger; -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowVersionMetaView.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowVersionMetaView.java deleted file mode 100644 index 3dd519b0ef..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowVersionMetaView.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.activepieces.flow.model; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.subdocuments.field.Variable; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import java.util.List; -import java.util.UUID; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class FlowVersionMetaView implements EntityMetadata { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid flowId; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private String displayName; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) - private EditState state; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private List<@Valid Variable> configs; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) - private long created; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) - private long updated; - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowVersionView.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowVersionView.java deleted file mode 100644 index 4e4a1eb50f..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowVersionView.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.activepieces.flow.model; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.common.error.ErrorResponse; -import com.activepieces.entity.enums.EditState; -import com.activepieces.trigger.model.TriggerMetadataView; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class FlowVersionView implements EntityMetadata { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid flowId; - - @JsonProperty - @NotEmpty - private String displayName; - - @JsonProperty - private TriggerMetadataView trigger; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Set errors; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private boolean valid; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) - private EditState state; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) private long created; - - @JsonProperty(access= JsonProperty.Access.READ_ONLY) private long updated; - - public Set getErrors(){ - if(Objects.isNull(errors)){ - return new HashSet<>(); - } - return new HashSet<>(errors); - } -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowView.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowView.java deleted file mode 100644 index d79144461b..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/FlowView.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.activepieces.flow.model; - -import com.activepieces.common.EntityMetadata; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.time.Instant; -import java.util.UUID; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@SuperBuilder(toBuilder = true) -public class FlowView implements EntityMetadata { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid collectionId; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private FlowVersionView lastVersion; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long created; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long updated; - - public void updateOrCreateDraft(FlowVersionView newDraft) { - this.lastVersion = newDraft; - } - - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/ManualFlowExecutionRequest.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/ManualFlowExecutionRequest.java deleted file mode 100644 index 69e69b7970..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/ManualFlowExecutionRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.activepieces.flow.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.validation.constraints.NotNull; -import java.util.Map; -import java.util.UUID; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class ManualFlowExecutionRequest { - - @JsonProperty - @NotNull - private Ksuid flowId; - - @JsonProperty - private Boolean async; - - @JsonProperty - @NotNull - private Ksuid collectionId; - - @JsonProperty - Map flowConfigs; - - @JsonProperty - @NotNull - Map payload; - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/TestFlowRequest.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/TestFlowRequest.java deleted file mode 100644 index b493ac41f7..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/model/TestFlowRequest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.flow.model; - - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Getter -public class TestFlowRequest { - - @JsonProperty - @NotNull - @Valid - private Map payload; - -} diff --git a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/util/FlowVersionUtil.java b/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/util/FlowVersionUtil.java deleted file mode 100644 index fc5f678f2a..0000000000 --- a/src/backend/flow-service/flow-client/src/main/java/com/activepieces/flow/util/FlowVersionUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.activepieces.flow.util; - -import com.activepieces.actions.model.action.ActionMetadataView; -import com.activepieces.actions.model.action.CodeActionMetadataView; -import com.activepieces.actions.model.action.ComponentActionMetadataView; -import com.activepieces.actions.model.action.LoopOnItemsActionMetadataView; -import com.activepieces.flow.model.FlowVersionView; -import lombok.experimental.UtilityClass; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -@UtilityClass -public class FlowVersionUtil { - - public static List findAllStepsWithArtifact(FlowVersionView flowVersionView) { - return findAllActions(flowVersionView).stream() - .filter(f -> f instanceof CodeActionMetadataView) - .map(f -> (CodeActionMetadataView) f) - .collect(Collectors.toList()); - } - - public static List findComponentActions(FlowVersionView flowVersionView) { - return findAllActions(flowVersionView).stream() - .filter(f -> f instanceof ComponentActionMetadataView) - .map(f -> (ComponentActionMetadataView) f) - .collect(Collectors.toList()); - } - - public static List findCodeActions(FlowVersionView flowVersionView) { - return findAllActions(flowVersionView).stream() - .filter(f -> f instanceof CodeActionMetadataView) - .map(f -> (CodeActionMetadataView) f) - .collect(Collectors.toList()); - } - - public static List findAllActions(FlowVersionView flowVersionView) { - List actions = new ArrayList<>(); - if (Objects.nonNull(flowVersionView.getTrigger())) { - actions = traverseAction(flowVersionView.getTrigger().getNextAction()); - } - return actions; - } - - public static List traverseAction(ActionMetadataView actionMetadataView) { - if (Objects.isNull(actionMetadataView)) { - return Collections.emptyList(); - } - List actions = new ArrayList<>(); - actions.add(actionMetadataView); - actions.addAll(traverseAction(actionMetadataView.getNextAction())); - if (actionMetadataView instanceof LoopOnItemsActionMetadataView) { - LoopOnItemsActionMetadataView loopOnItemsActionMetadataView = - (LoopOnItemsActionMetadataView) actionMetadataView; - actions.addAll(traverseAction(loopOnItemsActionMetadataView.getFirstLoopAction())); - } - return actions; - } - -} diff --git a/src/backend/flow-service/flow-server/pom.xml b/src/backend/flow-service/flow-server/pom.xml deleted file mode 100644 index c8d8600e0f..0000000000 --- a/src/backend/flow-service/flow-server/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - flow-service - com.activepieces - 1.0 - - 1.0 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - - - - - 4.0.0 - - flow-server - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - authentication-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - com.activepieces - project-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - com.activepieces - logging-client - 1.0 - compile - - - com.activepieces - executor-client - 1.0 - compile - - - com.activepieces - worker-client - 1.0 - compile - - - com.activepieces - file-client - 1.0 - compile - - - com.activepieces - lock-service - 1.0 - compile - - - com.activepieces - component-service - 1.0 - compile - - - diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/FlowServiceImpl.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/FlowServiceImpl.java deleted file mode 100644 index 56f823ca39..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/FlowServiceImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.activepieces.flow; - -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.FailedToObtainLockException; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionAlreadyLockedException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.pagination.PageFilter; -import com.activepieces.common.pagination.PageOperator; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.sql.Flow; -import com.activepieces.entity.sql.FlowVersion; -import com.activepieces.entity.sql.Instance; -import com.activepieces.flow.mapper.FlowMapper; -import com.activepieces.flow.model.CreateFlowRequest; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.model.FlowView; -import com.activepieces.flow.repository.FlowRepository; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.lock.LockService; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.jdbc.lock.JdbcLockRegistry; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.time.Duration; -import java.time.Instant; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; - - -@Log4j2 -@Service -public class FlowServiceImpl implements FlowService { - - private final FlowRepository repository; - private final FlowVersionServiceImpl flowVersionService; - private final FlowMapper flowMapper; - private final LockService lockService; - private final PermissionService permissionService; - - @Autowired - public FlowServiceImpl( - final FlowRepository repository, - final LockService lockService, - final FlowVersionServiceImpl flowVersionService, - final FlowMapper flowMapper, - final PermissionService permissionService) { - this.repository = repository; - this.lockService = lockService; - this.flowVersionService = flowVersionService; - this.flowMapper = flowMapper; - this.permissionService = permissionService; - } - - @Override - public SeekPage listByCollectionId(Ksuid integrationId, SeekPageRequest request) - throws PermissionDeniedException { - permissionService.requiresPermission(integrationId, Permission.READ_FLOW); - final List filters = List.of(new PageFilter(Flow.COLLECTION_ID, PageOperator.EQUAL, integrationId)); - return repository.findPageAsc(filters, request).convert(flowMapper::toView); - - } - - @Override - public FlowView create(Ksuid projectId, Ksuid collectionId, FlowVersionView flowVersionView) - throws PermissionDeniedException, ResourceNotFoundException, IOException { - permissionService.requiresPermission(collectionId, Permission.WRITE_FLOW); - Ksuid flowId = Ksuid.newKsuid(); - - FlowView flowView = - FlowView.builder() - .id(flowId) - .collectionId(collectionId) - .build(); - Flow savedFlowView = repository.save(flowMapper.fromView(flowView)); - permissionService.createResourceWithParent(flowId, collectionId, ResourceType.FLOW); - - // We need to save the flow then the version in order to attach it to the parent as resource - FlowVersionView versionView = - flowVersionService.createNew(flowId, flowVersionView); - return flowMapper.toView(savedFlowView); - } - - @Override - public Optional getOptional(Ksuid id) throws PermissionDeniedException { - Optional flowMetadataOptional = repository.findById(id); - if (flowMetadataOptional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(id, Permission.READ_FLOW); - return flowMetadataOptional.map(flowMapper::toView); - } - - @Override - public FlowView get(Ksuid id) throws FlowNotFoundException, PermissionDeniedException { - Optional flowMetadataOptional = getOptional(id); - if (flowMetadataOptional.isEmpty()) { - throw new FlowNotFoundException(id); - } - return flowMetadataOptional.get(); - } - - @Override - public FlowView updateDraft(Ksuid flowId, FlowVersionView request) - throws FlowNotFoundException, FlowVersionNotFoundException, PermissionDeniedException, ResourceNotFoundException, - FlowVersionAlreadyLockedException, IOException, FailedToObtainLockException { - Lock lock = lockService.tryLock(flowId.toInspectString(), Duration.ofMinutes(5)); - try { - permissionService.requiresPermission(flowId, Permission.WRITE_FLOW); - FlowView flow = get(flowId); - FlowVersionView draft = flow.getLastVersion(); - if (flow.getLastVersion().getState().equals(EditState.LOCKED)) { - draft = cloneVersion(flowId, draft).getLastVersion(); - } - FlowVersionView updatedVersion = flowVersionService.update(draft.getId(), request); - flow.updateOrCreateDraft(updatedVersion); - return saveFromView(flow); - }finally { - lock.unlock();; - } - } - - private FlowView cloneVersion(Ksuid flowId, FlowVersionView draftVersion) - throws FlowNotFoundException, PermissionDeniedException, - ResourceNotFoundException, IOException { - FlowView flow = get(flowId); - FlowVersionView clonedVersion = - flowVersionService.createNew(flowId, draftVersion); - flow.updateOrCreateDraft(clonedVersion); - return saveFromView(flow); - } - - private FlowView saveFromView(FlowView flow) { - return flowMapper.toView(repository.save(flowMapper.fromView(flow))); - } - - @Override - public void delete(Ksuid id) throws FlowNotFoundException, PermissionDeniedException { - permissionService.requiresPermission(id, Permission.WRITE_FLOW); - if (!repository.existsById(id)) { - throw new FlowNotFoundException(id); - } - repository.deleteById(id); - } -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/FlowVersionServiceImpl.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/FlowVersionServiceImpl.java deleted file mode 100644 index 6a506d42e6..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/FlowVersionServiceImpl.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.activepieces.flow; - -import com.activepieces.actions.model.action.CodeActionMetadataView; -import com.activepieces.actions.model.action.settings.CodeSettingsView; -import com.activepieces.cache.ConditionalCache; -import com.activepieces.common.error.exception.ConstraintsException; -import com.activepieces.common.error.exception.flow.FlowVersionAlreadyLockedException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.entity.enums.EditState; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.sql.FileEntity; -import com.activepieces.entity.sql.FlowVersion; -import com.activepieces.file.service.FileService; -import com.activepieces.flow.mapper.FlowVersionMapper; -import com.activepieces.flow.model.FlowVersionMetaView; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.repository.FlowVersionRepository; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ser.std.FileSerializer; -import com.github.ksuid.Ksuid; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Log4j2 -@Service -public class FlowVersionServiceImpl implements FlowVersionService { - - private final FlowVersionRepository flowVersionRepository; - private final PermissionService permissionService; - private final FlowVersionMapper flowVersionMapper; - private final FileService fileService; - private final ConditionalCache> conditionalCache; - - @Autowired - public FlowVersionServiceImpl( - final FlowVersionRepository flowVersionRepository, - final PermissionService permissionService, - final FileService fileService, - final FlowVersionMapper flowVersionMapper) { - Function> generatorFunction = flowVersionRepository::findById; - Function, Boolean> cacheCondition = - flowVersionOptional -> - flowVersionOptional.isPresent() - && flowVersionOptional.get().getState().equals(EditState.LOCKED); - this.fileService = fileService; - this.conditionalCache = new ConditionalCache<>(generatorFunction, cacheCondition); - this.flowVersionMapper = flowVersionMapper; - this.flowVersionRepository = flowVersionRepository; - this.permissionService = permissionService; - } - - public FlowVersionView createNew(Ksuid flowId, FlowVersionView newVersion) - throws ResourceNotFoundException, IOException { - Ksuid newVersionIUd = Ksuid.newKsuid(); - newVersion = newVersion.toBuilder().id(newVersionIUd).build(); - newVersion = uploadArtifacts(newVersion, true); - FlowVersionView savedFlowVersion = - saveFromView( - newVersion.toBuilder() - .flowId(flowId) - .state(EditState.DRAFT) - .build()); - - permissionService.createResourceWithParent( - savedFlowVersion.getId(), savedFlowVersion.getFlowId(), ResourceType.FLOW_VERSION); - return savedFlowVersion; - } - - public FlowVersionView update(Ksuid flowVersionId, FlowVersionView newVersion) - throws FlowVersionAlreadyLockedException, FlowVersionNotFoundException, - PermissionDeniedException, IOException { - FlowVersionView currentVersion = get(flowVersionId); - if (currentVersion.getState().equals(EditState.LOCKED)) { - throw new FlowVersionAlreadyLockedException(flowVersionId); - } - newVersion = uploadArtifacts(newVersion, false); - - FlowVersionView savedVersion = saveFromView( - currentVersion.toBuilder() - .trigger(newVersion.getTrigger()) - .errors(newVersion.getErrors()) - .valid(newVersion.isValid()) - .displayName(newVersion.getDisplayName()) - .state( - Objects.isNull(newVersion.getState()) - ? currentVersion.getState() - : newVersion.getState()) - .build()); - - return savedVersion; - } - - @Override - public FlowVersionView getLatest(Ksuid flowId) throws PermissionDeniedException { - permissionService.requiresPermission(flowId, Permission.READ_FLOW); - FlowVersion flowVersion = flowVersionRepository.findFirstByFlowIdOrderByIdDesc(flowId); - return flowVersionMapper.toView(flowVersion); - } - - @Override - public Optional getOptional(Ksuid id) throws PermissionDeniedException { - Optional optional = conditionalCache.get(id); - if (optional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(optional.get().getFlowId(), Permission.READ_FLOW); - FlowVersionView flowVersionView = flowVersionMapper.toView(optional.get()); - return Optional.of(flowVersionView); - } - - @Override - public List listByFlowId(Ksuid flowId) throws PermissionDeniedException { - List flowVersionMetaViews = - flowVersionRepository.findAllByFlowIdOrderByCreated(flowId); - if (!flowVersionMetaViews.isEmpty()) { - permissionService.requiresPermission(flowVersionMetaViews.get(0).getFlowId(), Permission.READ_FLOW); - } - return flowVersionMetaViews.stream() - .map(flow -> flowVersionMapper.toMeta(flowVersionMapper.toView(flow))) - .collect(Collectors.toList()); - } - - - - @Override - public FlowVersionView get(Ksuid id) - throws FlowVersionNotFoundException, PermissionDeniedException { - return getOptional(id).orElseThrow(() -> new FlowVersionNotFoundException(id)); - } - - @Override - public FlowVersionView persistPackagedFlow(FlowVersionView flowVersionView) { - return saveFromView(flowVersionView); - } - - @Override - public void lock(Ksuid id) - throws FlowVersionAlreadyLockedException, FlowVersionNotFoundException, - PermissionDeniedException { - FlowVersionView currentVersion = get(id); - if (!currentVersion.isValid()) { - throw new ConstraintsException(currentVersion.getErrors()); - } - if (currentVersion.getState().equals(EditState.LOCKED)) { - throw new FlowVersionAlreadyLockedException(id); - } - permissionService.requiresPermission(id, Permission.WRITE_FLOW); - saveFromView(currentVersion.toBuilder().state(EditState.LOCKED).build()); - } - - private FlowVersionView uploadArtifacts(final FlowVersionView newVersion, - final boolean clone) throws IOException { - final FlowVersionView clonedVersion = newVersion.toBuilder().build(); - List codeActionsWithArtifact = - FlowVersionUtil.findCodeActions(clonedVersion); - for (CodeActionMetadataView action : codeActionsWithArtifact) { - final CodeSettingsView codeSettings = action.getSettings(); - if(clone){ - if(Objects.nonNull(codeSettings.getArtifactSourceId())){ - FileEntity clonedFile = fileService.clone(codeSettings.getArtifactSourceId()); - codeSettings.setArtifactSourceId(clonedFile.getId()); - - if(Objects.nonNull(codeSettings.getArtifactPackagedId())){ - FileEntity packagedClonedFile = fileService.clone(codeSettings.getArtifactPackagedId()); - codeSettings.setArtifactPackagedId(packagedClonedFile.getId()); - } - } - } - - if(Objects.nonNull(codeSettings.getNewArtifactToUploadFile())){ - FileEntity file = fileService.save(codeSettings.getArtifactSourceId(), codeSettings.getNewArtifactToUploadFile().toMultiFile()); - codeSettings.setArtifactSourceId(file.getId()); - codeSettings.setArtifactPackagedId(null); - } - } - return clonedVersion; - } - - private FlowVersionView saveFromView(FlowVersionView FlowVersionView) { - FlowVersion savedVersion = - flowVersionRepository.save(flowVersionMapper.fromView(FlowVersionView)); - - return flowVersionMapper.toView(savedVersion); - } -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/controller/FlowController.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/controller/FlowController.java deleted file mode 100644 index 23c4d3157a..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/controller/FlowController.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.activepieces.flow.controller; - -import com.activepieces.action.FlowPublisherService; -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.common.error.exception.ConstraintsException; -import com.activepieces.common.error.exception.collection.CollectionNotFoundException; -import com.activepieces.common.error.exception.flow.FlowExecutionInternalError; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.pagination.Cursor; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.common.utils.ArtifactUtils; -import com.activepieces.flow.FlowService; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.CreateFlowRequest; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.model.FlowView; -import com.activepieces.flow.model.TestFlowRequest; -import com.activepieces.flow.validator.FlowVersionValidator; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.CollectionService; -import com.activepieces.piece.client.model.CollectionView; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.Valid; -import java.util.*; - -@RestController -@Hidden -public class FlowController { - - private final FlowService flowService; - private final FlowVersionService flowVersionService; - private final CollectionService collectionService; - private final FlowVersionValidator flowVersionValidator; - private final FlowPublisherService flowPublisherService; - - @Autowired - public FlowController( - @NonNull final FlowService flowService, - @NonNull final FlowVersionService flowVersionService, - @NonNull final CollectionService collectionService, - @NonNull final FlowPublisherService flowPublisherService, - @NonNull final FlowVersionValidator flowVersionValidator) { - this.flowService = flowService; - this.flowPublisherService = flowPublisherService; - this.flowVersionService = flowVersionService; - this.collectionService = collectionService; - this.flowVersionValidator = flowVersionValidator; - } - - @GetMapping("/collections/{collectionId}/flows") - public ResponseEntity> list( - @PathVariable Ksuid collectionId, - @RequestParam(value = "cursor", required = false) Cursor cursor, - @RequestParam(value = "limit", defaultValue = "10", required = false) int limit) - throws CollectionNotFoundException, PermissionDeniedException, FlowNotFoundException { - return ResponseEntity.ok( - flowService.listByCollectionId( - collectionId, new SeekPageRequest(cursor, limit))); - } - - @GetMapping("/flows/{flowId}") - public ResponseEntity get(@PathVariable Ksuid flowId) - throws FlowNotFoundException, PermissionDeniedException, CollectionNotFoundException { - return ResponseEntity.ok(flowService.get(flowId)); - } - - @PostMapping("/collections/{collectionId}/flows") - public ResponseEntity create( - @PathVariable Ksuid collectionId, - @RequestPart(value = "flow") @Valid CreateFlowRequest createFlowRequest, - @RequestPart(value = "artifacts", required = false) MultipartFile[] files) - throws Exception { - List fileList = - Objects.isNull(files) ? Collections.emptyList() : Arrays.asList(files); - List artifactFiles = ArtifactUtils.toArtifacts(fileList); - FlowVersionView finalRequest = - flowVersionValidator.constructRequest( - collectionId, null, FlowVersionView.builder().displayName(createFlowRequest.getDisplayName()).trigger(createFlowRequest.getTrigger()).build(), artifactFiles); - CollectionView collectionView = collectionService.get(collectionId); - return ResponseEntity.ok( - flowService.create( - collectionView.getProjectId(), - collectionId, finalRequest)); - } - - @PutMapping( - value = "/flows/{flowId}", - consumes = {"multipart/form-data"}) - public ResponseEntity update( - @PathVariable Ksuid flowId, - @RequestPart("flow") @Valid FlowVersionView versionRequestBody, - @RequestPart(value = "artifacts", required = false) MultipartFile[] files) - throws Exception { - List fileList = - (Objects.isNull(files) ? Collections.emptyList() : Arrays.asList(files)); - List artifactFiles = ArtifactUtils.toArtifacts(fileList); - FlowVersionView constructedRequest = - flowVersionValidator.constructRequest(null, flowId, versionRequestBody, artifactFiles); - return ResponseEntity.ok(flowService.updateDraft(flowId, constructedRequest)); - } - - @DeleteMapping("/flows/{flowId}") - public ResponseEntity delete(@PathVariable Ksuid flowId) - throws FlowNotFoundException, PermissionDeniedException, ResourceNotFoundException { - flowService.delete(flowId); - return ResponseEntity.ok().build(); - } - - @PostMapping("/collection-versions/{collectionVersionId}/flow-versions/{flowVersionId}/runs") - public ResponseEntity execute( - @PathVariable Ksuid collectionVersionId, - @PathVariable Ksuid flowVersionId, - @RequestBody @Valid TestFlowRequest request) - throws PermissionDeniedException, FlowVersionNotFoundException, - FlowExecutionInternalError, ResourceNotFoundException { - FlowVersionView flowVersionView = flowVersionService.get(flowVersionId); - if (!flowVersionView.isValid()) { - throw new ConstraintsException(flowVersionView.getErrors()); - } - InstanceRunView response = - flowPublisherService.executeTest( - collectionVersionId, flowVersionId, request.getPayload()); - return ResponseEntity.ok(response); - } - -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/controller/FlowVersionController.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/controller/FlowVersionController.java deleted file mode 100644 index 5d1d9c09d9..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/controller/FlowVersionController.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.activepieces.flow.controller; - -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.FlowVersionMetaView; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.UUID; - -@RestController -@Hidden -@RequestMapping -public class FlowVersionController { - - private final FlowVersionService flowVersionService; - - @Autowired - public FlowVersionController( - @NonNull final FlowVersionService flowVersionService) { - this.flowVersionService = flowVersionService; - } - - @GetMapping("/flows/versions/{versionId}") - public ResponseEntity get( - @PathVariable("versionId") Ksuid versionId) - throws PermissionDeniedException, FlowVersionNotFoundException { - FlowVersionView versionView = flowVersionService.get(versionId); - return ResponseEntity.ok(versionView); - } - - @GetMapping("/flows/{flowId}/versions") - public ResponseEntity> list( - @PathVariable("flowId") Ksuid flowId) - throws PermissionDeniedException, FlowVersionNotFoundException { - return ResponseEntity.ok(flowVersionService.listByFlowId(flowId)); - } - - -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/repository/FlowRepository.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/repository/FlowRepository.java deleted file mode 100644 index 166a0b067a..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/repository/FlowRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.activepieces.flow.repository; - -import com.activepieces.common.pagination.PaginationRepository; -import com.activepieces.entity.sql.Flow; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; - -import java.util.UUID; - -public interface FlowRepository extends CrudRepository , PaginationRepository { - -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/repository/FlowVersionRepository.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/repository/FlowVersionRepository.java deleted file mode 100644 index c5eb768cfe..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/repository/FlowVersionRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.flow.repository; - -import com.activepieces.entity.sql.CollectionVersion; -import com.activepieces.entity.sql.FlowVersion; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; - -import java.util.List; -import java.util.UUID; - -public interface FlowVersionRepository extends CrudRepository { - - FlowVersion findFirstByFlowIdOrderByIdDesc(Ksuid collectionId); - - List findAllByFlowIdOrderByCreated(Ksuid flowId); -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/FlowVersionRequestBuilder.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/FlowVersionRequestBuilder.java deleted file mode 100644 index 95b2a9ebc0..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/FlowVersionRequestBuilder.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.activepieces.flow.validator; - -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.flow.model.FlowVersionView; -import com.github.ksuid.Ksuid; - -import java.util.List; - -public interface FlowVersionRequestBuilder { - - FlowVersionView construct(Ksuid projectId, - Ksuid collectionId, FlowVersionView newVersion, List artifactFileList, FlowVersionView draftVersion) throws Exception; -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/FlowVersionValidator.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/FlowVersionValidator.java deleted file mode 100644 index 12d32c5d88..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/FlowVersionValidator.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.activepieces.flow.validator; - -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.component.ComponentService; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.flow.FlowService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.validator.constraints.*; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.github.ksuid.Ksuid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.validation.Validator; -import java.util.List; -import java.util.Objects; - -@Service -public class FlowVersionValidator { - - private final PermissionService permissionService; - private final UniqueStepsNameValidator uniqueStepsNameValidator; - private final CodeArtifactsValidator requiredCodeArtifactsValidator; - private final StepsValidator stepsValidator; - private final FlowValidValidator flowValidValidator; - private final FlowService flowService; - private final ErrorServiceHandler errorServiceHandler; - - @Autowired - public FlowVersionValidator( - PermissionService permissionService, - Validator validator, - ComponentService componentService, - ErrorServiceHandler errorServiceHandler, - FlowService flowService) { - this.errorServiceHandler = errorServiceHandler; - this.flowService = flowService; - this.permissionService = permissionService; - this.uniqueStepsNameValidator = new UniqueStepsNameValidator(); - this.flowValidValidator = new FlowValidValidator(); - this.stepsValidator = new StepsValidator(validator, componentService); - this.requiredCodeArtifactsValidator = new CodeArtifactsValidator(); - } - - public FlowVersionView constructRequest( - Ksuid collectionId, Ksuid flowId, FlowVersionView request, List files) - throws Exception { - if (Objects.isNull(collectionId)) { - collectionId = - permissionService - .getFirstResourceParentWithType(flowId, ResourceType.COLLECTION) - .getResourceId(); - } - Ksuid projectId = - permissionService - .getFirstResourceParentWithType(collectionId, ResourceType.PROJECT) - .getResourceId(); - - FlowVersionView draftVersion = getDraftVersion(flowId); - List flowVersionRequestBuilders = - List.of( - uniqueStepsNameValidator, - requiredCodeArtifactsValidator, - stepsValidator, - flowValidValidator); - FlowVersionView finalVersion = request.toBuilder().build(); - for (FlowVersionRequestBuilder flowVersionRequestBuilder : flowVersionRequestBuilders) { - finalVersion = - flowVersionRequestBuilder.construct( - projectId, collectionId, finalVersion, files, draftVersion); - } - - return finalVersion; - } - - private FlowVersionView getDraftVersion(Ksuid flowId) { - if (Objects.nonNull(flowId)) { - try { - return flowService.get(flowId).getLastVersion(); - } catch (FlowNotFoundException | PermissionDeniedException e) { - throw errorServiceHandler.createInternalError(e); - } - } - return null; - } -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/CodeArtifactsValidator.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/CodeArtifactsValidator.java deleted file mode 100644 index c07ea7956a..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/CodeArtifactsValidator.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.activepieces.flow.validator.constraints; - -import com.activepieces.actions.model.action.CodeActionMetadataView; -import com.activepieces.actions.model.action.settings.CodeSettingsView; -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponse; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.flow.validator.FlowVersionRequestBuilder; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import org.apache.commons.io.FilenameUtils; - -import java.util.*; - -@AllArgsConstructor -public class CodeArtifactsValidator implements FlowVersionRequestBuilder { - - @Override - public FlowVersionView construct( - Ksuid projectId, - Ksuid collectionId, - FlowVersionView flowVersion, - List artifactFileList, - FlowVersionView currentVersion) { - List codeActions = - FlowVersionUtil.findCodeActions(flowVersion); - Set errorResponses = flowVersion.getErrors(); - for (CodeActionMetadataView codeAction : codeActions) { - if (Objects.isNull(codeAction.getSettings())) { - continue; - } - CodeSettingsView codeSettings = codeAction.getSettings(); - CodeSettingsView oldCodeSettings = getArtifactFromCurrentVersion(currentVersion, codeAction.getName()); - if(Objects.nonNull(oldCodeSettings)){ - codeSettings.setArtifactSourceId(oldCodeSettings.getArtifactSourceId()); - codeSettings.setArtifactPackagedId(oldCodeSettings.getArtifactPackagedId()); - } - Optional file = - artifactFileList.stream() - .filter( - f -> - Objects.equals( - FilenameUtils.removeExtension(f.getOriginalFileName()), - codeAction.getName())) - .findFirst(); - if (file.isPresent()) { - codeSettings.setNewArtifactToUploadFile(file.get()); - continue; - } - if (Objects.nonNull(codeSettings.getArtifactSourceId())) { - continue; - } - errorResponses.add( - new ErrorResponse( - String.format("Missing artifact for action name=%s", codeAction.getName()), - ErrorCode.MISSING_CODE_ARTIFACTS)); - codeAction.setValid(false); - } - return flowVersion.toBuilder().errors(errorResponses).build(); - } - - - private CodeSettingsView getArtifactFromCurrentVersion(FlowVersionView currentVersion, String stepName) { - if (Objects.isNull(currentVersion)) { - return null; - } - Optional codeActionViewMetadataView = - FlowVersionUtil.findCodeActions(currentVersion).stream() - .filter(f -> f.getName().equals(stepName)) - .findFirst(); - if (codeActionViewMetadataView.isEmpty()) { - return null; - } - CodeSettingsView codeSettings = codeActionViewMetadataView.get().getSettings(); - if (Objects.isNull(codeSettings)) { - return null; - } - return codeSettings; - } -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/FlowValidValidator.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/FlowValidValidator.java deleted file mode 100644 index eeb2417bd4..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/FlowValidValidator.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.activepieces.flow.validator.constraints; - -import com.activepieces.actions.model.action.ActionMetadataView; -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.flow.validator.FlowVersionRequestBuilder; -import com.github.ksuid.Ksuid; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -public class FlowValidValidator implements FlowVersionRequestBuilder { - - @Override - public FlowVersionView construct( - Ksuid projectId, - Ksuid collectionId, - FlowVersionView flowVersion, - List artifactFileList, - FlowVersionView draftVersion) { - List actionsValidity = - FlowVersionUtil.findAllActions(flowVersion).stream() - .map(ActionMetadataView::isValid) - .collect(Collectors.toList()); - boolean valid = flowVersion.getErrors().size() == 0; - for (boolean actionValid : actionsValidity) { - valid = valid && actionValid; - } - if(Objects.nonNull(flowVersion.getTrigger())){ - valid = valid && flowVersion.getTrigger().isValid(); - } - return flowVersion.toBuilder().valid(valid).build(); - } -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/StepsValidator.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/StepsValidator.java deleted file mode 100644 index 17ec425fd7..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/StepsValidator.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.activepieces.flow.validator.constraints; - -import com.activepieces.actions.model.action.ActionMetadataView; -import com.activepieces.actions.model.action.ComponentActionMetadataView; -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.component.ComponentService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.flow.validator.FlowVersionRequestBuilder; -import com.activepieces.trigger.model.ComponentTriggerMetadataView; -import com.activepieces.trigger.model.EmptyTriggerMetadataView; -import com.activepieces.trigger.model.TriggerMetadataView; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; - -import javax.validation.Validator; -import java.util.List; -import java.util.Objects; - -@AllArgsConstructor -public class StepsValidator implements FlowVersionRequestBuilder { - - private final Validator validator; - private final ComponentService componentService; - - @Override - public FlowVersionView construct( - Ksuid projectId, - Ksuid collectionId, - FlowVersionView flowVersion, List artifactFileList, FlowVersionView draftVersion) { - if (Objects.isNull(flowVersion.getTrigger())) { - return flowVersion; - } - - TriggerMetadataView triggerMetadata = flowVersion.getTrigger(); - - triggerMetadata.setValid( - validator.validate(triggerMetadata).size() == 0 - && !(triggerMetadata instanceof EmptyTriggerMetadataView)); - if (triggerMetadata instanceof ComponentTriggerMetadataView) { - final ComponentTriggerMetadataView componentTrigger = (ComponentTriggerMetadataView) triggerMetadata; - triggerMetadata.setValid(triggerMetadata.isValid() && componentService.validateConfig(componentTrigger.getSettings().getComponentName(), - null, componentTrigger.getSettings().getTriggerName(), componentTrigger.getSettings().getInput())); - } - List actionMetadataViewList = FlowVersionUtil.findAllActions(flowVersion); - for (ActionMetadataView actionMetadataView : actionMetadataViewList) { - actionMetadataView.setValid(validator.validate(actionMetadataView).size() == 0); - if (actionMetadataView instanceof ComponentActionMetadataView) { - final ComponentActionMetadataView componentAction = (ComponentActionMetadataView) actionMetadataView; - actionMetadataView.setValid(actionMetadataView.isValid() - && componentService.validateConfig(componentAction.getSettings().getComponentName(), - componentAction.getSettings().getActionName(), null, componentAction.getSettings().getInput())); - } - } - return flowVersion; - } -} diff --git a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/UniqueStepsNameValidator.java b/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/UniqueStepsNameValidator.java deleted file mode 100644 index 92b80dc407..0000000000 --- a/src/backend/flow-service/flow-server/src/main/java/com/activepieces/flow/validator/constraints/UniqueStepsNameValidator.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.activepieces.flow.validator.constraints; - -import com.activepieces.actions.model.action.ActionMetadataView; -import com.activepieces.common.model.ArtifactFile; -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponse; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.flow.validator.FlowVersionRequestBuilder; -import com.github.ksuid.Ksuid; -import org.apache.commons.lang.StringUtils; - -import java.util.*; -import java.util.stream.Collectors; - -public class UniqueStepsNameValidator implements FlowVersionRequestBuilder { - - @Override - public FlowVersionView construct( - Ksuid projectId, - Ksuid collectionId, - FlowVersionView flowVersion, - List artifactFileList, - FlowVersionView draftVersion) { - List actionNames = - FlowVersionUtil.findAllActions(flowVersion).stream() - .map(ActionMetadataView::getName) - .collect(Collectors.toList()); - if (Objects.nonNull(flowVersion.getTrigger())) { - actionNames.add(flowVersion.getTrigger().getName()); - } - Set uniqueCenters = new HashSet<>(actionNames); - Set errorResponses = flowVersion.getErrors(); - uniqueCenters.remove(null); - if (uniqueCenters.size() != actionNames.size()) { - errorResponses.add( - new ErrorResponse( - String.format( - "Actions names are not unique %s", StringUtils.join(uniqueCenters, ',')), - ErrorCode.DUPLICATED_STEP_NAME)); - } - return flowVersion.toBuilder().errors(errorResponses).build(); - } -} diff --git a/src/backend/flow-service/pom.xml b/src/backend/flow-service/pom.xml deleted file mode 100644 index 878dc40045..0000000000 --- a/src/backend/flow-service/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - flow-service - pom - 1.0 - - flow-server - flow-client - - - diff --git a/src/backend/guardian-service/guardian-client/pom.xml b/src/backend/guardian-service/guardian-client/pom.xml deleted file mode 100644 index f01f096d57..0000000000 --- a/src/backend/guardian-service/guardian-client/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - guardian-client - - - entities - com.activepieces - compile - 1.0 - - - - 4.0.0 - - guardian-service - com.activepieces - 1.0 - - - - diff --git a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/PermissionService.java b/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/PermissionService.java deleted file mode 100644 index 68e5cc51b1..0000000000 --- a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/PermissionService.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.activepieces.guardian.client; - -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.enums.Role; -import com.activepieces.entity.sql.Resource; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.github.ksuid.Ksuid; -import lombok.NonNull; - -import java.util.UUID; -import java.util.concurrent.Future; - - -public interface PermissionService { - - void requiresPermission( - @NonNull final Ksuid resourceId, - @NonNull final Permission permission) - throws PermissionDeniedException; - - boolean hasPermission( - @NonNull Ksuid resourceId, @NonNull Permission permission); - - void grantRole( - @NonNull final Ksuid resourceId, @NonNull final Ksuid roleResourceId, @NonNull final Role role); - - Resource getFirstResourceParentWithType(Ksuid resourceId, ResourceType resourceType) throws ResourceNotFoundException; - - Resource createResource(Ksuid id, ResourceType resourceType); - - Resource createResourceWithParent(Ksuid id, Ksuid parentId, ResourceType resourceType) throws ResourceNotFoundException; - - void deleteOrAchiveResource(Ksuid resourceId) throws ResourceNotFoundException; - - Future deleteResourceAsync(Ksuid resourceId) throws ResourceNotFoundException; - - - Resource getResource(Ksuid resourceId) throws ResourceNotFoundException; -} diff --git a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/ResourceSubscriber.java b/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/ResourceSubscriber.java deleted file mode 100644 index 61e0f44e5b..0000000000 --- a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/ResourceSubscriber.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.activepieces.guardian.client; - -import com.activepieces.common.Subscriber; -import com.activepieces.entity.sql.Resource; -import com.activepieces.guardian.client.model.ResourceEventType; - -public interface ResourceSubscriber extends Subscriber { - -} diff --git a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/exception/PermissionDeniedException.java b/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/exception/PermissionDeniedException.java deleted file mode 100644 index 9596235e42..0000000000 --- a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/exception/PermissionDeniedException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.guardian.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; - -public class PermissionDeniedException extends Exception implements ErrorResponseException { - - public PermissionDeniedException(String message) { - super(message); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.PERMISSION_DENIED; - } -} diff --git a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/exception/ResourceNotFoundException.java b/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/exception/ResourceNotFoundException.java deleted file mode 100644 index 50346ac070..0000000000 --- a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/exception/ResourceNotFoundException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.guardian.client.exception; - -import com.github.ksuid.Ksuid; - - -public class ResourceNotFoundException extends Exception { - - private final Ksuid id; - - public ResourceNotFoundException(Ksuid id) { - super(String.format("Resource with Id=%s not found", id.toString())); - this.id = id; - } - - public Ksuid getId(){ - return this.id; - } - -} diff --git a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/model/ResourceEventType.java b/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/model/ResourceEventType.java deleted file mode 100644 index 4d5481210c..0000000000 --- a/src/backend/guardian-service/guardian-client/src/main/java/com/activepieces/guardian/client/model/ResourceEventType.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.activepieces.guardian.client.model; - -public enum ResourceEventType { - DELETE - -} diff --git a/src/backend/guardian-service/guardian-server/pom.xml b/src/backend/guardian-service/guardian-server/pom.xml deleted file mode 100644 index 34de2f1221..0000000000 --- a/src/backend/guardian-service/guardian-server/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - guardian-server - - - - maven-compiler-plugin - - 11 - 11 - - org.apache.maven.plugins - - - - - - - guardian-client - com.activepieces - compile - 1.0 - - - entities - com.activepieces - compile - 1.0 - - - com.activepieces - authentication-client - 1.0 - compile - - - 4.0.0 - - guardian-service - com.activepieces - 1.0 - - - - diff --git a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/ResourcePublisher.java b/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/ResourcePublisher.java deleted file mode 100644 index 2c8843f927..0000000000 --- a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/ResourcePublisher.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.guardian.server; - -import com.activepieces.common.Publisher; -import com.activepieces.entity.sql.Resource; -import com.activepieces.guardian.client.ResourceSubscriber; -import com.activepieces.guardian.client.model.ResourceEventType; -import lombok.NonNull; - -import java.util.List; - - -public class ResourcePublisher extends Publisher { - - public ResourcePublisher(@NonNull final List subscriberList){ - for(ResourceSubscriber subscriber: subscriberList){ - addSubscriber(subscriber); - } - } - -} diff --git a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/repository/ResourceAccessRepository.java b/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/repository/ResourceAccessRepository.java deleted file mode 100644 index 15a08223c8..0000000000 --- a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/repository/ResourceAccessRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.activepieces.guardian.server.repository; - -import com.activepieces.entity.sql.ResourceAccess; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -@Repository -public interface ResourceAccessRepository extends CrudRepository { - - Optional findByResourceIdAndPrincipleId(Ksuid resourceId, Ksuid principleId); - - List findAllByPrincipleId(Ksuid roleResourceId); -} diff --git a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/repository/ResourceRepository.java b/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/repository/ResourceRepository.java deleted file mode 100644 index a1863c6094..0000000000 --- a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/repository/ResourceRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.guardian.server.repository; - -import com.activepieces.entity.sql.Resource; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.UUID; - -@Repository -public interface ResourceRepository extends CrudRepository { - - List findAllByParentResourceId(Ksuid parentResourceId); - -} diff --git a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/service/PermissionsServiceImpl.java b/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/service/PermissionsServiceImpl.java deleted file mode 100644 index cc9f41682a..0000000000 --- a/src/backend/guardian-service/guardian-server/src/main/java/com/activepieces/guardian/server/service/PermissionsServiceImpl.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.activepieces.guardian.server.service; - -import com.activepieces.common.identity.PrincipleIdentity; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.enums.Role; -import com.activepieces.entity.sql.Resource; -import com.activepieces.entity.sql.ResourceAccess; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.guardian.client.model.ResourceEventType; -import com.activepieces.guardian.server.ResourcePublisher; -import com.activepieces.guardian.server.repository.ResourceAccessRepository; -import com.activepieces.guardian.server.repository.ResourceRepository; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.social.InternalServerErrorException; -import org.springframework.stereotype.Service; - -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Future; - -@Log4j2 -@Service -public class PermissionsServiceImpl implements PermissionService { - - private final ResourceAccessRepository resourceAccessRepository; - private final ResourceRepository resourceRepository; - private final ResourcePublisher resourcePublisher; - - @Autowired - public PermissionsServiceImpl( - ResourceRepository resourceRepository, - ResourceAccessRepository resourceAccessRepository, - ResourcePublisher resourcePublisher) { - this.resourcePublisher = resourcePublisher; - this.resourceAccessRepository = resourceAccessRepository; - this.resourceRepository = resourceRepository; - } - - @Override - public void requiresPermission(@NonNull Ksuid resourceId, @NonNull Permission permission) - throws PermissionDeniedException { - if (!hasPermission(resourceId, permission)) { - throw new PermissionDeniedException("Permission required: " + permission); - } - } - - @Override - public boolean hasPermission(@NonNull Ksuid resourceId, @NonNull Permission permission) { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - // Internal traffic, as its null - // TODO REPLACE WITH SPECIAL INSIDE SECURITY - if (Objects.isNull(authentication)) return true; - Object principle = authentication.getPrincipal(); - if (Objects.isNull(principle)) return false; - PrincipleIdentity resourceIdentity = (PrincipleIdentity) principle; - return recursiveLookUp(resourceId, permission, resourceIdentity.getId()); - } - - - private boolean recursiveLookUp( - @NonNull Ksuid resourceId, @NonNull Permission permission, @NonNull Ksuid roleResourceId) { - try { - Resource resource = getResource(resourceId); - Optional resourceAccessOptional = - this.resourceAccessRepository.findByResourceIdAndPrincipleId(resourceId, roleResourceId); - if (resourceAccessOptional.isPresent()) { - return resourceAccessOptional.get().getRole().hasPermission(permission); - } - if (Objects.nonNull(resource.getParentResourceId())) { - return recursiveLookUp(resource.getParentResourceId(), permission, roleResourceId); - } - } catch (ResourceNotFoundException ignored) { - ignored.printStackTrace(); - } - return false; - } - - @Override - public void grantRole(@NonNull Ksuid resourceId, @NonNull Ksuid principleId, @NonNull Role role) { - ResourceAccess resourceAccess = - ResourceAccess.builder().resourceId(resourceId).principleId(principleId).role(role).build(); - log.info(principleId + " has granted role " + role + " on resourceId=" + resourceId); - resourceAccessRepository.save(resourceAccess); - } - - @Override - public Resource getFirstResourceParentWithType(Ksuid resourceId, ResourceType resourceType) - throws ResourceNotFoundException { - Resource resource = getResource(resourceId); - if (resource.getResourceType().equals(resourceType)) { - return resource; - } - Resource parentResource = resource.getParent(); - if (Objects.isNull(parentResource)) { - return null; - } - return getFirstResourceParentWithType(parentResource.getResourceId(), resourceType); - } - - @Override - public Resource createResource(Ksuid id, ResourceType resourceType) { - try { - return createResourceWithParent(id, null, resourceType); - } catch (ResourceNotFoundException e) { - throw new InternalServerErrorException("PermissionService", e.getMessage()); - } - } - - @Override - public Resource createResourceWithParent(Ksuid id, Ksuid parentId, ResourceType resourceType) - throws ResourceNotFoundException { - Resource.ResourceBuilder builder = Resource.builder().resourceId(id).resourceType(resourceType); - if (Objects.nonNull(parentId)) { - builder.parent(getResource(parentId)); - builder.parentResourceId(parentId); - } - Resource resource = resourceRepository.save(builder.build()); - log.debug( - String.format( - "Created Resource with id=%s with type=%s", - resource.getResourceId(), resource.getResourceType().toString())); - return resource; - } - - @Override - public void deleteOrAchiveResource(Ksuid resourceId) throws ResourceNotFoundException { - Resource resource = getResource(resourceId); - if (!skipChildren(resource.getResourceType())) { - for (Resource child : resourceRepository.findAllByParentResourceId(resourceId)) { - deleteOrAchiveResource(child.getResourceId()); - } - } - log.info( - String.format( - "Deleted Resource with id=%s with type=%s", - resource.getResourceId(), resource.getResourceType().toString())); - resourcePublisher.notify(ResourceEventType.DELETE, resource); - if (!isLazyDeleted(resource.getResourceType())) { - resourceRepository.deleteById(resource.getResourceId()); - } - } - - // This resource don't get deleted, they are just marked as archive and will be deleted later. - private boolean isLazyDeleted(ResourceType resourceType) { - return resourceType.equals(ResourceType.INSTANCE); - } - - // Skip Runs as there could be too many of them and deleting would take long, since stale runs - // will be deleted anyway. - private boolean skipChildren(ResourceType resourceType) { - return resourceType.equals(ResourceType.INSTANCE); - } - - @Override - @Async - public Future deleteResourceAsync(Ksuid resourceId) throws ResourceNotFoundException { - deleteOrAchiveResource(resourceId); - return CompletableFuture.completedFuture(null); - } - - @Override - public Resource getResource(Ksuid resourceId) throws ResourceNotFoundException { - return resourceRepository - .findById(resourceId) - .orElseThrow(() -> new ResourceNotFoundException(resourceId)); - } -} diff --git a/src/backend/guardian-service/pom.xml b/src/backend/guardian-service/pom.xml deleted file mode 100644 index 1ce534091c..0000000000 --- a/src/backend/guardian-service/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - guardian-service - 4.0.0 - - - guardian-client - guardian-server - - pom - - backend - com.activepieces - 1.0 - - - - diff --git a/src/backend/instance-service/instance-client/pom.xml b/src/backend/instance-service/instance-client/pom.xml deleted file mode 100644 index bc57abc0e7..0000000000 --- a/src/backend/instance-service/instance-client/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - instance-service - com.activepieces - 1.0 - - 4.0.0 - - instance-client - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstancePublisher.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstancePublisher.java deleted file mode 100644 index c9e3dc4810..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstancePublisher.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.activepieces.instance.client; - -import com.activepieces.common.Publisher; -import com.activepieces.instance.client.model.InstanceEventType; -import com.activepieces.instance.client.model.InstanceView; - - -public class InstancePublisher extends Publisher { - - public InstancePublisher(){} - -} diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstanceService.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstanceService.java deleted file mode 100644 index c25469c1fc..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstanceService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.instance.client; - -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.error.exception.collection.*; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.instance.client.model.CreateOrUpdateInstanceRequest; -import com.activepieces.instance.client.model.InstanceView; -import com.activepieces.variable.model.exception.MissingConfigsException; -import com.github.ksuid.Ksuid; - -import java.util.Optional; - -public interface InstanceService { - - SeekPage listByCollectionId(Ksuid collectionId, SeekPageRequest pageRequest) throws PermissionDeniedException, InstanceNotFoundException; - - InstanceView create(Ksuid collectionId, CreateOrUpdateInstanceRequest instanceRequest) throws PermissionDeniedException, ResourceNotFoundException, FlowVersionNotFoundException, MissingConfigsException, CollectionVersionNotFoundException, CollectionNotFoundException, FlowNotFoundException, CollectionInvalidStateException, CollectionVersionAlreadyLockedException; - - Optional getOptional(Ksuid id) throws PermissionDeniedException; - - InstanceView get(Ksuid id) throws PermissionDeniedException, InstanceNotFoundException; - - void delete(Ksuid id) throws PermissionDeniedException, ResourceNotFoundException, InstanceNotFoundException, InterruptedException; - InstanceView getByCollectionId(Ksuid collectionId) throws PermissionDeniedException, CollectionInstanceNotFoundException; -} diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstanceSubscriber.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstanceSubscriber.java deleted file mode 100644 index 6f17a11b52..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/InstanceSubscriber.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.activepieces.instance.client; - -import com.activepieces.common.Subscriber; -import com.activepieces.instance.client.model.InstanceEventType; -import com.activepieces.instance.client.model.InstanceView; - -public interface InstanceSubscriber extends Subscriber { - -} diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/mapper/InstanceMapper.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/mapper/InstanceMapper.java deleted file mode 100644 index ecf953044f..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/mapper/InstanceMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.activepieces.instance.client.mapper; - -import com.activepieces.entity.sql.Instance; -import com.activepieces.instance.client.model.InstanceView; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.ksuid.Ksuid; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR; - -@Mapper(subclassExhaustiveStrategy = COMPILE_ERROR, componentModel = "spring") -public abstract class InstanceMapper { - - @Autowired - private ObjectMapper mapper; - - @Mappings({ - @Mapping(target = "flowVersionId", expression = "java(map(entity.getFlowVersionId()))"), - }) - public abstract Instance fromView(InstanceView entity); - - @Mappings({ - @Mapping(target = "flowVersionId", expression = "java(mapToIds(entity.getFlowVersionId()))"), - }) - public abstract InstanceView toView(Instance entity); - - public Map map(Map ids){ - return ids.entrySet().stream().map(f -> Map.entry(f.getKey().toString(), f.getValue().toString())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - public Map mapToIds(Map ids){ - return ids.entrySet().stream().map(f -> Map.entry(Ksuid.fromString(f.getKey()), Ksuid.fromString(f.getValue()))).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - - -} diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/CreateOrUpdateInstanceRequest.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/CreateOrUpdateInstanceRequest.java deleted file mode 100644 index 15020bd324..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/CreateOrUpdateInstanceRequest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.activepieces.instance.client.model; - -import com.activepieces.entity.enums.InstanceStatus; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotNull; -import java.util.Map; -import java.util.UUID; - -@NoArgsConstructor -@Getter -@AllArgsConstructor -@SuperBuilder(toBuilder = true) -public class CreateOrUpdateInstanceRequest { - - @JsonProperty @NotNull private InstanceStatus status; - -} diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/InstanceEventType.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/InstanceEventType.java deleted file mode 100644 index b3153f5e97..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/InstanceEventType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.activepieces.instance.client.model; - -public enum InstanceEventType { - CREATE, - UPDATE, - DELETE -} diff --git a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/InstanceView.java b/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/InstanceView.java deleted file mode 100644 index 5e06f3054a..0000000000 --- a/src/backend/instance-service/instance-client/src/main/java/com/activepieces/instance/client/model/InstanceView.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.activepieces.instance.client.model; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.InstanceStatus; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -@NoArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -public class InstanceView implements EntityMetadata { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty private Ksuid projectId; - - @JsonProperty private Ksuid collectionId; - - @JsonProperty private Ksuid collectionVersionId; - - @JsonProperty private Map flowVersionId; - - @JsonProperty private InstanceStatus status; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long created; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long updated; -} diff --git a/src/backend/instance-service/instance-server/pom.xml b/src/backend/instance-service/instance-server/pom.xml deleted file mode 100644 index e153101a5a..0000000000 --- a/src/backend/instance-service/instance-server/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - instance-service - com.activepieces - 1.0 - - 4.0.0 - - instance-server - - - com.activepieces - instance-client - 1.0 - compile - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - authentication-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - com.activepieces - project-client - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - junit - junit - test - - - com.activepieces - executor-client - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/InstanceServiceImpl.java b/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/InstanceServiceImpl.java deleted file mode 100644 index f495aee87f..0000000000 --- a/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/InstanceServiceImpl.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.activepieces.instance; - -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.error.exception.collection.*; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.pagination.PageFilter; -import com.activepieces.common.pagination.PageOperator; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.sql.Instance; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.instance.client.InstancePublisher; -import com.activepieces.instance.client.InstanceService; -import com.activepieces.instance.client.mapper.InstanceMapper; -import com.activepieces.instance.client.model.CreateOrUpdateInstanceRequest; -import com.activepieces.instance.client.model.InstanceEventType; -import com.activepieces.instance.client.model.InstanceView; -import com.activepieces.instance.repository.InstanceRepository; -import com.activepieces.piece.client.CollectionService; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionView; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -@Service -@Log4j2 -public class InstanceServiceImpl implements InstanceService { - - private final InstanceRepository instanceRepository; - private final InstanceMapper instanceMapper; - private final PermissionService permissionService; - private final InstancePublisher instancePublisher; - private final CollectionVersionService collectionVersionService; - private final CollectionService collectionService; - - @Autowired - public InstanceServiceImpl( - @NonNull final InstanceRepository instanceRepository, - @NonNull final InstanceMapper instanceMapper, - @NonNull final CollectionService collectionService, - @NonNull final CollectionVersionService collectionVersionService, - @NonNull final PermissionService permissionService, - @NonNull final InstancePublisher instancePublisher) { - this.collectionService = collectionService; - this.collectionVersionService = collectionVersionService; - this.instanceRepository = instanceRepository; - this.instancePublisher = instancePublisher; - this.permissionService = permissionService; - this.instanceMapper = instanceMapper; - } - - @Override - public SeekPage listByCollectionId( - Ksuid collectionId, SeekPageRequest request) - throws PermissionDeniedException { - permissionService.requiresPermission(collectionId, Permission.READ_INSTANCE); - final List filters = List.of(new PageFilter(Instance.COLLECTION_ID, PageOperator.EQUAL, collectionId)); - return instanceRepository.findPageAsc(filters, request).convert(instanceMapper::toView); - } - - @Override - public InstanceView create(Ksuid collectionId, CreateOrUpdateInstanceRequest request) - throws PermissionDeniedException, ResourceNotFoundException, CollectionVersionNotFoundException, CollectionNotFoundException, FlowNotFoundException, CollectionInvalidStateException, CollectionVersionAlreadyLockedException { - permissionService.requiresPermission(collectionId, Permission.WRITE_INSTANCE); - - CollectionView collectionView = collectionService.get(collectionId); - Map flowVersionIds = collectionVersionService.commit(collectionView.getLastVersion().getId()); - - // We should keep one instance at most - Optional oldInstance = instanceRepository.findFirstByCollectionId(collectionId); - if (oldInstance.isPresent()) { - // Let's Use existing delete method since it publish delete event. - try { - delete(oldInstance.get().getId()); - } catch (InstanceNotFoundException exception) { - // This case shouldn't happen since we check before. - throw new RuntimeException(exception); - } - } - - Instance metadata = - Instance.builder() - .id(Ksuid.newKsuid()) - .projectId(collectionView.getProjectId()) - .collectionId(collectionId) - .collectionVersionId(collectionView.getLastVersion().getId()) - .flowVersionId(instanceMapper.map(flowVersionIds)) - .status(request.getStatus()) - .build(); - - InstanceView savedView = instanceMapper.toView(instanceRepository.save(metadata)); - permissionService.createResourceWithParent( - savedView.getId(), savedView.getCollectionVersionId(), ResourceType.INSTANCE); - - instancePublisher.notify(InstanceEventType.CREATE, savedView); - return savedView; - } - - @Override - public Optional getOptional(Ksuid id) throws PermissionDeniedException { - Optional optional = instanceRepository.findById(id); - if (optional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(id, Permission.READ_INSTANCE); - return Optional.of(instanceMapper.toView(optional.get())); - } - - @Override - public InstanceView get(Ksuid id) throws PermissionDeniedException, InstanceNotFoundException { - Optional optional = getOptional(id); - if (optional.isEmpty()) { - throw new InstanceNotFoundException(id); - } - return optional.get(); - } - - - @Override - public void delete(Ksuid id) - throws PermissionDeniedException, ResourceNotFoundException, InstanceNotFoundException { - if (!instanceRepository.existsById(id)) { - throw new InstanceNotFoundException(id); - } - permissionService.requiresPermission(id, Permission.WRITE_INSTANCE); - InstanceView view = get(id); - instancePublisher.notify(InstanceEventType.DELETE, view); - permissionService.deleteResourceAsync(id); - } - - @Override - public InstanceView getByCollectionId(Ksuid collectionId) throws PermissionDeniedException, CollectionInstanceNotFoundException { - permissionService.requiresPermission(collectionId, Permission.READ_COLLECTION); - Optional instance =instanceRepository.findFirstByCollectionId(collectionId); - if(instance.isPresent()) - return instanceMapper.toView(instance.get()); - throw new CollectionInstanceNotFoundException(collectionId); - - } - -} diff --git a/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/controller/InstanceController.java b/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/controller/InstanceController.java deleted file mode 100644 index d044149c8a..0000000000 --- a/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/controller/InstanceController.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.activepieces.instance.controller; -import com.activepieces.action.FlowPublisherService; -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.error.exception.collection.*; -import com.activepieces.common.error.exception.flow.FlowExecutionInternalError; -import com.activepieces.common.error.exception.flow.FlowNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.flow.FlowService; -import com.activepieces.flow.model.FlowView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.instance.client.InstanceService; -import com.activepieces.instance.client.model.CreateOrUpdateInstanceRequest; -import com.activepieces.instance.client.model.InstanceView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.variable.model.exception.MissingConfigsException; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.*; - -@RestController -@Hidden -@RequestMapping -public class InstanceController { - - private final InstanceService instanceService; - private final FlowService flowService; - private final FlowPublisherService publisherService; - - @Autowired - public InstanceController(@NonNull final InstanceService instanceService, - @NonNull final FlowPublisherService publisherService, - @NonNull final FlowService flowService) { - this.instanceService = instanceService; - this.flowService = flowService; - this.publisherService = publisherService; - } - - @GetMapping("/instance/{instanceId}") - public ResponseEntity get(@PathVariable("instanceId") Ksuid instanceId) - throws PermissionDeniedException, InstanceNotFoundException { - return ResponseEntity.ok(instanceService.get(instanceId)); - } - - @GetMapping("/collections/{collectionId}/instance") - public ResponseEntity listByEnvironmentId( - @PathVariable("collectionId") Ksuid collectionId) - throws PermissionDeniedException, CollectionInstanceNotFoundException { - return ResponseEntity.ok(instanceService.getByCollectionId(collectionId)); - } - - @PostMapping("/collections/{collectionId}/instance") - public ResponseEntity create(@PathVariable("collectionId") Ksuid collectionId, @RequestBody @Valid CreateOrUpdateInstanceRequest request) - throws PermissionDeniedException, ResourceNotFoundException, FlowVersionNotFoundException, - CollectionVersionNotFoundException, MissingConfigsException, CollectionNotFoundException, FlowNotFoundException, CollectionInvalidStateException, CollectionVersionAlreadyLockedException { - - return ResponseEntity.ok(instanceService.create(collectionId, request)); - } - @DeleteMapping("/instance/{instanceId}") - public void delete(@PathVariable("instanceId") Ksuid instanceId) - throws PermissionDeniedException, InstanceNotFoundException, ResourceNotFoundException, - InterruptedException { - instanceService.delete(instanceId); - } - - @PostMapping({"/flows/{flowId}/webhook"}) - public ResponseEntity execute( - @PathVariable("flowId") Ksuid flowId, - @RequestBody @Valid Map payload) - throws PermissionDeniedException, FlowNotFoundException, FlowExecutionInternalError, MissingConfigsException, ResourceNotFoundException, InstanceNotFoundException { - SecurityContextHolder.getContext().setAuthentication(null); - final FlowView flowView = flowService.get(flowId); - final SeekPage instanceViewSeekPage = instanceService.listByCollectionId(flowView.getCollectionId(), new SeekPageRequest(null, 1)); - if (instanceViewSeekPage.getData().isEmpty()) { - throw new InstanceNotFoundException(flowId); - } - final InstanceView instanceView = instanceViewSeekPage.getData().get(0); - publisherService.executeInstance( - instanceView.getId(), - instanceView.getFlowVersionId().get(flowId), - payload); - return ResponseEntity.noContent().build(); - } -} diff --git a/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/repository/InstanceRepository.java b/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/repository/InstanceRepository.java deleted file mode 100644 index a788d7b86b..0000000000 --- a/src/backend/instance-service/instance-server/src/main/java/com/activepieces/instance/repository/InstanceRepository.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.instance.repository; - -import com.activepieces.common.pagination.PaginationRepository; -import com.activepieces.entity.sql.Instance; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -@Repository("InstanceRepository") -public interface InstanceRepository extends CrudRepository, PaginationRepository { - - - Optional findFirstByCollectionId(Ksuid collectionId); - -} diff --git a/src/backend/instance-service/pom.xml b/src/backend/instance-service/pom.xml deleted file mode 100644 index 7b3d1de531..0000000000 --- a/src/backend/instance-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - instance-service - pom - - instance-server - instance-client - - - - 11 - 11 - - - diff --git a/src/backend/isolate b/src/backend/isolate deleted file mode 100755 index fdf04fc103..0000000000 Binary files a/src/backend/isolate and /dev/null differ diff --git a/src/backend/lock-service/pom.xml b/src/backend/lock-service/pom.xml deleted file mode 100644 index 6bc110ca25..0000000000 --- a/src/backend/lock-service/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - lock-service - - - com.activepieces - entities - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/lock-service/src/main/java/com/activepieces/lock/JDBCLockService.java b/src/backend/lock-service/src/main/java/com/activepieces/lock/JDBCLockService.java deleted file mode 100644 index a7cb1880fd..0000000000 --- a/src/backend/lock-service/src/main/java/com/activepieces/lock/JDBCLockService.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.activepieces.lock; - -import com.activepieces.common.error.exception.FailedToObtainLockException; -import org.springframework.integration.jdbc.lock.JdbcLockRegistry; -import org.springframework.integration.support.locks.LockRegistry; -import org.springframework.stereotype.Service; - -import java.time.Duration; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; - -@Service -public class JDBCLockService implements LockService{ - private final LockRegistry lockRegistry; - - public JDBCLockService(JdbcLockRegistry jdbcLockRegistry) { - this.lockRegistry = jdbcLockRegistry; - } - - @Override - public Lock tryLock(String key, Duration timeout) throws FailedToObtainLockException { - Lock lock = lockRegistry.obtain(key); - try { - if(!lock.tryLock(timeout.getSeconds(), TimeUnit.SECONDS)){ - throw new FailedToObtainLockException(new RuntimeException(String.format("Lock %s timed out after %s seconds", key, timeout.getSeconds()))); - } - } catch (InterruptedException e) { - throw new FailedToObtainLockException(e); - } - return lock; - } -} \ No newline at end of file diff --git a/src/backend/lock-service/src/main/java/com/activepieces/lock/LockService.java b/src/backend/lock-service/src/main/java/com/activepieces/lock/LockService.java deleted file mode 100644 index 59af4a1ddf..0000000000 --- a/src/backend/lock-service/src/main/java/com/activepieces/lock/LockService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.activepieces.lock; - -import com.activepieces.common.error.exception.FailedToObtainLockException; - -import java.time.Duration; -import java.util.concurrent.locks.Lock; - -public interface LockService { - Lock tryLock(String key, Duration timeout) throws FailedToObtainLockException; -} \ No newline at end of file diff --git a/src/backend/logging-service/logging-client/pom.xml b/src/backend/logging-service/logging-client/pom.xml deleted file mode 100644 index c0ac968ada..0000000000 --- a/src/backend/logging-service/logging-client/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - logging-service - com.activepieces - 1.0 - - 4.0.0 - - logging-client - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - actions-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/InstanceRunService.java b/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/InstanceRunService.java deleted file mode 100644 index 272189bb88..0000000000 --- a/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/InstanceRunService.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.activepieces.logging.client; - -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.entity.subdocuments.runs.ExecutionStateView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.logging.client.exception.InstanceRunNotFoundException; -import com.activepieces.logging.client.model.InstanceRunView; -import com.github.ksuid.Ksuid; -import lombok.NonNull; - -import java.io.IOException; -import java.util.Optional; - -public interface InstanceRunService { - - Optional getOptional(@NonNull final Ksuid id) throws PermissionDeniedException; - - SeekPage list(@NonNull final Ksuid projectId, @NonNull final SeekPageRequest request) throws InstanceRunNotFoundException, PermissionDeniedException; - - InstanceRunView get(@NonNull final Ksuid id) throws InstanceRunNotFoundException, PermissionDeniedException; - - InstanceRunView createOrUpdate(@NonNull InstanceRunView request, ExecutionStateView executionStateView) throws ResourceNotFoundException, PermissionDeniedException, InstanceNotFoundException, IOException; - - -} diff --git a/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/exception/InstanceRunNotFoundException.java b/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/exception/InstanceRunNotFoundException.java deleted file mode 100644 index 0e52203fb8..0000000000 --- a/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/exception/InstanceRunNotFoundException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.logging.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class InstanceRunNotFoundException extends Exception implements ErrorResponseException { - - - public InstanceRunNotFoundException(Ksuid runId) { - super(String.format("Instance run with id=%s is not found", runId.toString())); - } - - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.INSTANCE_RUN_LOG_NOT_FOUND; - } -} diff --git a/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/model/InstanceRunView.java b/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/model/InstanceRunView.java deleted file mode 100644 index 8d1d5b5287..0000000000 --- a/src/backend/logging-service/logging-client/src/main/java/com/activepieces/logging/client/model/InstanceRunView.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.activepieces.logging.client.model; - -import com.activepieces.common.EntityMetadata; -import com.activepieces.entity.enums.FlowExecutionStatus; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.validation.constraints.NotNull; - -@Getter -@Setter -@Builder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor -@ToString -public class InstanceRunView implements EntityMetadata { - - @JsonProperty private Ksuid id; - - @JsonProperty private Ksuid instanceId; - - @JsonProperty private Ksuid projectId; - - @JsonProperty private Ksuid collectionId; - - @JsonProperty private Ksuid flowVersionId; - - @JsonProperty private Ksuid collectionVersionId; - - @JsonProperty private String flowDisplayName; - - @JsonProperty private String collectionDisplayName; - - @JsonProperty private FlowExecutionStatus status; - - @JsonProperty private Ksuid logsFileId; - - @JsonProperty private long finishTime; - - @JsonProperty private long startTime; - - @NotNull - @JsonProperty - @JsonInclude(JsonInclude.Include.NON_NULL) - private Object output; - - @JsonProperty - @JsonInclude(JsonInclude.Include.NON_NULL) - private Object errorMessage; - - - @JsonIgnore private long created; - - @JsonIgnore private long updated; -} diff --git a/src/backend/logging-service/logging-server/pom.xml b/src/backend/logging-service/logging-server/pom.xml deleted file mode 100644 index b508649663..0000000000 --- a/src/backend/logging-service/logging-server/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - logging-service - com.activepieces - 1.0 - - 4.0.0 - - logging-server - - - com.activepieces - logging-client - 1.0 - compile - - - com.activepieces - guardian-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - com.activepieces - file-client - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/InstanceRunServiceImpl.java b/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/InstanceRunServiceImpl.java deleted file mode 100644 index b046fa7116..0000000000 --- a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/InstanceRunServiceImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.activepieces.logging.server; - -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.common.pagination.PageFilter; -import com.activepieces.common.pagination.PageOperator; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.sql.FileEntity; -import com.activepieces.entity.sql.InstanceRun; -import com.activepieces.entity.subdocuments.runs.ExecutionStateView; -import com.activepieces.file.service.FileService; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.exception.InstanceRunNotFoundException; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.logging.server.mapper.InstanceRunMapper; -import com.activepieces.logging.server.repository.InstanceRunRepository; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; - -@Service -@Log4j2 -public class InstanceRunServiceImpl implements InstanceRunService { - - private final InstanceRunRepository repository; - private final PermissionService permissionService; - private final InstanceRunMapper mapper; - private final FileService fileService; - private final Executor executor; - private final ObjectMapper objectMapper; - private final ErrorServiceHandler errorServiceHandler; - - @Autowired - public InstanceRunServiceImpl( - final ObjectMapper objectMapper, - final FileService fileService, - InstanceRunRepository repository, - PermissionService permissionService, - ErrorServiceHandler errorServiceHandler, - InstanceRunMapper mapper) - throws IOException { - this.errorServiceHandler = errorServiceHandler; - this.fileService = fileService; - this.executor = Executors.newFixedThreadPool(8); - this.permissionService = permissionService; - this.repository = repository; - this.objectMapper = objectMapper; - this.mapper = mapper; - } - - @Override - public Optional getOptional(@NonNull Ksuid id) throws PermissionDeniedException { - Optional eventOptional = repository.findById(id); - if (eventOptional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(id, Permission.READ_INSTANCE_RUN); - InstanceRunView instanceRunView = mapper.toView(eventOptional.get()); - return Optional.of(instanceRunView); - } - - @Override - public SeekPage list( - @NonNull final Ksuid projectId, - @NonNull final SeekPageRequest request) - throws InstanceRunNotFoundException, PermissionDeniedException { - permissionService.requiresPermission(projectId, Permission.READ_INSTANCE_RUN); - final List filters = List.of(new PageFilter(InstanceRun.PROJECT_ID, PageOperator.EQUAL, projectId), - new PageFilter(InstanceRun.INSTANCE_ID, PageOperator.NOT_NULL, null)); - return repository.findPageDesc( filters, request).convert(mapper::toView); - } - - @Override - public InstanceRunView get(@NonNull Ksuid id) - throws InstanceRunNotFoundException, PermissionDeniedException { - Optional runOptional = getOptional(id); - if (runOptional.isEmpty()) { - throw new InstanceRunNotFoundException(id); - } - return runOptional.get(); - } - - @Override - public InstanceRunView createOrUpdate( - @NonNull InstanceRunView request, @NonNull ExecutionStateView executionStateView) - throws ResourceNotFoundException, PermissionDeniedException, - InstanceNotFoundException, IOException { - // No need for permissions as this will be used internally - // permissionService.requiresPermission(parentResourceId, Permission.CREATE_INSTANCE_RUN); - - request.setProjectId(request.getProjectId()); - InstanceRunView savedView = mapper.toView(repository.save(mapper.fromView(request))); - permissionService.createResourceWithParent( - savedView.getId(), request.getCollectionId(), ResourceType.INSTANCE_RUN); - - // They are lost due the transitions to database model and back - savedView.setOutput(request.getOutput()); - - executor.execute( - () -> { - try { - String json = objectMapper.writeValueAsString(executionStateView); - FileEntity file = fileService.save(null, new MockMultipartFile("file", request.getId().toString() + ".json", "application/json", json.getBytes(StandardCharsets.UTF_8))); - savedView.setLogsFileId(file.getId()); - repository.save(mapper.fromView(savedView)); - } catch (IOException e) { - throw errorServiceHandler.createInternalError(e); - } - }); - return savedView; - } - - - - -} diff --git a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/controller/InstanceRunController.java b/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/controller/InstanceRunController.java deleted file mode 100644 index 255e47d0bd..0000000000 --- a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/controller/InstanceRunController.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.activepieces.logging.server.controller; - -import com.activepieces.common.pagination.Cursor; -import com.activepieces.common.pagination.SeekPage; -import com.activepieces.common.pagination.SeekPageRequest; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.exception.InstanceRunNotFoundException; -import com.activepieces.logging.client.model.InstanceRunView; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.UUID; - -@CrossOrigin -@RestController -@Hidden -@RequestMapping -public class InstanceRunController { - - private final InstanceRunService instanceRunService; - - @Autowired - public InstanceRunController( - @NonNull final InstanceRunService instanceRunService) { - this.instanceRunService = instanceRunService; - } - - @GetMapping("/instance-runs/{instanceRunId}") - public ResponseEntity get( - @PathVariable("instanceRunId") Ksuid instanceRunId) - throws InstanceRunNotFoundException, PermissionDeniedException { - InstanceRunView instanceRunView = instanceRunService.get(instanceRunId); - return ResponseEntity.ok(instanceRunView); - } - - @GetMapping("/projects/{projectId}/instance-runs") - public ResponseEntity> list( - @PathVariable("projectId") Ksuid projectId, - @RequestParam(value = "cursor", required = false) Cursor cursor, - @RequestParam(value = "limit", defaultValue = "10", required = false) int limit) - throws PermissionDeniedException, InstanceRunNotFoundException { - return ResponseEntity.ok(instanceRunService.list(projectId, new SeekPageRequest(cursor, limit))); - } - -} diff --git a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/mapper/InstanceRunMapper.java b/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/mapper/InstanceRunMapper.java deleted file mode 100644 index d3ce8fcdd8..0000000000 --- a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/mapper/InstanceRunMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.activepieces.logging.server.mapper; - -import com.activepieces.entity.sql.InstanceRun; -import com.activepieces.entity.subdocuments.runs.ExecutionStateView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Map; - -import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR; - -@Mapper(subclassExhaustiveStrategy = COMPILE_ERROR, componentModel = "spring") -public abstract class InstanceRunMapper { - - @Autowired - private ObjectMapper objectMapper; - - - @Mappings({}) - public abstract InstanceRun fromView(InstanceRunView entity); - - @Mappings({}) - public abstract InstanceRunView toView(InstanceRun entity); - - @Mappings({}) - Map map(ExecutionStateView value){ - return objectMapper.convertValue(value, Map.class); - } - - @Mappings({}) - ExecutionStateView map(Map value){ - return objectMapper.convertValue(value, ExecutionStateView.class); - } - -} diff --git a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/repository/InstanceRunRepository.java b/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/repository/InstanceRunRepository.java deleted file mode 100644 index cdb41c78a6..0000000000 --- a/src/backend/logging-service/logging-server/src/main/java/com/activepieces/logging/server/repository/InstanceRunRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.activepieces.logging.server.repository; - -import com.activepieces.common.pagination.PaginationRepository; -import com.activepieces.entity.sql.InstanceRun; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; - -import java.util.UUID; - -public interface InstanceRunRepository extends CrudRepository, PaginationRepository { - - -} diff --git a/src/backend/logging-service/pom.xml b/src/backend/logging-service/pom.xml deleted file mode 100644 index c99bd88d3c..0000000000 --- a/src/backend/logging-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - logging-service - pom - - logging-client - logging-server - - - - 11 - 11 - - - diff --git a/src/backend/pom.xml b/src/backend/pom.xml deleted file mode 100644 index 3cfdb7449f..0000000000 --- a/src/backend/pom.xml +++ /dev/null @@ -1,300 +0,0 @@ - - - 4.0.0 - - com.activepieces - backend - 1.0 - pom - - spring-boot-starter-parent - org.springframework.boot - - 2.4.5 - - - authentication-service - project-service - collection-service - guardian-service - entities - flow-service - executor-service - trigger-service - actions-service - backend-loader - variable-service - instance-service - logging-service - worker-service - file-service - lock-service - feature-service - component-service - - - - org.springdoc - springdoc-openapi-ui - 1.6.4 - - - com.vladmihalcea - hibernate-types-52 - 2.2.2 - - - org.springframework.integration - spring-integration-jdbc - - - org.springframework.boot - spring-boot-starter-jdbc - - - - com.google.guava - guava - 14.0 - - - - com.github.ksuid - ksuid - 1.1.1 - - - - com.jayway.jsonpath - json-path - 2.7.0 - - - com.auth0 - jwks-rsa - 0.21.1 - - - commons-beanutils - commons-beanutils - 1.9.4 - - - org.hibernate - hibernate-validator - 6.1.2.Final - - - - commons-io - commons-io - 2.11.0 - - - spring-boot-starter-validation - org.springframework.boot - - - javax.validation - validation-api - - - org.quartz-scheduler - quartz - - - org.springframework - spring-context-support - - - org.springframework - spring-web - 5.3.13 - compile - - - - org.springframework - spring-core - 5.3.20 - - - - org.springframework.security - spring-security-core - 5.5.7 - compile - - - - passay - org.passay - 1.0 - - - commons-lang - commons-lang - 2.6 - - - org.postgresql - postgresql - runtime - 42.4.3 - - - org.flywaydb - flyway-core - - - - org.springframework.social - spring-social-core - 1.1.6.RELEASE - - - java-jwt - com.auth0 - 3.11.0 - - - spring-boot-starter-security - org.springframework.boot - - - spring-security-config - org.springframework.security - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - spring-boot-starter-web - org.springframework.boot - - - org.springframework.boot - spring-boot-starter-logging - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - - - lombok - org.projectlombok - 1.18.22 - - - spring-boot-starter-test - org.springframework.boot - test - - - spring-security-test - org.springframework.security - test - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.17.2 - - - com.fasterxml.jackson.core - jackson-databind - 2.13.4.1 - - - com.fasterxml.jackson.core - jackson-annotations - 2.13.3 - - - com.fasterxml.jackson.core - jackson-core - 2.13.3 - - - org.springframework - spring-test - 5.3.6 - - - org.hibernate - hibernate-core - 5.4.30.Final - - - org.springframework.data - spring-data-jpa - 2.4.8 - - - org.mapstruct - mapstruct - 1.5.0.Beta2 - - - org.springframework.boot - spring-boot-starter-log4j2 - - - org.graalvm - graal-sdk - 1.0.0-rc2 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.1 - - 11 - 11 - - - org.projectlombok - lombok - 1.18.22 - - - - org.projectlombok - lombok-mapstruct-binding - 0.2.0 - - - - org.mapstruct - mapstruct-processor - 1.5.0.Beta2 - - - - - - - - - - 11 - 11 - - - diff --git a/src/backend/project-service/pom.xml b/src/backend/project-service/pom.xml deleted file mode 100644 index 63fd57d1f5..0000000000 --- a/src/backend/project-service/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - project-service - 4.0.0 - pom - - backend - com.activepieces - 1.0 - - - - project-server - project-client - - diff --git a/src/backend/project-service/project-client/pom.xml b/src/backend/project-service/project-client/pom.xml deleted file mode 100644 index 8bb28fbae4..0000000000 --- a/src/backend/project-service/project-client/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - project-client - - - - com.activepieces - guardian-client - 1.0 - compile - - - 4.0.0 - - - project-service - com.activepieces - 1.0 - - - - diff --git a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/ProjectService.java b/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/ProjectService.java deleted file mode 100644 index 3ed90f7746..0000000000 --- a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/ProjectService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.activepieces.project.client; - -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.project.client.exception.ProjectNotFoundException; -import com.activepieces.project.client.model.CreateProjectRequest; -import com.activepieces.project.client.model.ProjectView; -import com.github.ksuid.Ksuid; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.List; -import java.util.Optional; - -public interface ProjectService { - - List listByOwnerId(Ksuid userId) ; - - ProjectView create( Ksuid ownerId, CreateProjectRequest view); - - Optional getOptional(Ksuid id) throws PermissionDeniedException; - - ProjectView get(Ksuid id) throws ProjectNotFoundException, PermissionDeniedException; - - ProjectView update(Ksuid id, ProjectView view) - throws ProjectNotFoundException, PermissionDeniedException; - - void delete(Ksuid id) throws ProjectNotFoundException, PermissionDeniedException, ResourceNotFoundException; -} diff --git a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/exception/ProjectNotFoundException.java b/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/exception/ProjectNotFoundException.java deleted file mode 100644 index 242e0d6bec..0000000000 --- a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/exception/ProjectNotFoundException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.project.client.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import com.github.ksuid.Ksuid; - -import java.util.UUID; - -public class ProjectNotFoundException extends Exception implements ErrorResponseException { - - public ProjectNotFoundException(Ksuid id) { - super(String.format("Project with id=%s is not found", id.toString())); - } - - @Override - public ErrorCode getErrorCode() { - return ErrorCode.PROJECT_NOT_FOUND; - } -} diff --git a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/mapper/ProjectMapper.java b/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/mapper/ProjectMapper.java deleted file mode 100644 index 20ad618171..0000000000 --- a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/mapper/ProjectMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.project.client.mapper; - -import com.activepieces.entity.sql.Project; -import com.activepieces.project.client.model.ProjectView; -import org.mapstruct.IterableMapping; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; - -import java.util.List; - -import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR; - -@Mapper(subclassExhaustiveStrategy = COMPILE_ERROR, componentModel = "spring") -public abstract class ProjectMapper { - - @Mappings({}) - public abstract Project fromView(ProjectView entity); - - @Mappings({}) - @ProjectToView - public abstract ProjectView toView(Project entity); - - @IterableMapping(qualifiedBy = ProjectToView.class) - public abstract List toView(List children); - - -} diff --git a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/mapper/ProjectToView.java b/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/mapper/ProjectToView.java deleted file mode 100644 index f95dd45165..0000000000 --- a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/mapper/ProjectToView.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.project.client.mapper; - -import org.mapstruct.Qualifier; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Qualifier -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.CLASS) -public @interface ProjectToView { -} \ No newline at end of file diff --git a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/model/CreateProjectRequest.java b/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/model/CreateProjectRequest.java deleted file mode 100644 index 57015ca033..0000000000 --- a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/model/CreateProjectRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.activepieces.project.client.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import javax.validation.constraints.NotEmpty; - -@NoArgsConstructor -@Getter -@Setter -@Builder -@AllArgsConstructor -public class CreateProjectRequest { - - @JsonProperty - @NotEmpty - private String displayName; - -} diff --git a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/model/ProjectView.java b/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/model/ProjectView.java deleted file mode 100644 index 7259629e72..0000000000 --- a/src/backend/project-service/project-client/src/main/java/com/activepieces/project/client/model/ProjectView.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.activepieces.project.client.model; - -import com.activepieces.common.EntityMetadata; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.github.ksuid.Ksuid; -import lombok.*; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.UUID; - -@NoArgsConstructor -@Getter -@Setter -@AllArgsConstructor -@Builder(toBuilder = true) -public class ProjectView implements EntityMetadata { - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private Ksuid id; - - @JsonProperty @NotNull @NotEmpty private String displayName; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long created; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private long updated; - -} diff --git a/src/backend/project-service/project-server/pom.xml b/src/backend/project-service/project-server/pom.xml deleted file mode 100644 index 4a01183361..0000000000 --- a/src/backend/project-service/project-server/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - project-server - - - project-client - com.activepieces - compile - 1.0 - - - guardian-client - com.activepieces - compile - 1.0 - - - authentication-client - com.activepieces - compile - 1.0 - - - com.activepieces - project-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - 4.0.0 - - project-service - com.activepieces - 1.0 - - - - 11 - 11 - - - - diff --git a/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/controller/ProjectController.java b/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/controller/ProjectController.java deleted file mode 100644 index 38776bbe7f..0000000000 --- a/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/controller/ProjectController.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.activepieces.project.server.controller; - -import com.activepieces.common.identity.UserIdentity; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.project.client.ProjectService; -import com.activepieces.project.client.exception.ProjectNotFoundException; -import com.activepieces.project.client.model.ProjectView; -import com.github.ksuid.Ksuid; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.annotation.Secured; -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; - -@RestController -@Hidden -@RequestMapping -public class ProjectController { - - private final ProjectService projectService; - - @Autowired - public ProjectController( - @NonNull final ProjectService projectService) { - this.projectService = projectService; - } - - @Secured("ROLE_USER") - @GetMapping("/projects") - public ResponseEntity> listForUser( - @AuthenticationPrincipal UserIdentity userIdentity) { - return ResponseEntity.ok( - projectService.listByOwnerId(userIdentity.getId())); - } - - @Secured("ROLE_USER") - @GetMapping("/projects/{projectId}") - public ResponseEntity get(@PathVariable("projectId") Ksuid projectId) - throws ProjectNotFoundException, PermissionDeniedException { - return ResponseEntity.ok(projectService.get(projectId)); - } - - @Secured("ROLE_USER") - @PutMapping("/projects/{projectId}") - public ResponseEntity update( - @PathVariable("projectId") Ksuid projectId, - @RequestBody @Valid ProjectView view) - throws ProjectNotFoundException, PermissionDeniedException { - return ResponseEntity.ok(projectService.update(projectId, view)); - } - -} diff --git a/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/repository/ProjectRepository.java b/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/repository/ProjectRepository.java deleted file mode 100644 index c9712847d8..0000000000 --- a/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/repository/ProjectRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.activepieces.project.server.repository; - -import com.activepieces.entity.sql.Project; -import com.github.ksuid.Ksuid; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.UUID; - -@Repository("ProjectRepository") -public interface ProjectRepository extends CrudRepository { - - List findAllByOwnerId(Ksuid ownerId); - -} diff --git a/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/service/ProjectServiceImpl.java b/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/service/ProjectServiceImpl.java deleted file mode 100644 index 0f97611209..0000000000 --- a/src/backend/project-service/project-server/src/main/java/com/activepieces/project/server/service/ProjectServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.activepieces.project.server.service; - -import com.activepieces.entity.enums.Permission; -import com.activepieces.entity.enums.ResourceType; -import com.activepieces.entity.enums.Role; -import com.activepieces.entity.sql.Project; -import com.activepieces.guardian.client.PermissionService; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.project.client.ProjectService; -import com.activepieces.project.client.exception.ProjectNotFoundException; -import com.activepieces.project.client.mapper.ProjectMapper; -import com.activepieces.project.client.model.CreateProjectRequest; -import com.activepieces.project.client.model.ProjectView; -import com.activepieces.project.server.repository.ProjectRepository; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -@Service -public class ProjectServiceImpl implements ProjectService { - - private final ProjectRepository projectRepository; - private final PermissionService permissionService; - private final ProjectMapper projectMapper; - - @Autowired - public ProjectServiceImpl( - @NonNull final ProjectRepository projectRepository, - @NonNull final PermissionService permissionService, - @NonNull final ProjectMapper projectMapper) { - this.permissionService = permissionService; - this.projectMapper = projectMapper; - this.projectRepository = projectRepository; - } - - @Override - public List listByOwnerId(Ksuid userId) { - ArrayList projectViewArrayList = new ArrayList<>(); - List projectList = projectRepository.findAllByOwnerId(userId); - for (Project project : projectList) { - projectViewArrayList.add(projectMapper.toView(project)); - } - return projectViewArrayList; - } - - @Override - public ProjectView create(@NonNull final Ksuid ownerId, @NonNull final CreateProjectRequest request) { - Project project = - Project.builder() - .id(Ksuid.newKsuid()) - .ownerId(ownerId) - .displayName(request.getDisplayName()) - .build(); - project = projectRepository.save(project); - permissionService.createResource( - project.getId(), ResourceType.PROJECT); - permissionService.grantRole(project.getId(), ownerId, Role.OWNER); - return projectMapper.toView(projectRepository.findById(project.getId()).get()); - } - - @Override - public Optional getOptional(@NonNull final Ksuid id) - throws PermissionDeniedException { - Optional projectOptional = projectRepository.findById(id); - if (projectOptional.isEmpty()) { - return Optional.empty(); - } - permissionService.requiresPermission(id, Permission.READ_PROJECT); - return Optional.of(projectMapper.toView(projectOptional.get())); - } - - @Override - public ProjectView get(@NonNull final Ksuid id) - throws ProjectNotFoundException, PermissionDeniedException { - Optional projectViewOptional = getOptional(id); - if (projectViewOptional.isEmpty()) { - throw new ProjectNotFoundException(id); - } - return projectViewOptional.get(); - } - @Override - public ProjectView update(@NonNull final Ksuid id, @NonNull final ProjectView view) - throws ProjectNotFoundException, PermissionDeniedException { - permissionService.requiresPermission(id, Permission.WRITE_PROJECT); - Optional projectOptional = projectRepository.findById(id); - if (projectOptional.isEmpty()) { - throw new ProjectNotFoundException(id); - } - Project project = projectOptional.get(); - project.setDisplayName(view.getDisplayName()); - return projectMapper.toView(projectRepository.save(project)); - } - - @Override - public void delete(@NonNull final Ksuid id) - throws ProjectNotFoundException, PermissionDeniedException, ResourceNotFoundException { - if (!projectRepository.existsById(id)) { - throw new ProjectNotFoundException(id); - } - permissionService.requiresPermission(id, Permission.WRITE_PROJECT); - permissionService.deleteOrAchiveResource(id); - } -} diff --git a/src/backend/trigger-service/pom.xml b/src/backend/trigger-service/pom.xml deleted file mode 100644 index 565b8d286c..0000000000 --- a/src/backend/trigger-service/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - trigger-service - pom - - trigger-client - scheduler-service - - - diff --git a/src/backend/trigger-service/scheduler-service/pom.xml b/src/backend/trigger-service/scheduler-service/pom.xml deleted file mode 100644 index ee6501e209..0000000000 --- a/src/backend/trigger-service/scheduler-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - trigger-service - com.activepieces - 1.0 - - 4.0.0 - - scheduler-service - pom - - scheduler-client - scheduler-server - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/trigger-service/scheduler-service/scheduler-client/pom.xml b/src/backend/trigger-service/scheduler-service/scheduler-client/pom.xml deleted file mode 100644 index e843c74162..0000000000 --- a/src/backend/trigger-service/scheduler-service/scheduler-client/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - scheduler-service - com.activepieces - 1.0 - - 4.0.0 - - scheduler-client - - - com.activepieces - trigger-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/trigger-service/scheduler-service/scheduler-client/src/main/java/com/activepieces/trigger/schedule/client/Job.java b/src/backend/trigger-service/scheduler-service/scheduler-client/src/main/java/com/activepieces/trigger/schedule/client/Job.java deleted file mode 100644 index 0360fff3f7..0000000000 --- a/src/backend/trigger-service/scheduler-service/scheduler-client/src/main/java/com/activepieces/trigger/schedule/client/Job.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.activepieces.trigger.schedule.client; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.time.Instant; - -@AllArgsConstructor -@NoArgsConstructor -@SuperBuilder -public class Job { - - @JsonProperty - private Instant nextFireTime; - - @JsonProperty - private String id; - - -} diff --git a/src/backend/trigger-service/scheduler-service/scheduler-client/src/main/java/com/activepieces/trigger/schedule/client/ScheduleService.java b/src/backend/trigger-service/scheduler-service/scheduler-client/src/main/java/com/activepieces/trigger/schedule/client/ScheduleService.java deleted file mode 100644 index 43cd016fc1..0000000000 --- a/src/backend/trigger-service/scheduler-service/scheduler-client/src/main/java/com/activepieces/trigger/schedule/client/ScheduleService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.activepieces.trigger.schedule.client; - -import org.quartz.SchedulerException; - -public interface ScheduleService { - - Job get(String id) throws SchedulerException; - -} diff --git a/src/backend/trigger-service/scheduler-service/scheduler-server/pom.xml b/src/backend/trigger-service/scheduler-service/scheduler-server/pom.xml deleted file mode 100644 index ce519e3bd0..0000000000 --- a/src/backend/trigger-service/scheduler-service/scheduler-server/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - scheduler-service - com.activepieces - 1.0 - - 4.0.0 - - scheduler-server - - - com.activepieces - authentication-client - 1.0 - compile - - - com.activepieces - scheduler-client - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - com.activepieces - instance-client - 1.0 - compile - - - com.activepieces - executor-client - 1.0 - compile - - - com.activepieces - component-service - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/trigger-service/scheduler-service/scheduler-server/src/main/java/com/activepieces/trigger/schedule/server/component/ScheduleServiceImpl.java b/src/backend/trigger-service/scheduler-service/scheduler-server/src/main/java/com/activepieces/trigger/schedule/server/component/ScheduleServiceImpl.java deleted file mode 100644 index e7083ce92d..0000000000 --- a/src/backend/trigger-service/scheduler-service/scheduler-server/src/main/java/com/activepieces/trigger/schedule/server/component/ScheduleServiceImpl.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.activepieces.trigger.schedule.server.component; - -import com.activepieces.common.error.ErrorServiceHandler; -import com.activepieces.common.error.exception.collection.CollectionVersionNotFoundException; -import com.activepieces.common.error.exception.flow.FlowVersionNotFoundException; -import com.activepieces.component.ComponentService; -import com.activepieces.entity.enums.ComponentTriggerType; -import com.activepieces.entity.enums.InstanceStatus; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.instance.client.InstancePublisher; -import com.activepieces.instance.client.InstanceSubscriber; -import com.activepieces.instance.client.model.InstanceEventType; -import com.activepieces.instance.client.model.InstanceView; -import com.activepieces.trigger.model.ComponentTriggerMetadataView; -import com.activepieces.trigger.model.ScheduleMetadataTriggerView; -import com.activepieces.trigger.model.TriggerMetadataView; -import com.activepieces.trigger.schedule.client.Job; -import com.activepieces.trigger.schedule.client.ScheduleService; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.quartz.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.util.Objects; - -import static org.quartz.CronScheduleBuilder.cronSchedule; - -@Service -@Log4j2 -public class ScheduleServiceImpl implements ScheduleService, InstanceSubscriber { - - private final Scheduler scheduler; - private final FlowVersionService flowVersionService; - private final ErrorServiceHandler errorServiceHandler; - private final ComponentService componentService; - - @Autowired - public ScheduleServiceImpl( - @NonNull final Scheduler scheduler, - @NonNull final FlowVersionService flowVersionService, - @NonNull final InstancePublisher instancePublisher, - @NonNull final ComponentService componentService, - @NonNull final ErrorServiceHandler errorServiceHandler) { - instancePublisher.addSubscriber(this); - this.scheduler = scheduler; - this.componentService = componentService; - this.errorServiceHandler = errorServiceHandler; - this.flowVersionService = flowVersionService; - } - - public Job create(InstanceView view, Ksuid flowVersionId, final String cronExpression) - throws SchedulerException, FlowVersionNotFoundException, - PermissionDeniedException { - FlowVersionView flowVersionView = flowVersionService.get(flowVersionId); - JobDetail jobDetail = - basicJobDetails( - view.getId(), flowVersionView.getFlowId(), buildJobDataMap(view, flowVersionId)); - Trigger trigger = buildJobTrigger(jobDetail, cronExpression); - scheduler.scheduleJob(jobDetail, trigger); - log.info( - String.format( - "Created Job for instanceId=%s for versionId %s with next fire %s", - view.getId(), flowVersionId, trigger.getNextFireTime().toString())); - return Job.builder() - .id(jobDetail.getKey().getName()) - .nextFireTime(trigger.getNextFireTime().toInstant()) - .build(); - } - - @Override - public Job get(String id) throws SchedulerException { - Trigger trigger = scheduler.getTrigger(new TriggerKey(id)); - return Job.builder().id(id).nextFireTime(trigger.getNextFireTime().toInstant()).build(); - } - - private JobDataMap buildJobDataMap(InstanceView instanceView, Ksuid flowVersionId) { - JobDataMap jobDataMap = new JobDataMap(); - jobDataMap.put(ScheduleTriggerJob.INSTANCE_ID, instanceView.getId()); - jobDataMap.put(ScheduleTriggerJob.FLOW_VERSION_ID, flowVersionId); - return jobDataMap; - } - - private String key(Ksuid instanceId, Ksuid flowId) { - return String.format("%s_%s", instanceId.toString(), flowId.toString()); - } - - private JobDetail basicJobDetails(Ksuid instanceId, Ksuid flowId, JobDataMap jobDataMap) { - return JobBuilder.newJob(ScheduleTriggerJob.class) - .withIdentity(key(instanceId, flowId)) - .usingJobData(jobDataMap) - .storeDurably() - .build(); - } - - private Trigger buildJobTrigger(final JobDetail jobDetail, - final String cronExpression) { - return TriggerBuilder.newTrigger() - .forJob(jobDetail) - .withIdentity(jobDetail.getKey().getName()) - .withSchedule( - cronSchedule(cronExpression) - .withMisfireHandlingInstructionDoNothing()) - .build(); - } - - private String getCronExpression(final TriggerMetadataView triggerMetadataView) throws IOException, InterruptedException { - if(triggerMetadataView instanceof ScheduleMetadataTriggerView){ - return ((ScheduleMetadataTriggerView) triggerMetadataView).getSettings().getCronExpression(); - } - if(triggerMetadataView instanceof ComponentTriggerMetadataView){ - ComponentTriggerMetadataView componentTrigger = (ComponentTriggerMetadataView) triggerMetadataView; - final ComponentTriggerType triggerType = componentService.getTriggerType( - componentTrigger.getSettings().getComponentName(), componentTrigger.getSettings().getTriggerName() - ); - if(triggerType.equals(ComponentTriggerType.POLLING)){ - final String fifteenMinutes = "0 */15 * ? * *"; - return fifteenMinutes; - } - } - return null; - } - private void createIfSchedule(InstanceView entity) - throws PermissionDeniedException, SchedulerException, IOException, - FlowVersionNotFoundException, CollectionVersionNotFoundException, InterruptedException { - for (Ksuid flowVersionId : entity.getFlowVersionId().values()) { - final FlowVersionView flowVersion = flowVersionService.getOptional(flowVersionId).orElseThrow(); - final String cronExpression = getCronExpression(flowVersion.getTrigger()); - if (Objects.nonNull(cronExpression)){ - log.info("Creating Schedule Job binding" + entity); - create(entity, flowVersionId, cronExpression); - } - } - } - - private void deleteSchedule(InstanceView entity) - throws PermissionDeniedException, SchedulerException, FlowVersionNotFoundException, CollectionVersionNotFoundException { - for (Ksuid flowVersionId : entity.getFlowVersionId().values()) { - FlowVersionView flowVersionView = flowVersionService.get(flowVersionId); - JobKey jobKey = new JobKey(key(entity.getId(), flowVersionView.getFlowId())); - if (scheduler.checkExists(jobKey)) { - log.info(String.format("Deleted Job for triggerId=%s ", entity.getId())); - scheduler.deleteJob(jobKey); - } - } - } - - @Override - public void onListen(InstanceEventType type, InstanceView entity) { - try { - switch (type) { - case CREATE: - if (entity.getStatus().equals(InstanceStatus.ENABLED)) { - createIfSchedule(entity); - } - break; - case DELETE: - deleteSchedule(entity); - break; - case UPDATE: - log.info("Updating Schedule Job binding" + entity.toString()); - deleteSchedule(entity); - if (entity.getStatus().equals(InstanceStatus.ENABLED)) { - createIfSchedule(entity); - } - break; - default: - break; - } - } catch (SchedulerException | PermissionDeniedException | FlowVersionNotFoundException | CollectionVersionNotFoundException | IOException | InterruptedException e) { - throw errorServiceHandler.createInternalError(e); - } - } -} diff --git a/src/backend/trigger-service/scheduler-service/scheduler-server/src/main/java/com/activepieces/trigger/schedule/server/component/ScheduleTriggerJob.java b/src/backend/trigger-service/scheduler-service/scheduler-server/src/main/java/com/activepieces/trigger/schedule/server/component/ScheduleTriggerJob.java deleted file mode 100644 index e0df8583f1..0000000000 --- a/src/backend/trigger-service/scheduler-service/scheduler-server/src/main/java/com/activepieces/trigger/schedule/server/component/ScheduleTriggerJob.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.activepieces.trigger.schedule.server.component; - -import com.activepieces.action.FlowPublisherService; -import com.activepieces.common.error.ErrorServiceHandler; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.quartz.QuartzJobBean; -import org.springframework.stereotype.Component; - -import java.util.Collections; -import java.util.UUID; - -@Component -public class ScheduleTriggerJob extends QuartzJobBean { - - private static final Logger logger = LoggerFactory.getLogger(ScheduleTriggerJob.class); - public static final String INSTANCE_ID = "instanceId"; - public static final String FLOW_VERSION_ID = "flowVersionId"; - - private final FlowPublisherService flowExecutionPublisher; - private final ErrorServiceHandler errorServiceHandler; - - @Autowired - public ScheduleTriggerJob( - @NonNull final FlowPublisherService flowExecutionPublisher, - @NonNull final ErrorServiceHandler errorServiceHandler) { - this.flowExecutionPublisher = flowExecutionPublisher; - this.errorServiceHandler = errorServiceHandler; - } - - @Override - protected void executeInternal(JobExecutionContext jobExecutionContext) { - JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); - Ksuid instanceId = (Ksuid) jobDataMap.get(INSTANCE_ID); - Ksuid flowVersionId = (Ksuid) jobDataMap.get(FLOW_VERSION_ID); - logger.info( - "Executing Job with key {} instance id {}", - jobExecutionContext.getJobDetail().getKey(), - instanceId); - try { - flowExecutionPublisher.executeInstance( - instanceId, flowVersionId, Collections.emptyMap()); - } catch (Exception e) { - throw errorServiceHandler.createInternalError(e); - } - - logger.debug( - "Finished Job with key {} instance id {}", - jobExecutionContext.getJobDetail().getKey(), - instanceId); - } -} diff --git a/src/backend/trigger-service/trigger-client/pom.xml b/src/backend/trigger-service/trigger-client/pom.xml deleted file mode 100644 index a9af79bce2..0000000000 --- a/src/backend/trigger-service/trigger-client/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - trigger-service - com.activepieces - 1.0 - - 4.0.0 - trigger-client - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - actions-client - 1.0 - compile - - - junit - junit - test - - - - - diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/mapper/TriggerMapper.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/mapper/TriggerMapper.java deleted file mode 100644 index 94046bc5ef..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/mapper/TriggerMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.activepieces.trigger.mapper; - -import com.activepieces.actions.mapper.ActionMapper; -import com.activepieces.entity.subdocuments.trigger.*; -import com.activepieces.trigger.model.*; -import org.mapstruct.Mapper; -import org.mapstruct.SubclassMapping; -import org.mapstruct.SubclassMappings; - -import static org.mapstruct.SubclassExhaustiveStrategy.RUNTIME_EXCEPTION; - -@Mapper( - subclassExhaustiveStrategy = RUNTIME_EXCEPTION, - componentModel = "spring", - uses = {ActionMapper.class}) -public abstract class TriggerMapper { - - @SubclassMappings( - value = { - @SubclassMapping( - source = ScheduleTriggerMetadata.class, - target = ScheduleMetadataTriggerView.class), - @SubclassMapping( - source = InstanceStoppedTriggerMetadata.class, - target = InstanceStoppedTriggerMetadataView.class), - @SubclassMapping( - source = InstanceStartedTriggerMetadata.class, - target = InstanceStartedTriggerMetadataView.class), - @SubclassMapping( - source = WebhookTriggerMetadata.class, - target = WebhookTriggerMetadataView.class), - @SubclassMapping( - source = ComponentTriggerMetadata.class, - target = ComponentTriggerMetadataView.class), - @SubclassMapping( - source = EmptyTriggerMetadata.class, - target = EmptyTriggerMetadataView.class) - }) - public abstract TriggerMetadataView toView(TriggerMetadata entity); - - @SubclassMappings( - value = { - @SubclassMapping( - source = ScheduleMetadataTriggerView.class, - target = ScheduleTriggerMetadata.class), - @SubclassMapping( - source = InstanceStoppedTriggerMetadataView.class, - target = InstanceStoppedTriggerMetadata.class), - @SubclassMapping( - source = InstanceStartedTriggerMetadataView.class, - target = InstanceStartedTriggerMetadata.class), - @SubclassMapping( - source = WebhookTriggerMetadataView.class, - target = WebhookTriggerMetadata.class), - @SubclassMapping( - source = ComponentTriggerMetadataView.class, - target = ComponentTriggerMetadata.class), - @SubclassMapping( - source = EmptyTriggerMetadataView.class, - target = EmptyTriggerMetadata.class) - }) - public abstract TriggerMetadata fromView(TriggerMetadataView entity); -} diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/ComponentTriggerMetadataView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/ComponentTriggerMetadataView.java deleted file mode 100644 index 5930f2ed1d..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/ComponentTriggerMetadataView.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.trigger.model; - -import com.activepieces.entity.subdocuments.trigger.settings.ComponentTriggerSettings; -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class ComponentTriggerMetadataView extends TriggerMetadataView { - - @JsonProperty - @Valid - @NotNull - private ComponentTriggerSettings settings; - -} \ No newline at end of file diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/EmptyTriggerMetadataView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/EmptyTriggerMetadataView.java deleted file mode 100644 index 7bbfa1b1b5..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/EmptyTriggerMetadataView.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.activepieces.trigger.model; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@NoArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class EmptyTriggerMetadataView extends TriggerMetadataView { - - -} diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/InstanceStartedTriggerMetadataView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/InstanceStartedTriggerMetadataView.java deleted file mode 100644 index a35301d3be..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/InstanceStartedTriggerMetadataView.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.trigger.model; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class InstanceStartedTriggerMetadataView extends TriggerMetadataView { - - @JsonProperty - @Valid - @NotNull - private EmptySettings settings; - -} \ No newline at end of file diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/InstanceStoppedTriggerMetadataView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/InstanceStoppedTriggerMetadataView.java deleted file mode 100644 index fc687124ac..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/InstanceStoppedTriggerMetadataView.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.trigger.model; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class InstanceStoppedTriggerMetadataView extends TriggerMetadataView { - - @JsonProperty - @Valid - @NotNull - private EmptySettings settings; - -} \ No newline at end of file diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/ScheduleMetadataTriggerView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/ScheduleMetadataTriggerView.java deleted file mode 100644 index a3830440bc..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/ScheduleMetadataTriggerView.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.activepieces.trigger.model; - -import com.activepieces.entity.subdocuments.trigger.settings.ScheduleTriggerSettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@SuperBuilder(toBuilder = true) -public class ScheduleMetadataTriggerView extends TriggerMetadataView { - - @JsonProperty - @Valid - @NotNull - private ScheduleTriggerSettings settings; - -} \ No newline at end of file diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/TriggerMetadataView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/TriggerMetadataView.java deleted file mode 100644 index 8e5205c94a..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/TriggerMetadataView.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.activepieces.trigger.model; - -import com.activepieces.actions.model.action.ActionMetadataView; -import com.activepieces.common.validation.CodeNameConstraints; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.*; -import lombok.experimental.SuperBuilder; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; -import java.io.Serializable; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property="type", visible = true, defaultImpl = EmptyTriggerMetadataView.class) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ScheduleMetadataTriggerView.class, name = "SCHEDULE"), - @JsonSubTypes.Type(value = EmptyTriggerMetadataView.class, name = "EMPTY"), - @JsonSubTypes.Type(value = InstanceStartedTriggerMetadataView.class, name = "COLLECTION_ENABLED"), - @JsonSubTypes.Type(value = InstanceStoppedTriggerMetadataView.class, name = "COLLECTION_DISABLED"), - @JsonSubTypes.Type(value = WebhookTriggerMetadataView.class, name = "WEBHOOK"), - @JsonSubTypes.Type(value = ComponentTriggerMetadataView.class, name = "COMPONENT_TRIGGER") -} -) -@ToString -@EqualsAndHashCode -public abstract class TriggerMetadataView implements Serializable { - - @Pattern(regexp = "SCHEDULE|EMPTY|WEBHOOK|COLLECTION_ENABLED|COLLECTION_DISABLED|COMPONENT_TRIGGER") - @JsonProperty - private String type; - - @JsonProperty - @NotEmpty - private String displayName; - - @JsonProperty - @CodeNameConstraints - private String name; - - @JsonProperty - private ActionMetadataView nextAction; - - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private boolean valid; - - public abstract TriggerMetadataViewBuilder toBuilder(); - - -} diff --git a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/WebhookTriggerMetadataView.java b/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/WebhookTriggerMetadataView.java deleted file mode 100644 index b7262b8ac1..0000000000 --- a/src/backend/trigger-service/trigger-client/src/main/java/com/activepieces/trigger/model/WebhookTriggerMetadataView.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.activepieces.trigger.model; - -import com.activepieces.entity.subdocuments.trigger.settings.EmptySettings; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@SuperBuilder(toBuilder = true) -public class WebhookTriggerMetadataView extends TriggerMetadataView { - - @JsonProperty - @Valid - @NotNull - private EmptySettings settings; - -} \ No newline at end of file diff --git a/src/backend/variable-service/pom.xml b/src/backend/variable-service/pom.xml deleted file mode 100644 index 1d4bca9b15..0000000000 --- a/src/backend/variable-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - variable-service - pom - - variable-client - variable-server - - - - 11 - 11 - - - diff --git a/src/backend/variable-service/variable-client/pom.xml b/src/backend/variable-service/variable-client/pom.xml deleted file mode 100644 index 488f213c54..0000000000 --- a/src/backend/variable-service/variable-client/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - variable-service - com.activepieces - 1.0 - - 4.0.0 - - variable-client - - - com.activepieces - entities - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/OAuth2Service.java b/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/OAuth2Service.java deleted file mode 100644 index 8cd1cc4d3c..0000000000 --- a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/OAuth2Service.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.variable.model; - -import com.activepieces.entity.subdocuments.field.connection.oauth2.OAuth2Variable; -import com.fasterxml.jackson.core.JsonProcessingException; -import org.springframework.http.ResponseEntity; - -import java.util.Map; - -public interface OAuth2Service { - - ResponseEntity validateAuthorizationCode(String clientId, String clientToken, String tokenUrl, String authorizationCode) throws JsonProcessingException; - - Map refreshAndGetAccessToken(OAuth2Variable oAuth2LoginSettings, Map authResponse); -} diff --git a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/VariableService.java b/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/VariableService.java deleted file mode 100644 index 62bbd1695e..0000000000 --- a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/VariableService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.variable.model; - -import com.activepieces.entity.subdocuments.field.Variable; -import com.activepieces.variable.model.exception.MissingConfigsException; - -import java.util.List; -import java.util.Map; - -public interface VariableService { - - Map flatConfigsValue(List pieceConfigs) throws MissingConfigsException; - - -} diff --git a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/exception/MissingConfigsException.java b/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/exception/MissingConfigsException.java deleted file mode 100644 index 05d54aee4c..0000000000 --- a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/exception/MissingConfigsException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.activepieces.variable.model.exception; - -import com.activepieces.common.error.ErrorCode; -import com.activepieces.common.error.ErrorResponseException; -import lombok.Getter; - -import java.util.List; - -@Getter -public class MissingConfigsException extends Exception implements ErrorResponseException { - - private final List configs; - - public MissingConfigsException(final List configs){ - super(String.format("The following variables=%s is required", String.join(",", configs))); - this.configs = configs; - } - - public MissingConfigsException(MissingConfigsException missingConfigsException, String actionName){ - super(String.format("The following configs=%s is required for actionName=%s", String.join(",", missingConfigsException.getConfigs()), actionName)); - this.configs = missingConfigsException.getConfigs(); - } - @Override - public ErrorCode getErrorCode() { - return ErrorCode.MISSING_CONFIGS; - } -} diff --git a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/request/ClaimOAuth2RequestWithSecret.java b/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/request/ClaimOAuth2RequestWithSecret.java deleted file mode 100644 index 33d4c7fa7e..0000000000 --- a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/request/ClaimOAuth2RequestWithSecret.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.activepieces.variable.model.request; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.NotNull; - -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Getter -public class ClaimOAuth2RequestWithSecret { - - @JsonProperty - @NotNull - private String code; - - @JsonProperty - @URL(regexp = "^(http|https).*") - private String tokenUrl; - - @JsonProperty - @NotNull - private String clientId; - - @JsonProperty - @NotNull - private String clientSecret; -} diff --git a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/request/RefreshConfigRequest.java b/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/request/RefreshConfigRequest.java deleted file mode 100644 index 0e42c72c4f..0000000000 --- a/src/backend/variable-service/variable-client/src/main/java/com/activepieces/variable/model/request/RefreshConfigRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.variable.model.request; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.Map; - -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Getter -public class RefreshConfigRequest { - - @JsonProperty @NotNull private Map configs; - -} diff --git a/src/backend/variable-service/variable-server/pom.xml b/src/backend/variable-service/variable-server/pom.xml deleted file mode 100644 index fc48a92ae2..0000000000 --- a/src/backend/variable-service/variable-server/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - variable-service - com.activepieces - 1.0 - - 4.0.0 - - variable-server - - - com.activepieces - variable-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - com.activepieces - worker-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/OAuth2ServiceImpl.java b/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/OAuth2ServiceImpl.java deleted file mode 100644 index f608a14075..0000000000 --- a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/OAuth2ServiceImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.activepieces.variable.server; - -import com.activepieces.entity.subdocuments.field.connection.oauth2.OAuth2Settings; -import com.activepieces.entity.subdocuments.field.connection.oauth2.OAuth2Variable; -import com.activepieces.variable.model.OAuth2Service; -import com.activepieces.variable.server.strategy.Auth2BodyStrategy; -import com.activepieces.variable.server.strategy.Auth2Strategy; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.HttpStatusCodeException; -import org.springframework.web.client.RestTemplate; - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@Log4j2 -@Service -public class OAuth2ServiceImpl implements OAuth2Service { - private final ObjectMapper objectMapper; - - private final List auth2Strategies; - private final String AUTH_RESPONSE = "auth_response"; - - @Autowired - public OAuth2ServiceImpl( - ObjectMapper objectMapper, - RestTemplate restTemplate, - @Value("${com.activepieces.redirect-url}") String redirectUrl) { - this.objectMapper = objectMapper; - this.auth2Strategies = List.of(new Auth2BodyStrategy(restTemplate, redirectUrl, objectMapper)); - } - - @Override - public ResponseEntity validateAuthorizationCode( - String clientId, String clientSecret, String tokenUrl, String authorizationCode) - throws JsonProcessingException { - ResponseEntity response = null; - for (Auth2Strategy auth2Strategy : auth2Strategies) { - try { - return ResponseEntity.ok( - Objects.requireNonNull( - auth2Strategy.claimCode( - clientId, clientSecret, tokenUrl, authorizationCode))); - } catch (Exception e) { - if (e instanceof HttpStatusCodeException) { - HttpStatus status = ((HttpStatusCodeException) e).getStatusCode(); - ObjectNode body = - objectMapper.readValue( - ((HttpStatusCodeException) e).getResponseBodyAsString(), ObjectNode.class); - response = ResponseEntity.status(status).body(body); - }else{ - e.printStackTrace(); - } - } - } - return response; - } - - - @Override - public Map refreshAndGetAccessToken( - @NotNull final OAuth2Variable variable, @NotNull final Map oAuth2Response) { - final String refreshToken = getRefreshToken(oAuth2Response); - if (Objects.isNull(refreshToken)) { - return oAuth2Response; - } - List exceptions = new ArrayList<>(); - OAuth2Settings settings = variable.getSettings(); - String clientSecret = settings.getClientSecret(); - Map refreshedResponse = oAuth2Response; - for (Auth2Strategy auth2Strategy : auth2Strategies) { - try { - refreshedResponse = - auth2Strategy.refreshToken( - settings.getClientId(), - clientSecret, - settings.getTokenUrl(), - settings.getRefreshUrl(), - refreshToken); - refreshedResponse.put(AUTH_RESPONSE, oAuth2Response.get(AUTH_RESPONSE)); - } catch (Exception ignored) { - exceptions.add(ignored); - } - } - if (getAccessToken(refreshedResponse) - .equals(getAccessToken(oAuth2Response))) { - log.error("Refresh failed"); - for (Exception exception : exceptions) { - log.error(exception); - } - } - return refreshedResponse; - } - - private static String getRefreshToken(Map objectNode){ - final String refreshToken = "refresh_token"; - if(!objectNode.containsKey(refreshToken)){ - return null; - } - return (String) objectNode.get("refresh_token"); - } - - private static String getAccessToken(Map objectNode){ - final String refreshToken = "access_token"; - if(!objectNode.containsKey(refreshToken)){ - return null; - } - return (String) objectNode.get("access_token"); - } - -} diff --git a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/VariableServiceImpl.java b/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/VariableServiceImpl.java deleted file mode 100644 index ec8cdb23de..0000000000 --- a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/VariableServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.activepieces.variable.server; - -import com.activepieces.entity.enums.InputVariableType; -import com.activepieces.entity.subdocuments.field.Variable; -import com.activepieces.entity.subdocuments.field.connection.oauth2.OAuth2Variable; -import com.activepieces.variable.model.OAuth2Service; -import com.activepieces.variable.model.VariableService; -import com.activepieces.worker.service.CodeExecutionService; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.java.Log; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -@Log -@Service -public class VariableServiceImpl implements VariableService { - - private final ObjectMapper mapper; - - private final OAuth2Service oAuth2Service; - private final CodeExecutionService codeExecutionService; - - @Autowired - public VariableServiceImpl( - ObjectMapper mapper, - CodeExecutionService codeExecutionService, - OAuth2Service oAuth2Service) { - this.codeExecutionService = codeExecutionService; - this.oAuth2Service = oAuth2Service; - this.mapper = mapper; - } - - @Override - public Map flatConfigsValue( - List pieceConfigs) { - Map clonedConfigs = new HashMap<>(); - for (Variable variableView : pieceConfigs) { - Object replacedValue = variableView.getValue(); - clonedConfigs.put(variableView.getKey(), refreshVariable(variableView, replacedValue)); - } - return clonedConfigs; - } - - - private Object refreshVariable(Variable variable, Object value) { - if (variable.getType().equals(InputVariableType.OAUTH2) && Objects.nonNull(value)) { - - return oAuth2Service.refreshAndGetAccessToken( - (OAuth2Variable) variable, (Map) value); - } - return value; - } - - -} diff --git a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/connector/OAuthController.java b/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/connector/OAuthController.java deleted file mode 100644 index 4ba3df2a58..0000000000 --- a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/connector/OAuthController.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.activepieces.variable.server.connector; - -import com.activepieces.variable.model.OAuth2Service; -import com.activepieces.variable.model.request.ClaimOAuth2RequestWithSecret; -import com.fasterxml.jackson.core.JsonProcessingException; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Hidden -@RequestMapping("oauth2") -public class OAuthController { - - private final OAuth2Service oAuth2Service; - @Autowired - public OAuthController( - @NonNull final OAuth2Service oAuth2Service) { - this.oAuth2Service = oAuth2Service; - } - @PostMapping("/claim-with-secret") - public ResponseEntity claimOAuth2(@RequestBody ClaimOAuth2RequestWithSecret request) - throws JsonProcessingException { - return oAuth2Service.validateAuthorizationCode( - request.getClientId(), - request.getClientSecret(), - request.getTokenUrl(), - request.getCode()); - } -} diff --git a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/strategy/Auth2BodyStrategy.java b/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/strategy/Auth2BodyStrategy.java deleted file mode 100644 index 63f767a6e9..0000000000 --- a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/strategy/Auth2BodyStrategy.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.activepieces.variable.server.strategy; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.extern.log4j.Log4j2; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.net.URI; -import java.util.Map; -import java.util.Objects; - -@Log4j2 -public class Auth2BodyStrategy implements Auth2Strategy { - - private final RestTemplate restTemplate; - private final String redirectUrl; - private final ObjectMapper objectMapper; - - public Auth2BodyStrategy( - final RestTemplate restTemplate, final String redirectUrl, final ObjectMapper objectMapper) { - this.restTemplate = restTemplate; - this.objectMapper = objectMapper; - this.redirectUrl = redirectUrl; - } - - @Override - public Map claimCode( - String clientId, String clientSecret, String tokenUrl, String authorizationCode) - throws JsonProcessingException { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("grant_type", "authorization_code"); - map.add("client_id", clientId); - map.add("client_secret", clientSecret); - map.add("redirect_uri", redirectUrl); - map.add("code", authorizationCode); - // map.add("code_verifier", "lEMSeXaXOAKAw53YlpPK"); - HttpEntity> request = new HttpEntity<>(map, headers); - String body = restTemplate.postForObject(URI.create(tokenUrl), request, String.class); - return objectMapper.convertValue(objectMapper.readValue(body, ObjectNode.class) - , new TypeReference<>() { - }); - } - - @Override - public Map refreshToken( - String clientId, String clientSecret, String tokenUrl, String refreshUrl, String refreshToken) - throws JsonProcessingException { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("grant_type", "refresh_token"); - map.add("client_id", clientId); - map.add("client_secret", clientSecret); - map.add("redirect_uri", redirectUrl); - map.add("refresh_token", refreshToken); - HttpEntity> request = new HttpEntity<>(map, headers); - String body = - restTemplate.postForObject( - URI.create( - Objects.nonNull(refreshUrl) && refreshUrl.length() > 0 ? refreshUrl : tokenUrl), - request, - String.class); - Map response = objectMapper.convertValue(objectMapper.readValue(body, ObjectNode.class) - ,new TypeReference>(){}); - response.putIfAbsent("refresh_token", refreshToken); - return response; - } -} diff --git a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/strategy/Auth2Strategy.java b/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/strategy/Auth2Strategy.java deleted file mode 100644 index b7713a869d..0000000000 --- a/src/backend/variable-service/variable-server/src/main/java/com/activepieces/variable/server/strategy/Auth2Strategy.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.variable.server.strategy; - - -import com.fasterxml.jackson.core.JsonProcessingException; - -import java.util.Map; - -public interface Auth2Strategy { - - Map claimCode( - String clientId, String clientSecret, String tokenUrl, String authorizationCode) throws JsonProcessingException; - - Map refreshToken(String clientId, String clientSecret, String tokenUrl, String refreshUrl, String refreshToken) throws JsonProcessingException; -} diff --git a/src/backend/worker-service/pom.xml b/src/backend/worker-service/pom.xml deleted file mode 100644 index 2ff030a750..0000000000 --- a/src/backend/worker-service/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - backend - com.activepieces - 1.0 - - 4.0.0 - - worker-service - pom - - worker-server - worker-client - - - - 11 - 11 - - - diff --git a/src/backend/worker-service/worker-client/pom.xml b/src/backend/worker-service/worker-client/pom.xml deleted file mode 100644 index 3c963628da..0000000000 --- a/src/backend/worker-service/worker-client/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - worker-service - com.activepieces - 1.0 - - 4.0.0 - - worker-client - - - com.activepieces - entities - 1.0 - compile - - - com.activepieces - flow-client - 1.0 - compile - - - com.activepieces - collection-client - 1.0 - compile - - - - - 11 - 11 - - - \ No newline at end of file diff --git a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/CodeExecutionStatusEnum.java b/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/CodeExecutionStatusEnum.java deleted file mode 100644 index b7e602e986..0000000000 --- a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/CodeExecutionStatusEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.activepieces.worker.model; - -import java.util.Objects; - -public enum CodeExecutionStatusEnum { - OK("OK"), - RUNTIME_ERROR("Runtime error"), - CRASHED("Program crashed"), - TIMEOUT("Timeout"), - INTERNAL_ERROR("Internal Error"), - UNKNOWN_ERROR("Unknown Error"), - INVALID_ARTIFACT("Invalid Artifact"); - - private final String message; - - CodeExecutionStatusEnum(String message){ - this.message = message; - } - - public String getMessage(){ - return message; - } - - public static CodeExecutionStatusEnum fromStatus(String status){ - if(Objects.isNull(status)){ - return OK; - } - switch (status){ - case "XX": - return INTERNAL_ERROR; - case "TO": - return TIMEOUT; - case "RE": - return RUNTIME_ERROR; - case "SG": - return CRASHED; - default: - return UNKNOWN_ERROR; - } - } -} diff --git a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/ExecutionCodeResult.java b/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/ExecutionCodeResult.java deleted file mode 100644 index ac6082ab08..0000000000 --- a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/ExecutionCodeResult.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.activepieces.worker.model; - -import com.activepieces.entity.subdocuments.runs.StepOutput; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import lombok.experimental.SuperBuilder; - -@Getter -@Setter -@SuperBuilder -@ToString -public class ExecutionCodeResult extends StepOutput { - - @JsonProperty - private CodeExecutionStatusEnum verdict; - - @JsonProperty - private double timeInSeconds; - - @JsonProperty - private String standardOutput; - -} diff --git a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/WorkerExecutionResult.java b/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/WorkerExecutionResult.java deleted file mode 100644 index 99e0e9b72c..0000000000 --- a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/model/WorkerExecutionResult.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.activepieces.worker.model; - -import com.activepieces.entity.enums.FlowExecutionStatus; -import com.activepieces.entity.subdocuments.runs.ExecutionStateView; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; -import lombok.experimental.SuperBuilder; - -@Getter -@Setter -@SuperBuilder -@ToString -@AllArgsConstructor -@NoArgsConstructor -public class WorkerExecutionResult { - - @JsonProperty private FlowExecutionStatus status; - - @JsonProperty private long duration; - - @JsonProperty private Object output; - - @JsonInclude(JsonInclude.Include.NON_NULL) - @JsonProperty - private Object errorMessage; - - @JsonProperty private ExecutionStateView executionState; -} diff --git a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/service/CodeExecutionService.java b/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/service/CodeExecutionService.java deleted file mode 100644 index 532398f8ff..0000000000 --- a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/service/CodeExecutionService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.activepieces.worker.service; - -import com.activepieces.worker.model.ExecutionCodeResult; -import com.fasterxml.jackson.databind.JsonNode; -import com.github.ksuid.Ksuid; - -import java.io.InputStream; - -public interface CodeExecutionService { - - - ExecutionCodeResult executeCode(JsonNode input, InputStream artifactHash) throws Exception; - -} diff --git a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/service/WorkerService.java b/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/service/WorkerService.java deleted file mode 100644 index 09d5b2c1ed..0000000000 --- a/src/backend/worker-service/worker-client/src/main/java/com/activepieces/worker/service/WorkerService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.activepieces.worker.service; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; - -import java.util.Map; - -public interface WorkerService { - - InstanceRunView executeFlow( - InstanceRunView instanceRun, - CollectionVersionView collectionVersionView, - FlowVersionView flowVersionView, - Map configsInput, - Object triggerPayload, - StorePath storePath) throws Exception; - -} diff --git a/src/backend/worker-service/worker-server/pom.xml b/src/backend/worker-service/worker-server/pom.xml deleted file mode 100644 index 2d785817d2..0000000000 --- a/src/backend/worker-service/worker-server/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - worker-service - com.activepieces - 1.0 - - 4.0.0 - - worker-server - - - junit - junit - test - - - com.activepieces - flow-client - 1.0 - compile - - - com.activepieces - executor-server - 1.0 - compile - - - com.activepieces - worker-client - 1.0 - compile - - - com.activepieces - file-client - 1.0 - compile - - - com.activepieces - lock-service - 1.0 - compile - - - - - 11 - 11 - - - diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/Sandbox.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/Sandbox.java deleted file mode 100644 index 57578c0801..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/Sandbox.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.activepieces.worker; - -import com.activepieces.authentication.client.JWTService; -import com.activepieces.common.identity.WorkerIdentity; -import com.activepieces.common.utils.ArtifactUtils; -import com.activepieces.entity.subdocuments.runs.ActionExecutionStatus; -import com.activepieces.entity.subdocuments.runs.StepOutput; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.apache.commons.io.FileUtils; - -import javax.validation.constraints.NotNull; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.Map; - -@Log4j2 -public class Sandbox { - - private final int boxId; - private final long TIME_LIMIT_IN_SECONDS = 15 * 60L; - private final String META_FILENAME = "meta.txt"; - private final String STANDARD_OUTPUT = "_standardOutput.txt"; - private final String STANDARD_ERROR = "_standardError.txt"; - private final JWTService jwtService; - - public Sandbox(@NonNull final JWTService jwtService, - final int boxId) { - this.boxId = boxId; - this.jwtService = jwtService; - } - - public int getBoxId() { - return this.boxId; - } - - public void init() throws IOException, InterruptedException { - runIsolate(String.format("--box-id=%d --init", boxId)); - } - - public void clean() throws IOException, InterruptedException { - runIsolate(String.format("--box-id=%d --cleanup", boxId)); - } - - public String runIsolate(String command) throws IOException, InterruptedException { - String ISOLATE_BINARY = "./isolate"; - final String commandLine = String.format("%s %s", ISOLATE_BINARY, command); - log.info(commandLine); - return ArtifactUtils.runCommandAsRoot(commandLine); - } - - public void writeCode(@NotNull String fileName, @NonNull InputStream inputStream) - throws IOException { - File targetFilePath = new File(getSandboxFilePath("codes/" + fileName)); - FileUtils.copyInputStreamToFile(inputStream, targetFilePath); - } - - public void writeFlow( - @NotNull FlowVersionView flowVersionView, @NonNull ObjectMapper objectMapper) - throws IOException { - String targetFilePath = - getSandboxFilePath("flows/" + flowVersionView.getId().toString() + ".json"); - FileUtils.writeStringToFile( - new File(targetFilePath), - objectMapper.writeValueAsString(flowVersionView), - Charset.forName("UTF-8")); - } - - public void writeEntryPoint( - @NonNull CollectionVersionView collectionVersionView, - @NonNull FlowVersionView flowVersionView, - @NonNull String apiUrl, - @NonNull ObjectMapper objectMapper) - throws IOException { - String targetFilePath = getSandboxFilePath("input.json"); - ObjectNode entryJson = objectMapper.createObjectNode(); - entryJson.put("flowVersionId", flowVersionView.getId().toString()); - entryJson.put("collectionVersionId", collectionVersionView.getId().toString()); - entryJson.put("apiUrl", apiUrl); - entryJson.put("workerToken", jwtService.createTokenWithDefaultExpiration( - WorkerIdentity.builder() - .collectionId(collectionVersionView.getCollectionId()) - .flowId(flowVersionView.getFlowId()) - .build() - )); - FileUtils.writeStringToFile( - new File(targetFilePath), - objectMapper.writeValueAsString(entryJson), - Charset.forName("UTF-8")); - } - - public void writeContext( - @NotNull Map userInput, @NonNull ObjectMapper objectMapper) - throws IOException { - String targetFilePath = getSandboxFilePath("context.json"); - FileUtils.writeStringToFile( - new File(targetFilePath), - objectMapper.writeValueAsString(userInput), - Charset.forName("UTF-8")); - } - - public void writeConfigs( - @NotNull Map userInput, @NonNull ObjectMapper objectMapper) - throws IOException { - String targetFilePath = getSandboxFilePath("configs.json"); - FileUtils.writeStringToFile( - new File(targetFilePath), - objectMapper.writeValueAsString(userInput), - Charset.forName("UTF-8")); - } - - public void writeTriggerPayload( - @NotNull Object userInput, @NonNull ObjectMapper objectMapper) - throws IOException { - String targetFilePath = getSandboxFilePath("triggerPayload.json"); - StepOutput stepOutput = - StepOutput.builder() - .duration(0) - .output(userInput) - .status(ActionExecutionStatus.SUCCEEDED).build(); - FileUtils.writeStringToFile( - new File(targetFilePath), - objectMapper.writeValueAsString(stepOutput), - Charset.forName("UTF-8")); - } - - public void writeCollection( - @NonNull CollectionVersionView collectionVersionView, @NonNull ObjectMapper objectMapper) - throws IOException { - String targetFilePath = - getSandboxFilePath("collections/" + collectionVersionView.getId().toString() + ".json"); - FileUtils.writeStringToFile( - new File(targetFilePath), - objectMapper.writeValueAsString(collectionVersionView), - Charset.forName("UTF-8")); - } - - public String getSandboxFilePath(String fileName) { - return getSandboxFolderPath() + fileName; - } - - public String runJsFile(String fileName, String args) throws IOException, InterruptedException { - return runIsolate( - String.format( - "--dir=/usr/bin/ --dir=/etc/ --share-net --full-env --box-id=%d --processes --wall-time=%d " - + "--meta=%s --stdout=%s --stderr=%s " - + " --run /usr/bin/node %s %s", - boxId, - TIME_LIMIT_IN_SECONDS, - getSandboxFilePath(META_FILENAME), - STANDARD_OUTPUT, - STANDARD_ERROR, - fileName, args)); - } - - private String getSandboxFolderPath() { - String SANDBOX_LOCATION_TEMPLATE = "/var/local/lib/isolate/%d"; - return String.format(SANDBOX_LOCATION_TEMPLATE, boxId) + "/box/"; - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/Worker.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/Worker.java deleted file mode 100644 index c27c854ced..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/Worker.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.activepieces.worker; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.authentication.client.JWTService; -import com.activepieces.common.Constants; -import com.activepieces.file.service.FileService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.worker.service.FlowArtifactBuilderService; -import com.activepieces.worker.steps.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.Getter; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Getter -@Log4j2 -public class Worker { - - private final int workerId; - private final Sandbox sandbox; - private final List steps = new ArrayList<>(); - private final String apiUrl; - - public Worker( - int workerId, - @NonNull final String apiUrl, - @NonNull final JWTService jwtService, - @NonNull FlowArtifactBuilderService builderService, - @NonNull InstanceRunService instanceRunService, - @NonNull FileService fileService, - @NonNull ObjectMapper objectMapper) { - this.workerId = workerId; - this.sandbox = new Sandbox(jwtService, workerId); - this.apiUrl = apiUrl; - steps.add(new PrepareSandbox(this)); - steps.add( - new DownloadRequiredFiles( - this, - apiUrl, - fileService, - builderService, - objectMapper)); - steps.add(new ExecuteWorker(this, objectMapper)); - steps.add(new UploadRunState(instanceRunService)); - } - - public InstanceRunView run( - InstanceRunView instanceRunView, - CollectionVersionView collectionVersion, - FlowVersionView flowVersion, - Map configs, - Object triggerPayload, - StorePath storePath) - throws Exception { - long startTimeMs = System.currentTimeMillis(); - HashMap output = new HashMap<>(); - for (Step step : steps) { - step.next(instanceRunView, collectionVersion, flowVersion, configs, triggerPayload, output, storePath); - } - log.info("Preparing Sandbox {} took {}ms", sandbox.getBoxId(), System.currentTimeMillis() - startTimeMs); - return (InstanceRunView) output.get(Constants.RUN_RESULT_IN_MAP); - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/controller/CodeController.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/controller/CodeController.java deleted file mode 100644 index 4966c09b0e..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/controller/CodeController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.activepieces.worker.controller; - -import com.activepieces.worker.service.CodeExecutionService; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.annotation.Secured; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -@CrossOrigin -@RestController -@Hidden -@RequestMapping -public class CodeController { - - private final CodeExecutionService codeExecutionService; - private final ObjectMapper objectMapper; - - @Autowired - public CodeController( - @NonNull final ObjectMapper objectMapper, - @NonNull final CodeExecutionService codeExecutionService) { - this.codeExecutionService = codeExecutionService; - this.objectMapper = objectMapper; - } - - @Secured("ROLE_USER") - @PostMapping("/execute-code") - public ResponseEntity create( - @RequestPart(value = "input") Object jsonNode, - @RequestPart(value = "artifact") MultipartFile multipartFile) - throws Exception { - return ResponseEntity.ok( - codeExecutionService.executeCode( - objectMapper.convertValue(jsonNode, JsonNode.class), multipartFile.getInputStream())); - } - -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/CodeBuildService.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/CodeBuildService.java deleted file mode 100644 index dba8a21030..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/CodeBuildService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.activepieces.worker.service; - -import com.activepieces.worker.workers.CodeBuildWorker; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.NonNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - -@Service -public class CodeBuildService { - - private final BlockingQueue blockingQueue; - private final ArrayList workers; - private static final int NUMBER_OF_BUILDER = 32; - - @Autowired - public CodeBuildService(@NonNull final ObjectMapper objectMapper) { - this.blockingQueue = new LinkedBlockingQueue<>(); - this.workers = new ArrayList<>(); - for (int i = 0; i < NUMBER_OF_BUILDER; ++i) { - final CodeBuildWorker codeBuildWorker = new CodeBuildWorker(i, objectMapper); - workers.add(codeBuildWorker); - blockingQueue.add(i); - } - } - - public CodeBuildWorker obtainWorker() throws InterruptedException { - int workerIndex = this.blockingQueue.take(); - return workers.get(workerIndex); - } - - public void releaseWorker(CodeBuildWorker worker) { - blockingQueue.add(worker.getWorkerId()); - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/CodeExecutionServiceImpl.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/CodeExecutionServiceImpl.java deleted file mode 100644 index c8083cdaca..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/CodeExecutionServiceImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.activepieces.worker.service; - -import com.activepieces.authentication.client.JWTService; -import com.activepieces.common.error.exception.CodeArtifactBuildFailure; -import com.activepieces.entity.subdocuments.runs.ActionExecutionStatus; -import com.activepieces.worker.Sandbox; -import com.activepieces.worker.model.CodeExecutionStatusEnum; -import com.activepieces.worker.model.ExecutionCodeResult; -import com.activepieces.worker.workers.CodeBuildWorker; -import com.activepieces.worker.workers.CodeExecutionWorker; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.ksuid.Ksuid; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - -@Service -@Log4j2 -public class CodeExecutionServiceImpl implements CodeExecutionService { - - private static final int NUMBER_OF_WORKERS = 8; - private static final int NUMBER_OF_TEST_WORKER = 4; - - private final ArrayList workers; - private final BlockingQueue blockingQueue; - - private final ArrayList testWorkers; - private final BlockingQueue testBlockingQueue; - private final CodeBuildService codeBuildService; - - @Autowired - public CodeExecutionServiceImpl( - final CodeBuildService codeBuildService, - final JWTService jwtService, - final ObjectMapper objectMapper) { - this.codeBuildService = codeBuildService; - this.blockingQueue = new LinkedBlockingQueue<>(); - this.workers = new ArrayList<>(); - for (int i = 0; i < NUMBER_OF_WORKERS; ++i) { - this.blockingQueue.add(i); - final Sandbox sandbox = new Sandbox(jwtService, i); - this.workers.add(new CodeExecutionWorker(objectMapper, sandbox)); - } - - this.testBlockingQueue = new LinkedBlockingQueue<>(); - this.testWorkers = new ArrayList<>(); - for (int i = 0; i < NUMBER_OF_TEST_WORKER; ++i) { - this.testBlockingQueue.add(i); - final Sandbox sandbox = new Sandbox(jwtService, i + NUMBER_OF_WORKERS); - this.testWorkers.add(new CodeExecutionWorker(objectMapper, sandbox)); - } - } - - - public ExecutionCodeResult executeCode(JsonNode input, InputStream artifact) throws Exception { - int workerIndex = this.testBlockingQueue.take(); - CodeExecutionWorker codeExecutionWorker = this.testWorkers.get(workerIndex); - ExecutionCodeResult result; - CodeBuildWorker codeBuildWorker = codeBuildService.obtainWorker(); - try { - result = - codeExecutionWorker.executeSync(input, codeBuildWorker.build(artifact)); - } finally { - codeBuildService.releaseWorker(codeBuildWorker); - } - this.testBlockingQueue.add(workerIndex); - return result; - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/FlowArtifactBuilderService.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/FlowArtifactBuilderService.java deleted file mode 100644 index 7624c7bedb..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/FlowArtifactBuilderService.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.activepieces.worker.service; - -import com.activepieces.actions.model.action.CodeActionMetadataView; -import com.activepieces.actions.model.action.settings.CodeSettingsView; -import com.activepieces.common.error.exception.FailedToObtainLockException; -import com.activepieces.entity.sql.FileEntity; -import com.activepieces.file.service.FileService; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.lock.LockService; -import com.activepieces.worker.workers.CodeBuildWorker; -import com.github.ksuid.Ksuid; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.stereotype.Service; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.time.Duration; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.locks.Lock; - -@Service -@Log4j2 -public class FlowArtifactBuilderService { - - private final CodeBuildService codeBuildService; - private final FlowVersionService flowVersionService; - private final FileService fileService; - private final LockService lockService; - - @Autowired - public FlowArtifactBuilderService( - @NonNull final CodeBuildService codeBuildService, - @NonNull final FlowVersionService flowVersionService, - @NonNull final LockService lockService, - @NonNull final FileService fileService) { - this.codeBuildService = codeBuildService; - this.fileService = fileService; - this.lockService = lockService; - this.flowVersionService = flowVersionService; - } - - public FlowVersionView buildAllSteps(@NonNull final FlowVersionView flowVersionView) throws Exception { - Lock lock = lockService.tryLock(flowVersionView.getFlowId().toString(), Duration.ofMinutes(5)); - try { - List codeActions = FlowVersionUtil.findCodeActions(flowVersionView); - boolean changed = false; - for (CodeActionMetadataView codeAction : codeActions) { - CodeSettingsView codeSettingsView = codeAction.getSettings(); - if (Objects.isNull(codeSettingsView.getArtifactPackagedId())) { - final CodeBuildWorker codeBuildWorker = codeBuildService.obtainWorker(); - final FileEntity fileEntity = fileService.getFileById(codeSettingsView.getArtifactSourceId()).get(); - final InputStream buildStream = codeBuildWorker.build(new ByteArrayInputStream(fileEntity.getData())); - final FileEntity outputEntity = fileService.save(null, - new MockMultipartFile("file", - "artifact.zip", - "application/zip", buildStream.readAllBytes())); - codeSettingsView.setArtifactPackagedId(outputEntity.getId()); - changed = true; - log.info("Built an package for an action {} with id {}", codeAction.getDisplayName(), outputEntity.getId()); - } - } - if (!changed) { - return flowVersionView; - } - return flowVersionService.persistPackagedFlow(flowVersionView); - }catch (FailedToObtainLockException e){ - throw new RuntimeException(e); - } finally { - lock.unlock(); - } - } - -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/WorkerServiceImpl.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/WorkerServiceImpl.java deleted file mode 100644 index 1c6e075660..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/service/WorkerServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.activepieces.worker.service; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.authentication.client.JWTService; -import com.activepieces.file.service.FileService; -import com.activepieces.flow.FlowVersionService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.CollectionVersionService; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.worker.Worker; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import lombok.extern.log4j.Log4j2; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - -@Service -@Log4j2 -public class WorkerServiceImpl implements WorkerService { - - private static final int NUMBER_OF_WORKERS = 64; - - private final ArrayList workers; - private final BlockingQueue blockingQueue; - - @Autowired - public WorkerServiceImpl( - @Value("${com.activepieces.api-prefix}") final String apiUrl, - final InstanceRunService instanceRunService, - final FileService fileService, - final JWTService jwtService, - final FlowArtifactBuilderService flowArtifactBuilderService, - final ObjectMapper objectMapper) { - final ObjectMapper lowerCamelCaseMapper = objectMapper.copy().setPropertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE); - this.workers = new ArrayList<>(); - this.blockingQueue = new LinkedBlockingQueue<>(); - for (int i = 0; i < NUMBER_OF_WORKERS; ++i) { - this.blockingQueue.add(i); - this.workers.add( - new Worker(i + 20, apiUrl, jwtService, flowArtifactBuilderService, instanceRunService, fileService, lowerCamelCaseMapper)); - } - } - - /** - * Step 1: Parse All code Actions. - * Step 2: Make sure all code actions are built. - * Step 3: Create Sandbox. - * Step 4: Bind these directories to Sandbox. - * Step 6: Execution flow with - * Typescript worker. - */ - public InstanceRunView executeFlow( - InstanceRunView instanceRunView, - CollectionVersionView collectionVersionView, - FlowVersionView flowVersionView, - Map configs, - Object triggerPayload, - StorePath storePath) - throws Exception { - InstanceRunView resultRun; - int workerIndex = this.blockingQueue.take(); - log.debug( - "Worker {} Started running flow Id {} with collectName {} and flowName {}", workerIndex, flowVersionView.getId().toString(), collectionVersionView.getDisplayName(), flowVersionView.getDisplayName()); - resultRun = - this.workers - .get(workerIndex) - .run(instanceRunView, collectionVersionView, flowVersionView, configs, triggerPayload, storePath); - - this.blockingQueue.add(workerIndex); - log.debug( - "Worker {} Finished running flow Id {}", workerIndex, flowVersionView.getId().toString()); - return resultRun; - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/DownloadRequiredFiles.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/DownloadRequiredFiles.java deleted file mode 100644 index 159c394559..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/DownloadRequiredFiles.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.activepieces.worker.steps; - -import com.activepieces.actions.model.action.CodeActionMetadataView; -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.common.utils.ArtifactUtils; -import com.activepieces.entity.sql.FileEntity; -import com.activepieces.file.service.FileService; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.flow.util.FlowVersionUtil; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.common.Constants; -import com.activepieces.worker.Worker; -import com.activepieces.worker.service.FlowArtifactBuilderService; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -@Log4j2 -public class DownloadRequiredFiles extends Step { - - private final ObjectMapper objectMapper; - private final FlowArtifactBuilderService flowBuilderService; - private final FileService fileService; - private final Worker worker; - private final String apiUrl; - - public DownloadRequiredFiles( - @NonNull final Worker worker, - @NonNull final String apiUrl, - @NonNull final FileService fileService, - @NonNull final FlowArtifactBuilderService flowBuilderService, - @NonNull final ObjectMapper objectMapper) { - this.apiUrl = apiUrl; - this.objectMapper = objectMapper; - this.fileService = fileService; - this.flowBuilderService = flowBuilderService; - this.worker = worker; - } - - @Override - public void next( - InstanceRunView instanceRunView, - CollectionVersionView collectionVersionView, - FlowVersionView flowVersionView, - Map configs, - Object triggerPayload, - Map output, - StorePath storePath) - throws Exception { - long startTime = System.currentTimeMillis(); - flowVersionView = flowBuilderService.buildAllSteps(flowVersionView); - downloadArtifacts(flowVersionView); - worker.getSandbox().writeContext(Collections.emptyMap(), objectMapper); - worker.getSandbox().writeConfigs(configs, objectMapper); - worker.getSandbox() - .writeEntryPoint( - collectionVersionView, - flowVersionView, - apiUrl, - objectMapper); - worker.getSandbox().writeTriggerPayload(triggerPayload, objectMapper); - worker.getSandbox().writeFlow(flowVersionView, objectMapper); - worker.getSandbox().writeCollection(collectionVersionView, objectMapper); - - final Resource workerExecutor = new ClassPathResource(Constants.ACTIVEPIECES_WORKER_JS); - final File workerExecutorDest = - new File(worker.getSandbox().getSandboxFilePath(Constants.ACTIVEPIECES_WORKER_JS)); - Files.copy( - workerExecutor.getInputStream(), - workerExecutorDest.toPath(), - StandardCopyOption.REPLACE_EXISTING); - log.info("Downloading artifacts took {}ms", System.currentTimeMillis() - startTime); - } - - private void downloadArtifacts(FlowVersionView flowVersionView) { - final List allCodeActions = FlowVersionUtil.findCodeActions(flowVersionView); - - allCodeActions.parallelStream() - .forEach( - codeSettings -> { - try { - FileEntity fileEntity = fileService.getFileById(codeSettings.getSettings().getArtifactPackagedId()).get(); - String jsFileName = - ArtifactUtils.bundledFileName( - codeSettings.getSettings().getArtifactPackagedId().toString()); - InputStream inputStream = new ByteArrayInputStream(fileEntity.getData()); - worker.getSandbox().writeCode(jsFileName, inputStream); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } - -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/ExecuteWorker.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/ExecuteWorker.java deleted file mode 100644 index 1e7f44b39a..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/ExecuteWorker.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.activepieces.worker.steps; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.common.Constants; -import com.activepieces.worker.Worker; -import com.activepieces.worker.model.WorkerExecutionResult; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; - -import java.io.File; -import java.io.IOException; -import java.util.Map; - -@Log4j2 -public class ExecuteWorker extends Step { - - private final Worker worker; - private final ObjectMapper objectMapper; - - public ExecuteWorker( - @NonNull final Worker worker, - @NonNull final ObjectMapper objectMapper) { - this.worker = worker; - this.objectMapper = objectMapper; - } - - @Override - public void next( - InstanceRunView instanceRunView, - CollectionVersionView collectionVersionView, - FlowVersionView flowVersionView, - Map input, - Object triggerPayload, - Map output, - StorePath storePath) throws IOException, InterruptedException { - long startTime = System.currentTimeMillis(); - worker.getSandbox().runJsFile(Constants.ACTIVEPIECES_WORKER_JS, Constants.WORKER_EXECUTE_FLOW_ARG); - File outputFile = new File(worker.getSandbox().getSandboxFilePath(Constants.WORKER_OUTPUT_FILE)); - output.put(Constants.WORKER_RESULT_IN_MAP,objectMapper.readValue(outputFile, WorkerExecutionResult.class)); - log.info("Execution Time took {}ms", System.currentTimeMillis() - startTime); - } - -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/PrepareSandbox.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/PrepareSandbox.java deleted file mode 100644 index 6ace1f35cd..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/PrepareSandbox.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.activepieces.worker.steps; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.worker.Worker; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; - -import java.io.IOException; -import java.util.Map; - -@Log4j2 -public class PrepareSandbox extends Step { - private final Worker worker; - - public PrepareSandbox(@NonNull final Worker worker) { - this.worker = worker; - } - - @Override - public void next( - InstanceRunView instanceRunView, - CollectionVersionView collectionVersionView, - FlowVersionView flowVersionView, - Map configInput, - Object triggerPayload, - Map output, - StorePath storePath) - throws IOException, InterruptedException { - worker.getSandbox().clean(); - worker.getSandbox().init(); - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/Step.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/Step.java deleted file mode 100644 index 11129d960e..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/Step.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.activepieces.worker.steps; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; - -import java.util.Map; - -public abstract class Step { - - public abstract void next( - InstanceRunView instanceRun, - CollectionVersionView collectionVersion, - FlowVersionView flowVersion, - Map configInput, - Object triggerPayload, - Map output, - StorePath storePath) - throws Exception; -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/UploadRunState.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/UploadRunState.java deleted file mode 100644 index ef4e806fa4..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/steps/UploadRunState.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.activepieces.worker.steps; - -import com.activepieces.actions.store.model.StorePath; -import com.activepieces.common.error.exception.InstanceNotFoundException; -import com.activepieces.flow.model.FlowVersionView; -import com.activepieces.guardian.client.exception.PermissionDeniedException; -import com.activepieces.guardian.client.exception.ResourceNotFoundException; -import com.activepieces.logging.client.InstanceRunService; -import com.activepieces.logging.client.model.InstanceRunView; -import com.activepieces.piece.client.model.CollectionVersionView; -import com.activepieces.common.Constants; -import com.activepieces.worker.model.WorkerExecutionResult; -import lombok.NonNull; -import lombok.extern.log4j.Log4j2; - -import java.io.IOException; -import java.time.Instant; -import java.util.Map; - -@Log4j2 -public class UploadRunState extends Step { - - private final InstanceRunService instanceRunService; - - public UploadRunState(@NonNull final InstanceRunService instanceRunService) { - this.instanceRunService = instanceRunService; - } - - @Override - public void next( - InstanceRunView instanceRun, - CollectionVersionView collectionVersionView, - FlowVersionView flowVersionView, - Map input, - Object triggerPayload, - Map output, - StorePath storePath) - throws IOException, InstanceNotFoundException, - PermissionDeniedException, ResourceNotFoundException { - long startTime = System.currentTimeMillis(); - WorkerExecutionResult workerExecutionResult = - (WorkerExecutionResult) output.get(Constants.WORKER_RESULT_IN_MAP); - instanceRun.setStatus(workerExecutionResult.getStatus()); - instanceRun.setOutput(workerExecutionResult.getOutput()); - instanceRun.setFinishTime(Instant.now().toEpochMilli()); - output.put( - Constants.RUN_RESULT_IN_MAP, - instanceRunService.createOrUpdate(instanceRun, workerExecutionResult.getExecutionState())); - log.info("Uploaded Run State {}ms", System.currentTimeMillis() - startTime); - } -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/workers/CodeBuildWorker.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/workers/CodeBuildWorker.java deleted file mode 100644 index e25d5d6513..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/workers/CodeBuildWorker.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.activepieces.worker.workers; - -import com.activepieces.common.utils.ArtifactUtils; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.log4j.Log4j2; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringEscapeUtils; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import java.io.*; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -@Log4j2 -public class CodeBuildWorker { - - private final int workerId; - private final String CODE_BUILDER_FOLDER = "code-build"; - private final ObjectMapper objectMapper; - - public CodeBuildWorker(final int workerId, final ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - this.workerId = workerId; - } - - public int getWorkerId(){ - return workerId; - } - - public InputStream build(final InputStream rawArtifactZipFile) throws Exception { - log.info("Building using worker " + workerId); - File buildFolder = - new File(CODE_BUILDER_FOLDER + File.separator + workerId + File.separator + "build"); - FileUtils.deleteDirectory(buildFolder); - buildFolder.mkdirs(); - File zipFolder = new File(buildFolder.getAbsolutePath() + File.separator + "build.zip"); - ArtifactUtils.writeToFile(zipFolder, rawArtifactZipFile); - - ArtifactUtils.extractArtifact(zipFolder); - zipFolder.delete(); - - addWebpack(buildFolder); - - long startTime = System.currentTimeMillis(); - ArtifactUtils.runCommandAsRoot( - String.format("npm --prefix %s install", buildFolder.getAbsolutePath())); - - log.info("Npm install took {}ms", System.currentTimeMillis() - startTime); - startTime = System.currentTimeMillis(); - - String commandResult = ArtifactUtils.runCommandAsRoot( - String.format("npm --prefix %s run build:prod", buildFolder.getAbsolutePath())); - - log.info("Npm build took {}ms", System.currentTimeMillis() - startTime); - - File bundledJs = buildFolder.toPath().resolve("dist").resolve("bundle.js").toFile(); - if(!bundledJs.exists()){ - log.error(commandResult); - final Resource invalidArtifact = new ClassPathResource("invalid-code.js"); - String errorCodeFile = new String(invalidArtifact.getInputStream().readAllBytes(), StandardCharsets.UTF_8); - errorCodeFile = errorCodeFile.replace("${ERROR_MESSAGE}", StringEscapeUtils.escapeJavaScript(commandResult)); - return new ByteArrayInputStream(errorCodeFile.getBytes()); - } - return new FileInputStream(bundledJs); - } - - private void addWebpack(File buildFolder) throws IOException { - log.info("Adding webpack"); - File packageJsonFile = buildFolder.toPath().resolve("package.json").toFile(); - File webpackFile = buildFolder.toPath().resolve("webpack.config.js").toFile(); - - Map packageJson = - packageJsonFile.exists() - ? objectMapper.readValue(packageJsonFile, Map.class) - : Collections.emptyMap(); - - packageJson.putIfAbsent("scripts", new HashMap<>()); - Map scripts = (Map) packageJson.get("scripts"); - scripts.put("build:prod", "webpack --mode production"); - - FileUtils.writeStringToFile( - packageJsonFile, objectMapper.writeValueAsString(packageJson), Charset.forName("UTF-8")); - - final String webpackConfigJson = - "const path = require('path');\n" + - "module.exports = {\n" + - " target: 'node',\n" + - " externalsPresets: { node: true },\n" + - " entry: './index.js', // make sure this matches the main root of your code \n" + - " resolve: {\n" + - " preferRelative: true,\n" + - " extensions: ['.js']\n" + - " },\n" + - " output: {\n" + - " libraryTarget: 'commonjs2',\n" + - " path: path.join(__dirname, 'dist'), // this can be any path and directory you want\n" + - " filename: 'bundle.js',\n" + - " },\n" + - " optimization: {\n" + - " minimize: true, // enabling this reduces file size and readability\n" + - " },\n" + - "};\n"; - FileUtils.writeStringToFile(webpackFile, webpackConfigJson, Charset.forName("UTF-8")); - } - - -} diff --git a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/workers/CodeExecutionWorker.java b/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/workers/CodeExecutionWorker.java deleted file mode 100644 index feef010603..0000000000 --- a/src/backend/worker-service/worker-server/src/main/java/com/activepieces/worker/workers/CodeExecutionWorker.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.activepieces.worker.workers; - -import com.activepieces.common.error.exception.InvalidCodeArtifactException; -import com.activepieces.common.utils.ArtifactUtils; -import com.activepieces.entity.subdocuments.runs.ActionExecutionStatus; -import com.activepieces.worker.Sandbox; -import com.activepieces.worker.model.CodeExecutionStatusEnum; -import com.activepieces.worker.model.ExecutionCodeResult; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.log4j.Log4j2; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.HashMap; -import java.util.Map; - -@Log4j2 -public class CodeExecutionWorker { - - private final String FUNCTION_OUTPUT = "_functionOutput.txt"; - private final String STANDARD_OUTPUT = "_standardOutput.txt"; - private final String STANDARD_ERROR = "_standardError.txt"; - private final String INPUT_FILENAME = "_input.txt"; - private final String META_FILENAME = "meta.txt"; - - private final Sandbox sandbox; - private final ObjectMapper objectMapper; - - public CodeExecutionWorker( - final ObjectMapper objectMapper, - final Sandbox sandbox) { - this.sandbox = sandbox; - this.objectMapper = objectMapper; - } - - public ExecutionCodeResult executeSync(final JsonNode input, final InputStream bundledJs) - throws InterruptedException { - try { - ExecutionCodeResult result; - sandbox.clean(); - sandbox.init(); - copyBundledJs(bundledJs); - run(input); - result = - constructResult(input, fetchStandardOutput(), fetchStandardError(), fetchCodeReturn()); - return result; - } catch (IOException | InvalidCodeArtifactException exception) { - exception.printStackTrace(); - return ExecutionCodeResult.builder() - .input(input) - .verdict(CodeExecutionStatusEnum.INVALID_ARTIFACT) - .status(ActionExecutionStatus.FAILED) - .errorMessage(CodeExecutionStatusEnum.INVALID_ARTIFACT.getMessage()) - .build(); - } - } - - private void copyBundledJs(InputStream artifact) - throws IOException, InvalidCodeArtifactException { - final File destFile = new File(sandbox.getSandboxFilePath("index.js")); - Files.copy(artifact, destFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - - // Copy code-executor - final Resource codeExecutor = new ClassPathResource("code-executor.js"); - final File codeExecutorDest = new File(sandbox.getSandboxFilePath("code-executor.js")); - Files.copy( - codeExecutor.getInputStream(), - codeExecutorDest.toPath(), - StandardCopyOption.REPLACE_EXISTING); - final File indexFile = new File(sandbox.getSandboxFilePath("index.js")); - if (!indexFile.exists()) { - throw new InvalidCodeArtifactException(""); - } - } - - private ExecutionCodeResult constructResult( - JsonNode input, String output, String errorMessage, Object codeReturn) throws IOException { - String meta = - ArtifactUtils.readOutputFromStream( - new FileReader(sandbox.getSandboxFilePath(META_FILENAME))); - String[] lines = meta.split("\n"); - Map metaResult = new HashMap<>(); - for (String line : lines) { - String[] keyValue = line.split(":"); - metaResult.put(keyValue[0], keyValue[1]); - } - CodeExecutionStatusEnum status = CodeExecutionStatusEnum.fromStatus(metaResult.get("status")); - return ExecutionCodeResult.builder() - .verdict(status) - .timeInSeconds(Double.parseDouble(metaResult.get("time"))) - .output(codeReturn) - .errorMessage(errorMessage) - .input(input) - .status( - status.equals(CodeExecutionStatusEnum.OK) - ? ActionExecutionStatus.SUCCEEDED - : ActionExecutionStatus.FAILED) - .standardOutput(output) - .build(); - } - - private Object tryParseJson(String output) { - try { - return objectMapper.valueToTree(objectMapper.readTree(output)); - } catch (JsonProcessingException e) { - return output; - } - } - - private Object fetchCodeReturn() throws IOException { - File outputFile = new File(sandbox.getSandboxFilePath(FUNCTION_OUTPUT)); - if (!outputFile.exists()) return null; - return tryParseJson(ArtifactUtils.readOutputFromStream(new FileReader(outputFile))); - } - - private String fetchStandardError() throws IOException { - return ArtifactUtils.readOutputFromStream( - new FileReader(sandbox.getSandboxFilePath(STANDARD_ERROR))); - } - - private String fetchStandardOutput() throws IOException { - return ArtifactUtils.readOutputFromStream( - new FileReader(sandbox.getSandboxFilePath(STANDARD_OUTPUT))); - } - - private String run(JsonNode input) throws IOException, InterruptedException { - try (PrintWriter out = new PrintWriter(sandbox.getSandboxFilePath(INPUT_FILENAME))) { - out.println(objectMapper.writeValueAsString(input)); - } - return sandbox.runJsFile("code-executor.js", ""); - } - - -} diff --git a/src/worker/packages/backend/src/helper/pagination/build-paginator.ts b/src/worker/packages/backend/src/helper/pagination/build-paginator.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/backend/src/helper/pagination/pagination-utils.ts b/src/worker/packages/backend/src/helper/pagination/pagination-utils.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/backend/src/instance-run/instance-run-controller.ts b/src/worker/packages/backend/src/instance-run/instance-run-controller.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/backend/src/instance-run/instance-run-entity.ts b/src/worker/packages/backend/src/instance-run/instance-run-entity.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/backend/src/instance-run/instance-run-module.ts b/src/worker/packages/backend/src/instance-run/instance-run-module.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/backend/src/instance-run/instance-run-repo.ts b/src/worker/packages/backend/src/instance-run/instance-run-repo.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/backend/src/instance-run/instance-run-service.ts b/src/worker/packages/backend/src/instance-run/instance-run-service.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/engine/src/action/action-factory.ts b/src/worker/packages/engine/src/action/action-factory.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/engine/src/action/piece-action-handler.ts b/src/worker/packages/engine/src/action/piece-action-handler.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/engine/test/action/component-action.test.ts b/src/worker/packages/engine/test/action/component-action.test.ts old mode 100644 new mode 100755 diff --git a/src/worker/packages/engine/test/executors/piece-executer.test.ts b/src/worker/packages/engine/test/executors/piece-executer.test.ts old mode 100644 new mode 100755