public DomainProfile findByApiKey(String apiKey) { DomainProfile profile = domainProfileMap.get(apiKey); if (profile == null) { throw ApiNotFoundException.notFound("Domain not found with api key: " + apiKey); } return profile; }
private JobDefinitionEntity loadJob(Application app, String jobDefinitionId) { JobDefinitionEntity jobDefinitionEntity = jobDefinitionStore.getByDocumentId(jobDefinitionId); if (jobDefinitionEntity == null) { String msg = String.format("The job definition \"%s\" does not exist.", jobDefinitionId); throw ApiNotFoundException.notFound(msg); } return jobDefinitionEntity; }
public DomainProfile findByDomainName(String domainName) { for (DomainProfile profile : domainProfileMap.values()) { if (profile.getDomainName().equalsIgnoreCase(domainName)) { return profile; } } throw ApiNotFoundException.notFound("The specified domain name was not found."); }
private JobDefinitionEntity loadJob(Application app, String jobDefinitionId) { JobDefinitionEntity jobDefinitionEntity = jobDefinitionStore.getByDocumentId(jobDefinitionId); if (jobDefinitionEntity == null) { String msg = String.format("The job definition \"%s\" does not exist.", jobDefinitionId); throw ApiNotFoundException.notFound(msg); } return jobDefinitionEntity; }
private JobDefinitionEntity loadJob(Application app, String jobDefinitionId) { JobDefinitionStore store = JobsApplication.get(app, JobDefinitionStore.class); JobDefinitionEntity jobDefinitionEntity = store.getByDocumentId(jobDefinitionId); if (jobDefinitionEntity == null) { String msg = String.format("The job definition \"%s\" does not exist.", jobDefinitionId); throw ApiNotFoundException.notFound(msg); } return jobDefinitionEntity; }
protected final void throwIfNotFound(GetEntityResponse response, String message) { if (response.isEmpty() || response.isNotFound()) { throw ApiNotFoundException.notFound(message); } }
protected final void throwIfNotFound(GetAttachmentResponse response, String message) { if (response.isEmpty() || response.isNotFound()) { throw ApiNotFoundException.notFound(message); } } }
protected final void throwError(CouchResponse response, String message) { if (response.isNotFound()) { throw ApiNotFoundException.notFound(message); } else if (response.isConflict()) { throw ApiConflictException.conflict(message); } else { message = format("%s: %s", message, response.getErrorReason()).trim(); throw ApiException.internalServerError(message); } }
public DomainProfileEntity findByDomainName(String domainName) { CouchViewQuery viewQuery = CouchViewQuery.builder("DomainProfile", "ByDomainName") .key(domainName) .build(); GetEntityResponse<DomainProfileEntity> response = couchDatabase.get() .entity(DomainProfileEntity.class, viewQuery) .onError(r -> throwError(r, format("Failure retrieving active domain profile by name [%s] - %s", r.getHttpStatus(), r.getErrorReason()))) .execute(); if (response.isEmpty()) { throw ApiNotFoundException.notFound("The specified domain does not exist."); } else if (response.getSize() > 1) { throw ApiNotFoundException.notFound("Multiple domain profiles found with name " + domainName); } return response.getFirstEntity(); }