use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class SiteComponent method getViewNamePrefix.
/**
* @param serverName
* @return view name prefix
*/
public String getViewNamePrefix(String serverName) {
SysDomain sysDomain = getDomain(serverName);
SysSite site = getSite(serverName);
return getViewNamePrefix(site, sysDomain);
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class ScheduledJob method executeInternal.
@Override
public void executeInternal(JobExecutionContext context) throws JobExecutionException {
Integer taskId = (Integer) context.getJobDetail().getJobDataMap().get(ScheduledTask.ID);
SysTask task = BeanComponent.getSysTaskService().getEntity(taskId);
if (null != task) {
if (ScheduledTask.TASK_STATUS_READY == task.getStatus() && BeanComponent.getSysTaskService().updateStatusToRunning(task.getId())) {
LogTask entity = new LogTask(task.getSiteId(), task.getId(), new Date(), false);
BeanComponent.getLogTaskService().save(entity);
boolean success = false;
String result;
try {
success = true;
Map<String, Object> map = new HashMap<>();
map.put("task", task);
SysSite site = BeanComponent.getSiteService().getEntity(task.getSiteId());
AbstractFreemarkerView.exposeSite(map, site);
String fulllPath = SiteComponent.getFullFileName(site, task.getFilePath());
result = FreeMarkerUtils.generateStringByFile(fulllPath, BeanComponent.getTemplateComponent().getTaskConfiguration(), map);
} catch (IOException | TemplateException e) {
result = e.getMessage();
}
entity.setEndtime(new Date());
entity.setSuccess(success);
entity.setResult(result);
BeanComponent.getLogTaskService().update(entity.getId(), entity, ignoreProperties);
BeanComponent.getSysTaskService().updateStatus(task.getId(), ScheduledTask.TASK_STATUS_READY);
}
} else {
BeanComponent.getScheduledTask().delete(taskId);
}
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class SysUserTokenAdminController method delete.
/**
* @param authToken
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("delete")
public String delete(String authToken, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
SysUserToken entity = service.getEntity(authToken);
Long userId = getAdminFromSession(session).getId();
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", userId, entity.getUserId(), model)) {
return TEMPLATE_ERROR;
}
service.delete(authToken);
logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB_MANAGER, "delete.usertoken", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class TaskTemplateAdminController method runTask.
/**
* @param filePath
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("runTask")
public String runTask(String filePath, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
model.addAttribute("filePath", filePath);
try {
String fulllPath = SiteComponent.getFullFileName(site, filePath);
Map<String, Object> map = new HashMap<>();
AbstractFreemarkerView.exposeAttribute(map, request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath());
model.addAttribute("result", FreeMarkerUtils.generateStringByFile(fulllPath, templateComponent.getTaskConfiguration(), map));
} catch (IOException | TemplateException e) {
model.addAttribute(ERROR, e.getMessage());
log.error(e.getMessage(), e);
}
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "run.task.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(model)));
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class UeditorAdminController method uploadScraw.
/**
* @param file
* @param request
* @param session
* @return view name
*/
@RequestMapping(params = "action=" + ACTION_UPLOAD_SCRAW)
@ResponseBody
public Map<String, Object> uploadScraw(String file, HttpServletRequest request, HttpSession session) {
SysSite site = getSite(request);
if (CommonUtils.notEmpty(file)) {
byte[] data = VerificationUtils.base64Decode(file);
String fileName = fileComponent.getUploadFileName(SCRAW_TYPE);
File dest = new File(siteComponent.getWebFilePath(site, fileName));
try {
FileUtils.writeByteArrayToFile(dest, data);
logUploadService.save(new LogUpload(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, true, dest.length(), RequestUtils.getIpAddress(request), CommonUtils.getDate(), fileName));
Map<String, Object> map = getResultMap(true);
map.put("size", data.length);
map.put("title", dest.getName());
map.put("url", fileName);
map.put("type", SCRAW_TYPE);
map.put("original", "scraw" + SCRAW_TYPE);
return map;
} catch (IllegalStateException | IOException e) {
log.error(e.getMessage(), e);
return getResultMap(false);
}
}
return getResultMap(false);
}
Aggregations