Search in sources :

Example 36 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class PublishPageDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    String path = handler.getString("path", SEPARATOR);
    SysSite site = getSite(handler);
    String fullPath = siteComponent.getWebTemplateFilePath(site, path);
    File file = new File(fullPath);
    if (file.isFile()) {
        Map<String, Boolean> map = new LinkedHashMap<>();
        CmsPageMetadata metadata = metadataComponent.getTemplateMetadata(fullPath);
        if (CommonUtils.notEmpty(metadata.getPublishPath())) {
            try {
                templateComponent.createStaticFile(site, SiteComponent.getFullFileName(site, path), metadata.getPublishPath(), null, metadata, null);
                map.put(path, true);
            } catch (IOException | TemplateException e) {
                map.put(path, false);
            }
            handler.put("map", map).render();
        }
    } else if (file.isDirectory()) {
        handler.put("map", deal(site, path)).render();
    }
}
Also used : CmsPageMetadata(com.publiccms.views.pojo.entities.CmsPageMetadata) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) File(java.io.File) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 37 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysDeptDirective method execute.

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

Example 38 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysSiteDirective method execute.

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

Example 39 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysUserDirective method execute.

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

Example 40 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysAppTokenAdminController 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);
    SysAppToken entity = service.getEntity(authToken);
    Long userId = getAdminFromSession(session).getId();
    if (null != entity) {
        SysApp app = appService.getEntity(entity.getAppId());
        if (null != app) {
            if (ControllerUtils.verifyNotEquals("siteId", site.getId(), app.getSiteId(), model)) {
                return TEMPLATE_ERROR;
            }
            service.delete(authToken);
            logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB_MANAGER, "delete.apptoken", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        }
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysApp(com.publiccms.entities.sys.SysApp) SysAppToken(com.publiccms.entities.sys.SysAppToken) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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