public AccountRequest(AccountQuery query, AccountAction operation) { this.query = ExceptionUtils.assertNotNull(query, "query"); this.operation = ExceptionUtils.assertNotNull(operation, "operation"); }
public ApiException toBadRequestException() { String msg = StringUtils.toDelineatedString("\n", this); return ApiException.badRequest(msg); } }
private void sendEmail(URL templateUrl, String emailAddress, String subject, String message) { try { String template = IoUtils.toString(templateUrl); String content = template.replace("${message-content}", message); // AwsUtils.sendEmail(subject, content, "Munchie Monster <support@munchiemonster.com>", new MunMonEmailAddress(emailAddress)); } catch (Exception e) { String msg = String.format("Exception sending email to %s", emailAddress); throw ApiException.internalServerError(msg, e); } }
protected void assertResponse(int status) { HttpStatusCode statusCode = HttpStatusCode.findByCode(status); if (statusCode.isOk() == false) { String msg = String.format("Unexpected response: %s %s", status, statusCode.getReason()); throw new ApiException(statusCode, msg); } }
protected Response createResponse(int status, Throwable ex) { logException(ex, status); String message = ExceptionUtils.getMessage(ex); if (renderAsJson) { message = message.replace("\\", "\\\\"); message = message.replace("\"", "\\\""); String json = String.format(JSON_TEMPLATE, status, message); return Response.status(status).entity(json).type(MediaType.APPLICATION_JSON).build(); } else { return Response.status(status).entity(message).type(MediaType.TEXT_PLAIN).build(); } }
private Domain getDomain() { if (_domain != null) { return _domain; } DomainStore domainStore = execContext.getDomainStore(); _domain = domainStore.getByDomainKey(domainKey); execContext.setDomain(_domain); Account account = getAccount(); if (_domain == null) { throw ApiException.notFound(domainKey); } return _domain; }
public void setApiKey(String apiKey) { ExceptionUtils.assertNotNull(apiKey, "apiKey"); this.apiKey = apiKey; }
public Account executeOperation(Account account, LogInAction operation) { if (account == null) { throw ApiException.badRequest(Account.INVALID_USER_NAME_OR_PASSWORD); } if (account.hasTempPassword()) { account.clearTempPassword(); store.update(account); } return account; }
public void setDomainId(long domainId) { ExceptionUtils.assertNotNull(domainId, "domainId"); this.domainId = domainId; }
public ManagePluginApi(Domain domain, PushType pushType) { this.pushType = ExceptionUtils.assertNotNull(pushType, "pushType"); this.domain = ExceptionUtils.assertNotNull(domain, "domain"); }
public LqNotificationsDelegate(PluginContext pluginContext, Domain domain, PushRequest pushRequest, LqNotificationPush push, LqNotificationsConfig config) { super(pluginContext, pushRequest); this.appContext = pluginContext.getAppContext(); this.config = ExceptionUtils.assertNotNull(config, "config"); this.push = ExceptionUtils.assertNotNull(push, "push"); this.domain = ExceptionUtils.assertNotNull(domain, "domain"); }
public GoogleTalkDelegate(PluginContext pluginContext, Domain domain, PushRequest pushRequest, GoogleTalkPush push, GoogleTalkConfig config) { super(pluginContext, pushRequest); this.config = ExceptionUtils.assertNotNull(config, "config"); this.push = ExceptionUtils.assertNotNull(push, "push"); this.domain = ExceptionUtils.assertNotNull(domain, "domain"); this.appContext = pluginContext.getAppContext(); }
public SesEmailDelegate(PluginContext pluginContext, Domain domain, PushRequest pushRequest, SesEmailPush push, SesEmailConfig config) { super(pluginContext, pushRequest); this.push = ExceptionUtils.assertNotNull(push, "push"); this.config = ExceptionUtils.assertNotNull(config, "config"); this.domain = ExceptionUtils.assertNotNull(domain, "domain"); this.appContext = pluginContext.getAppContext(); }
public NotificationDelegateV1(PluginContext pluginContext, Domain domain, PushRequest pushRequest, NotificationPushV1 push) { super(pluginContext, pushRequest); this.push = ExceptionUtils.assertNotNull(push, "push"); this.pluginContext = ExceptionUtils.assertNotNull(pluginContext, "context"); this.domain = ExceptionUtils.assertNotNull(domain, "domain"); this.appContext = pluginContext.getAppContext(); }
public Sequence(SequenceType sequenceType, String firstValue) { this.sequenceId = ExceptionUtils.assertNotNull(sequenceType, "sequenceType").getId(); this.lastValue = ExceptionUtils.assertNotNull(firstValue, "firstValue"); }
public void setResourceUrl(String resourceUrl) { ExceptionUtils.assertNotNull(resourceUrl, "resourceUrl"); if (resourceUrl.endsWith("/")) { resourceUrl = resourceUrl.substring(0, resourceUrl.length()-1); } this.resourceUrl = resourceUrl; } }
public void setApiUrl(String apiUrl) { ExceptionUtils.assertNotNull(apiUrl, "apiUrl"); if (apiUrl.endsWith("/")) { apiUrl = apiUrl.substring(0, apiUrl.length()-1); } this.apiUrl = apiUrl; }
@Override public InputStream getResourceAsStream(final TemplateProcessingParameters templateProcessingParameters, final String resourceName) { ExceptionUtils.assertNotNull(resourceName, "resourceName"); InputStream is = getClass().getResourceAsStream(resourceName); if (is != null) return is; String msg = String.format("The resource \"%s\" was not found.", resourceName); throw new IllegalArgumentException(msg); } }
public CouchPropertyPlaceholderConfigurer(CouchServer couchServer, String databaseName, String entityName) throws MalformedURLException, URISyntaxException { ExceptionUtils.assertNotNull(couchServer, "couchServer"); ExceptionUtils.assertNotNull(entityName, "entityName"); AppConfigStore store = new AppConfigStore(couchServer, databaseName); CouchResourceLoader loader = new CouchResourceLoader(store); resources[0] = loader.getResource(entityName); }
public DefaultCouchStore(CouchServer couchServer, String databaseName, Class<T> entityType) { this.entityType = ExceptionUtils.assertNotNull(entityType, "entityType"); ExceptionUtils.assertNotNull(databaseName, "databaseName"); this.database = couchServer.database(databaseName); if (database == null || database.exists() == false) { String msg = String.format("The database \"%s\" does not exist.", databaseName); throw new IllegalArgumentException(msg); } }