use of io.apiman.manager.api.beans.apis.ApiVersionStatusBean in project apiman by apiman.
the class EntityValidator method getStatus.
/**
* @see io.apiman.manager.api.core.IApiValidator#getStatus(io.apiman.manager.api.beans.apis.ApiVersionBean, java.util.List)
*/
@Override
public ApiVersionStatusBean getStatus(ApiVersionBean api, List<PolicySummaryBean> policies) {
ApiVersionStatusBean status = new ApiVersionStatusBean();
status.setStatus(api.getStatus());
// Why are we not yet "Ready"?
if (api.getStatus() == ApiStatus.Created || api.getStatus() == ApiStatus.Ready) {
// 1. Implementation endpoint + endpoint type
// ///////////////////////////////////////////
StatusItemBean item = new StatusItemBean();
// $NON-NLS-1$
item.setId("endpoint");
// $NON-NLS-1$
item.setName(Messages.i18n.format("EntityValidator.endpoint.name"));
item.setDone(true);
if (api.getEndpoint() == null || api.getEndpoint().trim().isEmpty() || api.getEndpointType() == null) {
item.setDone(false);
// $NON-NLS-1$
item.setRemediation(Messages.i18n.format("EntityValidator.endpoint.description"));
}
status.getItems().add(item);
// 2. Gateway selected
item = new StatusItemBean();
// $NON-NLS-1$
item.setId("gateways");
// $NON-NLS-1$
item.setName(Messages.i18n.format("EntityValidator.gateways.name"));
item.setDone(true);
if (api.getGateways() == null || api.getGateways().isEmpty()) {
item.setDone(false);
// $NON-NLS-1$
item.setRemediation(Messages.i18n.format("EntityValidator.gateways.description"));
}
status.getItems().add(item);
// 3. Public or at least one plan
// ///////////////////////////////
item = new StatusItemBean();
// $NON-NLS-1$
item.setId("plans");
// $NON-NLS-1$
item.setName(Messages.i18n.format("EntityValidator.plans.name"));
item.setDone(true);
if (!api.isPublicAPI() && (api.getPlans() == null || api.getPlans().isEmpty())) {
item.setDone(false);
// $NON-NLS-1$
item.setRemediation(Messages.i18n.format("EntityValidator.plans.description"));
}
status.getItems().add(item);
// 4. At least one Policy (optional)
// //////////////////////////////////
item = new StatusItemBean();
// $NON-NLS-1$
item.setId("policies");
// $NON-NLS-1$
item.setName(Messages.i18n.format("EntityValidator.policies.name"));
item.setDone(true);
item.setOptional(true);
if (policies.isEmpty()) {
item.setDone(false);
// $NON-NLS-1$
item.setRemediation(Messages.i18n.format("EntityValidator.policies.description"));
}
status.getItems().add(item);
}
return status;
}
Aggregations