Search in sources :

Example 61 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class LogOperateDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Long id = handler.getLong("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        LogOperate entity = service.getEntity(id);
        if (null != entity && site.getId() == entity.getSiteId()) {
            handler.put("object", entity).render();
        }
    } else {
        Long[] ids = handler.getLongArray("ids");
        if (CommonUtils.notEmpty(ids)) {
            List<LogOperate> entityList = service.getEntitys(ids);
            Map<String, LogOperate> map = new LinkedHashMap<>();
            for (LogOperate entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 62 with LogOperate

use of com.publiccms.entities.log.LogOperate 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 63 with LogOperate

use of com.publiccms.entities.log.LogOperate 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 64 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class PlaceController method delete.

/**
 * @param id
 * @param returnUrl
 * @param request
 * @param session
 * @param response
 * @param model
 * @return view name
 */
@RequestMapping("delete")
public String delete(Long id, String returnUrl, HttpServletRequest request, HttpSession session, HttpServletResponse response, ModelMap model) {
    SysSite site = getSite(request);
    if (CommonUtils.empty(returnUrl)) {
        returnUrl = site.getDynamicPath();
    }
    CmsPlace entity = service.getEntity(id);
    SysUser user = getUserFromSession(session);
    String filePath = siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + entity.getPath());
    CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(filePath);
    if (ControllerUtils.verifyCustom("manage", null == entity || null == user || CommonUtils.empty(metadata.getAdminIds()) || !ArrayUtils.contains(metadata.getAdminIds(), user.getId()), model) || ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
        return REDIRECT + returnUrl;
    } else {
        service.delete(id);
        logOperateService.save(new LogOperate(site.getId(), user.getId(), LogLoginService.CHANNEL_WEB, "delete.place", RequestUtils.getIpAddress(request), CommonUtils.getDate(), id.toString()));
        return REDIRECT + returnUrl;
    }
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsPlace(com.publiccms.entities.cms.CmsPlace) SysUser(com.publiccms.entities.sys.SysUser) CmsPlaceMetadata(com.publiccms.views.pojo.entities.CmsPlaceMetadata) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 65 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class PlaceController method save.

/**
 * @param entity
 * @param returnUrl
 * @param placeParamters
 * @param request
 * @param session
 * @param response
 * @param model
 * @return view name
 */
@RequestMapping(value = "save")
public String save(CmsPlace entity, String returnUrl, @ModelAttribute CmsPlaceParamters placeParamters, HttpServletRequest request, HttpSession session, HttpServletResponse response, ModelMap model) {
    SysSite site = getSite(request);
    if (CommonUtils.empty(returnUrl)) {
        returnUrl = site.getDynamicPath();
    }
    if (null != entity && CommonUtils.notEmpty(entity.getPath())) {
        entity.setPath(entity.getPath().replace("//", SEPARATOR));
        String filePath = siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + entity.getPath());
        CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(filePath);
        SysUser user = getUserFromSession(session);
        if (ControllerUtils.verifyCustom("contribute", null == metadata || !metadata.isAllowContribute() || 0 >= metadata.getSize() || (null == user && !metadata.isAllowAnonymous()), model)) {
            return REDIRECT + returnUrl;
        }
        if (null != entity.getId()) {
            CmsPlace oldEntity = service.getEntity(entity.getId());
            if (null == oldEntity || CommonUtils.empty(oldEntity.getUserId()) || null == user || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model) || ControllerUtils.verifyNotEquals("siteId", user.getId(), oldEntity.getUserId(), model)) {
                return REDIRECT + returnUrl;
            }
            entity = service.update(entity.getId(), entity, ignoreProperties);
            logOperateService.save(new LogOperate(site.getId(), user.getId(), LogLoginService.CHANNEL_WEB, "update.place", RequestUtils.getIpAddress(request), CommonUtils.getDate(), entity.getPath()));
        } else {
            entity.setSiteId(site.getId());
            Long userId = null;
            if (null != user) {
                userId = user.getId();
                entity.setUserId(user.getId());
            }
            service.save(entity);
            logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB, "save.place", RequestUtils.getIpAddress(request), CommonUtils.getDate(), entity.getPath()));
        }
        Map<String, String> map = ExtendUtils.getExtentDataMap(placeParamters.getExtendDataList(), metadataComponent.getPlaceMetadata(filePath).getExtendList());
        String extentString = ExtendUtils.getExtendString(map);
        attributeService.updateAttribute(entity.getId(), extentString);
    }
    return REDIRECT + returnUrl;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsPlace(com.publiccms.entities.cms.CmsPlace) SysUser(com.publiccms.entities.sys.SysUser) CmsPlaceMetadata(com.publiccms.views.pojo.entities.CmsPlaceMetadata) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LogOperate (com.publiccms.entities.log.LogOperate)117 SysSite (com.publiccms.entities.sys.SysSite)117 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)115 SysUser (com.publiccms.entities.sys.SysUser)15 IOException (java.io.IOException)13 CmsContent (com.publiccms.entities.cms.CmsContent)9 File (java.io.File)9 MultipartFile (org.springframework.web.multipart.MultipartFile)8 CmsCategory (com.publiccms.entities.cms.CmsCategory)7 TemplateException (freemarker.template.TemplateException)7 SysDept (com.publiccms.entities.sys.SysDept)6 SysTask (com.publiccms.entities.sys.SysTask)6 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)5 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)5 CmsPlace (com.publiccms.entities.cms.CmsPlace)4 CmsWord (com.publiccms.entities.cms.CmsWord)4 SysDomain (com.publiccms.entities.sys.SysDomain)4 SysRoleUser (com.publiccms.entities.sys.SysRoleUser)4 CmsModel (com.publiccms.views.pojo.entities.CmsModel)4 CmsCategoryType (com.publiccms.entities.cms.CmsCategoryType)3