From b8b51f9fc23b6b171351a8c3b05c39e81df61e69 Mon Sep 17 00:00:00 2001 From: Marcello Teodori <151025+mteodori@users.noreply.github.com> Date: Tue, 21 Jan 2020 04:45:46 +0000 Subject: [PATCH 1/4] fix(AAE-1207): Updated graphql-jpa-query version to 0.4.0 --- pom.xml | 2 +- services/api/pom.xml | 5 + .../graphql/web/api/GraphQLQueryRequest.java | 117 +++++++++ .../graphql/web/api/GraphQLQueryResult.java | 102 ++++++++ ...ctivitiGraphQLSchemaAutoConfiguration.java | 15 +- services/schema/pom.xml | 4 + .../GraphQLSchemaAutoConfiguration.java | 57 ----- .../schema/GraphQLSchemaConfigurer.java | 22 -- .../schema/GraphQLSchemaFactoryBean.java | 79 ------ .../schema/GraphQLShemaRegistration.java | 35 --- .../main/resources/META-INF/spring.factories | 2 - .../GraphQLSchemaAutoConfigurationTest.java | 13 +- ...GraphQLSubscriptionsAutoConfiguration.java | 7 +- services/web/pom.xml | 4 + .../ActivitiGraphQLAutoConfiguration.java | 12 +- .../web/ActivitiGraphQLController.java | 228 ------------------ .../ActivitiGraphQLAutoConfigurationTest.java | 11 +- .../web/ActivitiGraphQLControllerTest.java | 28 ++- .../src/main/resources/metadata.properties | 3 + .../starter/ActivitiGraphQLStarterIT.java | 117 +++------ 20 files changed, 312 insertions(+), 551 deletions(-) create mode 100644 services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java create mode 100644 services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryResult.java delete mode 100644 services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfiguration.java delete mode 100644 services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaConfigurer.java delete mode 100644 services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaFactoryBean.java delete mode 100644 services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLShemaRegistration.java delete mode 100644 services/schema/src/main/resources/META-INF/spring.factories delete mode 100644 services/web/src/main/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLController.java create mode 100644 starter/src/main/resources/metadata.properties diff --git a/pom.xml b/pom.xml index bc30847..4848e62 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 7.1.26 7.1.208 ${project.version} - 0.3.35 + 0.4.0 diff --git a/services/api/pom.xml b/services/api/pom.xml index 2a89f44..2f690b6 100644 --- a/services/api/pom.xml +++ b/services/api/pom.xml @@ -16,6 +16,11 @@ jackson-annotations + + javax.validation + validation-api + + \ No newline at end of file diff --git a/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java b/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java new file mode 100644 index 0000000..f0347e2 --- /dev/null +++ b/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java @@ -0,0 +1,117 @@ +package org.activiti.cloud.services.notifications.graphql.web.api; + +import java.util.Collections; +import java.util.Map; + +import javax.validation.constraints.NotNull; + +/** + * GraphQL JSON HTTP Request Wrapper Class + */ +public class GraphQLQueryRequest { + + @NotNull + private String query; + + private Map variables; + + private GraphQLQueryRequest(Builder builder) { + this.query = builder.query; + this.variables = builder.variables; + } + + GraphQLQueryRequest() { + } + + /** + * @param query + */ + public GraphQLQueryRequest(String query) { + super(); + this.query = query; + } + + /** + * @return the query + */ + public String getQuery() { + return this.query; + } + + /** + * @return the variables + */ + public Map getVariables() { + return this.variables; + } + + /** + * Creates builder to build {@link GraphQLQueryRequest}. + * @return created builder + */ + public static IQueryStage builder() { + return new Builder(); + } + + /** + * Definition of a stage for staged builder. + */ + public interface IQueryStage { + + /** + * Builder method for query parameter. + * @param query field to set + * @return builder + */ + public IBuildStage withQuery(String query); + } + + /** + * Definition of a stage for staged builder. + */ + public interface IBuildStage { + + /** + * Builder method for variables parameter. + * @param variables field to set + * @return builder + */ + public IBuildStage withVariables(Map variables); + + /** + * Builder method of the builder. + * @return built class + */ + public GraphQLQueryRequest build(); + } + + /** + * Builder to build {@link GraphQLQueryRequest}. + */ + public static final class Builder implements IQueryStage, IBuildStage { + + private String query; + private Map variables = Collections.emptyMap(); + + private Builder() { + } + + @Override + public IBuildStage withQuery(String query) { + this.query = query; + return this; + } + + @Override + public IBuildStage withVariables(Map variables) { + this.variables = variables; + return this; + } + + @Override + public GraphQLQueryRequest build() { + return new GraphQLQueryRequest(this); + } + } + +} diff --git a/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryResult.java b/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryResult.java new file mode 100644 index 0000000..a9a75c8 --- /dev/null +++ b/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryResult.java @@ -0,0 +1,102 @@ +package org.activiti.cloud.services.notifications.graphql.web.api; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class GraphQLQueryResult { + + private Map data; + private List> errors; + private Map extensions; + + private GraphQLQueryResult(Builder builder) { + this.data = builder.data; + this.errors = builder.errors; + this.extensions = builder.extensions; + } + + /** + * Default + */ + GraphQLQueryResult() { + } + + public Map getData() { + return data; + } + + public List> getErrors() { + return errors; + } + + public Map getExtensions() { + return extensions; + } + + /** + * Creates a builder to build {@link GraphQLQueryResult} and initialize it with the given object. + * @param graphQLQueryResult to initialize the builder with + * @return created builder + */ + public static Builder builderFrom(GraphQLQueryResult graphQLQueryResult) { + return new Builder(graphQLQueryResult); + } + + /** + * Builder to build {@link GraphQLQueryResult}. + */ + public static final class Builder { + + private Map data = Collections.emptyMap(); + private List> errors = Collections.emptyList(); + private Map extensions = Collections.emptyMap(); + + public Builder() { + } + + private Builder(GraphQLQueryResult graphQLQueryResult) { + this.data = graphQLQueryResult.data; + this.errors = graphQLQueryResult.errors; + this.extensions = graphQLQueryResult.extensions; + } + + /** + * Builder method for data parameter. + * @param data field to set + * @return builder + */ + public Builder withData(Map data) { + this.data = data; + return this; + } + + /** + * Builder method for errors parameter. + * @param errors field to set + * @return builder + */ + public Builder withErrors(List> errors) { + this.errors = errors; + return this; + } + + /** + * Builder method for extensions parameter. + * @param extensions field to set + * @return builder + */ + public Builder withExtensions(Map extensions) { + this.extensions = extensions; + return this; + } + + /** + * Builder method of the builder. + * @return built class + */ + public GraphQLQueryResult build() { + return new GraphQLQueryResult(this); + } + } +} diff --git a/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java b/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java index 3ab278a..89bb094 100644 --- a/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java +++ b/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java @@ -17,13 +17,6 @@ import javax.persistence.EntityManager; -import com.introproventures.graphql.jpa.query.schema.JavaScalars; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; -import graphql.GraphQL; -import graphql.schema.GraphQLScalarType; -import graphql.schema.GraphQLSchema; -import org.activiti.cloud.notifications.graphql.schema.GraphQLSchemaConfigurer; -import org.activiti.cloud.notifications.graphql.schema.GraphQLShemaRegistration; import org.activiti.cloud.services.query.model.ProcessInstanceEntity; import org.activiti.cloud.services.query.model.VariableValue; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -31,6 +24,14 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Configuration; +import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaConfigurer; +import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLShemaRegistration; +import com.introproventures.graphql.jpa.query.schema.JavaScalars; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; +import graphql.GraphQL; +import graphql.schema.GraphQLScalarType; +import graphql.schema.GraphQLSchema; + /** * Spring Boot auto configuration of Activiti GraphQL Query Service components */ diff --git a/services/schema/pom.xml b/services/schema/pom.xml index 8bb3642..7a10a44 100644 --- a/services/schema/pom.xml +++ b/services/schema/pom.xml @@ -25,6 +25,10 @@ com.graphql-java graphql-java + + com.introproventures + graphql-jpa-query-autoconfigure + org.springframework.boot spring-boot-configuration-processor diff --git a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfiguration.java b/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfiguration.java deleted file mode 100644 index 6f44e02..0000000 --- a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfiguration.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 Alfresco, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.cloud.notifications.graphql.schema; - -import java.util.ArrayList; -import java.util.List; - -import graphql.GraphQL; -import graphql.schema.GraphQLSchema; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.CollectionUtils; - -@Configuration -@ConditionalOnClass(GraphQL.class) -public class GraphQLSchemaAutoConfiguration { - - private final List graphQLSchemaConfigurers = new ArrayList<>(); - - @Autowired(required = true) - public void setGraphQLSchemaConfigurers(List configurers) { - if (!CollectionUtils.isEmpty(configurers)) { - graphQLSchemaConfigurers.addAll(configurers); - } - } - - @Bean - @ConditionalOnMissingBean(GraphQLSchema.class) - public GraphQLSchemaFactoryBean graphQLSchemaFactoryBean() { - GraphQLShemaRegistration graphQLShemaRegistration = new GraphQLShemaRegistration(); - - for (GraphQLSchemaConfigurer configurer : graphQLSchemaConfigurers) { - configurer.configure(graphQLShemaRegistration); - } - - return new GraphQLSchemaFactoryBean(graphQLShemaRegistration.getManagedGraphQLSchemas()); - - }; - - -} diff --git a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaConfigurer.java b/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaConfigurer.java deleted file mode 100644 index c9b16b9..0000000 --- a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaConfigurer.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 Alfresco, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.cloud.notifications.graphql.schema; - -public interface GraphQLSchemaConfigurer { - - void configure(GraphQLShemaRegistration registry); - -} diff --git a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaFactoryBean.java b/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaFactoryBean.java deleted file mode 100644 index 9d20f6d..0000000 --- a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaFactoryBean.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2018 Alfresco, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.cloud.notifications.graphql.schema; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import graphql.schema.GraphQLFieldDefinition; -import graphql.schema.GraphQLObjectType; -import graphql.schema.GraphQLSchema; -import org.springframework.beans.factory.config.AbstractFactoryBean; - -public class GraphQLSchemaFactoryBean extends AbstractFactoryBean{ - - private final GraphQLSchema[] managedGraphQLSchemas; - - public GraphQLSchemaFactoryBean(GraphQLSchema[] managedGraphQLSchemas) { - this.managedGraphQLSchemas = managedGraphQLSchemas; - } - - @Override - protected GraphQLSchema createInstance() throws Exception { - - GraphQLSchema.Builder schemaBuilder = GraphQLSchema.newSchema(); - - List mutations = Stream.of(managedGraphQLSchemas) - .map(GraphQLSchema::getMutationType) - .filter(Objects::nonNull) - .map(GraphQLObjectType::getFieldDefinitions) - .flatMap(children -> children.stream()) - .collect(Collectors.toList()); - - List queries = Stream.of(managedGraphQLSchemas) - .map(GraphQLSchema::getQueryType) - .filter(Objects::nonNull) - .map(GraphQLObjectType::getFieldDefinitions) - .flatMap(children -> children.stream()) - .collect(Collectors.toList()); - - List subscriptions = Stream.of(managedGraphQLSchemas) - .map(GraphQLSchema::getSubscriptionType) - .filter(Objects::nonNull) - .map(GraphQLObjectType::getFieldDefinitions) - .flatMap(children -> children.stream()) - .collect(Collectors.toList()); - - if(!mutations.isEmpty()) - schemaBuilder.mutation(GraphQLObjectType.newObject().name("Mutation").fields(mutations)); - - if(!queries.isEmpty()) - schemaBuilder.query(GraphQLObjectType.newObject().name("Query").fields(queries)); - - if(!subscriptions.isEmpty()) - schemaBuilder.subscription(GraphQLObjectType.newObject().name("Subscription").fields(subscriptions)); - - return schemaBuilder.build(); - } - - @Override - public Class getObjectType() { - return GraphQLSchema.class; - } - -} diff --git a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLShemaRegistration.java b/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLShemaRegistration.java deleted file mode 100644 index 181033e..0000000 --- a/services/schema/src/main/java/org/activiti/cloud/notifications/graphql/schema/GraphQLShemaRegistration.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2018 Alfresco, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.cloud.notifications.graphql.schema; - -import java.util.LinkedHashSet; -import java.util.Set; - -import graphql.schema.GraphQLSchema; - -public class GraphQLShemaRegistration { - - Set managedGraphQLSchemas = new LinkedHashSet(); - - public void register(GraphQLSchema graphQLSchema) { - managedGraphQLSchemas.add(graphQLSchema); - } - - public GraphQLSchema[] getManagedGraphQLSchemas() { - return managedGraphQLSchemas.toArray(new GraphQLSchema[] {}); - } - -} diff --git a/services/schema/src/main/resources/META-INF/spring.factories b/services/schema/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 328d2de..0000000 --- a/services/schema/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.activiti.cloud.notifications.graphql.schema.GraphQLSchemaAutoConfiguration \ No newline at end of file diff --git a/services/schema/src/test/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfigurationTest.java b/services/schema/src/test/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfigurationTest.java index 95613dd..7edc08a 100644 --- a/services/schema/src/test/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfigurationTest.java +++ b/services/schema/src/test/java/org/activiti/cloud/notifications/graphql/schema/GraphQLSchemaAutoConfigurationTest.java @@ -19,11 +19,6 @@ import java.util.Map; -import graphql.GraphQL; -import graphql.Scalars; -import graphql.schema.GraphQLFieldDefinition; -import graphql.schema.GraphQLObjectType; -import graphql.schema.GraphQLSchema; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -33,6 +28,14 @@ import org.springframework.stereotype.Component; import org.springframework.test.context.junit4.SpringRunner; +import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaConfigurer; +import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLShemaRegistration; +import graphql.GraphQL; +import graphql.Scalars; +import graphql.schema.GraphQLFieldDefinition; +import graphql.schema.GraphQLObjectType; +import graphql.schema.GraphQLSchema; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=WebEnvironment.NONE) public class GraphQLSchemaAutoConfigurationTest { diff --git a/services/subscriptions/src/main/java/org/activiti/cloud/services/notifications/graphql/subscriptions/config/GraphQLSubscriptionsAutoConfiguration.java b/services/subscriptions/src/main/java/org/activiti/cloud/services/notifications/graphql/subscriptions/config/GraphQLSubscriptionsAutoConfiguration.java index 4f0e926..994d573 100644 --- a/services/subscriptions/src/main/java/org/activiti/cloud/services/notifications/graphql/subscriptions/config/GraphQLSubscriptionsAutoConfiguration.java +++ b/services/subscriptions/src/main/java/org/activiti/cloud/services/notifications/graphql/subscriptions/config/GraphQLSubscriptionsAutoConfiguration.java @@ -17,9 +17,6 @@ import java.util.List; -import graphql.GraphQL; -import org.activiti.cloud.notifications.graphql.schema.GraphQLSchemaConfigurer; -import org.activiti.cloud.notifications.graphql.schema.GraphQLShemaRegistration; import org.activiti.cloud.services.notifications.graphql.events.RoutingKeyResolver; import org.activiti.cloud.services.notifications.graphql.events.model.EngineEvent; import org.activiti.cloud.services.notifications.graphql.subscriptions.GraphQLSubscriptionSchemaBuilder; @@ -37,6 +34,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.messaging.Message; import org.springframework.messaging.simp.stomp.ReactorNettyTcpStompClient; + +import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaConfigurer; +import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLShemaRegistration; +import graphql.GraphQL; import reactor.core.publisher.Flux; @Configuration diff --git a/services/web/pom.xml b/services/web/pom.xml index 94e54ec..0419fd0 100644 --- a/services/web/pom.xml +++ b/services/web/pom.xml @@ -17,6 +17,10 @@ com.introproventures graphql-jpa-query-schema + + com.introproventures + graphql-jpa-query-web + com.fasterxml.jackson.core jackson-databind diff --git a/services/web/src/main/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfiguration.java b/services/web/src/main/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfiguration.java index 0cf9ed8..a98fe41 100644 --- a/services/web/src/main/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfiguration.java +++ b/services/web/src/main/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfiguration.java @@ -15,17 +15,16 @@ */ package org.activiti.cloud.services.graphql.autoconfigure; -import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; -import graphql.GraphQL; -import graphql.schema.GraphQLSchema; -import org.activiti.cloud.services.graphql.web.ActivitiGraphQLController; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; + +import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; +import graphql.GraphQL; +import graphql.schema.GraphQLSchema; /** * Spring Boot auto configuration of Activiti GraphQL Query Service components @@ -39,7 +38,6 @@ public class ActivitiGraphQLAutoConfiguration { * Provides default configuration of Activiti GraphQL JPA Query Components */ @Configuration - @Import(ActivitiGraphQLController.class) public static class DefaultActivitiGraphQLJpaConfiguration { @Bean diff --git a/services/web/src/main/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLController.java b/services/web/src/main/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLController.java deleted file mode 100644 index b8d2879..0000000 --- a/services/web/src/main/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLController.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2018 Alfresco, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.cloud.services.graphql.web; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.http.MediaType; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; - - - -/** - * Activiti GraphQL Query Spring Rest Controller with HTTP mapping endpoints for GraphQLExecutor relay - * @see Serving GraphQL over HTTP - */ -@RestController -@ConditionalOnWebApplication -@ConditionalOnProperty(name = "spring.activiti.cloud.services.notifications.graphql.enabled", matchIfMissing = true) -public class ActivitiGraphQLController { - - private static final String PATH = "${spring.activiti.cloud.services.notifications.graphql.path:/graphql}"; - public static final String APPLICATION_GRAPHQL_VALUE = "application/graphql"; - - private final GraphQLExecutor graphQLExecutor; - private final ObjectMapper mapper; - - /** - * Creates instance of Spring GraphQLController RestController - * @param graphQLExecutor {@link GraphQLExecutor} instance - * @param mapper {@link ObjectMapper} instance - */ - public ActivitiGraphQLController(GraphQLExecutor graphQLExecutor, - ObjectMapper mapper) { - super(); - this.graphQLExecutor = graphQLExecutor; - this.mapper = mapper; - } - - /** - * Handle standard GraphQL POST request that consumes - * "application/json" content type with a JSON-encoded body - * of the following format: - *
-     * {
-     *   "query": "...",
-     *   "variables": { "myVariable": "someValue", ... }
-     * }
-     * 
- * @param queryRequest object - * @return {@link Map} response - * @throws IOException - */ - @PostMapping(value = PATH, - consumes = {MediaType.APPLICATION_JSON_VALUE}, - produces = MediaType.APPLICATION_JSON_VALUE) - public Map executePostJsonRequest(@RequestBody @Valid final GraphQLQueryRequest queryRequest) throws IOException { - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - - return graphQLExecutor.execute(queryRequest.getQuery(), - queryRequest.getVariables()).toSpecification(); - - } - - /** - * Handle HTTP GET request. - * The GraphQL query should be specified in the "query" query string. - * i.e.
 http://server/graphql?query={query{name}}
- *

- * Query variables can be sent as a JSON-encoded string in an additional - * query parameter called variables. - * @param query encoded JSON string - * @param variables encoded JSON string - * @return {@link Map} response - * @throws IOException - */ - @GetMapping(value = PATH, - consumes = {APPLICATION_GRAPHQL_VALUE}, - produces = MediaType.APPLICATION_JSON_VALUE) - public Map executeGetQueryRequest( - @RequestParam(name = "query") final String query, - @RequestParam(name = "variables", required = false) final String variables) throws IOException { - Map variablesMap = variablesStringToMap(variables); - - return graphQLExecutor.execute(query, - variablesMap).toSpecification(); - } - - /** - * Handle HTTP FORM POST request. - * The GraphQL query should be specified in the "query" query parameter string. - *

- * Query variables can be sent as a JSON-encoded string in an additional - * query parameter called variables. - * @param query encoded JSON string - * @param variables encoded JSON string - * @return {@link Map} response - * @throws IOException - */ - @PostMapping(value = PATH, - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - public Map executePostFormRequest( - @RequestParam(name = "query") final String query, - @RequestParam(name = "variables", required = false) final String variables) throws IOException { - Map variablesMap = variablesStringToMap(variables); - - return graphQLExecutor.execute(query, - variablesMap).toSpecification(); - } - - /** - * Handle POST with the "application/graphql" Content-Type header. - * Treat the HTTP POST body contents as the GraphQL query string. - * @param queryRequest a valid {@link GraphQLQueryRequest} input argument - * @return {@link Map} response - * @throws IOException - */ - @PostMapping(value = PATH, - consumes = APPLICATION_GRAPHQL_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - public Map executePostApplicationGraphQL( - @RequestBody final String query) throws IOException { - return graphQLExecutor.execute(query, - null).toSpecification(); - } - - /** - * Convert String argument to a Map as expected by {@link GraphQLJpaExecutor#execute(String, Map)}. GraphiQL posts both - * query and variables as JSON encoded String, so Spring MVC mapping is useless here. - * See: http://graphql.org/learn/serving-over-http/ - * @param json JSON encoded string variables - * @return a {@link HashMap} object of variable key-value pairs - * @throws IOException - */ - @SuppressWarnings("unchecked") - private Map variablesStringToMap(final String json) throws IOException { - Map variables = null; - - if (json != null && !json.isEmpty()) { - variables = mapper.readValue(json, - Map.class); - } - - return variables; - } - - /** - * GraphQL JSON HTTP Request Wrapper Class - */ - @Validated - public static class GraphQLQueryRequest { - - @NotNull - private String query; - - private Map variables; - - GraphQLQueryRequest() { - } - - /** - * @param query - */ - public GraphQLQueryRequest(String query) { - super(); - this.query = query; - } - - /** - * @return the query - */ - public String getQuery() { - return this.query; - } - - /** - * @param query the query to set - */ - public void setQuery(String query) { - this.query = query; - } - - /** - * @return the variables - */ - public Map getVariables() { - return this.variables; - } - - /** - * @param variables the variables to set - */ - public void setVariables(Map variables) { - this.variables = variables; - } - } -} diff --git a/services/web/src/test/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfigurationTest.java b/services/web/src/test/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfigurationTest.java index 7cf194e..5228711 100644 --- a/services/web/src/test/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfigurationTest.java +++ b/services/web/src/test/java/org/activiti/cloud/services/graphql/autoconfigure/ActivitiGraphQLAutoConfigurationTest.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; -import graphql.schema.GraphQLSchema; -import org.activiti.cloud.services.graphql.web.ActivitiGraphQLController; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -30,6 +26,11 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit4.SpringRunner; +import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; +import com.introproventures.graphql.jpa.query.web.GraphQLController; +import graphql.schema.GraphQLSchema; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class ActivitiGraphQLAutoConfigurationTest { @@ -44,7 +45,7 @@ public class ActivitiGraphQLAutoConfigurationTest { private GraphQLExecutor graphQLExecutor; @Autowired - private ActivitiGraphQLController graphQLController; + private GraphQLController graphQLController; @SpringBootApplication static class Application { diff --git a/services/web/src/test/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLControllerTest.java b/services/web/src/test/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLControllerTest.java index eef2842..09e9ef3 100644 --- a/services/web/src/test/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLControllerTest.java +++ b/services/web/src/test/java/org/activiti/cloud/services/graphql/web/ActivitiGraphQLControllerTest.java @@ -27,11 +27,6 @@ import java.util.HashMap; import java.util.Map; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; -import graphql.ExecutionResultImpl; -import org.activiti.cloud.services.graphql.web.ActivitiGraphQLController.GraphQLQueryRequest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -46,9 +41,18 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; +import com.introproventures.graphql.jpa.query.web.GraphQLController; +import com.introproventures.graphql.jpa.query.web.GraphQLController.GraphQLQueryRequest; +import graphql.ExecutionResultImpl; + @RunWith(SpringRunner.class) -@WebMvcTest(controllers = ActivitiGraphQLController.class) +@WebMvcTest(controllers = GraphQLController.class) public class ActivitiGraphQLControllerTest { + + public static final String APPLICATION_GRAPHQL_VALUE = "application/graphql"; @Autowired private MockMvc mockmvc; @@ -60,7 +64,7 @@ public class ActivitiGraphQLControllerTest { private ObjectMapper mapper; @Configuration - @Import(ActivitiGraphQLController.class) + @Import(GraphQLController.class) static class Config { } @@ -101,7 +105,7 @@ private ResultActions perform(final String json) throws Exception { public void testGraphqlGetQueryNoVariables() throws Exception { mockmvc.perform(get("/graphql") .param("query", "{Tasks(where: {name: {EQ: \"name\"}}){select{id}}}") - .contentType(ActivitiGraphQLController.APPLICATION_GRAPHQL_VALUE) + .contentType(APPLICATION_GRAPHQL_VALUE) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) @@ -115,7 +119,7 @@ public void testGraphqlGetQueryNoVariables() throws Exception { public void testGraphqlPostQuery() throws Exception { mockmvc.perform(post("/graphql") .content("{Tasks(where: {name: {EQ: \"name\"}}){select{id}}}") - .contentType(ActivitiGraphQLController.APPLICATION_GRAPHQL_VALUE) + .contentType(APPLICATION_GRAPHQL_VALUE) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) @@ -131,7 +135,7 @@ public void testGraphqlQueryGetWithNullVariables() throws Exception { mockmvc.perform(get("/graphql") .param("query", "{Tasks(where: {name: {EQ: \"name\"}}){select{id}}}") .param("variables", (String) null) - .contentType(ActivitiGraphQLController.APPLICATION_GRAPHQL_VALUE) + .contentType(APPLICATION_GRAPHQL_VALUE) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) @@ -150,7 +154,7 @@ public void testGraphqlGetQueryWithVariables() throws Exception { mockmvc.perform(get("/graphql") .param("query", "{Tasks(where: {name: {EQ: \"name\"}}){select{id}}}") .param("variables", variablesStr) - .contentType(ActivitiGraphQLController.APPLICATION_GRAPHQL_VALUE) + .contentType(APPLICATION_GRAPHQL_VALUE) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) @@ -165,7 +169,7 @@ public void testGraphqlQueryGetWithEmptyVariables() throws Exception { mockmvc.perform(get("/graphql") .param("query", "{Tasks(where: {name: {EQ: \"name\"}}){select{id}}}") .param("variables", "") - .contentType(ActivitiGraphQLController.APPLICATION_GRAPHQL_VALUE)) + .contentType(APPLICATION_GRAPHQL_VALUE)) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) ; diff --git a/starter/src/main/resources/metadata.properties b/starter/src/main/resources/metadata.properties new file mode 100644 index 0000000..036fa72 --- /dev/null +++ b/starter/src/main/resources/metadata.properties @@ -0,0 +1,3 @@ +activiti.cloud.service.type=notifications-graphql + +spring.jpa.open-in-view=false \ No newline at end of file diff --git a/starter/src/test/java/org/activiti/cloud/notifications/graphql/starter/ActivitiGraphQLStarterIT.java b/starter/src/test/java/org/activiti/cloud/notifications/graphql/starter/ActivitiGraphQLStarterIT.java index 5785898..74245ba 100644 --- a/starter/src/test/java/org/activiti/cloud/notifications/graphql/starter/ActivitiGraphQLStarterIT.java +++ b/starter/src/test/java/org/activiti/cloud/notifications/graphql/starter/ActivitiGraphQLStarterIT.java @@ -17,12 +17,16 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import graphql.ExecutionResult; -import graphql.GraphQLError; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.time.Duration; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.TimeoutException; + import org.activiti.api.runtime.model.impl.BPMNMessageImpl; import org.activiti.api.runtime.model.impl.BPMNSignalImpl; import org.activiti.api.runtime.model.impl.BPMNTimerImpl; @@ -52,7 +56,7 @@ import org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl; import org.activiti.cloud.notifications.graphql.test.EngineEventsMessageProducer; import org.activiti.cloud.notifications.graphql.test.EngineEventsMessageProducer.EngineEvents; -import org.activiti.cloud.services.graphql.web.ActivitiGraphQLController.GraphQLQueryRequest; +import org.activiti.cloud.services.notifications.graphql.web.api.GraphQLQueryResult; import org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage; import org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessageType; import org.activiti.cloud.services.query.model.ProcessDefinitionEntity; @@ -69,7 +73,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -77,6 +80,12 @@ import org.springframework.http.ResponseEntity; import org.springframework.messaging.support.MessageBuilder; import org.springframework.test.context.junit4.SpringRunner; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.introproventures.graphql.jpa.query.web.GraphQLController.GraphQLQueryRequest; import reactor.core.publisher.Mono; import reactor.core.publisher.ReplayProcessor; import reactor.netty.NettyPipeline; @@ -84,17 +93,6 @@ import reactor.netty.http.client.HttpClient.WebsocketSender; import reactor.test.StepVerifier; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.time.Duration; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeoutException; - @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class ActivitiGraphQLStarterIT { @@ -1041,13 +1039,13 @@ public void testGraphqlWsSubprotocolServerUnauthorized() throws JsonProcessingEx public void testGraphql() { GraphQLQueryRequest query = new GraphQLQueryRequest("{Tasks(where:{name:{EQ: \"" + TASK_NAME + "\"}}){select{id assignee priority}}}"); - ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query,authHeaders), Result.class); + ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query,authHeaders), GraphQLQueryResult.class); assertThat(entity.getStatusCode()) .describedAs(entity.toString()) .isEqualTo(HttpStatus.OK); - Result result = entity.getBody(); + GraphQLQueryResult result = entity.getBody(); assertThat(result).isNotNull(); assertThat(result.getErrors()) @@ -1065,7 +1063,7 @@ public void testGraphqlUnauthorized() { keycloakTokenProducer.setKeycloakTestUser(HRUSER); authHeaders = keycloakTokenProducer.authorizationHeaders(); - ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query,authHeaders), Result.class); + ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query,authHeaders), GraphQLQueryResult.class); assertThat(HttpStatus.FORBIDDEN) .describedAs(entity.toString()) @@ -1096,13 +1094,13 @@ public void testGraphqlWhere() { " }"); // @formatter:on - ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), Result.class); + ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), GraphQLQueryResult.class); assertThat(entity.getStatusCode()) .describedAs(entity.toString()) .isEqualTo(HttpStatus.OK); - Result result = entity.getBody(); + GraphQLQueryResult result = entity.getBody(); assertThat(result).isNotNull(); assertThat(result.getErrors()) @@ -1144,13 +1142,13 @@ public void testGraphqlNesting() { + "}"); // @formatter:on - ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), Result.class); + ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), GraphQLQueryResult.class); assertThat(entity.getStatusCode()) .describedAs(entity.toString()) .isEqualTo(HttpStatus.OK); - Result result = entity.getBody(); + GraphQLQueryResult result = entity.getBody(); assertThat(result).isNotNull(); assertThat(result.getErrors()) @@ -1178,19 +1176,19 @@ public void testGraphqlReverse() { ); // @formatter:on - ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), Result.class); + ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), GraphQLQueryResult.class); assertThat(entity.getStatusCode()) .describedAs(entity.toString()) .isEqualTo(HttpStatus.OK); - Result result = entity.getBody(); + GraphQLQueryResult result = entity.getBody(); assertThat(result).isNotNull(); assertThat(result.getErrors()) .isNull(); - assertThat(((Map) result.getData()).get("ProcessVariables")).isNotNull(); + assertThat(result.getData().get("ProcessVariables")).isNotNull(); } @Test @@ -1202,13 +1200,13 @@ public void testGraphqlArguments() throws JsonParseException, JsonMappingExcepti query.setVariables(variables); - ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), Result.class); + ResponseEntity entity = rest.postForEntity(GRAPHQL_URL, new HttpEntity<>(query, authHeaders), GraphQLQueryResult.class); assertThat(entity.getStatusCode()) .describedAs(entity.toString()) .isEqualTo(HttpStatus.OK); - Result result = entity.getBody(); + GraphQLQueryResult result = entity.getBody(); assertThat(result).isNotNull(); assertThat(result.getErrors()) @@ -1234,9 +1232,6 @@ class StringObjectMapBuilder extends MapBuilder, K, V> { - - protected static final SpelExpressionParser PARSER = new SpelExpressionParser(); - private final Map map = new LinkedHashMap<>(); public B put(K key, V value) { @@ -1255,57 +1250,3 @@ protected final B _this() { } - -class Result implements ExecutionResult { - - private Map data; - private List errors; - private Map extensions; - - /** - * Default - */ - Result() { - } - - /** - * @param data the data to set - */ - public void setData(Map data) { - this.data = data; - } - - /** - * @param errors the errors to set - */ - public void setErrors(List errors) { - this.errors = errors; - } - - /** - * @param extensions the extensions to set - */ - public void setExtensions(Map extensions) { - this.extensions = extensions; - } - - @Override - public T getData() { - return (T) data; - } - - @Override - public List getErrors() { - return errors; - } - - @Override - public Map getExtensions() { - return extensions; - } - - @Override - public Map toSpecification() { - return null; - } -} From b127e25f833bbb9085fc708fc43b6bd933aa9f66 Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Tue, 21 Jan 2020 14:22:07 -0800 Subject: [PATCH 2/4] fix: Removed GraphQLQueryRequest(String) constructor --- .../graphql/web/api/GraphQLQueryRequest.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java b/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java index f0347e2..6cc2d18 100644 --- a/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java +++ b/services/api/src/main/java/org/activiti/cloud/services/notifications/graphql/web/api/GraphQLQueryRequest.java @@ -23,14 +23,6 @@ private GraphQLQueryRequest(Builder builder) { GraphQLQueryRequest() { } - /** - * @param query - */ - public GraphQLQueryRequest(String query) { - super(); - this.query = query; - } - /** * @return the query */ From 9801561a3afd4286432902d08a486021818a6a7e Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Tue, 21 Jan 2020 16:28:01 -0800 Subject: [PATCH 3/4] fix(Jenkinsfile): Updated PR preview version to use SNAPSHOT qualifier --- Jenkinsfile | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a049d40..b196c45 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,6 +14,7 @@ pipeline { branch "PR-*" } environment { + PREVIEW_VERSION = maven_project_version().replaceAll("SNAPSHOT","$BRANCH_NAME-$BUILD_NUMBER-SNAPSHOT") PREVIEW_VERSION = "7.1.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER" PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase() HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase() @@ -33,6 +34,9 @@ pipeline { when { branch "${RELEASE_BRANCH}" } + environment { + VERSION = jx_release_version() + } steps { container("maven") { // ensure we're not on a detached head @@ -41,25 +45,25 @@ pipeline { sh "jx step git credentials" // so we can retrieve the version in later steps - sh "echo \$(jx-release-version) > VERSION" - sh "mvn versions:set -DnewVersion=\$(cat VERSION)" + sh "echo $VERSION > VERSION" + sh "mvn versions:set -DnewVersion=$VERSION" sh "mvn clean verify" retry(5){ sh "git add --all" - sh "git commit -m \"Release \$(cat VERSION)\" --allow-empty" - sh "git tag -fa v\$(cat VERSION) -m \"Release version \$(cat VERSION)\"" + sh "git commit -m \"Release $VERSION\" --allow-empty" + sh "git tag -fa v$VERSION -m \"Release version $VERSION\"" - sh "git push origin v\$(cat VERSION)" + sh "git push origin v$VERSION" } sh "mvn clean deploy -DskipTests" retry(2){ - sh "updatebot push-version --kind maven ${RELEASE_ARTIFACT} \$(cat VERSION)" + sh "updatebot push-version --kind maven ${RELEASE_ARTIFACT} $VERSION" sh "rm -rf .updatebot-repos/" sh "sleep \$((RANDOM % 10))" - sh "updatebot push-version --kind maven ${RELEASE_ARTIFACT} \$(cat VERSION)" + sh "updatebot push-version --kind maven ${RELEASE_ARTIFACT} $VERSION" } } } @@ -104,3 +108,15 @@ pipeline { } } } + +def jx_release_version() { + container('maven') { + return sh( script: "echo \$(jx-release-version)", returnStdout: true).trim() + } +} + +def maven_project_version() { + container('maven') { + return sh( script: "echo \$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -f pom.xml)", returnStdout: true).trim() + } +} \ No newline at end of file From 2cce1d9716cf87f5ceb1da96731a49e29bb7158f Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Tue, 21 Jan 2020 16:29:24 -0800 Subject: [PATCH 4/4] fix(Jenkinsfile): removed duplicate PREVIEW_VERSION --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b196c45..bca03d5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,6 @@ pipeline { } environment { PREVIEW_VERSION = maven_project_version().replaceAll("SNAPSHOT","$BRANCH_NAME-$BUILD_NUMBER-SNAPSHOT") - PREVIEW_VERSION = "7.1.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER" PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase() HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase() }