Index: pom.xml
===================================================================
diff -u -r25e72c1b1feeea878dac441ae16157af5ff7f2c2 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- pom.xml (.../pom.xml) (revision 25e72c1b1feeea878dac441ae16157af5ff7f2c2)
+++ pom.xml (.../pom.xml) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -10,7 +10,7 @@
4.0.0
313devgrp
java-service-tree-framework-backend-server
- 22.11.23
+ 22.11.24
pom
java-service-tree-framework
Index: web-module/pom.xml
===================================================================
diff -u -r25e72c1b1feeea878dac441ae16157af5ff7f2c2 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/pom.xml (.../pom.xml) (revision 25e72c1b1feeea878dac441ae16157af5ff7f2c2)
+++ web-module/pom.xml (.../pom.xml) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -7,7 +7,7 @@
313devgrp
java-service-tree-framework-backend-server
- 22.11.23
+ 22.11.24
../pom.xml
@@ -17,7 +17,7 @@
Web Project by 313 DEV GRP
- 23.01.07
+ 23.01.08
Index: web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepository.java
===================================================================
diff -u -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepository.java (.../FileRepository.java) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3)
+++ web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepository.java (.../FileRepository.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -12,9 +12,7 @@
package egovframework.api.arms.module_filerepository.service;
import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateService;
-import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO;
public interface FileRepository extends JsTreeHibernateService {
- public T addNodeWithRef(T jsTreeHibernateDTO) throws Exception;
}
\ No newline at end of file
Index: web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepositoryImpl.java
===================================================================
diff -u -ref381a7d8a044cd402172087c5bf151ec77625cf -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepositoryImpl.java (.../FileRepositoryImpl.java) (revision ef381a7d8a044cd402172087c5bf151ec77625cf)
+++ web-module/src/main/java/egovframework/api/arms/module_filerepository/service/FileRepositoryImpl.java (.../FileRepositoryImpl.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -11,72 +11,14 @@
*/
package egovframework.api.arms.module_filerepository.service;
-import egovframework.com.ext.jstree.springHibernate.core.dao.JsTreeHibernateDao;
import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateServiceImpl;
-import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Isolation;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.Resource;
-
@Service("fileRepository")
public class FileRepositoryImpl extends JsTreeHibernateServiceImpl implements FileRepository{
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- @SuppressWarnings("rawtypes")
- @Resource(name = "jsTreeHibernateDao")
- private JsTreeHibernateDao jsTreeHibernateDao;
-
- @SuppressWarnings("unchecked")
- @Override
- @Transactional(rollbackFor = { Exception.class }, isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED)
- public T addNodeWithRef(T jsTreeHibernateDTO) throws Exception {
-
- jsTreeHibernateDao.setClazz(jsTreeHibernateDTO.getClass());
- if (jsTreeHibernateDTO.getRef() < 0) {
- throw new RuntimeException("ref is minus");
- } else {
- T nodeByRef = (T) jsTreeHibernateDao.getUnique(jsTreeHibernateDTO.getRef());
-
- if ("default".equals(nodeByRef.getC_type())) {
- throw new RuntimeException("nodeByRef is default Type");
- }
-
- nodeByRef.setWhere("c_parentid", nodeByRef.getC_id());
- final long lastPosiotionOfNodeByRef = jsTreeHibernateDao.getCount(nodeByRef);
-
- jsTreeHibernateDTO.setC_position(lastPosiotionOfNodeByRef);
-
- long rightPointFromNodeByRef = nodeByRef.getC_right();
- rightPointFromNodeByRef = Math.max(rightPointFromNodeByRef, 1);
-
- long spaceOfTargetNode = 2;
-
- this.stretchLeftRightForMyselfFromJstree(spaceOfTargetNode, rightPointFromNodeByRef,
- jsTreeHibernateDTO.getCopy(), null, jsTreeHibernateDTO);
-
- long targetNodeLevel = jsTreeHibernateDTO.getRef() == 0 ? 0 : nodeByRef.getC_level() + 1;
-
- jsTreeHibernateDTO.setC_parentid(jsTreeHibernateDTO.getRef());
- jsTreeHibernateDTO.setC_left(rightPointFromNodeByRef);
- jsTreeHibernateDTO.setC_right(rightPointFromNodeByRef + 1);
- jsTreeHibernateDTO.setC_level(targetNodeLevel);
-
- long insertSeqResult = (long) jsTreeHibernateDao.insert(jsTreeHibernateDTO);
- if (insertSeqResult > 0) {
- final long SUCCESS = 1;
- jsTreeHibernateDTO.setStatus(SUCCESS);
- jsTreeHibernateDTO.setId(insertSeqResult);
- } else {
- throw new RuntimeException("심각한 오류 발생 - 삽입 노드");
- }
- }
- return jsTreeHibernateDTO;
- }
-
}
\ No newline at end of file
Index: web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java
===================================================================
diff -u -r8b191f4ce87e9bde997c6caf2232d468eb1061d3 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java (.../UserPdServiceController.java) (revision 8b191f4ce87e9bde997c6caf2232d468eb1061d3)
+++ web-module/src/main/java/egovframework/api/arms/module_pdservice/controller/UserPdServiceController.java (.../UserPdServiceController.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -19,10 +19,12 @@
import egovframework.api.arms.module_pdservice.service.PdService;
import egovframework.api.arms.module_pdserviceversion.model.PdServiceVersionDTO;
import egovframework.api.arms.module_pdserviceversion.service.PdServiceVersion;
+import egovframework.api.arms.util.FileHandler;
import egovframework.api.arms.util.PropertiesReader;
import egovframework.com.ext.jstree.springHibernate.core.controller.SHVAbstractController;
import egovframework.com.ext.jstree.springHibernate.core.util.Util_TitleChecker;
import egovframework.com.ext.jstree.springHibernate.core.validation.group.AddNode;
+import egovframework.com.ext.jstree.support.util.ParameterParser;
import egovframework.com.utl.fcc.service.EgovFileUploadUtil;
import egovframework.com.utl.fcc.service.EgovFormBasedFileVo;
import lombok.extern.slf4j.Slf4j;
@@ -67,9 +69,6 @@
@Resource(name = "reqAddTemplateInstallDB")
ArmsInstallDB reqAddTemplateInstallDB;
- @Resource(name = "egov.dataSource")
- DataSource dataSource;
-
@PostConstruct
public void initialize() {
setJsTreeHibernateService(pdService);
@@ -159,61 +158,14 @@
*/
@ResponseBody
@RequestMapping(value="/uploadFileToNode.do")
- public ModelAndView uploadFileToNode(final MultipartHttpServletRequest multiRequest, @RequestParam("fileIdLink") Long fileIdLink, Model model) throws Exception {
+ public ModelAndView uploadFileToNode(final MultipartHttpServletRequest multiRequest,
+ HttpServletRequest request, Model model) throws Exception {
- logger.info("fileIdLink -> " + fileIdLink);
+ ParameterParser parser = new ParameterParser(request);
+ long fileIdLink = parser.getLong("fileIdLink");
+ String c_title = "pdService";
- // Spring multipartResolver 미사용 시 (commons-fileupload 활용)
- //List list = EgovFormBasedFileUtil.uploadFiles(request, uploadDir, maxFileSize);
-
- // Spring multipartResolver 사용시
- PropertiesReader propertiesReader = new PropertiesReader("egovframework/egovProps/globals.properties");
- String uploadDir = propertiesReader.getProperty("Globals.fileStorePath");
- long maxFileSize = new Long(313);
- List list = EgovFileUploadUtil.uploadFiles(multiRequest, uploadDir, maxFileSize);
-
-
- EgovFormBasedFileVo egovFormBasedFileVo = list.get(0);
-
- FileRepositoryDTO fileRepositoryDTO = new FileRepositoryDTO();
-
- fileRepositoryDTO.setFileName(egovFormBasedFileVo.getFileName());
- fileRepositoryDTO.setContentType(egovFormBasedFileVo.getContentType());
- fileRepositoryDTO.setServerSubPath(egovFormBasedFileVo.getServerSubPath());
- fileRepositoryDTO.setPhysicalName(egovFormBasedFileVo.getPhysicalName());
- fileRepositoryDTO.setSize(egovFormBasedFileVo.getSize());
- fileRepositoryDTO.setName(egovFormBasedFileVo.getName());
-
- fileRepositoryDTO.setUrl(egovFormBasedFileVo.getUrl());
- //TODO: 썸네일 개발 필요
- fileRepositoryDTO.setThumbnailUrl(egovFormBasedFileVo.getThumbnailUrl());
-
- fileRepositoryDTO.setDelete_url(egovFormBasedFileVo.getDelete_url());
- fileRepositoryDTO.setDelete_type(egovFormBasedFileVo.getDelete_type());
- fileRepositoryDTO.setFileIdLink(fileIdLink);
-
- fileRepositoryDTO.setRef(new Long(2));
- fileRepositoryDTO.setC_title("pdService");
- fileRepositoryDTO.setC_type("default");
-
- FileRepositoryDTO returnFileRepositoryDTO = fileRepository.addNodeWithRef(fileRepositoryDTO);
- if(returnFileRepositoryDTO.getStatus() == 1L){
- logger.info("returnFileRepositoryDTO => " + returnFileRepositoryDTO.getC_id());
- }
- logger.info("fileRepository.getNode(returnFileRepositoryDTO).getC_id() ==> " + fileRepository.getNode(returnFileRepositoryDTO).getC_id());
- //delete 파라미터인 id 값을 업데이트 치기 위해서.
- fileRepositoryDTO.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId());
- fileRepositoryDTO.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId());
- fileRepositoryDTO.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId());
-
- fileRepository.updateNode(fileRepositoryDTO);
-
- egovFormBasedFileVo.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId());
- egovFormBasedFileVo.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId());
- egovFormBasedFileVo.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId());
-
- HashMap> map = new HashMap();
- map.put("files", list);
+ HashMap> map = FileHandler.upload(multiRequest, fileIdLink, c_title, fileRepository, logger);
ModelAndView modelAndView = new ModelAndView("jsonView");
modelAndView.addObject("result", map);
Index: web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/controller/UserPdServiceVersionController.java
===================================================================
diff -u -r9328381608b679a7f66c02117a302fc4fa22d1a5 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/controller/UserPdServiceVersionController.java (.../UserPdServiceVersionController.java) (revision 9328381608b679a7f66c02117a302fc4fa22d1a5)
+++ web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/controller/UserPdServiceVersionController.java (.../UserPdServiceVersionController.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -15,6 +15,7 @@
import egovframework.api.arms.module_pdserviceversion.service.PdServiceVersion;
import egovframework.com.ext.jstree.springHibernate.core.controller.SHVAbstractController;
import lombok.extern.slf4j.Slf4j;
+import org.hibernate.criterion.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,7 +52,9 @@
public ModelAndView getVersion(PdServiceVersionDTO pdServiceVersionDTO, ModelMap model,
HttpServletRequest request) throws Exception {
- List pdServiceVersionDTOS = pdServiceVersion.getVersion(pdServiceVersionDTO);
+ pdServiceVersionDTO.setOrder(Order.asc("c_left"));
+ pdServiceVersionDTO.setWhere("c_pdservice_link", pdServiceVersionDTO.getC_id().toString());
+ List pdServiceVersionDTOS = pdServiceVersion.getChildNode(pdServiceVersionDTO);
logger.info("UserPdServiceVersionController :: getVersion :: pdServiceVersionDTOS = " + pdServiceVersionDTOS.size());
ModelAndView modelAndView = new ModelAndView("jsonView");
@@ -67,7 +70,7 @@
ModelAndView modelAndView = new ModelAndView("jsonView");
- modelAndView.addObject("result", pdServiceVersion.updateVersionNode(pdServiceVersionDTO));
+ modelAndView.addObject("result", pdServiceVersion.updateNode(pdServiceVersionDTO));
return modelAndView;
}
Index: web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/service/PdServiceVersion.java
===================================================================
diff -u -r9328381608b679a7f66c02117a302fc4fa22d1a5 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/service/PdServiceVersion.java (.../PdServiceVersion.java) (revision 9328381608b679a7f66c02117a302fc4fa22d1a5)
+++ web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/service/PdServiceVersion.java (.../PdServiceVersion.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -11,15 +11,8 @@
*/
package egovframework.api.arms.module_pdserviceversion.service;
-import egovframework.api.arms.module_pdserviceversion.model.PdServiceVersionDTO;
import egovframework.com.ext.jstree.springHibernate.core.service.JsTreeHibernateService;
-import egovframework.com.ext.jstree.springHibernate.core.vo.JsTreeHibernateSearchDTO;
-import java.util.List;
-
public interface PdServiceVersion extends JsTreeHibernateService {
- public List getVersion(T jsTreeHibernateDTO) throws Exception;
- public int updateVersionNode(T jsTreeHibernateDTO) throws Exception;
-
}
\ No newline at end of file
Index: web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/service/PdServiceVersionImpl.java
===================================================================
diff -u -r9328381608b679a7f66c02117a302fc4fa22d1a5 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/service/PdServiceVersionImpl.java (.../PdServiceVersionImpl.java) (revision 9328381608b679a7f66c02117a302fc4fa22d1a5)
+++ web-module/src/main/java/egovframework/api/arms/module_pdserviceversion/service/PdServiceVersionImpl.java (.../PdServiceVersionImpl.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -33,44 +33,4 @@
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- @SuppressWarnings("rawtypes")
- @Resource(name = "jsTreeHibernateDao")
- private JsTreeHibernateDao jsTreeHibernateDao;
-
- @Override
- public List getVersion(T jsTreeHibernateDTO) throws Exception {
- jsTreeHibernateDao.setClazz(jsTreeHibernateDTO.getClass());
- jsTreeHibernateDTO.setOrder(Order.asc("c_left"));
- jsTreeHibernateDTO.setWhere("c_pdservice_link", jsTreeHibernateDTO.getC_id().toString());
- List list = jsTreeHibernateDao.getList(jsTreeHibernateDTO);
- return list;
- }
-
-
- @SuppressWarnings("unchecked")
- @Transactional(rollbackFor = { Exception.class }, propagation = Propagation.REQUIRED)
- public int updateVersionNode(T jsTreeHibernateDTO) throws Exception {
-
- jsTreeHibernateDao.setClazz(jsTreeHibernateDTO.getClass());
- T alterTargetNode = (T) jsTreeHibernateDao.getUnique(jsTreeHibernateDTO.getC_id());
-
- for (Field field : ReflectionUtils.getAllFields(jsTreeHibernateDTO.getClass())) {
-
- field.setAccessible(true);
-
- Object value = field.get(jsTreeHibernateDTO);
-
- if (!ObjectUtils.isEmpty(value)) {
- field.setAccessible(true);
- field.set(alterTargetNode, value);
- }
-
- }
- jsTreeHibernateDao.update(alterTargetNode);
-
-
- return 1;
-
- }
-
}
\ No newline at end of file
Index: web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java
===================================================================
diff -u -redd027be48d7a8347d15ec6e56a7ad91cf0a7190 -r1ef1321bb86080bac3998083f059d27762a92f2a
--- web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java (.../UserReqAddController.java) (revision edd027be48d7a8347d15ec6e56a7ad91cf0a7190)
+++ web-module/src/main/java/egovframework/api/arms/module_reqadd/controller/UserReqAddController.java (.../UserReqAddController.java) (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -26,6 +26,7 @@
import egovframework.api.arms.module_reqadd.model.ReqAddDTO;
import egovframework.api.arms.module_reqadd.service.ReqAdd;
import egovframework.api.arms.module_reqaddlog.service.ReqAddLog;
+import egovframework.api.arms.util.FileHandler;
import egovframework.api.arms.util.PropertiesReader;
import egovframework.com.ext.jstree.springHibernate.core.controller.SHVAbstractController;
import egovframework.com.ext.jstree.springHibernate.core.interceptor.SessionUtil;
@@ -287,57 +288,14 @@
@ResponseBody
@RequestMapping(value="/uploadFileToNode.do")
public ModelAndView uploadFileToNode(final MultipartHttpServletRequest multiRequest,
- @RequestParam("fileIdLink") Long fileIdLink,
- @RequestParam("c_title") String c_title,Model model) throws Exception {
+ HttpServletRequest request, Model model) throws Exception {
- logger.info("fileIdLink -> " + fileIdLink);
+ ParameterParser parser = new ParameterParser(request);
+ long fileIdLink = parser.getLong("fileIdLink");
+ String c_title = parser.get("c_title");
- // Spring multipartResolver 미사용 시 (commons-fileupload 활용)
- //List list = EgovFormBasedFileUtil.uploadFiles(request, uploadDir, maxFileSize);
+ HashMap> map = FileHandler.upload(multiRequest, fileIdLink, c_title, fileRepository, logger);
- // Spring multipartResolver 사용시
- PropertiesReader propertiesReader = new PropertiesReader("egovframework/egovProps/globals.properties");
- String uploadDir = propertiesReader.getProperty("Globals.fileStorePath");
- long maxFileSize = new Long(313);
- List list = EgovFileUploadUtil.uploadFiles(multiRequest, uploadDir, maxFileSize);
-
- for ( EgovFormBasedFileVo egovFormBasedFileVo : list) {
-
- FileRepositoryDTO fileRepositoryDTO = new FileRepositoryDTO();
- fileRepositoryDTO.setFileName(egovFormBasedFileVo.getFileName());
- fileRepositoryDTO.setContentType(egovFormBasedFileVo.getContentType());
- fileRepositoryDTO.setServerSubPath(egovFormBasedFileVo.getServerSubPath());
- fileRepositoryDTO.setPhysicalName(egovFormBasedFileVo.getPhysicalName());
- fileRepositoryDTO.setSize(egovFormBasedFileVo.getSize());
- fileRepositoryDTO.setName(egovFormBasedFileVo.getName());
-
- fileRepositoryDTO.setUrl(egovFormBasedFileVo.getUrl());
- //TODO: 썸네일 개발 필요
- fileRepositoryDTO.setThumbnailUrl(egovFormBasedFileVo.getThumbnailUrl());
-
- fileRepositoryDTO.setDelete_url(egovFormBasedFileVo.getDelete_url());
- fileRepositoryDTO.setDelete_type(egovFormBasedFileVo.getDelete_type());
- fileRepositoryDTO.setFileIdLink(fileIdLink);
-
- fileRepositoryDTO.setRef(new Long(1));
- fileRepositoryDTO.setC_title(c_title);
- fileRepositoryDTO.setC_type("default");
-
- FileRepositoryDTO returnFileRepositoryDTO = fileRepository.addNode(fileRepositoryDTO);
- //delete 파라미터인 id 값을 업데이트 치기 위해서.
- fileRepositoryDTO.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId());
- fileRepositoryDTO.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId());
- fileRepositoryDTO.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId());
-
- fileRepository.updateNode(fileRepositoryDTO);
-
- egovFormBasedFileVo.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId());
- egovFormBasedFileVo.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId());
- egovFormBasedFileVo.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId());
-
- }
- HashMap> map = new HashMap();
- map.put("files", list);
ModelAndView modelAndView = new ModelAndView("jsonView");
modelAndView.addObject("result", map);
Index: web-module/src/main/java/egovframework/api/arms/util/FileHandler.java
===================================================================
diff -u
--- web-module/src/main/java/egovframework/api/arms/util/FileHandler.java (revision 0)
+++ web-module/src/main/java/egovframework/api/arms/util/FileHandler.java (revision 1ef1321bb86080bac3998083f059d27762a92f2a)
@@ -0,0 +1,73 @@
+package egovframework.api.arms.util;
+
+import egovframework.api.arms.module_filerepository.model.FileRepositoryDTO;
+import egovframework.api.arms.module_filerepository.service.FileRepository;
+import egovframework.com.utl.fcc.service.EgovFileUploadUtil;
+import egovframework.com.utl.fcc.service.EgovFormBasedFileVo;
+import org.slf4j.Logger;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import sun.util.logging.PlatformLogger;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class FileHandler {
+
+ public static HashMap> upload(MultipartHttpServletRequest multiRequest,
+ long fileIdLink,
+ String c_title,
+ FileRepository fileRepository,
+ Logger logger) throws Exception {
+
+ logger.info("FileHandler :: upload :: fileIdLink -> " + fileIdLink + " , c_title -> " + c_title);
+
+ // Spring multipartResolver 미사용 시 (commons-fileupload 활용)
+ //List list = EgovFormBasedFileUtil.uploadFiles(request, uploadDir, maxFileSize);
+
+ // Spring multipartResolver 사용시
+ PropertiesReader propertiesReader = new PropertiesReader("egovframework/egovProps/globals.properties");
+ String uploadDir = propertiesReader.getProperty("Globals.fileStorePath");
+ long maxFileSize = new Long(313);
+ List list = EgovFileUploadUtil.uploadFiles(multiRequest, uploadDir, maxFileSize);
+
+ for (EgovFormBasedFileVo egovFormBasedFileVo : list) {
+
+ FileRepositoryDTO fileRepositoryDTO = new FileRepositoryDTO();
+ fileRepositoryDTO.setFileName(egovFormBasedFileVo.getFileName());
+ fileRepositoryDTO.setContentType(egovFormBasedFileVo.getContentType());
+ fileRepositoryDTO.setServerSubPath(egovFormBasedFileVo.getServerSubPath());
+ fileRepositoryDTO.setPhysicalName(egovFormBasedFileVo.getPhysicalName());
+ fileRepositoryDTO.setSize(egovFormBasedFileVo.getSize());
+ fileRepositoryDTO.setName(egovFormBasedFileVo.getName());
+
+ fileRepositoryDTO.setUrl(egovFormBasedFileVo.getUrl());
+ //TODO: 썸네일 개발 필요
+ fileRepositoryDTO.setThumbnailUrl(egovFormBasedFileVo.getThumbnailUrl());
+
+ fileRepositoryDTO.setDelete_url(egovFormBasedFileVo.getDelete_url());
+ fileRepositoryDTO.setDelete_type(egovFormBasedFileVo.getDelete_type());
+ fileRepositoryDTO.setFileIdLink(fileIdLink);
+
+ fileRepositoryDTO.setRef(new Long(2));
+ fileRepositoryDTO.setC_title(c_title);
+ fileRepositoryDTO.setC_type("default");
+
+ FileRepositoryDTO returnFileRepositoryDTO = fileRepository.addNode(fileRepositoryDTO);
+ //delete 파라미터인 id 값을 업데이트 치기 위해서.
+ fileRepositoryDTO.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId());
+ fileRepositoryDTO.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId());
+ fileRepositoryDTO.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId());
+
+ fileRepository.updateNode(fileRepositoryDTO);
+
+ egovFormBasedFileVo.setUrl("/auth-user/api/arms/fileRepository" + "/downloadFileByNode/" + returnFileRepositoryDTO.getId());
+ egovFormBasedFileVo.setThumbnailUrl("/auth-user/api/arms/fileRepository" + "/thumbnailUrlFileToNode/" + returnFileRepositoryDTO.getId());
+ egovFormBasedFileVo.setDelete_url("/auth-user/api/arms/fileRepository" + "/deleteFileByNode/" + returnFileRepositoryDTO.getId());
+
+ }
+
+ HashMap> map = new HashMap();
+ map.put("files", list);
+ return map;
+ }
+}