Class ModuleAdminController

java.lang.Object
com.easydesk.web.controller.ModuleAdminController

@Controller public class ModuleAdminController extends Object
Module 을 추가/삭제하는 관리 화면. Module 은 easydesk-spring-security 안에 새로 추가한 엔티티로, Group 과 1:1 로 연결된다 (EasyDeskModuleImpl#save() 가 최초 저장 시 같은 이름의 Group 을 함께 만든다 - easydesk-spring-core 의 무거운 CMS Module 이 아니다).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    RequestItemType 에 포함되지 않은 ModuleItemType column (COMMENTS / MODERATION / MAX_VOTES).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModuleAdminController(SecurityService moduleSecurityService, org.springframework.context.MessageSource messageSource)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add(RequestModule form, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
     
    attributeGroups(Long moduleId, Integer typeId, String activeGroupName, HttpSession session, org.springframework.ui.Model model)
    선택한 ItemType 에 정의된 AttributeGroup 들을 AttributeGroupTypeEnum(10개) 기준으로 tab 화면에 보여준다
    attributesForGroup(Long moduleId, Integer typeId, String groupName, Integer activeTab, HttpSession session, org.springframework.ui.Model model)
    선택한 AttributeGroup(name 으로 식별)에 등록할 수 있는 Attribute 목록을 Attribute/UserAttribute 두 tab 으로 보여준다
    initializeItemType(Long moduleId, Integer typeId, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    선택한 ModuleItemType 의 core ModuleItemType#initialize() 를 실행한다 (내부적으로 itemType.initialize() 도 함께 호출되어 AttributeGroup/ItemTypeAttribute/ItemTypeOption 뿐 아니라 Module 관련 등록까지 함께 처리됨).
    itemTypes(Long id, HttpSession session, org.springframework.ui.Model model)
     
    list(HttpSession session, org.springframework.ui.Model model)
     
    moduleUsers(Long moduleId, HttpSession session, org.springframework.ui.Model model)
    이 Module(=Group) 에 등록된 사용자 목록을 보여준다.
    moveAttributes(Long moduleId, Integer typeId, String groupName, String targetGroupName, List<Integer> selectedAttributeIds, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    AttributeGroup 화면에서 선택한 Attribute 들을 다른 AttributeGroup 으로 이동시키거나 (targetGroupName 이 MOVE_TARGET_REMOVE 이면) 현재 Group 에서 제거한다.
    registerAttributes(Long moduleId, Integer typeId, String groupName, List<Integer> selectedAttributeIds, Integer activeTab, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    화면에서 선택한 Attribute 들을 이 AttributeGroup 에 등록한다 (core 의 AttributeFactory.getFactory(group).add(attribute) 사용).
    registerItemTypes(Long id, List<Integer> selectedTypeIds, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    화면에서 선택한 ItemType 들을 현재 Module 에 등록한다 (EasyDeskModule#add(ItemType) 사용). 1. module.add(itemType) 의 실제 동작(내부적으로 ModuleItemType 등을 어떻게 구성하는지)은 아직 검증이 더 필요하다고 해서, 여기서는 일단 호출까지만 연결해 두었다. 2.
    remove(Long id, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
     
    updateUserRoles(Long moduleId, Long userId, List<Integer> selectedRoleIds, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    화면에서 체크한 Role 목록과 실제 부여된 Role 목록을 비교해서, 새로 체크된 것은 moduleSecurityService.getModelManager().grant(user, group, role), 체크 해제된 것은 .revoke(user, group, role) 로 반영한다.
    userRoles(Long moduleId, Long userId, HttpSession session, org.springframework.ui.Model model)
    특정 사용자가 이 Module(=Group) 에서 가지고 있는 Role 목록(check 표시)을 보여준다.
    view(Long id, HttpSession session, org.springframework.ui.Model model)
    Module 하나를 Item(Artifactizable#getArtifact()) 으로 보여주는 상세 화면.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ModuleAdminController

      public ModuleAdminController(@Qualifier("moduleSecurityService") SecurityService moduleSecurityService, org.springframework.context.MessageSource messageSource)
  • Method Details

    • list

      @Screen("AdminModules") @GetMapping("/admin/modules") public String list(HttpSession session, org.springframework.ui.Model model)
    • moduleUsers

      @Screen("AdminModuleUsers") @GetMapping("/admin/modules/{moduleId}/users") public String moduleUsers(@PathVariable("moduleId") Long moduleId, HttpSession session, org.springframework.ui.Model model)
      이 Module(=Group) 에 등록된 사용자 목록을 보여준다. EasyDeskUserGroupRoleManager.getUserGroupRoles(Group) 로 이 Group 에 속한 EasyDeskUserGroupRole 전체(Role 은 ANY, 즉 특정 Role 로 필터링하지 않음)를 조회해서 사용자별로 묶어 보여준다. 우측의 "Role 변경" 버튼은 userRoles() 화면으로 이동한다.
    • userRoles

      @Screen("AdminModuleUserRoles") @GetMapping("/admin/modules/{moduleId}/users/{userId}/roles") public String userRoles(@PathVariable("moduleId") Long moduleId, @PathVariable("userId") Long userId, HttpSession session, org.springframework.ui.Model model)
      특정 사용자가 이 Module(=Group) 에서 가지고 있는 Role 목록(check 표시)을 보여준다.
    • updateUserRoles

      @Screen("AdminModuleUserRoles") @PostMapping("/admin/modules/{moduleId}/users/{userId}/roles") public String updateUserRoles(@PathVariable("moduleId") Long moduleId, @PathVariable("userId") Long userId, @RequestParam(value="selectedRoleIds",required=false) List<Integer> selectedRoleIds, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      화면에서 체크한 Role 목록과 실제 부여된 Role 목록을 비교해서, 새로 체크된 것은 moduleSecurityService.getModelManager().grant(user, group, role), 체크 해제된 것은 .revoke(user, group, role) 로 반영한다.
    • view

      @Screen("AdminItemView") @GetMapping("/admin/modules/{moduleId}/view") public String view(@PathVariable("moduleId") Long id, HttpSession session, org.springframework.ui.Model model)
      Module 하나를 Item(Artifactizable#getArtifact()) 으로 보여주는 상세 화면. ModuleManager.getInstance(id) 로 Module(=EasyDeskModule) 을 구하고, Artifactizable 구현을 통해 getArtifact() 로 Item 을 얻은 뒤, ItemViewSupport 로 화면용 데이터를 만든다.
    • itemTypes

      @Screen("AdminModuleItemTypes") @GetMapping("/admin/modules/{moduleId}/item-types") public String itemTypes(@PathVariable("moduleId") Long id, HttpSession session, org.springframework.ui.Model model)
    • initializeItemType

      @Screen("AdminModuleItemTypes") @PostMapping("/admin/modules/{moduleId}/item-types/{typeId}/initialize") public String initializeItemType(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      선택한 ModuleItemType 의 core ModuleItemType#initialize() 를 실행한다 (내부적으로 itemType.initialize() 도 함께 호출되어 AttributeGroup/ItemTypeAttribute/ItemTypeOption 뿐 아니라 Module 관련 등록까지 함께 처리됨). 본목록(ItemTypeEnum 기준)에서 아직 이 Module 에 등록되지 않은 ItemType (row.order == null) 은 화면에서 체크박스를 disable 처리해서 애초에 이 요청이 오지 않도록 막아둔다. 다만 "ItemType 실험실" 목록은 아직 등록되지 않은 것도 체크할 수 있게 해 두었으므로, 이 경우 여기서 module.add(itemType) 로 먼저 등록한 뒤 initialize() 를 실행한다.
    • attributeGroups

      @Screen("AdminModuleAttributeGroups") @GetMapping("/admin/modules/{moduleId}/item-types/{typeId}/attribute-groups") public String attributeGroups(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @RequestParam(value="groupName",required=false) String activeGroupName, HttpSession session, org.springframework.ui.Model model)
      선택한 ItemType 에 정의된 AttributeGroup 들을 AttributeGroupTypeEnum(10개) 기준으로 tab 화면에 보여준다. - 이 Module 에 해당 ItemType 이 등록되어 있으면(ModuleItemType 존재) mit.getAttributeGroup(name), 등록되어 있지 않으면 itemType.getAttributeGroup(name) 으로 조회한다. - AttributeGroupTypeEnum.getName() 이 AttributeGroup.NAME 과 매칭되는 문자열이다 (AttributeGroup.java/AttributeGroupFactory.java 에서 실제로 쓰이는 패턴). - group 이 없으면(아직 정의되지 않은 AttributeGroupType) attributes 는 빈 목록으로 둔다.
    • moveAttributes

      @Screen("AdminModuleAttributeGroups") @PostMapping("/admin/modules/{moduleId}/item-types/{typeId}/attribute-groups/move") public String moveAttributes(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @RequestParam(value="groupName",required=false) String groupName, @RequestParam(value="targetGroupName",required=false) String targetGroupName, @RequestParam(value="selectedAttributeIds",required=false) List<Integer> selectedAttributeIds, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      AttributeGroup 화면에서 선택한 Attribute 들을 다른 AttributeGroup 으로 이동시키거나 (targetGroupName 이 MOVE_TARGET_REMOVE 이면) 현재 Group 에서 제거한다. core 에 새로 추가된 AttributeFactory#remove(Attribute, EasyDeskUser) 를 사용해서 먼저 현재(before) Group 에서 제거하고, 삭제가 아니면 AttributeFactory#add(Attribute) 로 대상(after) Group 에 등록한다. EasyDeskUser 는 로그인 시 SecurityContext 에 등록해 둔 userId (SecurityContextHolder, ThreadLocal) 로 EasyDeskUserManager.getInstance(userId) 해서 얻는다.
    • attributesForGroup

      @Screen("AdminModuleAttributes") @GetMapping("/admin/modules/{moduleId}/item-types/{typeId}/attribute-groups/{groupName}/attributes") public String attributesForGroup(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @PathVariable("groupName") String groupName, @RequestParam(value="tab",required=false,defaultValue="0") Integer activeTab, HttpSession session, org.springframework.ui.Model model)
      선택한 AttributeGroup(name 으로 식별)에 등록할 수 있는 Attribute 목록을 Attribute/UserAttribute 두 tab 으로 보여준다. - "Attribute" tab: AttributeGroup.getAttributes() 와 같은 필터(REMOVED=false, User type 제외). - "UserAttribute" tab: 위와 반대로 AttributeTypeEnum.User 타입만. (AttributeGroup.getAttributes()/getAttributeAttributeGroup() 둘 다 User type 은 일부러 제외하도록 되어 있어서, 등록 여부 확인은 AttributeAttributeGroupPeer 를 직접 조회한다.) - checkbox 로 등록하는 것은 EasyDesk core 의 AttributeFactory.getFactory(group).add(attribute) 사용.
    • registerAttributes

      @Screen("AdminModuleAttributes") @PostMapping("/admin/modules/{moduleId}/item-types/{typeId}/attribute-groups/{groupName}/attributes") public String registerAttributes(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @PathVariable("groupName") String groupName, @RequestParam(value="selectedAttributeIds",required=false) List<Integer> selectedAttributeIds, @RequestParam(value="activeTab",required=false,defaultValue="0") Integer activeTab, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      화면에서 선택한 Attribute 들을 이 AttributeGroup 에 등록한다 (core 의 AttributeFactory.getFactory(group).add(attribute) 사용).
    • registerItemTypes

      @Screen("AdminModuleItemTypes") @PostMapping("/admin/modules/{moduleId}/item-types") public String registerItemTypes(@PathVariable("moduleId") Long id, @RequestParam(value="selectedTypeIds",required=false) List<Integer> selectedTypeIds, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      화면에서 선택한 ItemType 들을 현재 Module 에 등록한다 (EasyDeskModule#add(ItemType) 사용). 1. module.add(itemType) 의 실제 동작(내부적으로 ModuleItemType 등을 어떻게 구성하는지)은 아직 검증이 더 필요하다고 해서, 여기서는 일단 호출까지만 연결해 두었다. 2. 접속자의 "현재 Module" 은 easydesk-spring-modules 의 TransactionContextInterceptor 가 URL 의 {moduleId} 를 읽어 TransactionContextHolder(ThreadLocal) 에 반영한다 (TransactionContextHolder.getContext().getModuleId()). 이 화면은 아직 @PathVariable 값을 직접 사용한다.
    • add

      @Screen("AdminModules") @PostMapping("/admin/modules/add") public String add(@ModelAttribute("RequestModule") RequestModule form, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    • remove

      @Screen("AdminModules") @PostMapping("/admin/modules/remove") public String remove(@RequestParam("id") Long id, HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)