Search in sources :

Example 96 with SysSite

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);
}
Also used : SysDomain(com.publiccms.entities.sys.SysDomain) SysSite(com.publiccms.entities.sys.SysSite)

Example 97 with SysSite

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);
    }
}
Also used : HashMap(java.util.HashMap) TemplateException(freemarker.template.TemplateException) SysTask(com.publiccms.entities.sys.SysTask) IOException(java.io.IOException) Date(java.util.Date) SysSite(com.publiccms.entities.sys.SysSite) LogTask(com.publiccms.entities.log.LogTask)

Example 98 with SysSite

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;
}
Also used : SysUserToken(com.publiccms.entities.sys.SysUserToken) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 99 with SysSite

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;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) HashMap(java.util.HashMap) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 100 with SysSite

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);
}
Also used : LogUpload(com.publiccms.entities.log.LogUpload) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

SysSite (com.publiccms.entities.sys.SysSite)175 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)135 LogOperate (com.publiccms.entities.log.LogOperate)117 IOException (java.io.IOException)33 SysUser (com.publiccms.entities.sys.SysUser)21 LinkedHashMap (java.util.LinkedHashMap)19 TemplateException (freemarker.template.TemplateException)15 File (java.io.File)14 CmsContent (com.publiccms.entities.cms.CmsContent)12 CmsCategory (com.publiccms.entities.cms.CmsCategory)11 MultipartFile (org.springframework.web.multipart.MultipartFile)10 SysTask (com.publiccms.entities.sys.SysTask)9 HashMap (java.util.HashMap)8 LogUpload (com.publiccms.entities.log.LogUpload)7 SysDept (com.publiccms.entities.sys.SysDept)7 SysUserToken (com.publiccms.entities.sys.SysUserToken)7 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)7 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)6 CmsPlace (com.publiccms.entities.cms.CmsPlace)5 SysDomain (com.publiccms.entities.sys.SysDomain)5