수정
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
package com.eactive.eai.rms.onl.manage.authoutbound;
|
||||
|
||||
import com.eactive.eai.agent.command.CommonCommand;
|
||||
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
|
||||
import com.eactive.eai.rms.common.login.SessionManager;
|
||||
import com.eactive.eai.rms.common.vo.GridResponse;
|
||||
import com.eactive.eai.rms.onl.manage.comm.property.PropertyGroupUI;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
public class OutboundFixedCredentialController extends OnlBaseAnnotationController {
|
||||
enum CommandType { RELOAD, DELETE };
|
||||
|
||||
public static final Log logger = LogFactory.getLog(OutboundFixedCredentialController.class);
|
||||
|
||||
@Autowired
|
||||
OutboundOAuthCredentialManService service ;
|
||||
|
||||
@GetMapping(value = "/onl/admin/authoutbound/outboundFixedCredentialMan.view")
|
||||
public void view() {
|
||||
}
|
||||
|
||||
@GetMapping(value = "/onl/admin/authoutbound/outboundFixedCredentialMan.view", params = "cmd=DETAIL")
|
||||
public String viewDetail() {
|
||||
return "/onl/admin/authoutbound/outboundFixedCredentialManDetail";
|
||||
}
|
||||
|
||||
@PostMapping(value= "/onl/admin/authoutbound/outboundFixedCredentialMan.json", params = "cmd=LIST")
|
||||
public ResponseEntity<GridResponse<OutboundOAuthCredentialUI>>selectList(String searchAdapterGroupName, Pageable pageable) {
|
||||
Page<OutboundOAuthCredentialUI> page = service.selectList(pageable, searchAdapterGroupName);
|
||||
Page<OutboundOAuthCredentialUI> filteredPage =
|
||||
new PageImpl<>(
|
||||
page.filter(i -> "fixed_token".equals(i.getGrantType()))
|
||||
.stream()
|
||||
.collect(Collectors.toList()),
|
||||
pageable,
|
||||
page.getTotalElements() // 또는 filtered.size()
|
||||
);
|
||||
return ResponseEntity.ok(new GridResponse<>(filteredPage));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authoutbound/outboundFixedCredentialMan.json", params = "cmd=DETAIL")
|
||||
public ResponseEntity<OutboundOAuthCredentialUI> selectDetail(String adapterGroupName) throws Exception {
|
||||
OutboundOAuthCredentialUI outboundOAuthCredentialUI = service.selectDetail(adapterGroupName);
|
||||
return ResponseEntity.ok(outboundOAuthCredentialUI);
|
||||
}
|
||||
|
||||
@PostMapping(value= "/onl/admin/authoutbound/outboundFixedCredentialMan.json",params = "cmd=LIST_DETAIL_COMBO")
|
||||
public ResponseEntity<Map<String, Object>> selectDetailCombo() throws Exception {
|
||||
Map<String, Object> map = service.selectDetailCombo();
|
||||
return ResponseEntity.ok(map);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authoutbound/outboundFixedCredentialMan.json", params = "cmd=INSERT")
|
||||
public ResponseEntity<Void> insert(OutboundOAuthCredentialUI outboundOAuthCredentialUI) throws Exception {
|
||||
service.insert(outboundOAuthCredentialUI);
|
||||
commandOAuthInfo(CommandType.RELOAD, outboundOAuthCredentialUI.getAdapterGroupName());
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authoutbound/outboundFixedCredentialMan.json", params = "cmd=UPDATE")
|
||||
public ResponseEntity<Void> update(OutboundOAuthCredentialUI outboundOAuthCredentialUI) throws Exception {
|
||||
service.update(outboundOAuthCredentialUI);
|
||||
commandOAuthInfo(CommandType.RELOAD, outboundOAuthCredentialUI.getAdapterGroupName());
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authoutbound/outboundFixedCredentialMan.json", params = "cmd=DELETE")
|
||||
public ResponseEntity<Void> delete(String adapterGroupName) throws Exception {
|
||||
service.delete(adapterGroupName);
|
||||
commandOAuthInfo(CommandType.DELETE, adapterGroupName);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
private boolean commandOAuthInfo(CommandType commandType, String adapterGroupName) {
|
||||
String commandClass ;
|
||||
|
||||
if(CommandType.DELETE == commandType){
|
||||
commandClass = "com.eactive.eai.agent.authoutbound.RemoveOutboundOAuthCredentialCommand";
|
||||
}else{
|
||||
commandClass = "com.eactive.eai.agent.authoutbound.ReloadOutboundOAuthCredentialCommand";
|
||||
}
|
||||
logger.warn("Command:" + commandType + ", Target: " + adapterGroupName);
|
||||
CommonCommand command = new CommonCommand(commandClass, adapterGroupName);
|
||||
try {
|
||||
agentUtilService.broadcast(command);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Command error", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user