fix(manager-api): remove stray annotation on tags (was wrong
MODIFY
manager/api/beans/src/main/java/io/apiman/manager/api/beans/apis/ApiBean.java
manager/api/beans/src/main/java/io/apiman/manager/api/beans/apis/ApiBean.java
@@ -76,7 +76,6 @@ public class ApiBean implements Serializable, Cloneable {
joinColumns = { @JoinColumn(name = "api_id"), @JoinColumn(name = "org_id") },
inverseJoinColumns = @JoinColumn(name = "tag_id")
)
- @JsonIgnore
private Set<KeyValueTag> tags = new HashSet<>();
@Column(name = "created_by", updatable=false, nullable=false)
private String createdBy;

MODIFY
manager/api/jpa/src/main/java/io/apiman/manager/api/jpa/JpaStorage.java
manager/api/jpa/src/main/java/io/apiman/manager/api/jpa/JpaStorage.java
@@ -1164,7 +1164,7 @@ public class JpaStorage extends AbstractJpaStorage implements IStorage, IStorage
@Override
public List<ApiBean> getApisByTagNameAndValue(String tagKey, String tagValue) {
- TypedQuery<ApiBean> query = getSession()
+ TypedQuery<ApiBean> query = getActiveEntityManager()
.createQuery(
"SELECT ApiBean FROM ApiBean avb "
+ "JOIN avb.tags tag "
@@ -1179,7 +1179,7 @@ public class JpaStorage extends AbstractJpaStorage implements IStorage, IStorage
}
@Override
- public List<ApiBean> getApisByTagName(@NotNull String tagKey) {
+ public List<ApiBean> getApisByTagName(String tagKey) {
TypedQuery<ApiBean> query = getActiveEntityManager()
.createQuery(
"SELECT ApiBean FROM ApiBean avb "

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/OrganizationResourceImpl.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/OrganizationResourceImpl.java
@@ -28,6 +28,7 @@ import io.apiman.manager.api.beans.apis.NewApiVersionBean;
import io.apiman.manager.api.beans.apis.UpdateApiBean;
import io.apiman.manager.api.beans.apis.UpdateApiVersionBean;
import io.apiman.manager.api.beans.apis.dto.ApiBeanDto;
+import io.apiman.manager.api.beans.apis.dto.KeyValueTagDto;
import io.apiman.manager.api.beans.audit.AuditEntryBean;
import io.apiman.manager.api.beans.clients.ApiKeyBean;
import io.apiman.manager.api.beans.clients.ClientBean;
@@ -523,24 +524,6 @@ public class OrganizationResourceImpl implements IOrganizationResource, DataAcce
return apiService.createApi(organizationId, bean);
}
- // @Override
- // public ApiBean createApi(String organizationId, MultipartFormDataInput multipartInput)
- // throws OrganizationNotFoundException, ApiAlreadyExistsException, NotAuthorizedException, InvalidNameException, IOException {
- // securityContext.checkPermissions(PermissionType.apiEdit, organizationId);
- // Preconditions.checkArgument(multipartInput.getParts().size() != 2, "Expected 'api' and 'image'");
- //
- // // Try to do image first as it is probably more likely to fail.
- // MultipartUploadHolder image = MultipartHelper.getRequiredImage(multipartInput, "image");
- // BlobRef blobRef = blobStore.storeBlob(image.getFilename(), image.getMediaType().toString(), image.getFileBackedOutputStream());
- //
- // // Simply convert to NewApiBean and store reference.
- // InputPart apiPart = MultipartHelper.getRequiredPart(multipartInput, "api", MediaType.APPLICATION_JSON_TYPE);
- // // TODO(msavy): probably better to have a separate DTO than for imageref @JsonIgnore?
- // NewApiBean api = apiPart.getBody(NewApiBean.class, null);
- // api.setImage(blobRef.getId());
- // return apiService.createApi(organizationId, api);
- // }
-
@Override
public List<ApiSummaryBean> listApis(String organizationId) throws OrganizationNotFoundException {
// No permission check is needed, because this would break All Organizations UI
@@ -561,24 +544,11 @@ public class OrganizationResourceImpl implements IOrganizationResource, DataAcce
apiService.updateApi(organizationId, apiId, bean);
}
- // @Override
- // public void updateApi(String organizationId, String apiId, MultipartFormDataInput multipartInput)
- // throws ApiNotFoundException, NotAuthorizedException, IOException {
- // securityContext.checkPermissions(PermissionType.apiEdit, organizationId);
- //
- // Preconditions.checkArgument(multipartInput.getParts().size() != 2, "Expected 'api' and 'image'");
- //
- // // Try to do image first as it is probably more likely to fail.
- // MultipartUploadHolder image = MultipartHelper.getRequiredImage(multipartInput, "image");
- // BlobRef blobRef = blobStore.storeBlob(image.getFilename(), image.getMediaType().toString(), image.getFileBackedOutputStream());
- //
- // // Simply convert to NewApiBean and store reference.
- // InputPart apiPart = MultipartHelper.getRequiredPart(multipartInput, "api", MediaType.APPLICATION_JSON_TYPE);
- // // TODO(msavy): probably better to have a separate DTO than for imageref @JsonIgnore?
- // UpdateApiBean update = apiPart.getBody(UpdateApiBean.class, null);
- // update.setImage(blobRef.getId());
- // apiService.updateApi(organizationId, apiId, update);
- // }
+ @Override
+ public void tagApi(String organizationId, String apiId, KeyValueTagDto bean) throws ApiNotFoundException, NotAuthorizedException {
+ securityContext.checkPermissions(PermissionType.apiEdit, organizationId);
+ apiService.addTag(organizationId, apiId, bean);
+ }
@Override
public void deleteApi(String organizationId, String apiId)

MODIFY
manager/api/rest/src/main/java/io/apiman/manager/api/rest/IOrganizationResource.java
manager/api/rest/src/main/java/io/apiman/manager/api/rest/IOrganizationResource.java
@@ -25,6 +25,7 @@ import io.apiman.manager.api.beans.apis.NewApiVersionBean;
import io.apiman.manager.api.beans.apis.UpdateApiBean;
import io.apiman.manager.api.beans.apis.UpdateApiVersionBean;
import io.apiman.manager.api.beans.apis.dto.ApiBeanDto;
+import io.apiman.manager.api.beans.apis.dto.KeyValueTagDto;
import io.apiman.manager.api.beans.audit.AuditEntryBean;
import io.apiman.manager.api.beans.clients.ApiKeyBean;
import io.apiman.manager.api.beans.clients.ClientBean;
@@ -866,14 +867,6 @@ public interface IOrganizationResource {
public ApiBeanDto createApi(@PathParam("organizationId") String organizationId, @NotNull NewApiBean bean)
throws OrganizationNotFoundException, ApiAlreadyExistsException, NotAuthorizedException,
InvalidNameException;
-
- // @POST
- // @Path("{organizationId}/apis")
- // @Consumes(MediaType.MULTIPART_FORM_DATA)
- // @Produces(MediaType.APPLICATION_JSON)
- // public ApiBean createApi(@PathParam("organizationId") String organizationId, @NotNull MultipartFormDataInput multipartInput)
- // throws OrganizationNotFoundException, ApiAlreadyExistsException, NotAuthorizedException, InvalidNameException, IOException;
-
/**
* Use this endpoint to get a list of all APIs in the Organization.
* @summary List APIs
@@ -929,16 +922,12 @@ public interface IOrganizationResource {
@PathParam("apiId") String apiId, UpdateApiBean bean)
throws ApiNotFoundException, NotAuthorizedException;
- /**
- * As {@link #updateApi(String, String, UpdateApiBean)}, but with an image to represent the API.
- */
- // @PUT
- // @Path("{organizationId}/apis/{apiId}")
- // @Consumes(MediaType.MULTIPART_FORM_DATA)
- // @Produces(MediaType.APPLICATION_JSON)
- // public void updateApi(@PathParam("organizationId") String organizationId, @PathParam("apiId") String apiId,
- // @NotNull @MultipartForm MultipartFormDataInput multipartInput)
- // throws ApiNotFoundException, NotAuthorizedException, IOException;
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("{organizationId}/apis/{apiId}/tags")
+ void tagApi(@PathParam("organizationId") String organizationId,
+ @PathParam("apiId") String apiId, KeyValueTagDto bean)
+ throws ApiNotFoundException, NotAuthorizedException;
/**
* Use this endpoint to delete an API. There are multiple restrictions on this capability. Specifically,

DELETE
test/suite/src/test/java/io/apiman/manager/api/jpa/AbstractJpaStorageTest.java
-import static org.junit.Assert.*;
-/**
- *
- *
- * @author Marc Savy {@literal <marc@blackparrotlabs.io>}
- */public class AbstractJpaStorageTest {
-
-}
\ No newline at end of file

DELETE
test/suite/src/test/java/io/apiman/manager/api/jpa/model/outbox/OutboxEventEntityTest.java
-// package io.apiman.manager.api.jpa.model.outbox;
-//
-// import io.apiman.manager.api.beans.events.AccountSignupEvent;
-// import io.apiman.manager.api.beans.events.ApimanEvent;
-// import io.apiman.manager.api.beans.events.ApimanEventHeaders;
-// import io.apiman.manager.api.beans.events.EventVersion;
-// import io.apiman.manager.api.beans.events.IVersionedApimanEvent;
-//
-// import java.net.URI;
-//
-// import com.fasterxml.jackson.annotation.JsonIgnore;
-// import com.fasterxml.jackson.databind.JsonNode;
-// import com.fasterxml.jackson.databind.ObjectMapper;
-// import org.apache.commons.lang3.StringUtils;
-// import org.junit.Test;
-//
-// /**
-// * @author Marc Savy {@literal <marc@blackparrotlabs.io>}
-// */
-// public class OutboxEventEntityTest {
-// private static final ObjectMapper OM = new ObjectMapper();
-//
-// @Test
-// public void test() {
-// ApimanEventHeaders headers = ApimanEventHeaders
-// .builder()
-// .setId("test")
-// .setSource(URI.create("http://replaceme.local/foo"))
-// .setSubject("SsoNewAccount")
-// .build();
-//
-// AccountSignupEvent apimanEvent = AccountSignupEvent
-// .builder()
-// .setHeaders(headers)
-// .setUserId("fb0123")
-// .setUsername("msavy")
-// .setEmailAddress("email@address.local")
-// .setFirstName("John")
-// .setSurname("Smith")
-// .build();
-//
-// long eventVersion = getEventVersion(apimanEvent, headers);
-// String eventType = getType(apimanEvent);
-//
-// OutboxEventEntity outboxEvent = new OutboxEventEntity()
-// .setEventVersion(eventVersion)
-// .setType(eventType)
-// .setSource(headers.getSource().toString())
-// .setSubject(headers.getSubject())
-// .setTime(headers.getTime())
-// .setPayload(serializeWithoutHeaders(apimanEvent));
-//
-// System.out.println("OK worked " + outboxEvent);
-// }
-//
-// private JsonNode serializeWithoutHeaders(IVersionedApimanEvent apimanEvent) {
-// OM.addMixIn(apimanEvent.getClass(), IgnoreHeadersMixin.class);
-// return OM.valueToTree(apimanEvent);
-// }
-//
-// private String getType(IVersionedApimanEvent apimanEvent) {
-// String currentValue = apimanEvent.getHeaders().getType();
-// if (StringUtils.isEmpty(currentValue)) {
-// return apimanEvent.getClass().getCanonicalName();
-// } else {
-// return currentValue;
-// }
-// }
-//
-// private long getEventVersion(IVersionedApimanEvent event, ApimanEventHeaders headers) {
-// // Version was not set, get it from the annotation if possible.
-// if (headers.getEventVersion() <= 0) {
-// ApimanEvent ev = event.getClass().getAnnotation(EventVersion.class);
-// if (ev == null) {
-// return 1;
-// }
-// return ev.value();
-// } else {
-// return headers.getEventVersion();
-// }
-// }
-//
-// private abstract static class IgnoreHeadersMixin {
-//
-// @JsonIgnore
-// public abstract ApimanEventHeaders getHeaders();
-// }
-// }

fix(manager-api): remove stray annotation on tags (was wrong @JsonIgnore)