Search in sources :

Example 1 with CmsPlace

use of com.publiccms.entities.cms.CmsPlace in project PublicCMS-preview by sanluan.

the class CmsPlaceAdminController method save.

/**
 * @param entity
 * @param placeParamters
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping(value = "save", method = RequestMethod.POST)
public String save(CmsPlace entity, @ModelAttribute CmsPlaceParamters placeParamters, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (null != entity && CommonUtils.notEmpty(entity.getPath())) {
        entity.setPath(entity.getPath().replace("//", SEPARATOR));
        SysSite site = getSite(request);
        Long userId = getAdminFromSession(session).getId();
        if (CommonUtils.empty(entity.getItemType()) || CommonUtils.empty(entity.getItemId())) {
            entity.setItemType(CmsPlaceService.ITEM_TYPE_CUSTOM);
            entity.setItemId(null);
        }
        if (null != entity.getId()) {
            CmsPlace oldEntity = service.getEntity(entity.getId());
            if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
                return TEMPLATE_ERROR;
            }
            entity = service.update(entity.getId(), entity, ignoreProperties);
            if (null != entity) {
                logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB_MANAGER, "update.place", RequestUtils.getIpAddress(request), CommonUtils.getDate(), entity.getPath()));
            }
        } else {
            entity.setUserId(userId);
            entity.setSiteId(site.getId());
            entity.setStatus(CmsPlaceService.STATUS_NORMAL);
            service.save(entity);
            logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB_MANAGER, "save.place", RequestUtils.getIpAddress(request), CommonUtils.getDate(), entity.getPath()));
        }
        String filePath = siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + 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 TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsPlace(com.publiccms.entities.cms.CmsPlace) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CmsPlace

use of com.publiccms.entities.cms.CmsPlace in project PublicCMS-preview by sanluan.

the class CmsPlaceService method check.

/**
 * @param id
 */
public void check(Serializable id) {
    CmsPlace entity = getEntity(id);
    if (null != entity) {
        entity.setStatus(STATUS_NORMAL);
        Date now = CommonUtils.getDate();
        if (now.after(entity.getPublishDate())) {
            entity.setPublishDate(now);
        }
    }
}
Also used : CmsPlace(com.publiccms.entities.cms.CmsPlace) Date(java.util.Date)

Example 3 with CmsPlace

use of com.publiccms.entities.cms.CmsPlace in project PublicCMS-preview by sanluan.

the class PlaceController method check.

/**
 * @param id
 * @param returnUrl
 * @param request
 * @param session
 * @param response
 * @param model
 * @return view name
 */
@RequestMapping("check")
public String check(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.check(id);
        logOperateService.save(new LogOperate(site.getId(), user.getId(), LogLoginService.CHANNEL_WEB, "check.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 4 with CmsPlace

use of com.publiccms.entities.cms.CmsPlace in project PublicCMS-preview by sanluan.

the class CmsPlaceDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Long id = handler.getLong("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsPlace 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<CmsPlace> entityList = service.getEntitys(ids);
            Map<String, CmsPlace> map = new LinkedHashMap<>();
            for (CmsPlace entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsPlace(com.publiccms.entities.cms.CmsPlace) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with CmsPlace

use of com.publiccms.entities.cms.CmsPlace 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)

Aggregations

CmsPlace (com.publiccms.entities.cms.CmsPlace)6 SysSite (com.publiccms.entities.sys.SysSite)5 LogOperate (com.publiccms.entities.log.LogOperate)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 SysUser (com.publiccms.entities.sys.SysUser)3 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)3 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1