String msg = request.getParameter(Params.MESSAGE.getParamName());
if (msg == null || msg.isEmpty()) {
response.addFieldError(Params.MESSAGE.getParamName(),
FieldErrorTypes.FIELD_IS_EMPTY);
throw new RequestException(ReqErrorTypes.MISSING_ARGUMENT);
}
// String field is limited to 500 chars...
if (msg.length() > 499)
throw new RequestException(ReqErrorTypes.CONTENT_EXCEED_MAX_LENGTH);
final int maxItemsForFreeAcount = 25;
int priority = 0;
try {
priority = Integer.parseInt(request.getParameter(Params.PRIORITY
.getParamName()));
} catch (NumberFormatException e) {
log.warning(e.getMessage());
response.addFieldError(Params.PRIORITY.getParamName(),
FieldErrorTypes.VALUE_NOT_VALID);
throw new RequestException(ReqErrorTypes.MISSING_ARGUMENT);
}
HasMoreItems hasMore = new HasMoreItems();
List<PersonalNotesData> items = (List<PersonalNotesData>) helper
.getOwnerItems(request, PersonalNotesData.class,
request.getFilterBy(),
request.getFilterByDeclaration(), null, null, 0, 1000,
hasMore);
if (items.size() >= maxItemsForFreeAcount)
throw new RequestException(
ReqErrorTypes.ITEMS_NUM_EXCEED_USER_QUOTA);
PersonalNotesData item = new PersonalNotesData(
request.getTrustedParameterValue("personalNotesMessage", true),
priority, request);