use of com.willshex.gson.web.service.server.InputValidationException in project blogwt by billy1380.
the class ArchiveEntryValidator method lookup.
public static ArchiveEntry lookup(ArchiveEntry archiveEntry, String name) throws InputValidationException {
if (archiveEntry == null)
throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, TYPE + ": " + name);
boolean isIdLookup = false, isYearMonthLookup = false;
if (archiveEntry.id != null) {
isIdLookup = true;
} else if (archiveEntry.year != null && archiveEntry.month != null) {
isYearMonthLookup = true;
}
if (!(isIdLookup || isYearMonthLookup))
throwServiceError(InputValidationException.class, ApiError.DataTypeNoLookup, TYPE + ": " + name);
ArchiveEntry lookupArchiveEntry = null;
if (isIdLookup) {
lookupArchiveEntry = ArchiveEntryServiceProvider.provide().getArchiveEntry(archiveEntry.id);
} else if (isYearMonthLookup) {
lookupArchiveEntry = ArchiveEntryServiceProvider.provide().getMonthArchiveEntry(archiveEntry.month, archiveEntry.year);
}
if (lookupArchiveEntry == null)
throwServiceError(InputValidationException.class, ApiError.DataTypeNotFound, TYPE + ": " + name);
return lookupArchiveEntry;
}
use of com.willshex.gson.web.service.server.InputValidationException in project blogwt by billy1380.
the class MetaNotificationValidator method lookup.
public static MetaNotification lookup(MetaNotification metaNotification, String name) throws InputValidationException {
notNull(metaNotification, CLASS, name);
boolean isIdLookup = false, isCodeLookup = false;
if (metaNotification.id != null) {
isIdLookup = true;
} else if (metaNotification.code != null) {
isCodeLookup = true;
}
if (!(isIdLookup || isCodeLookup))
throwServiceError(InputValidationException.class, ApiError.DataTypeNoLookup, TYPE + ": " + name);
MetaNotification lookupMetaNotification = null;
if (isIdLookup) {
lookupMetaNotification = MetaNotificationServiceProvider.provide().getMetaNotification(metaNotification.id);
} else if (isCodeLookup) {
lookupMetaNotification = MetaNotificationServiceProvider.provide().getCodeMetaNotification(metaNotification.code);
}
if (lookupMetaNotification == null)
throwServiceError(InputValidationException.class, ApiError.DataTypeNotFound, TYPE + ": " + name);
return lookupMetaNotification;
}
use of com.willshex.gson.web.service.server.InputValidationException in project blogwt by billy1380.
the class NotificationSettingValidator method lookup.
public static NotificationSetting lookup(NotificationSetting notificationSetting, String name) throws InputValidationException {
notNull(notificationSetting, CLASS, name);
boolean isIdLookup = false, isUserMetaNotificationLookup = false;
if (notificationSetting.id != null) {
isIdLookup = true;
} else if (notificationSetting.user != null && notificationSetting.meta != null) {
isUserMetaNotificationLookup = true;
}
if (!(isIdLookup || isUserMetaNotificationLookup))
throwServiceError(InputValidationException.class, ApiError.DataTypeNoLookup, TYPE + ": " + name);
NotificationSetting lookupNotificationSetting = null;
if (isIdLookup) {
notificationSetting = NotificationSettingServiceProvider.provide().getNotificationSetting(notificationSetting.id);
} else if (isUserMetaNotificationLookup) {
notificationSetting.user = UserValidator.lookup(notificationSetting.user, name + ".user");
notificationSetting.meta = MetaNotificationValidator.lookup(notificationSetting.meta, name + ".meta");
notificationSetting = NotificationSettingServiceProvider.provide().getMetaUserNotificationSetting(notificationSetting.meta, notificationSetting.user);
}
if (lookupNotificationSetting == null)
throwServiceError(InputValidationException.class, ApiError.DataTypeNotFound, TYPE + ": " + name);
return notificationSetting;
}
use of com.willshex.gson.web.service.server.InputValidationException in project blogwt by billy1380.
the class PageValidator method lookup.
public static Page lookup(Page page, String name) throws InputValidationException {
if (page == null)
throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, TYPE + ": " + name);
boolean isIdLookup = false, isSlugLookup = false;
if (page.id != null) {
isIdLookup = true;
} else if (page.slug != null) {
isSlugLookup = true;
}
if (!(isIdLookup || isSlugLookup))
throwServiceError(InputValidationException.class, ApiError.DataTypeNoLookup, TYPE + ": " + name);
Page lookupPage;
if (isIdLookup) {
lookupPage = PageServiceProvider.provide().getPage(page.id);
} else {
lookupPage = PageServiceProvider.provide().getSlugPage(page.slug, Boolean.FALSE);
}
if (lookupPage == null)
throwServiceError(InputValidationException.class, ApiError.DataTypeNotFound, TYPE + ": " + name);
return lookupPage;
}
use of com.willshex.gson.web.service.server.InputValidationException in project blogwt by billy1380.
the class ResourceValidator method lookup.
public static Resource lookup(Resource resource, String name) throws InputValidationException {
if (resource == null)
throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, TYPE + ": " + name);
boolean isIdLookup = false;
if (resource.id != null) {
isIdLookup = true;
}
if (!isIdLookup)
throwServiceError(InputValidationException.class, ApiError.DataTypeNoLookup, TYPE + ": " + name);
Resource lookupResource = null;
if (isIdLookup) {
lookupResource = ResourceServiceProvider.provide().getResource(resource.id);
}
if (lookupResource == null)
throwServiceError(InputValidationException.class, ApiError.DataTypeNotFound, TYPE + ": " + name);
return lookupResource;
}
Aggregations