if (PermalinkQueryService.invalidPagePermalinkFormat(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(langPropsService.get("invalidPermalinkFormatLabel"));
}
if (permalinkQueryService.exist(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel"));
}
}
page.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-"));
// Editor type
final JSONObject preference = preferenceQueryService.getPreference();
page.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
final String ret = pageRepository.add(page);
transaction.commit();
return ret;
} catch (final JSONException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(e);
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(e);
}
}