You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/10/07 11:55:22 UTC
[incubator-streampipes] branch STREAMPIPES-438 updated: Remova REST
endpoint for adapter templates
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch STREAMPIPES-438
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
The following commit(s) were added to refs/heads/STREAMPIPES-438 by this push:
new 9f283bb Remova REST endpoint for adapter templates
9f283bb is described below
commit 9f283bbb32c399285dade06b3f20b1c1ceff9c4e
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Thu Oct 7 13:55:03 2021 +0200
Remova REST endpoint for adapter templates
---
.../backend/StreamPipesResourceConfig.java | 1 -
.../AdapterTemplateMasterManagement.java | 105 ---------------------
.../AdapterTemplateMasterManagementTest.java | 59 ------------
.../rest/impl/connect/AdapterTemplateResource.java | 89 -----------------
4 files changed, 254 deletions(-)
diff --git a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
index dde7dcd..3f3a90b 100644
--- a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
+++ b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesResourceConfig.java
@@ -119,7 +119,6 @@ public class StreamPipesResourceConfig extends ResourceConfig {
// Connect Master
register(WelcomePageMaster.class);
register(AdapterResource.class);
- register(AdapterTemplateResource.class);
register(DescriptionResource.class);
register(SourcesResource.class);
register(GuessResource.class);
diff --git a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/AdapterTemplateMasterManagement.java b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/AdapterTemplateMasterManagement.java
deleted file mode 100644
index fec1eb9..0000000
--- a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/AdapterTemplateMasterManagement.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.streampipes.connect.container.master.management;
-
-import org.apache.streampipes.connect.api.exception.AdapterException;
-import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import org.apache.streampipes.model.connect.adapter.AdapterDescriptionList;
-import org.apache.streampipes.model.connect.adapter.GenericAdapterSetDescription;
-import org.apache.streampipes.model.connect.adapter.GenericAdapterStreamDescription;
-import org.apache.streampipes.model.util.Cloner;
-import org.apache.streampipes.storage.api.IAdapterTemplateStorage;
-import org.apache.streampipes.storage.couchdb.impl.AdapterTemplateStorageImpl;
-
-import java.util.List;
-import java.util.UUID;
-
-
-@Deprecated
-public class AdapterTemplateMasterManagement {
-
- private IAdapterTemplateStorage adapterTemplateStorage;
-
- public AdapterTemplateMasterManagement() {
- this.adapterTemplateStorage = new AdapterTemplateStorageImpl();
-
- }
-
- public AdapterTemplateMasterManagement(IAdapterTemplateStorage adapterTemplateStorage) {
- this.adapterTemplateStorage = adapterTemplateStorage;
- }
-
- public String addAdapterTemplate(AdapterDescription adapterDescription) throws AdapterException {
-
-// String uri = "http://streampipes.org/adapter/template/" + UUID.randomUUID().toString();
- adapterDescription = new Cloner().adapterDescription(adapterDescription);
-
- String uri = adapterDescription.getUri() + UUID.randomUUID().toString();
- adapterDescription.setUri(uri);
- adapterDescription.setElementId(uri);
-
- if (adapterDescription instanceof GenericAdapterSetDescription) {
- String id = ((GenericAdapterSetDescription) adapterDescription).getFormatDescription().getElementId();
- id = id + "/" + UUID.randomUUID().toString();
- ((GenericAdapterSetDescription) adapterDescription).getFormatDescription().setElementId(id);
-
- id = ((GenericAdapterSetDescription) adapterDescription).getProtocolDescription().getElementId();
- id = id + "/" + UUID.randomUUID().toString();
- ((GenericAdapterSetDescription) adapterDescription).getProtocolDescription().setElementId(id);
-
- id = ((GenericAdapterSetDescription) adapterDescription).getDataSet().getElementId();
- id = id + "/" + UUID.randomUUID().toString();
- ((GenericAdapterSetDescription) adapterDescription).getDataSet().setElementId(id);
- }
-
- if (adapterDescription instanceof GenericAdapterStreamDescription) {
- String id = ((GenericAdapterStreamDescription) adapterDescription).getFormatDescription().getElementId();
- id = id + "/" + UUID.randomUUID().toString();
- ((GenericAdapterStreamDescription) adapterDescription).getFormatDescription().setElementId(id);
-
- id = ((GenericAdapterStreamDescription) adapterDescription).getProtocolDescription().getElementId();
- id = id + "/" + UUID.randomUUID().toString();
- ((GenericAdapterStreamDescription) adapterDescription).getProtocolDescription().setElementId(id);
-
- id = ((GenericAdapterStreamDescription) adapterDescription).getDataStream().getElementId();
- id = id + "/" + UUID.randomUUID().toString();
- ((GenericAdapterStreamDescription) adapterDescription).getDataStream().setElementId(id);
- }
-
- this.adapterTemplateStorage.storeAdapterTemplate(adapterDescription);
- return adapterDescription.getElementId();
- }
-
-
- public AdapterDescriptionList getAllAdapterTemplates() throws AdapterException {
- List<AdapterDescription> adapterDescriptions = this.adapterTemplateStorage.getAllAdapterTemplates();
- AdapterDescriptionList result = new AdapterDescriptionList();
- result.setList(adapterDescriptions);
-
- return result;
- }
-
- public void deleteAdapterTemplates(String id) throws AdapterException {
- this.adapterTemplateStorage.deleteAdapterTemplate(id);
- }
-
- public void setAdapterTemplateStorage(IAdapterTemplateStorage adapterTemplateStorage) {
- this.adapterTemplateStorage = adapterTemplateStorage;
- }
-}
diff --git a/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/AdapterTemplateMasterManagementTest.java b/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/AdapterTemplateMasterManagementTest.java
deleted file mode 100644
index 17bc969..0000000
--- a/streampipes-connect-container-master/src/test/java/org/apache/streampipes/connect/container/master/management/AdapterTemplateMasterManagementTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.streampipes.connect.container.master.management;
-
-import org.apache.streampipes.connect.api.exception.AdapterException;
-import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import org.apache.streampipes.model.connect.adapter.AdapterDescriptionList;
-import org.apache.streampipes.model.connect.adapter.GenericAdapterStreamDescription;
-import org.apache.streampipes.storage.couchdb.impl.AdapterTemplateStorageImpl;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@Deprecated
-public class AdapterTemplateMasterManagementTest {
-
- @Test
- public void getAllAdapterTemplates() throws AdapterException {
- String uri = "http://test.uri";
- AdapterDescription adapterDescription = new GenericAdapterStreamDescription();
- adapterDescription.setUri(uri);
-
- AdapterTemplateStorageImpl adapterStorage = mock(AdapterTemplateStorageImpl.class);
- when(adapterStorage.getAllAdapterTemplates()).thenReturn(Arrays.asList(adapterDescription));
-
- AdapterTemplateMasterManagement adapterTemplateMasterManagement = new AdapterTemplateMasterManagement();
- adapterTemplateMasterManagement.setAdapterTemplateStorage(adapterStorage);
-
-
- AdapterDescriptionList result = adapterTemplateMasterManagement.getAllAdapterTemplates();
-
-
- assertNotNull(result);
- assertNotNull(result.getList());
- assertEquals(1, result.getList().size());
- assertEquals(uri, result.getList().get(0).getUri());
- }
-}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/AdapterTemplateResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/AdapterTemplateResource.java
deleted file mode 100644
index 4763666..0000000
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/AdapterTemplateResource.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.streampipes.rest.impl.connect;
-
-import org.apache.streampipes.connect.api.exception.AdapterException;
-import org.apache.streampipes.connect.container.master.management.AdapterTemplateMasterManagement;
-import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import org.apache.streampipes.model.connect.adapter.AdapterDescriptionList;
-import org.apache.streampipes.model.message.Notifications;
-import org.apache.streampipes.rest.shared.annotation.JacksonSerialized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-@Deprecated
-@Path("/v2/connect/master/adapters/template")
-public class AdapterTemplateResource extends AbstractAdapterResource<AdapterTemplateMasterManagement> {
-
- private static final Logger LOG = LoggerFactory.getLogger(AdapterTemplateResource.class);
-
- public AdapterTemplateResource() {
- super(AdapterTemplateMasterManagement::new);
- }
-
- @POST
- @JacksonSerialized
- @Produces(MediaType.APPLICATION_JSON)
- public Response addAdapterTemplate(AdapterDescription adapterDescription) {
- try {
- String adapterTemplateId = managementService.addAdapterTemplate(adapterDescription);
- LOG.info("User: " + getAuthenticatedUsername() + " added adapter as adapter template");
-
- return ok(Notifications.success(adapterTemplateId));
- } catch (AdapterException e) {
- LOG.error("Error while storing the adapter template", e);
- return ok(Notifications.error(e.getMessage()));
- }
- }
-
- @GET
- @JacksonSerialized
- @Path("/all")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getAllAdapterTemplates() {
- try {
- AdapterDescriptionList result = managementService.getAllAdapterTemplates();
-
- return ok(result);
- } catch (AdapterException e) {
- LOG.error("Error while getting all adapter templates", e);
- return ok(Notifications.error(e.getMessage()));
- }
-
- }
-
- @DELETE
- @JacksonSerialized
- @Path("/{id}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response deleteAdapter(@PathParam("id") String id) {
-
- try {
- managementService.deleteAdapterTemplates(id);
- return ok(true);
- } catch (AdapterException e) {
- LOG.error("Error while deleting adapter with id " + id, e);
- return fail();
- }
- }
-}