use of org.b3log.latke.servlet.annotation.Before in project symphony by b3log.
the class AdminProcessor method addDomain.
/**
* Adds a domain.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-domain", method = HTTPRequestMethod.POST)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void addDomain(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final String domainTitle = request.getParameter(Domain.DOMAIN_TITLE);
if (StringUtils.isBlank(domainTitle)) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/error.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.put(Keys.MSG, langPropsService.get("invalidDomainTitleLabel"));
dataModelService.fillHeaderAndFooter(request, response, dataModel);
return;
}
if (null != domainQueryService.getByTitle(domainTitle)) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/error.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.put(Keys.MSG, langPropsService.get("duplicatedDomainLabel"));
dataModelService.fillHeaderAndFooter(request, response, dataModel);
return;
}
String domainId;
try {
final JSONObject domain = new JSONObject();
domain.put(Domain.DOMAIN_TITLE, domainTitle);
domain.put(Domain.DOMAIN_URI, domainTitle);
domain.put(Domain.DOMAIN_DESCRIPTION, domainTitle);
domain.put(Domain.DOMAIN_STATUS, Domain.DOMAIN_STATUS_C_VALID);
domainId = domainMgmtService.addDomain(domain);
} catch (final ServiceException e) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/error.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.put(Keys.MSG, e.getMessage());
dataModelService.fillHeaderAndFooter(request, response, dataModel);
return;
}
response.sendRedirect(Latkes.getServePath() + "/admin/domain/" + domainId);
}
use of org.b3log.latke.servlet.annotation.Before in project symphony by b3log.
the class AdminProcessor method showAddArticle.
/**
* Shows add article.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-article", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/add-article.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.annotation.Before in project symphony by b3log.
the class AdminProcessor method updateReservedWord.
/**
* Updates a reserved word.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @param id the specified reserved wordid
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/reserved-word/{id}", method = HTTPRequestMethod.POST)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void updateReservedWord(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response, final String id) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/reserved-word.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final JSONObject word = optionQueryService.getOption(id);
dataModel.put(Common.WORD, word);
final Enumeration<String> parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
final String name = parameterNames.nextElement();
final String value = request.getParameter(name);
word.put(name, value);
}
optionMgmtService.updateOption(id, word);
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.annotation.Before in project symphony by b3log.
the class AdminProcessor method showTag.
/**
* Shows a tag.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @param tagId the specified tag id
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/tag/{tagId}", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showTag(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response, final String tagId) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/tag.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final JSONObject tag = tagQueryService.getTag(tagId);
dataModel.put(Tag.TAG, tag);
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.annotation.Before in project symphony by b3log.
the class AdminProcessor method showIndex.
/**
* Shows admin index.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showIndex(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/index.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModelService.fillHeaderAndFooter(request, response, dataModel);
dataModel.put(Common.ONLINE_VISITOR_CNT, optionQueryService.getOnlineVisitorCount());
dataModel.put(Common.ONLINE_MEMBER_CNT, optionQueryService.getOnlineMemberCount());
final JSONObject statistic = optionQueryService.getStatistic();
dataModel.put(Option.CATEGORY_C_STATISTIC, statistic);
}
Aggregations