private void registerAll() { Collection<ApplicationEntity> applicationEntities = applicationEntityService.findAll(); applicationEntities.forEach(this::register); }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
protected ApplicationEntity.Status getApplicationStatus() { ApplicationEntity applicationEntity = applicationEntityService.getByUUIDOrAppId(null, config.getString(APP_ID_PATH)); return applicationEntity.getStatus(); }
@GET @Produces(MediaType.APPLICATION_JSON) public RESTResponse<Collection<ApplicationEntity>> getApplicationEntities(@QueryParam("siteId") String siteId) { return RESTResponse.async(() -> { if (siteId == null) { return entityService.findAll(); } else { return entityService.findBySiteId(siteId); } }).get(); }
@DELETE @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public RESTResponse<SiteEntity> deleteSiteByUUID(UUIDRequest uuidRequest) { return RESTResponse.async(() -> { int appCount = entityService.findBySiteId(siteEntityService.getByUUID(uuidRequest.getUuid()).getSiteId()).size(); if (appCount > 0) { throw new SiteDeleteException("This site has enabled applications, remove them first"); } return siteEntityService.deleteByUUID(uuidRequest.getUuid()); }).get(); }
@DELETE @Path("/{siteId}") @Produces(MediaType.APPLICATION_JSON) public RESTResponse<SiteEntity> deleteSiteBySiteId(@PathParam("siteId") String siteId) { return RESTResponse.async(() -> { int appCount = entityService.findBySiteId(siteId).size(); if (appCount > 0) { throw new SiteDeleteException("This site has enabled applications, remove them first"); } return siteEntityService.deleteBySiteId(siteId); }).get(); }
default DashboardEntity createOrUpdate(DashboardEntity dashboardEntity, User user) throws EntityNotFoundException { Preconditions.checkNotNull(dashboardEntity, "DashboardEntity should not be null"); if (dashboardEntity.getUuid() == null) { Preconditions.checkArgument(dashboardEntity.getAuthor() == null, "author is immutable"); dashboardEntity.setAuthor(user.getName()); return create(dashboardEntity); } else { return update(dashboardEntity, user); } } }
default PolicyEntity createOrUpdatePolicyProto(PolicyEntity policyProto) { Preconditions.checkNotNull(policyProto, "PolicyProto should not be null"); Preconditions.checkNotNull(policyProto.getDefinition(), "PolicyProto definition should not be null"); if (policyProto.getName() == null) { policyProto.setName(String.format("[%s]%s", policyProto.getDefinition().getAlertCategory(), policyProto.getDefinition().getName())); } if (policyProto.getUuid() == null) { return create(policyProto); } else { return update(policyProto); } }
protected void awaitApplicationStatus(ApplicationEntity applicationEntity, ApplicationEntity.Status status) throws InterruptedException { int attempt = 0; while (attempt < 30) { attempt ++; if (applicationEntity.getStatus() == status) { break; } else { statusUpdateService.updateApplicationEntityStatus(applicationEntity); Thread.sleep(1000); } } if (attempt >= 30) { Assert.fail("Failed to wait for application to STOPPED after 10 attempts"); } } }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
protected void awaitApplicationStop(ApplicationEntity applicationEntity) throws InterruptedException { int attempt = 0; while (attempt < 30) { attempt ++; if (applicationEntity.getStatus() == ApplicationEntity.Status.STOPPED || applicationEntity.getStatus() == ApplicationEntity.Status.INITIALIZED) { break; } else { statusUpdateService.updateApplicationEntityStatus(applicationEntity); Thread.sleep(1000); } } if (attempt >= 30) { Assert.fail("Failed to wait for application to STOPPED after 10 attempts"); } }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); } }
private Map<String, Object> getAppConfig(String site, String appType) { ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); } }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
private Map<String, Object> getAppConfig(String site, String appType) { ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
private Map<String, Object> getAppConfig(String site, String appType){ ApplicationEntity entity = entityService.getBySiteIdAndAppType(site, appType); return entity.getConfiguration(); }
private void validateDependingApplicationInstalled(ApplicationEntity applicationEntity) { if (applicationEntity.getDescriptor().getDependencies() != null) { for (ApplicationDependency dependency : applicationEntity.getDescriptor().getDependencies()) { if (dependency.isRequired() && applicationEntityService.getBySiteIdAndAppType(applicationEntity.getSite().getSiteId(), dependency.getType()) == null) { throw new IllegalStateException("Required dependency " + dependency.toString() + " of " + applicationEntity.getDescriptor().getType() + " was not installed"); } } } }