feat(manager-api): add image to client, API, and client summaries
MODIFY
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/RateLimitingPolicy.java
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/RateLimitingPolicy.java
@@ -44,8 +44,8 @@ import org.apache.commons.lang3.StringUtils;
*/
public class RateLimitingPolicy extends AbstractMappedPolicy<RateLimitingConfig> {
- protected static final String NO_USER_AVAILABLE = new String();
- protected static final String NO_CLIENT_AVAILABLE = new String();
+ protected static final String NO_USER_AVAILABLE = "";
+ protected static final String NO_CLIENT_AVAILABLE = "";
private static final String DEFAULT_LIMIT_HEADER = "X-RateLimit-Limit"; //$NON-NLS-1$
private static final String DEFAULT_REMAINING_HEADER = "X-RateLimit-Remaining"; //$NON-NLS-1$

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
@@ -66,7 +66,7 @@ public class ApiBean implements Serializable, Cloneable {
private String name;
@Column(name = "image_file_ref", updatable = true, nullable = true) // Reference to file storage (we'll ship with DB blob)
@BlobReference
- private String imageFileRef;
+ private String image;
@Column(updatable=true, nullable=true, length=512)
private String description;
@Column(name = "created_by", updatable=false, nullable=false)
@@ -183,12 +183,12 @@ public class ApiBean implements Serializable, Cloneable {
this.numPublished = numPublished;
}
- public String getImageFileRef() {
- return imageFileRef;
+ public String getImage() {
+ return image;
}
- public void setImageFileRef(String imageFileRef) {
- this.imageFileRef = imageFileRef;
+ public void setImage(String imageFileRef) {
+ this.image = imageFileRef;
}
/* (non-Javadoc)

MODIFY
manager/api/beans/src/main/java/io/apiman/manager/api/beans/clients/ClientBean.java
manager/api/beans/src/main/java/io/apiman/manager/api/beans/clients/ClientBean.java
*/
package io.apiman.manager.api.beans.clients;
+import io.apiman.manager.api.beans.download.BlobReference;
import io.apiman.manager.api.beans.orgs.OrganizationBasedCompositeId;
import io.apiman.manager.api.beans.orgs.OrganizationBean;
@@ -22,7 +23,6 @@ import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;
-
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -63,6 +63,9 @@ public class ClientBean implements Serializable, Cloneable {
private String id;
@Column(nullable=false)
private String name;
+ @Column(name = "image_file_ref", updatable = true, nullable = true) // Reference to file storage (we'll ship with DB blob)
+ @BlobReference
+ private String imageFileRef;
@Column(updatable=true, nullable=true, length=512)
private String description;
@Column(name = "created_by", updatable=false, nullable=false)
@@ -157,6 +160,25 @@ public class ClientBean implements Serializable, Cloneable {
this.createdBy = createdBy;
}
+ public String getImage() {
+ return imageFileRef;
+ }
+
+ public ClientBean setImageFileRef(String imageFileRef) {
+ this.imageFileRef = imageFileRef;
+ return this;
+ }
+
+ public Set<ClientVersionBean> getClientVersionSet() {
+ return clientVersionSet;
+ }
+
+ public ClientBean setClientVersionSet(
+ Set<ClientVersionBean> clientVersionSet) {
+ this.clientVersionSet = clientVersionSet;
+ return this;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/

MODIFY
manager/api/beans/src/main/java/io/apiman/manager/api/beans/events/AccountSignupEvent.java
manager/api/beans/src/main/java/io/apiman/manager/api/beans/events/AccountSignupEvent.java
@@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.apache.commons.lang3.Validate;
/**
- * Account signup event fired by an external SSO.
+ * Account signup event
*
* @author Marc Savy {@literal <marc@blackparrotlabs.io>}
*/

MODIFY
manager/api/beans/src/main/java/io/apiman/manager/api/beans/summary/ApiSummaryBean.java
manager/api/beans/src/main/java/io/apiman/manager/api/beans/summary/ApiSummaryBean.java
*/
package io.apiman.manager.api.beans.summary;
+import io.apiman.manager.api.beans.download.BlobReference;
+
import java.io.Serializable;
import java.util.Date;
@@ -35,6 +37,8 @@ public class ApiSummaryBean implements Serializable {
private String organizationId;
private String organizationName;
+ @BlobReference
+ private String image;
private String id;
private String name;
private String description;
@@ -130,6 +134,15 @@ public class ApiSummaryBean implements Serializable {
this.createdOn = createdOn;
}
+ public String getImage() {
+ return image;
+ }
+
+ public ApiSummaryBean setImage(String imageFileRef) {
+ this.image = imageFileRef;
+ return this;
+ }
+
/**
* @see java.lang.Object#hashCode()
*/

MODIFY
manager/api/beans/src/main/java/io/apiman/manager/api/beans/summary/ClientSummaryBean.java
manager/api/beans/src/main/java/io/apiman/manager/api/beans/summary/ClientSummaryBean.java
*/
package io.apiman.manager.api.beans.summary;
+import io.apiman.manager.api.beans.download.BlobReference;
+
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -33,6 +35,8 @@ public class ClientSummaryBean implements Serializable {
private String organizationId;
private String organizationName;
+ @BlobReference
+ private String imageFileRef;
private String id;
private String name;
private String description;
@@ -135,6 +139,15 @@ public class ClientSummaryBean implements Serializable {
return serialVersionUID;
}
+ public String getImageFileRef() {
+ return imageFileRef;
+ }
+
+ public ClientSummaryBean setImage(String imageFileRef) {
+ this.imageFileRef = imageFileRef;
+ return this;
+ }
+
/**
* @see java.lang.Object#hashCode()
*/

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
@@ -729,6 +729,7 @@ public class JpaStorage extends AbstractJpaStorage implements IStorage, IStorage
summary.setId(client.getId());
summary.setName(client.getName());
summary.setDescription(client.getDescription());
+ summary.setImage(client.getImage());
// TODO find the number of contracts - probably need native SQL for that
summary.setNumContracts(0);
summary.setOrganizationId(client.getOrganization().getId());
@@ -754,6 +755,7 @@ public class JpaStorage extends AbstractJpaStorage implements IStorage, IStorage
OrganizationBean organization = api.getOrganization();
summary.setId(api.getId());
summary.setName(api.getName());
+ summary.setImage(api.getImage());
summary.setDescription(api.getDescription());
summary.setCreatedOn(api.getCreatedOn());
summary.setOrganizationId(api.getOrganization().getId());

RENAME
manager/api/rest-impl/src/main/java/io/apiman/manager/api/notifications/email/handlers/ApiSignupApprovalRequest.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/notifications/email/handlers/ContractApprovalRequest.java
@@ -12,10 +12,10 @@ import javax.inject.Inject;
* @author Marc Savy {@literal <marc@blackparrotlabs.io>}
*/
@ApplicationScoped
-public class ApiSignupApprovalRequest implements INotificationHandler {
+public class ContractApprovalRequest implements INotificationHandler {
@Inject
- public ApiSignupApprovalRequest() {}
+ public ContractApprovalRequest() {}
@Override
public void handle(NotificationDto<? extends IVersionedApimanEvent> rawNotification) {
@@ -27,7 +27,7 @@ public class ApiSignupApprovalRequest implements INotificationHandler {
@Override
public boolean wants(NotificationDto<? extends IVersionedApimanEvent> notification) {
- if (notification.getReason().equals(ContractApprovalRequestNotificationProducer.APIMAN_API_APPROVAL_REQUEST)) {
+ if (notification.getReason().equals(ContractApprovalRequestNotificationProducer.APIMAN_CLIENT_CONTRACT_REASON)) {
return true;
}
return false;

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/notifications/producers/ContractApprovalRequestNotificationProducer.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/notifications/producers/ContractApprovalRequestNotificationProducer.java
@@ -16,7 +16,7 @@ import javax.enterprise.event.Observes;
import javax.inject.Inject;
/**
- * Accept a {@link ContractApprovalRequestEvent} and produce a {@link #APIMAN_API_APPROVAL_REQUEST} notification.
+ * Accept a {@link ContractApprovalRequestEvent} and produce a {@link #APIMAN_CLIENT_CONTRACT_REASON} notification.
*
* @author Marc Savy {@literal <marc@blackparrotlabs.io>}
*/
@@ -24,7 +24,7 @@ import javax.inject.Inject;
public class ContractApprovalRequestNotificationProducer implements INotificationProducer {
private static final IApimanLogger LOGGER = ApimanLoggerFactory.getLogger(ContractApprovalRequestNotificationProducer.class);
- public static final String APIMAN_API_APPROVAL_REQUEST = "apiman.api.approval.request";
+ public static final String APIMAN_CLIENT_CONTRACT_REASON = "apiman.client.contract.approval.request";
private NotificationService notificationService;
@Inject
@@ -46,7 +46,7 @@ public class ContractApprovalRequestNotificationProducer implements INotificatio
.setRecipientType(RecipientType.PERMISSION);
newNotification.setRecipient(List.of(planAdmins))
- .setReason(APIMAN_API_APPROVAL_REQUEST)
+ .setReason(APIMAN_CLIENT_CONTRACT_REASON)
.setReasonMessage("Signup request for API")
.setCategory(NotificationCategory.API_ADMINISTRATION)
.setPayload(signupEvent);

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java
@@ -48,7 +48,6 @@ import io.apiman.manager.api.core.IStorageQuery;
import io.apiman.manager.api.core.exceptions.StorageException;
import io.apiman.manager.api.gateway.IGatewayLink;
import io.apiman.manager.api.gateway.IGatewayLinkFactory;
-import io.apiman.manager.api.notifications.email.handlers.ApiSignupApprovalRequest;
import io.apiman.manager.api.rest.IActionResource;
import io.apiman.manager.api.rest.IOrganizationResource;
import io.apiman.manager.api.rest.exceptions.ActionException;
@@ -62,6 +61,7 @@ import io.apiman.manager.api.rest.exceptions.util.ExceptionFactory;
import io.apiman.manager.api.rest.impl.audit.AuditUtils;
import io.apiman.manager.api.rest.impl.util.DataAccessUtilMixin;
import io.apiman.manager.api.security.ISecurityContext;
+import io.apiman.manager.api.service.ActionService;
import io.apiman.manager.api.service.ContractService;
import java.util.ArrayList;
@@ -98,6 +98,7 @@ public class ActionResourceImpl implements IActionResource, DataAccessUtilMixin
private IClientValidator clientValidator;
private ISecurityContext securityContext;
+ private ActionService actionService;
/**
* Constructor.
@@ -110,7 +111,8 @@ public class ActionResourceImpl implements IActionResource, DataAccessUtilMixin
IGatewayLinkFactory gatewayLinkFactory,
IOrganizationResource orgs,
IClientValidator clientValidator,
- ISecurityContext securityContext
+ ISecurityContext securityContext,
+ ActionService actionService
) {
this.storage = storage;
this.contractService = contractService;
@@ -119,6 +121,7 @@ public class ActionResourceImpl implements IActionResource, DataAccessUtilMixin
this.orgs = orgs;
this.clientValidator = clientValidator;
this.securityContext = securityContext;
+ this.actionService = actionService;
}
public ActionResourceImpl() {
@@ -665,6 +668,4 @@ public class ActionResourceImpl implements IActionResource, DataAccessUtilMixin
LOGGER.debug(String.format("Successfully locked Plan %s: %s", //$NON-NLS-1$
versionBean.getPlan().getName(), versionBean.getPlan()));
}
-
- private ApiSignupApprovalRequest
}

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/RestHelper.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/RestHelper.java
@@ -63,6 +63,7 @@ public final class RestHelper {
apiSummary.setId(apiSummaryBean.getId());
apiSummary.setName(apiSummaryBean.getName());
apiSummary.setDescription(apiSummaryBean.getDescription());
+ apiSummary.setImage(apiSummaryBean.getImage());
apis.add(apiSummary);
}
return apis;

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ActionService.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ActionService.java
@@ -16,7 +16,7 @@ import java.util.UUID;
import javax.inject.Inject;
import javax.transaction.Transactional;
-import static io.apiman.manager.api.notifications.producers.ContractApprovalRequestNotificationProducer.APIMAN_API_APPROVAL_REQUEST;
+import static io.apiman.manager.api.notifications.producers.ContractApprovalRequestNotificationProducer.APIMAN_CLIENT_CONTRACT_REASON;
/**
* @author Marc Savy {@literal <marc@blackparrotlabs.io>}
@@ -43,7 +43,7 @@ public class ActionService implements DataAccessUtilMixin {
.builder()
.setId(UUID.randomUUID().toString())
.setSource(URI.create("/a/b/c"))
- .setSubject(APIMAN_API_APPROVAL_REQUEST)
+ .setSubject(APIMAN_CLIENT_CONTRACT_REASON)
.setTime(OffsetDateTime.now())
.build();
@@ -59,8 +59,4 @@ public class ActionService implements DataAccessUtilMixin {
LOGGER.debug("Sending approval request event {0}", approvalRequestEvent);
eventService.fireEvent(approvalRequestEvent);
}
-
- public void sendContractApproval(String userId, String clientId, String apiId, Long contractId) {
-
- }
}

MODIFY
manager/api/rest/src/main/java/io/apiman/manager/api/rest/IEventResource.java
manager/api/rest/src/main/java/io/apiman/manager/api/rest/IEventResource.java
@@ -10,7 +10,7 @@ import javax.ws.rs.core.MediaType;
import io.swagger.annotations.Api;
/**
- * An event receiving API.
+ * An event receiving REST API.
*
* @author Marc Savy {@literal <marc@blackparrotlabs.io>}
*/
@@ -19,7 +19,7 @@ import io.swagger.annotations.Api;
public interface IEventResource {
/**
- * For SSO to push new events
+ * For SSO to push new account events
*/
@POST
@Path("sso/users")

feat(manager-api): add image to client, API, and client summaries