();
+
+ // Check that we have a file upload request
+ boolean isMultipart = ServletFileUpload.isMultipartContent(request);
+
+ if (isMultipart) {
+ // Create a new file upload handler
+ ServletFileUpload upload = new ServletFileUpload();
+ upload.setFileSizeMax(maxFileSize); // SizeLimitExceededException
+
+ // Parse the request
+ FileItemIterator iter = upload.getItemIterator(request);
+ while (iter.hasNext()) {
+ FileItemStream item = iter.next();
+ String name = item.getFieldName();
+ InputStream stream = item.openStream();
+ if (item.isFormField()) {
+ LOGGER.info("Form field '{}' with value '{}' detected.", name, Streams.asString(stream));
+ } else {
+ LOGGER.info("File field '{}' with file name '{}' detected.", name, item.getName());
+
+ if ("".equals(item.getName())) {
+ continue;
+ }
+
+ // Process the input stream
+ EgovFormBasedFileVo vo = new EgovFormBasedFileVo();
+
+ String tmp = item.getName();
+
+ if (tmp.lastIndexOf("\\") >= 0) {
+ tmp = tmp.substring(tmp.lastIndexOf("\\") + 1);
+ }
+
+ vo.setFileName(tmp);
+ vo.setContentType(item.getContentType());
+ vo.setServerSubPath(getTodayString());
+ vo.setPhysicalName(getPhysicalFileName());
+
+ if (tmp.lastIndexOf(".") >= 0) {
+ vo.setPhysicalName(vo.getPhysicalName() + tmp.substring(tmp.lastIndexOf(".")));
+ }
+
+ long size = saveFile(stream, new File(EgovWebUtil.filePathBlackList(where) + SEPERATOR + vo.getServerSubPath() + SEPERATOR + vo.getPhysicalName()));
+
+ vo.setSize(size);
+
+ list.add(vo);
+ }
+ }
+ } else {
+ throw new IOException("form's 'enctype' attribute have to be 'multipart/form-data'");
+ }
+
+ return list;
+ }
+
+ /**
+ * 파일을 Download 처리한다.
+ *
+ * @param response
+ * @param where
+ * @param serverSubPath
+ * @param physicalName
+ * @param original
+ * @throws Exception
+ */
+ public static void downloadFile(HttpServletResponse response, String where, String serverSubPath, String physicalName, String original) throws Exception {
+ String downFileName = where + SEPERATOR + serverSubPath + SEPERATOR + physicalName;
+
+ File file = new File(EgovWebUtil.filePathBlackList(downFileName));
+
+ if (!file.exists()) {
+ throw new FileNotFoundException(downFileName);
+ }
+
+ if (!file.isFile()) {
+ throw new FileNotFoundException(downFileName);
+ }
+
+ byte[] b = new byte[BUFFER_SIZE];
+
+ original = original.replaceAll("\r", "").replaceAll("\n", "");
+ response.setContentType("application/octet-stream");
+ response.setHeader("Content-Disposition", "attachment; filename=\"" + convert(original) + "\";");
+ response.setHeader("Content-Transfer-Encoding", "binary");
+ response.setHeader("Pragma", "no-cache");
+ response.setHeader("Expires", "0");
+
+ BufferedInputStream fin = null;
+ BufferedOutputStream outs = null;
+
+ try {
+ fin = new BufferedInputStream(new FileInputStream(file));
+ outs = new BufferedOutputStream(response.getOutputStream());
+
+ int read = 0;
+
+ while ((read = fin.read(b)) != -1) {
+ outs.write(b, 0, read);
+ }
+ } finally {
+ EgovResourceCloseHelper.close(outs, fin);
+ }
+ }
+
+ /**
+ * 이미지에 대한 미리보기 기능을 제공한다.
+ *
+ * mimeType의 경우는 JSP 상에서 다음과 같이 얻을 수 있다.
+ * getServletConfig().getServletContext().getMimeType(name);
+ *
+ * @param response
+ * @param where
+ * @param serverSubPath
+ * @param physicalName
+ * @param mimeType
+ * @throws Exception
+ */
+ public static void viewFile(HttpServletResponse response, String where, String serverSubPath, String physicalName, String mimeTypeParam) throws Exception {
+ String mimeType = mimeTypeParam;
+ String downFileName = where + SEPERATOR + serverSubPath + SEPERATOR + physicalName;
+
+ File file = new File(EgovWebUtil.filePathBlackList(downFileName));
+
+ if (!file.exists()) {
+ throw new FileNotFoundException(downFileName);
+ }
+
+ if (!file.isFile()) {
+ throw new FileNotFoundException(downFileName);
+ }
+
+ byte[] b = new byte[BUFFER_SIZE];
+
+ if (mimeType == null) {
+ mimeType = "application/octet-stream;";
+ }
+
+ response.setContentType(EgovWebUtil.removeCRLF(mimeType));
+ response.setHeader("Content-Disposition", "filename=image;");
+
+ BufferedInputStream fin = null;
+ BufferedOutputStream outs = null;
+
+ try {
+ fin = new BufferedInputStream(new FileInputStream(file));
+ outs = new BufferedOutputStream(response.getOutputStream());
+
+ int read = 0;
+
+ while ((read = fin.read(b)) != -1) {
+ outs.write(b, 0, read);
+ }
+ } finally {
+ EgovResourceCloseHelper.close(outs, fin);
+ }
+ }
+}
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovFormBasedFileVo.java b/src/main/java/egovframework/com/utl/fcc/service/EgovFormBasedFileVo.java
new file mode 100644
index 0000000..48512db
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovFormBasedFileVo.java
@@ -0,0 +1,104 @@
+package egovframework.com.utl.fcc.service;
+
+import java.io.Serializable;
+
+/**
+ * @Class Name : EgovFormBasedFileVo.java
+ * @Description : Form-based File Upload VO
+ * @Modification Information
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.08.26 한성곤 최초 생성
+ *
+ * @author 공통컴포넌트 개발팀 한성곤
+ * @since 2009.08.26
+ * @version 1.0
+ * @see
+ *
+ * Copyright (C) 2008 by MOPAS All right reserved.
+ */
+@SuppressWarnings("serial")
+public class EgovFormBasedFileVo implements Serializable {
+ /** 파일명 */
+ private String fileName = "";
+ /** ContextType */
+ private String contentType = "";
+ /** 하위 디렉토리 지정 */
+ private String serverSubPath = "";
+ /** 물리적 파일명 */
+ private String physicalName = "";
+ /** 파일 사이즈 */
+ private long size = 0L;
+
+ /**
+ * fileName attribute를 리턴한다.
+ * @return the fileName
+ */
+ public String getFileName() {
+ return fileName;
+ }
+ /**
+ * fileName attribute 값을 설정한다.
+ * @param fileName the fileName to set
+ */
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+ /**
+ * contentType attribute를 리턴한다.
+ * @return the contentType
+ */
+ public String getContentType() {
+ return contentType;
+ }
+ /**
+ * contentType attribute 값을 설정한다.
+ * @param contentType the contentType to set
+ */
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+ /**
+ * serverSubPath attribute를 리턴한다.
+ * @return the serverSubPath
+ */
+ public String getServerSubPath() {
+ return serverSubPath;
+ }
+ /**
+ * serverSubPath attribute 값을 설정한다.
+ * @param serverSubPath the serverSubPath to set
+ */
+ public void setServerSubPath(String serverSubPath) {
+ this.serverSubPath = serverSubPath;
+ }
+ /**
+ * physicalName attribute를 리턴한다.
+ * @return the physicalName
+ */
+ public String getPhysicalName() {
+ return physicalName;
+ }
+ /**
+ * physicalName attribute 값을 설정한다.
+ * @param physicalName the physicalName to set
+ */
+ public void setPhysicalName(String physicalName) {
+ this.physicalName = physicalName;
+ }
+ /**
+ * size attribute를 리턴한다.
+ * @return the size
+ */
+ public long getSize() {
+ return size;
+ }
+ /**
+ * size attribute 값을 설정한다.
+ * @param size the size to set
+ */
+ public void setSize(long size) {
+ this.size = size;
+ }
+}
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovFormBasedUUID.java b/src/main/java/egovframework/com/utl/fcc/service/EgovFormBasedUUID.java
new file mode 100644
index 0000000..6df377b
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovFormBasedUUID.java
@@ -0,0 +1,521 @@
+package egovframework.com.utl.fcc.service;
+
+import java.io.Serializable;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+/**
+ *
+ * A class that represents an immutable universally unique identifier (UUID). A
+ * UUID represents a 128-bit value.
+ *
+ *
+ * There exist different variants of these global identifiers. The methods of
+ * this class are for manipulating the Leach-Salz variant, although the
+ * constructors allow the creation of any variant of UUID (described below).
+ *
+ *
+ * The layout of a variant 2 (Leach-Salz) UUID is as follows:
+ *
+ * The most significant long consists of the following unsigned fields:
+ *
+ *
+ * 0xFFFFFFFF00000000 time_low
+ * 0x00000000FFFF0000 time_mid
+ * 0x000000000000F000 version
+ * 0x0000000000000FFF time_hi
+ *
+ *
+ * The least significant long consists of the following unsigned fields:
+ *
+ *
+ * 0xC000000000000000 variant
+ * 0x3FFF000000000000 clock_seq
+ * 0x0000FFFFFFFFFFFF node
+ *
+ *
+ *
+ * The variant field contains a value which identifies the layout of the
+ * UUID. The bit layout described above is valid only for a
+ * UUID with a variant value of 2, which indicates the Leach-Salz
+ * variant.
+ *
+ *
+ * The version field holds a value that describes the type of this UUID.
+ * There are four different basic types of UUIDs: time-based, DCE security,
+ * name-based, and randomly generated UUIDs. These types have a version value of
+ * 1, 2, 3 and 4, respectively.
+ *
+ *
+ * For more information including algorithms used to create UUIDs,
+ * see the Internet-Draft UUIDs
+ * and GUIDs or the standards body definition at ISO/IEC 11578:1996.
+ *
+ * @version 1.14, 07/12/04
+ * @since 1.5
+ */
+@SuppressWarnings("serial")
+public class EgovFormBasedUUID implements Serializable {
+ /*
+ * The most significant 64 bits of this UUID.
+ *
+ * @serial
+ */
+ private final long mostSigBits;
+
+ /*
+ * The least significant 64 bits of this UUID.
+ *
+ * @serial
+ */
+ private final long leastSigBits;
+
+ /*
+ * The version number associated with this UUID. Computed on demand.
+ */
+ private transient int version = -1;
+
+ /*
+ * The variant number associated with this UUID. Computed on demand.
+ */
+ private transient int variant = -1;
+
+ /*
+ * The timestamp associated with this UUID. Computed on demand.
+ */
+ private transient volatile long timestamp = -1;
+
+ /*
+ * The clock sequence associated with this UUID. Computed on demand.
+ */
+ private transient int sequence = -1;
+
+ /*
+ * The node number associated with this UUID. Computed on demand.
+ */
+ private transient long node = -1;
+
+ /*
+ * The hashcode of this UUID. Computed on demand.
+ */
+ private transient int hashCode = -1;
+
+ /*
+ * The random number generator used by this class to create random based
+ * UUIDs.
+ */
+ private static volatile SecureRandom numberGenerator = null;
+
+ // Constructors and Factories
+
+ /*
+ * Private constructor which uses a byte array to construct the new UUID.
+ */
+ private EgovFormBasedUUID(byte[] data) {
+ long msb = 0;
+ long lsb = 0;
+ for (int i = 0; i < 8; i++)
+ msb = (msb << 8) | (data[i] & 0xff);
+ for (int i = 8; i < 16; i++)
+ lsb = (lsb << 8) | (data[i] & 0xff);
+ this.mostSigBits = msb;
+ this.leastSigBits = lsb;
+ }
+
+ /**
+ * Constructs a new UUID using the specified data.
+ * mostSigBits is used for the most significant 64 bits of the
+ * UUID and leastSigBits becomes the least significant
+ * 64 bits of the UUID.
+ *
+ * @param mostSigBits
+ * @param leastSigBits
+ */
+ public EgovFormBasedUUID(long mostSigBits, long leastSigBits) {
+ this.mostSigBits = mostSigBits;
+ this.leastSigBits = leastSigBits;
+ }
+
+ /**
+ * Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
+ *
+ * The UUID is generated using a cryptographically strong
+ * pseudo random number generator.
+ *
+ * @return a randomly generated UUID.
+ */
+ public static EgovFormBasedUUID randomUUID() {
+ SecureRandom ng = numberGenerator;
+ if (ng == null) {
+ numberGenerator = ng = new SecureRandom();
+ }
+
+ byte[] randomBytes = new byte[16];
+ ng.nextBytes(randomBytes);
+ randomBytes[6] &= 0x0f; /* clear version */
+ randomBytes[6] |= 0x40; /* set to version 4 */
+ randomBytes[8] &= 0x3f; /* clear variant */
+ randomBytes[8] |= 0x80; /* set to IETF variant */
+
+ return new EgovFormBasedUUID(randomBytes);
+ }
+
+ /**
+ * Static factory to retrieve a type 3 (name based) UUID based on
+ * the specified byte array.
+ *
+ * @param name
+ * a byte array to be used to construct a UUID.
+ * @return a UUID generated from the specified array.
+ */
+ public static EgovFormBasedUUID nameUUIDFromBytes(byte[] name) {
+ MessageDigest md;
+ try {
+ // 2011.10.10 보안점검 후속조치 암호화 알고리즘 변경(MD5 -> SHA-256)
+ //md = MessageDigest.getInstance("MD5");
+ md = MessageDigest.getInstance("SHA-256");
+ } catch (NoSuchAlgorithmException nsae) {
+ //throw new InternalError("MD5 not supported");
+ throw new InternalError("SHA-256 not supported");
+ }
+ // 2011.10.10 보안점검 후속조치
+ if (md == null) {
+ throw new RuntimeException("MessageDigest is null!!");
+ }
+ // 2014.09.20 보안점검 후속 조치
+ // Random 방식의 salt 추가
+ SecureRandom ng = new SecureRandom();
+ byte[] randomBytes = new byte[16];
+ ng.nextBytes(randomBytes);
+
+ md.reset();
+ md.update(randomBytes);
+ byte[] sha = md.digest(name);
+
+
+ byte[] md5Bytes = new byte[8];
+ System.arraycopy(sha, 0, md5Bytes, 0, 8);
+ //2011.10.10 보안점검 후속조치 끝
+
+ md5Bytes[6] &= 0x0f; /* clear version */
+ md5Bytes[6] |= 0x30; /* set to version 3 */
+ md5Bytes[8] &= 0x3f; /* clear variant */
+ md5Bytes[8] |= 0x80; /* set to IETF variant */
+
+ return new EgovFormBasedUUID(md5Bytes);
+ }
+
+ /**
+ * Creates a UUID from the string standard representation as
+ * described in the {@link #toString} method.
+ *
+ * @param name
+ * a string that specifies a UUID.
+ * @return a UUID with the specified value.
+ * @throws IllegalArgumentException
+ * if name does not conform to the string representation as
+ * described in {@link #toString}.
+ */
+ public static EgovFormBasedUUID fromString(String name) {
+ String[] components = name.split("-");
+ if (components.length != 5)
+ throw new IllegalArgumentException("Invalid UUID string: " + name);
+ for (int i = 0; i < 5; i++)
+ components[i] = "0x" + components[i];
+
+ long mostSigBits = Long.decode(components[0]).longValue();
+ mostSigBits <<= 16;
+ mostSigBits |= Long.decode(components[1]).longValue();
+ mostSigBits <<= 16;
+ mostSigBits |= Long.decode(components[2]).longValue();
+
+ long leastSigBits = Long.decode(components[3]).longValue();
+ leastSigBits <<= 48;
+ leastSigBits |= Long.decode(components[4]).longValue();
+
+ return new EgovFormBasedUUID(mostSigBits, leastSigBits);
+ }
+
+ // Field Accessor Methods
+
+ /**
+ * Returns the least significant 64 bits of this UUID's 128 bit value.
+ *
+ * @return the least significant 64 bits of this UUID's 128 bit value.
+ */
+ public long getLeastSignificantBits() {
+ return leastSigBits;
+ }
+
+ /**
+ * Returns the most significant 64 bits of this UUID's 128 bit value.
+ *
+ * @return the most significant 64 bits of this UUID's 128 bit value.
+ */
+ public long getMostSignificantBits() {
+ return mostSigBits;
+ }
+
+ /**
+ * The version number associated with this UUID. The version
+ * number describes how this UUID was generated.
+ *
+ * The version number has the following meaning:
+ *
+ *
+ * - 1 Time-based UUID
+ *
- 2 DCE security UUID
+ *
- 3 Name-based UUID
+ *
- 4 Randomly generated UUID
+ *
+ *
+ * @return the version number of this UUID.
+ */
+ public int version() {
+ if (version < 0) {
+ // Version is bits masked by 0x000000000000F000 in MS long
+ version = (int) ((mostSigBits >> 12) & 0x0f);
+ }
+ return version;
+ }
+
+ /**
+ * The variant number associated with this UUID. The variant
+ * number describes the layout of the UUID.
+ *
+ * The variant number has the following meaning:
+ *
+ *
+ * - 0 Reserved for NCS backward compatibility
+ *
- 2 The Leach-Salz variant (used by this class)
+ *
- 6 Reserved, Microsoft Corporation backward compatibility
+ *
- 7 Reserved for future definition
+ *
+ *
+ * @return the variant number of this UUID.
+ */
+ public int variant() {
+ if (variant < 0) {
+ // This field is composed of a varying number of bits
+ if ((leastSigBits >>> 63) == 0) {
+ variant = 0;
+ } else if ((leastSigBits >>> 62) == 2) {
+ variant = 2;
+ } else {
+ variant = (int) (leastSigBits >>> 61);
+ }
+ }
+ return variant;
+ }
+
+ /**
+ * The timestamp value associated with this UUID.
+ *
+ *
+ * The 60 bit timestamp value is constructed from the time_low, time_mid,
+ * and time_hi fields of this UUID. The resulting timestamp is
+ * measured in 100-nanosecond units since midnight, October 15, 1582 UTC.
+ *
+ *
+ * The timestamp value is only meaningful in a time-based UUID, which has
+ * version type 1. If this UUID is not a time-based UUID then
+ * this method throws UnsupportedOperationException.
+ *
+ * @throws UnsupportedOperationException
+ * if this UUID is not a version 1 UUID.
+ */
+ public long timestamp() {
+ if (version() != 1) {
+ throw new UnsupportedOperationException("Not a time-based UUID");
+ }
+ long result = timestamp;
+ if (result < 0) {
+ result = (mostSigBits & 0x0000000000000FFFL) << 48;
+ result |= ((mostSigBits >> 16) & 0xFFFFL) << 32;
+ result |= mostSigBits >>> 32;
+ timestamp = result;
+ }
+ return result;
+ }
+
+ /**
+ * The clock sequence value associated with this UUID.
+ *
+ *
+ * The 14 bit clock sequence value is constructed from the clock sequence
+ * field of this UUID. The clock sequence field is used to guarantee
+ * temporal uniqueness in a time-based UUID.
+ *
+ *
+ * The clockSequence value is only meaningful in a time-based UUID, which
+ * has version type 1. If this UUID is not a time-based UUID then this
+ * method throws UnsupportedOperationException.
+ *
+ * @return the clock sequence of this UUID.
+ * @throws UnsupportedOperationException
+ * if this UUID is not a version 1 UUID.
+ */
+ public int clockSequence() {
+ if (version() != 1) {
+ throw new UnsupportedOperationException("Not a time-based UUID");
+ }
+ if (sequence < 0) {
+ sequence = (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
+ }
+ return sequence;
+ }
+
+ /**
+ * The node value associated with this UUID.
+ *
+ *
+ * The 48 bit node value is constructed from the node field of this UUID.
+ * This field is intended to hold the IEEE 802 address of the machine that
+ * generated this UUID to guarantee spatial uniqueness.
+ *
+ *
+ * The node value is only meaningful in a time-based UUID, which has version
+ * type 1. If this UUID is not a time-based UUID then this method throws
+ * UnsupportedOperationException.
+ *
+ * @return the node value of this UUID.
+ * @throws UnsupportedOperationException
+ * if this UUID is not a version 1 UUID.
+ */
+ public long node() {
+ if (version() != 1) {
+ throw new UnsupportedOperationException("Not a time-based UUID");
+ }
+ if (node < 0) {
+ node = leastSigBits & 0x0000FFFFFFFFFFFFL;
+ }
+ return node;
+ }
+
+ // Object Inherited Methods
+
+ /**
+ * Returns a String object representing this
+ * UUID.
+ *
+ *
+ * The UUID string representation is as described by this BNF :
+ *
+ *
+ * UUID = <time_low> "-" <time_mid> "-"
+ * <time_high_and_version> "-"
+ * <variant_and_sequence> "-"
+ * <node>
+ * time_low = 4*<hexOctet>
+ * time_mid = 2*<hexOctet>
+ * time_high_and_version = 2*<hexOctet>
+ * variant_and_sequence = 2*<hexOctet>
+ * node = 6*<hexOctet>
+ * hexOctet = <hexDigit><hexDigit>
+ * hexDigit =
+ * "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+ * | "a" | "b" | "c" | "d" | "e" | "f"
+ * | "A" | "B" | "C" | "D" | "E" | "F"
+ *
+ *
+ * @return a string representation of this UUID.
+ */
+ @Override
+ public String toString() {
+ return (digits(mostSigBits >> 32, 8) + "-"
+ + digits(mostSigBits >> 16, 4) + "-" + digits(mostSigBits, 4)
+ + "-" + digits(leastSigBits >> 48, 4) + "-" + digits(
+ leastSigBits, 12));
+ }
+
+ /** Returns val represented by the specified number of hex digits. */
+ private static String digits(long val, int digits) {
+ long hi = 1L << (digits * 4);
+ return Long.toHexString(hi | (val & (hi - 1))).substring(1);
+ }
+
+ /**
+ * Returns a hash code for this UUID.
+ *
+ * @return a hash code value for this UUID.
+ */
+ @Override
+ public int hashCode() {
+ if (hashCode == -1) {
+ hashCode = (int) ((mostSigBits >> 32) ^ mostSigBits
+ ^ (leastSigBits >> 32) ^ leastSigBits);
+ }
+ return hashCode;
+ }
+
+ /**
+ * Compares this object to the specified object. The result is true
+ * if and only if the argument is not null, is a UUID
+ * object, has the same variant, and contains the same value, bit for bit,
+ * as this UUID.
+ *
+ * @param obj
+ * the object to compare with.
+ * @return true if the objects are the same;
+ * false otherwise.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ // 보안 취약점 점검 지적사항 반영 시작
+ if (obj == null)
+ return false;
+ // 보안 취약점 점검 지적사항 반영 시작 끝
+ if (!(obj instanceof EgovFormBasedUUID))
+ return false;
+ if (((EgovFormBasedUUID) obj).variant() != this.variant())
+ return false;
+ EgovFormBasedUUID id = (EgovFormBasedUUID) obj;
+ return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
+ }
+
+ // Comparison Operations
+
+ /**
+ * Compares this UUID with the specified UUID.
+ *
+ *
+ * The first of two UUIDs follows the second if the most significant field
+ * in which the UUIDs differ is greater for the first UUID.
+ *
+ * @param val
+ * UUID to which this UUID is to be
+ * compared.
+ * @return -1, 0 or 1 as this UUID is less than, equal to, or
+ * greater than val.
+ */
+ public int compareTo(EgovFormBasedUUID val) {
+ // The ordering is intentionally set up so that the UUIDs
+ // can simply be numerically compared as two numbers
+ return (this.mostSigBits < val.mostSigBits ? -1
+ : (this.mostSigBits > val.mostSigBits ? 1
+ : (this.leastSigBits < val.leastSigBits ? -1
+ : (this.leastSigBits > val.leastSigBits ? 1 : 0))));
+ }
+
+ /**
+ * Reconstitute the UUID instance from a stream (that is,
+ * deserialize it). This is necessary to set the transient fields to their
+ * correct uninitialized value so they will be recomputed on demand.
+ */
+ private void readObject(java.io.ObjectInputStream in)
+ throws java.io.IOException, ClassNotFoundException {
+
+ in.defaultReadObject();
+
+ // Set "cached computation" fields to their initial values
+ version = -1;
+ variant = -1;
+ timestamp = -1;
+ sequence = -1;
+ node = -1;
+ hashCode = -1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovFormatCheckUtil.java b/src/main/java/egovframework/com/utl/fcc/service/EgovFormatCheckUtil.java
new file mode 100644
index 0000000..fbdc29c
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovFormatCheckUtil.java
@@ -0,0 +1,207 @@
+package egovframework.com.utl.fcc.service;
+
+/**
+ *
+ * 포맷유효성체크 에 대한 Util 클래스
+ * @author 공통컴포넌트 개발팀 윤성록
+ * @since 2009.06.23
+ * @version 1.0
+ * @see
+ *
+ *
+ * << 개정이력(Modification Information) >>
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.06.23 윤성록 최초 생성
+ *
+ *
+ */
+public class EgovFormatCheckUtil {
+
+ /**
+ * XXX - XXX- XXXX 형식의 전화번호 앞, 중간, 뒤 문자열 3개 입력 받아 유요한 전화번호형식인지 검사.
+ *
+ *
+ * @param 전화번호 문자열( 3개 )
+ * @return 유효한 전화번호 형식인지 여부 (True/False)
+ */
+ public static boolean checkFormatTell(String tell1, String tell2, String tell3) {
+
+ String[] check = {"02", "031", "032", "033", "041", "042", "043", "051", "052", "053", "054", "055", "061",
+ "062", "063", "070", "080", "0505"}; //존재하는 국번 데이터
+ String temp = tell1 + tell2 + tell3;
+
+ for(int i=0; i < temp.length(); i++){
+ if (temp.charAt(i) < '0' || temp.charAt(i) > '9')
+ return false;
+ } //숫자가 아닌 값이 들어왔는지를 확인
+
+ for(int i = 0; i < check.length; i++){
+ if(tell1.equals(check[i])) break;
+ if(i == check.length - 1) return false;
+ } //국번입력이 제대로 되었는지를 확인
+
+ if(tell2.charAt(0) == '0') return false;
+
+ if(tell1.equals("02")){
+ if(tell2.length() != 3 && tell2.length() !=4) return false;
+ if(tell3.length() != 4) return false; //서울지역(02)국번 입력때의 전화 번호 형식유효성 체크
+ }else{
+ if(tell2.length() != 3) return false;
+ if(tell3.length() != 4) return false;
+ } //서울을 제외한 지역(국번 입력때의 전화 번호 형식유효성 체크
+
+ return true;
+ }
+
+ /**
+ * XXX - XXX- XXXX 형식의 전화번호 하나를 입력 받아 유요한 전화번호형식인지 검사.
+ *
+ *
+ * @param 전화번호 문자열 (1개)
+ * @return 유효한 전화번호 형식인지 여부 (True/False)
+ */
+ public static boolean checkFormatTell(String tellNumber) {
+
+ String temp1;
+ String temp2;
+ String temp3;
+ String tell = tellNumber;
+
+ tell = tell.replace("-", "");
+
+ if(tell.length() < 9 || tell.length() > 11 || tell.charAt(0) != '0') return false; //전화번호 길이에 대한 체크
+
+ if(tell.charAt(1) =='2'){ //서울지역 (02)국번의 경우일때
+ temp1 = tell.substring(0,2);
+ if(tell.length() == 9){
+ temp2 = tell.substring(2,5);
+ temp3 = tell.substring(5,9);
+ }else if(tell.length() == 10){
+ temp2 = tell.substring(2,6);
+ temp3 = tell.substring(6,10);
+ }else
+ return false;
+ } else if(tell.substring(0,4).equals("0505")){ //평생번호(0505)국번의 경우일때
+ if(tell.length() != 11) return false;
+ temp1 = tell.substring(0,4);
+ temp2 = tell.substring(4,7);
+ temp3 = tell.substring(7,11);
+ } else { // 서울지역 및 "0505" 를 제외한 일반적인 경우일때
+ if(tell.length() != 10) return false;
+ temp1 = tell.substring(0,3);
+ temp2 = tell.substring(3,6);
+ temp3 = tell.substring(6,10);
+ }
+
+ return checkFormatTell(temp1, temp2, temp3);
+ }
+
+ /**
+ * XXX - XXX- XXXX 형식의 휴대폰번호 앞, 중간, 뒤 문자열 3개 입력 받아 유요한 휴대폰번호형식인지 검사.
+ *
+ *
+ * @param 휴대폰번호 문자열,(3개)
+ * @return 유효한 휴대폰번호 형식인지 여부 (True/False)
+ */
+ public static boolean checkFormatCell(String cell1, String cell2, String cell3) {
+ String[] check = {"010", "011", "016", "017", "018", "019"}; //유효한 휴대폰 첫자리 번호 데이터
+ String temp = cell1 + cell2 + cell3;
+
+ for(int i=0; i < temp.length(); i++){
+ if (temp.charAt(i) < '0' || temp.charAt(i) > '9')
+ return false;
+ } //숫자가 아닌 값이 들어왔는지를 확인
+
+ for(int i = 0; i < check.length; i++){
+ if(cell1.equals(check[i])) break;
+ if(i == check.length - 1) return false;
+ } // 휴대폰 첫자리 번호입력의 유효성 체크
+
+ if(cell2.charAt(0) == '0') return false;
+
+ if(cell2.length() != 3 && cell2.length() !=4) return false;
+ if(cell3.length() != 4) return false;
+
+ return true;
+ }
+
+ /**
+ * XXXXXXXXXX 형식의 휴대폰번호 문자열 3개 입력 받아 유요한 휴대폰번호형식인지 검사.
+ *
+ *
+ * @param 휴대폰번호 문자열(1개)
+ * @return 유효한 휴대폰번호 형식인지 여부 (True/False)
+ */
+ public static boolean checkFormatCell(String cellNumber) {
+
+ String temp1;
+ String temp2;
+ String temp3;
+
+ String cell = cellNumber;
+ cell = cell.replace("-", "");
+
+ if(cell.length() < 10 || cell.length() > 11 || cell.charAt(0) != '0') return false;
+
+ if(cell.length() == 10){ //전체 10자리 휴대폰 번호일 경우
+ temp1 = cell.substring(0,3);
+ temp2 = cell.substring(3,6);
+ temp3 = cell.substring(6,10);
+ }else{ //전체 11자리 휴대폰 번호일 경우
+ temp1 = cell.substring(0,3);
+ temp2 = cell.substring(3,7);
+ temp3 = cell.substring(7,11);
+ }
+
+ return checkFormatCell(temp1, temp2, temp3);
+ }
+
+ /**
+ * 이메일의 앞, 뒤 문자열 2개 입력 받아 유요한 이메일형식인지 검사.
+ *
+ *
+ * @param 이메일 문자열 (2개)
+ * @return 유효한 이메일 형식인지 여부 (True/False)
+ */
+ public static boolean checkFormatMail(String mail1, String mail2) {
+
+ int count = 0;
+
+ for(int i = 0; i < mail1.length(); i++){
+ if(mail1.charAt(i) <= 'z' && mail1.charAt(i) >= 'a') continue;
+ else if(mail1.charAt(i) <= 'Z' && mail1.charAt(i) >= 'A') continue;
+ else if(mail1.charAt(i) <= '9' && mail1.charAt(i) >= '0') continue;
+ else if(mail1.charAt(i) == '-' && mail1.charAt(i) == '_') continue;
+ else return false;
+ } // 유효한 문자, 숫자인지 체크
+
+ for(int i = 0; i < mail2.length(); i++){
+ if(mail2.charAt(i) <= 'z' && mail2.charAt(i) >= 'a') continue;
+ else if(mail2.charAt(i) == '.'){ count++; continue;}
+ else return false;
+ } // 메일 주소의 형식 체크(XXX.XXX 형태)
+
+ if(count == 1) return true;
+ else return false;
+
+ }
+
+ /**
+ * 이메일의 전체문자열 1개 입력 받아 유요한 이메일형식인지 검사.
+ *
+ *
+ * @param 이메일 문자열 (1개)
+ * @return 유효한 이메일 형식인지 여부 (True/False)
+ */
+ public static boolean checkFormatMail(String mail) {
+
+ String[] temp = mail.split("@"); // '@' 를 기점으로 앞, 뒤 문자열 구분
+
+ if(temp.length == 2) return checkFormatMail(temp[0], temp[1]);
+ else return false;
+ }
+
+}
+
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovNumberCheckUtil.java b/src/main/java/egovframework/com/utl/fcc/service/EgovNumberCheckUtil.java
new file mode 100644
index 0000000..88d3370
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovNumberCheckUtil.java
@@ -0,0 +1,246 @@
+package egovframework.com.utl.fcc.service;
+
+/**
+ *
+ * 번호유효성체크 에 대한 Util 클래스
+ * @author 공통컴포넌트 개발팀 윤성록
+ * @since 2009.06.10
+ * @version 1.0
+ * @see
+ *
+ *
+ * << 개정이력(Modification Information) >>
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.06.10 윤성록 최초 생성
+ * 2012.02.27 이기하 법인번호 체크로직 수정
+ *
+ *
+ */
+public class EgovNumberCheckUtil {
+
+ /**
+ * XXXXXX - XXXXXXX 형식의 주민번호 앞, 뒤 문자열 2개 입력 받아 유효한 주민번호인지 검사.
+ *
+ *
+ * @param 6자리 주민앞번호 문자열 , 7자리 주민뒷번호 문자열
+ * @return 유효한 주민번호인지 여부 (True/False)
+ */
+ @SuppressWarnings("static-access")
+ public static boolean checkJuminNumber(String jumin1, String jumin2) {
+
+ EgovDateUtil egovDateUtil = new EgovDateUtil();
+ String juminNumber = jumin1 + jumin2;
+ String IDAdd = "234567892345"; // 주민등록번호에 가산할 값
+
+ int count_num = 0;
+ int add_num = 0;
+ int total_id = 0; //검증을 위한 변수선언
+
+ if (juminNumber.length() != 13) return false; // 주민등록번호 자리수가 맞는가를 확인
+
+ for (int i = 0; i <12 ; i++){
+ if(juminNumber.charAt(i)< '0' || juminNumber.charAt(i) > '9') return false; //숫자가 아닌 값이 들어왔는지를 확인
+ count_num = Character.getNumericValue(juminNumber.charAt(i));
+ add_num = Character.getNumericValue(IDAdd.charAt(i));
+ total_id += count_num * add_num; //유효자리 검증식을 적용
+ }
+
+ if(Character.getNumericValue(juminNumber.charAt(0)) == 0 || Character.getNumericValue(juminNumber.charAt(0)) == 1){
+ if(Character.getNumericValue(juminNumber.charAt(6)) > 4) return false;
+ String temp = "20" + juminNumber.substring(0,6);
+ if(!egovDateUtil.checkDate(temp)) return false;
+ }else{
+ if(Character.getNumericValue(juminNumber.charAt(6)) > 2) return false;
+ String temp = "19" + juminNumber.substring(0,6);
+ if(!egovDateUtil.checkDate(temp)) return false;
+ } //주민번호 앞자리 날짜유효성체크 & 성별구분 숫자 체크
+
+ if(Character.getNumericValue(juminNumber.charAt(12)) == (11 - (total_id % 11)) % 10) //마지막 유효숫자와 검증식을 통한 값의 비교
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * XXXXXXXXXXXXX 형식의 13자리 주민번호 1개를 입력 받아 유효한 주민번호인지 검사.
+ *
+ *
+ * @param 13자리 주민번호 문자열
+ * @return 유효한 주민번호인지 여부 (True/False)
+ */
+ public static boolean checkJuminNumber(String jumin) {
+
+ if(jumin.length() != 13) return false;
+
+ return checkJuminNumber(jumin.substring(0,6), jumin.substring(6,13)); //주민번호
+ }
+
+ /**
+ * XXXXXX - XXXXXXX 형식의 법인번호 앞, 뒤 문자열 2개 입력 받아 유효한 법인번호인지 검사.
+ *
+ *
+ * @param 6자리 법인앞번호 문자열 , 7자리 법인뒷번호 문자열
+ * @return 유효한 법인번호인지 여부 (True/False)
+ */
+ public static boolean checkBubinNumber(String bubin1, String bubin2) {
+
+ String bubinNumber = bubin1 + bubin2;
+
+ int hap = 0;
+ int temp = 1; //유효검증식에 사용하기 위한 변수
+
+ if(bubinNumber.length() != 13) return false; //법인번호의 자리수가 맞는 지를 확인
+
+ for(int i=0; i < 13; i++){
+ if (bubinNumber.charAt(i) < '0' || bubinNumber.charAt(i) > '9') //숫자가 아닌 값이 들어왔는지를 확인
+ return false;
+ }
+
+
+ // 2012.02.27 법인번호 체크로직 수정( i<13 -> i<12 )
+ // 맨끝 자리 수는 전산시스템으로 오류를 검증하기 위해 부여되는 검증번호임
+ for ( int i=0; i<12; i++){
+ if(temp ==3) temp = 1;
+ hap = hap + (Character.getNumericValue(bubinNumber.charAt(i)) * temp);
+ temp++;
+ } //검증을 위한 식의 계산
+
+ if ((10 - (hap%10))%10 == Character.getNumericValue(bubinNumber.charAt(12))) //마지막 유효숫자와 검증식을 통한 값의 비교
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * XXXXXXXXXXXXX 형식의 13자리 법인번호 1개를 입력 받아 유효한 법인번호인지 검사.
+ *
+ *
+ * @param 13자리 법인번호 문자열
+ * @return 유효한 법인번호인지 여부 (True/False)
+ */
+ public static boolean checkBubinNumber(String bubin) {
+
+ if(bubin.length() != 13) return false;
+
+ return checkBubinNumber(bubin.substring(0,6), bubin.substring(6,13));
+ }
+
+
+ /**
+ * XXX - XX - XXXXX 형식의 사업자번호 앞,중간, 뒤 문자열 3개 입력 받아 유효한 사업자번호인지 검사.
+ *
+ *
+ * @param 3자리 사업자앞번호 문자열 , 2자리 사업자중간번호 문자열, 5자리 사업자뒷번호 문자열
+ * @return 유효한 사업자번호인지 여부 (True/False)
+ */
+ public static boolean checkCompNumber(String comp1, String comp2, String comp3) {
+
+ String compNumber = comp1 + comp2 + comp3;
+
+ int hap = 0;
+ int temp = 0;
+ int check[] = {1,3,7,1,3,7,1,3,5}; //사업자번호 유효성 체크 필요한 수
+
+ if(compNumber.length() != 10) //사업자번호의 길이가 맞는지를 확인한다.
+ return false;
+
+ for(int i=0; i < 9; i++){
+ if(compNumber.charAt(i) < '0' || compNumber.charAt(i) > '9') //숫자가 아닌 값이 들어왔는지를 확인한다.
+ return false;
+
+ hap = hap + (Character.getNumericValue(compNumber.charAt(i)) * check[temp]); //검증식 적용
+ temp++;
+ }
+
+ hap += (Character.getNumericValue(compNumber.charAt(8))*5)/10;
+
+ if ((10 - (hap%10))%10 == Character.getNumericValue(compNumber.charAt(9))) //마지막 유효숫자와 검증식을 통한 값의 비교
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * XXXXXXXXXX 형식의 10자리 사업자번호 3개를 입력 받아 유효한 사업자번호인지 검사.
+ *
+ *
+ * @param 10자리 사업자번호 문자열
+ * @return 유효한 사업자번호인지 여부 (True/False)
+ */
+ public static boolean checkCompNumber(String comp) {
+
+ if(comp.length() != 10) return false;
+ return checkCompNumber(comp.substring(0,3), comp.substring(3,5), comp.substring(5,10));
+ }
+
+ /**
+ * XXXXXX - XXXXXXX 형식의 외국인등록번호 앞, 뒤 문자열 2개 입력 받아 유효한 외국인등록번호인지 검사.
+ *
+ *
+ * @param 6자리 외국인등록앞번호 문자열 , 7자리 외국인등록뒷번호 문자열
+ * @return 유효한 외국인등록번호인지 여부 (True/False)
+ */
+ @SuppressWarnings("static-access")
+ public static boolean checkforeignNumber( String foreign1, String foreign2 ) {
+
+ EgovDateUtil egovDateUtil = new EgovDateUtil();
+ String foreignNumber = foreign1 + foreign2;
+ int check = 0;
+
+ if( foreignNumber.length() != 13 ) //외국인등록번호의 길이가 맞는지 확인한다.
+ return false;
+
+ for(int i=0; i < 13; i++){
+ if (foreignNumber.charAt(i) < '0' || foreignNumber.charAt(i) > '9') //숫자가 아닌 값이 들어왔는지를 확인한다.
+ return false;
+ }
+
+ if(Character.getNumericValue(foreignNumber.charAt(0)) == 0 || Character.getNumericValue(foreignNumber.charAt(0)) == 1){
+ if(Character.getNumericValue(foreignNumber.charAt(6)) == 5 && Character.getNumericValue(foreignNumber.charAt(6)) == 6) return false;
+ String temp = "20" + foreignNumber.substring(0,6);
+ if(!egovDateUtil.checkDate(temp)) return false;
+ }else{
+ if(Character.getNumericValue(foreignNumber.charAt(6)) == 5 && Character.getNumericValue(foreignNumber.charAt(6)) == 6) return false;
+ String temp = "19" + foreignNumber.substring(0,6);
+ if(!egovDateUtil.checkDate(temp)) return false;
+ } //외국인등록번호 앞자리 날짜유효성체크 & 성별구분 숫자 체크
+
+ for( int i = 0 ; i < 12 ; i++ ) {
+ check += ( ( 9 - i % 8 ) * Character.getNumericValue( foreignNumber.charAt( i ) ) );
+ }
+
+ if ( check % 11 == 0 ){
+ check = 1;
+ }else if ( check % 11==10 ){
+ check = 0;
+ }else
+ check = check % 11;
+
+ if ( check + 2 > 9 ){
+ check = check + 2- 10;
+ }else check = check+2; //검증식을 통합 값의 도출
+
+ if( check == Character.getNumericValue( foreignNumber.charAt( 12 ) ) ) //마지막 유효숫자와 검증식을 통한 값의 비교
+ return true;
+ else
+ return false;
+ }
+
+
+ /**
+ * XXXXXXXXXXXXX 형식의 13자리 외국인등록번호 1개를 입력 받아 유효한 외국인등록번호인지 검사.
+ *
+ *
+ * @param 13자리 외국인등록번호 문자열
+ * @return 유효한 외국인등록번호인지 여부 (True/False)
+ */
+ public static boolean checkforeignNumber( String foreign ) {
+
+ if(foreign.length() != 13) return false;
+ return checkforeignNumber(foreign.substring(0,6), foreign.substring(6,13));
+ }
+}
+
+
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovNumberFormat.java b/src/main/java/egovframework/com/utl/fcc/service/EgovNumberFormat.java
new file mode 100644
index 0000000..701eda4
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovNumberFormat.java
@@ -0,0 +1,258 @@
+package egovframework.com.utl.fcc.service;
+
+import java.text.NumberFormat;
+import java.util.Locale;
+
+/**
+ * 숫자, 통화, 퍼센트에 대한 형식 변환을 수행하는 클래스
+ */
+public class EgovNumberFormat {
+
+ private static final int MAX_FRACTION_DIGIT = 3;
+ private static final boolean GROUPING_USED = true;
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param number 숫자
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Number number) {
+ return formatNumber(number, GROUPING_USED, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Locale locale, Number number) {
+ return formatNumber(locale, number, GROUPING_USED, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Number number, boolean groupingUsed) {
+ return formatNumber(number, groupingUsed, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Locale locale, Number number, boolean groupingUsed) {
+ return formatNumber(locale, number, groupingUsed, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param number 숫자
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Number number, int maxFactionDigits) {
+ return formatNumber(number, GROUPING_USED, maxFactionDigits);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Locale locale, Number number, int maxFactionDigits) {
+ return formatNumber(locale, number, GROUPING_USED, maxFactionDigits);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Number number, boolean groupingUsed, int maxFactionDigits) {
+ NumberFormat numberberFormat = NumberFormat.getNumberInstance();
+ numberberFormat.setGroupingUsed(groupingUsed);
+ numberberFormat.setMaximumFractionDigits(maxFactionDigits);
+ return numberberFormat.format(number);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 숫자를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 숫자 문자열
+ */
+ public static String formatNumber(Locale locale, Number number, boolean groupingUsed, int maxFactionDigits) {
+ NumberFormat numberberFormat = NumberFormat.getNumberInstance(locale);
+ numberberFormat.setGroupingUsed(groupingUsed);
+ numberberFormat.setMaximumFractionDigits(maxFactionDigits);
+ return numberberFormat.format(number);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 통화를 변환한다.
+ *
+ * @param number 숫자
+ * @return 통화 문자열
+ */
+ public static String formatCurrency(Number number) {
+ return formatCurrency(number, GROUPING_USED);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 통화를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @return 통화 문자열
+ */
+ public static String formatCurrency(Locale locale, Number number) {
+ return formatCurrency(locale, number, GROUPING_USED);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 통화를 변환한다.
+ *
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @return 통화 문자열
+ */
+ public static String formatCurrency(Number number, boolean groupingUsed) {
+ NumberFormat numberberFormat = NumberFormat.getCurrencyInstance();
+ numberberFormat.setGroupingUsed(groupingUsed);
+ return numberberFormat.format(number);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 통화를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @return 통화 문자열
+ */
+ public static String formatCurrency(Locale locale, Number number, boolean groupingUsed) {
+ NumberFormat numberberFormat = NumberFormat.getCurrencyInstance(locale);
+ numberberFormat.setGroupingUsed(groupingUsed);
+ return numberberFormat.format(number);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param number 숫자
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Number number) {
+ return formatPercent(number, GROUPING_USED, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Locale locale, Number number) {
+ return formatPercent(locale, number, GROUPING_USED, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Number number, boolean groupingUsed) {
+ return formatPercent(number, groupingUsed, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Locale locale, Number number, boolean groupingUsed) {
+ return formatPercent(locale, number, groupingUsed, MAX_FRACTION_DIGIT);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param number 숫자
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Number number, int maxFactionDigits) {
+ return formatPercent(number, GROUPING_USED, maxFactionDigits);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Locale locale, Number number, int maxFactionDigits) {
+ return formatPercent(locale, number, GROUPING_USED, maxFactionDigits);
+ }
+
+ /**
+ * 기본 Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Number number, boolean groupingUsed, int maxFactionDigits) {
+ NumberFormat numberberFormat = NumberFormat.getPercentInstance();
+ numberberFormat.setGroupingUsed(groupingUsed);
+ numberberFormat.setMaximumFractionDigits(maxFactionDigits);
+ return numberberFormat.format(number);
+ }
+
+ /**
+ * Locale에 해당하는 형식으로 퍼센트를 변환한다.
+ *
+ * @param locale 로케일
+ * @param number 숫자
+ * @param groupingUsed 그룹 분리기호 포함 여부
+ * @param maxFactionDigits 변환된 문자열에서 출력할 소수점 이하 최대 자리수
+ * @return 퍼센트 문자열
+ */
+ public static String formatPercent(Locale locale, Number number, boolean groupingUsed, int maxFactionDigits) {
+ NumberFormat numberberFormat = NumberFormat.getPercentInstance(locale);
+ numberberFormat.setGroupingUsed(groupingUsed);
+ numberberFormat.setMaximumFractionDigits(maxFactionDigits);
+ return numberberFormat.format(number);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovNumberUtil.java b/src/main/java/egovframework/com/utl/fcc/service/EgovNumberUtil.java
new file mode 100644
index 0000000..2735e8b
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovNumberUtil.java
@@ -0,0 +1,216 @@
+/**
+ * @Class Name : EgovNumberUtil.java
+ * @Description : 숫자 데이터 처리 관련 유틸리티
+ * @Modification Information
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.02.13 이삼섭 최초 생성
+ *
+ * @author 공통 서비스 개발팀 이삼섭
+ * @since 2009. 02. 13
+ * @version 1.0
+ * @see
+ *
+ */
+
+package egovframework.com.utl.fcc.service;
+
+import java.security.SecureRandom;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class EgovNumberUtil {
+
+ /**
+ * 특정숫자 집합에서 랜덤 숫자를 구하는 기능 시작숫자와 종료숫자 사이에서 구한 랜덤 숫자를 반환한다
+ *
+ * @param startNum - 시작숫자
+ * @param endNum - 종료숫자
+ * @return 랜덤숫자
+ * @see
+ */
+ public static int getRandomNum(int startNum, int endNum) {
+ int randomNum = 0;
+
+ // 랜덤 객체 생성
+ SecureRandom rnd = new SecureRandom();
+
+ do {
+ // 종료숫자내에서 랜덤 숫자를 발생시킨다.
+ randomNum = rnd.nextInt(endNum + 1);
+ } while (randomNum < startNum); // 랜덤 숫자가 시작숫자보다 작을경우 다시 랜덤숫자를 발생시킨다.
+
+ return randomNum;
+ }
+
+ /**
+ * 특정 숫자 집합에서 특정 숫자가 있는지 체크하는 기능 12345678에서 7이 있는지 없는지 체크하는 기능을 제공함
+ *
+ * @param sourceInt - 특정숫자집합
+ * @param searchInt - 검색숫자
+ * @return 존재여부
+ * @see
+ */
+ public static Boolean getNumSearchCheck(int sourceInt, int searchInt) {
+ String sourceStr = String.valueOf(sourceInt);
+ String searchStr = String.valueOf(searchInt);
+
+ // 특정숫자가 존재하는지 하여 위치값을 리턴한다. 없을 시 -1
+ if (sourceStr.indexOf(searchStr) == -1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * 숫자타입을 문자열로 변환하는 기능 숫자 20081212를 문자열 '20081212'로 변환하는 기능
+ *
+ * @param srcNumber - 숫자
+ * @return 문자열
+ * @see
+ */
+ public static String getNumToStrCnvr(int srcNumber) {
+ String rtnStr = null;
+
+ rtnStr = String.valueOf(srcNumber);
+
+ return rtnStr;
+ }
+
+ /**
+ * 숫자타입을 데이트 타입으로 변환하는 기능
+ * 숫자 20081212를 데이트타입 '2008-12-12'로 변환하는 기능
+ * @param srcNumber - 숫자
+ * @return String
+ * @see
+ */
+ public static String getNumToDateCnvr(int srcNumber) {
+
+ String pattern = null;
+ String cnvrStr = null;
+
+ String srcStr = String.valueOf(srcNumber);
+
+ // Date 형태인 8자리 및 14자리만 정상처리
+ if (srcStr.length() != 8 && srcStr.length() != 14) {
+ throw new IllegalArgumentException("Invalid Number: " + srcStr + " Length=" + srcStr.trim().length());
+ }
+
+ if (srcStr.length() == 8) {
+ pattern = "yyyyMMdd";
+ } else if (srcStr.length() == 14) {
+ pattern = "yyyyMMddhhmmss";
+ }
+
+ SimpleDateFormat dateFormatter = new SimpleDateFormat(pattern, Locale.KOREA);
+
+ Date cnvrDate = null;
+
+ try {
+ cnvrDate = dateFormatter.parse(srcStr);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+
+ cnvrStr = String.format("%1$tY-%1$tm-%1$td", cnvrDate);
+
+ return cnvrStr;
+
+ }
+
+ /**
+ * 체크할 숫자 중에서 숫자인지 아닌지 체크하는 기능
+ * 숫자이면 True, 아니면 False를 반환한다
+ * @param checkStr - 체크문자열
+ * @return 숫자여부
+ * @see
+ */
+ public static Boolean getNumberValidCheck(String checkStr) {
+
+ int i;
+ //String sourceStr = String.valueOf(sourceInt);
+
+ int checkStrLt = checkStr.length();
+
+ for (i = 0; i < checkStrLt; i++) {
+
+ // 아스키코드값( '0'-> 48, '9' -> 57)
+ if (checkStr.charAt(i) > 47 && checkStr.charAt(i) < 58) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * 특정숫자를 다른 숫자로 치환하는 기능 숫자 12345678에서 123를 999로 변환하는 기능을 제공(99945678)
+ *
+ * @param srcNumber - 숫자집합
+ * @param cnvrSrcNumber - 원래숫자
+ * @param cnvrTrgtNumber - 치환숫자
+ * @return 치환숫자
+ * @see
+ */
+ public static int getNumberCnvr(int srcNumber, int cnvrSrcNumber, int cnvrTrgtNumber) {
+
+ // 입력받은 숫자를 문자열로 변환
+ String source = String.valueOf(srcNumber);
+ String subject = String.valueOf(cnvrSrcNumber);
+ String object = String.valueOf(cnvrTrgtNumber);
+
+ StringBuffer rtnStr = new StringBuffer();
+ String preStr = "";
+ String nextStr = source;
+
+ // 원본숫자에서 변환대상숫자의 위치를 찾는다.
+ while (source.indexOf(subject) >= 0) {
+ preStr = source.substring(0, source.indexOf(subject)); // 변환대상숫자 위치까지 숫자를 잘라낸다
+ nextStr = source.substring(source.indexOf(subject) + subject.length(), source.length());
+ source = nextStr;
+ rtnStr.append(preStr).append(object); // 변환대상위치 숫자에 변환할 숫자를 붙여준다.
+ }
+ rtnStr.append(nextStr); // 변환대상 숫자 이후 숫자를 붙여준다.
+
+ return Integer.parseInt(rtnStr.toString());
+ }
+
+ /**
+ * 특정숫자가 실수인지, 정수인지, 음수인지 체크하는 기능 123이 실수인지, 정수인지, 음수인지 체크하는 기능을 제공함
+ *
+ * @param srcNumber - 숫자집합
+ * @return -1(음수), 0(정수), 1(실수)
+ * @see
+ */
+ public static int checkRlnoInteger(double srcNumber) {
+
+ // byte 1바이트 ▶소수점이 없는 숫자로, 범위 -2^7 ~ 2^7 -1
+ // short 2바이트 ▶소수점이 없는 숫자로, 범위 -2^15 ~ 2^15 -1
+ // int 4바이트 ▶소수점이 없는 숫자로, 범위 -2^31 ~ 2^31 - 1
+ // long 8바이트 ▶소수점이 없는 숫자로, 범위 -2^63 ~ 2^63-1
+
+ // float 4바이트 ▶소수점이 있는 숫자로, 끝에 F 또는 f 가 붙는 숫자 (예:3.14f)
+ // double 8바이트 ▶소수점이 있는 숫자로, 끝에 아무것도 붙지 않는 숫자 (예:3.14)
+ // ▶소수점이 있는 숫자로, 끝에 D 또는 d 가 붙는 숫자(예:3.14d)
+
+ String cnvrString = null;
+
+ if (srcNumber < 0) {
+ return -1;
+ } else {
+ cnvrString = String.valueOf(srcNumber);
+
+ if (cnvrString.indexOf(".") == -1) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+}
diff --git a/src/main/java/egovframework/com/utl/fcc/service/EgovStringUtil.java b/src/main/java/egovframework/com/utl/fcc/service/EgovStringUtil.java
new file mode 100644
index 0000000..eaaee5f
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/fcc/service/EgovStringUtil.java
@@ -0,0 +1,884 @@
+/**
+ * @Class Name : EgovStringUtil.java
+ * @Description : 문자열 데이터 처리 관련 유틸리티
+ * @Modification Information
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.01.13 박정규 최초 생성
+ * 2009.02.13 이삼섭 내용 추가
+ *
+ * @author 공통 서비스 개발팀 박정규
+ * @since 2009. 01. 13
+ * @version 1.0
+ * @see
+ *
+ */
+
+package egovframework.com.utl.fcc.service;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the ";License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS"; BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.security.SecureRandom;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+public class EgovStringUtil {
+ /**
+ * 빈 문자열 "".
+ */
+ public static final String EMPTY = "";
+
+ /**
+ * Padding을 할 수 있는 최대 수치
+ */
+ // private static final int PAD_LIMIT = 8192;
+
+ /**
+ * An array of Strings used for padding.
+ * Used for efficient space padding. The length of each String expands as needed.
+ */
+ /*
+ private static final String[] PADDING = new String[Character.MAX_VALUE];
+
+ static {
+ // space padding is most common, start with 64 chars
+ PADDING[32] = " ";
+ }
+ */
+
+ /**
+ * 문자열이 지정한 길이를 초과했을때 지정한길이에다가 해당 문자열을 붙여주는 메서드.
+ * @param source 원본 문자열 배열
+ * @param output 더할문자열
+ * @param slength 지정길이
+ * @return 지정길이로 잘라서 더할분자열 합친 문자열
+ */
+ public static String cutString(String source, String output, int slength) {
+ String returnVal = null;
+ if (source != null) {
+ if (source.length() > slength) {
+ returnVal = source.substring(0, slength) + output;
+ } else
+ returnVal = source;
+ }
+ return returnVal;
+ }
+
+ /**
+ * 문자열이 지정한 길이를 초과했을때 해당 문자열을 삭제하는 메서드
+ * @param source 원본 문자열 배열
+ * @param slength 지정길이
+ * @return 지정길이로 잘라서 더할분자열 합친 문자열
+ */
+ public static String cutString(String source, int slength) {
+ String result = null;
+ if (source != null) {
+ if (source.length() > slength) {
+ result = source.substring(0, slength);
+ } else
+ result = source;
+ }
+ return result;
+ }
+
+ /**
+ *
+ * String이 비었거나("") 혹은 null 인지 검증한다.
+ *
+ *
+ *
+ * StringUtil.isEmpty(null) = true
+ * StringUtil.isEmpty("") = true
+ * StringUtil.isEmpty(" ") = false
+ * StringUtil.isEmpty("bob") = false
+ * StringUtil.isEmpty(" bob ") = false
+ *
+ *
+ * @param str - 체크 대상 스트링오브젝트이며 null을 허용함
+ * @return true - 입력받은 String 이 빈 문자열 또는 null인 경우
+ */
+ public static boolean isEmpty(String str) {
+ return str == null || str.length() == 0;
+ }
+
+ /**
+ * 기준 문자열에 포함된 모든 대상 문자(char)를 제거한다.
+ *
+ *
+ * StringUtil.remove(null, *) = null
+ * StringUtil.remove("", *) = ""
+ * StringUtil.remove("queued", 'u') = "qeed"
+ * StringUtil.remove("queued", 'z') = "queued"
+ *
+ *
+ * @param str 입력받는 기준 문자열
+ * @param remove 입력받는 문자열에서 제거할 대상 문자열
+ * @return 제거대상 문자열이 제거된 입력문자열. 입력문자열이 null인 경우 출력문자열은 null
+ */
+ public static String remove(String str, char remove) {
+ if (isEmpty(str) || str.indexOf(remove) == -1) {
+ return str;
+ }
+ char[] chars = str.toCharArray();
+ int pos = 0;
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i] != remove) {
+ chars[pos++] = chars[i];
+ }
+ }
+ return new String(chars, 0, pos);
+ }
+
+ /**
+ * 문자열 내부의 콤마 character(,)를 모두 제거한다.
+ *
+ *
+ * StringUtil.removeCommaChar(null) = null
+ * StringUtil.removeCommaChar("") = ""
+ * StringUtil.removeCommaChar("asdfg,qweqe") = "asdfgqweqe"
+ *
+ *
+ * @param str 입력받는 기준 문자열
+ * @return " , "가 제거된 입력문자열
+ * 입력문자열이 null인 경우 출력문자열은 null
+ */
+ public static String removeCommaChar(String str) {
+ return remove(str, ',');
+ }
+
+ /**
+ * 문자열 내부의 마이너스 character(-)를 모두 제거한다.
+ *
+ *
+ * StringUtil.removeMinusChar(null) = null
+ * StringUtil.removeMinusChar("") = ""
+ * StringUtil.removeMinusChar("a-sdfg-qweqe") = "asdfgqweqe"
+ *
+ *
+ * @param str 입력받는 기준 문자열
+ * @return " - "가 제거된 입력문자열
+ * 입력문자열이 null인 경우 출력문자열은 null
+ */
+ public static String removeMinusChar(String str) {
+ return remove(str, '-');
+ }
+
+ /**
+ * 원본 문자열의 포함된 특정 문자열을 새로운 문자열로 변환하는 메서드
+ * @param source 원본 문자열
+ * @param subject 원본 문자열에 포함된 특정 문자열
+ * @param object 변환할 문자열
+ * @return sb.toString() 새로운 문자열로 변환된 문자열
+ */
+ public static String replace(String source, String subject, String object) {
+ StringBuffer rtnStr = new StringBuffer();
+ String preStr = "";
+ String nextStr = source;
+ String srcStr = source;
+
+ while (srcStr.indexOf(subject) >= 0) {
+ preStr = srcStr.substring(0, srcStr.indexOf(subject));
+ nextStr = srcStr.substring(srcStr.indexOf(subject) + subject.length(), srcStr.length());
+ srcStr = nextStr;
+ rtnStr.append(preStr).append(object);
+ }
+ rtnStr.append(nextStr);
+
+ return rtnStr.toString();
+ }
+
+ /**
+ * 원본 문자열의 포함된 특정 문자열 첫번째 한개만 새로운 문자열로 변환하는 메서드
+ * @param source 원본 문자열
+ * @param subject 원본 문자열에 포함된 특정 문자열
+ * @param object 변환할 문자열
+ * @return sb.toString() 새로운 문자열로 변환된 문자열 / source 특정문자열이 없는 경우 원본 문자열
+ */
+ public static String replaceOnce(String source, String subject, String object) {
+ StringBuffer rtnStr = new StringBuffer();
+ String preStr = "";
+ String nextStr = source;
+ if (source.indexOf(subject) >= 0) {
+ preStr = source.substring(0, source.indexOf(subject));
+ nextStr = source.substring(source.indexOf(subject) + subject.length(), source.length());
+ rtnStr.append(preStr).append(object).append(nextStr);
+
+ return rtnStr.toString();
+ } else {
+ return source;
+ }
+ }
+
+ /**
+ * subject에 포함된 각각의 문자를 object로 변환한다.
+ *
+ * @param source 원본 문자열
+ * @param subject 원본 문자열에 포함된 특정 문자열
+ * @param object 변환할 문자열
+ * @return sb.toString() 새로운 문자열로 변환된 문자열
+ */
+ public static String replaceChar(String source, String subject, String object) {
+ StringBuffer rtnStr = new StringBuffer();
+ String preStr = "";
+ String nextStr = source;
+ String srcStr = source;
+
+ char chA;
+
+ for (int i = 0; i < subject.length(); i++) {
+ chA = subject.charAt(i);
+
+ if (srcStr.indexOf(chA) >= 0) {
+ preStr = srcStr.substring(0, srcStr.indexOf(chA));
+ nextStr = srcStr.substring(srcStr.indexOf(chA) + 1, srcStr.length());
+ srcStr = rtnStr.append(preStr).append(object).append(nextStr).toString();
+ }
+ }
+
+ return srcStr;
+ }
+
+ /**
+ * str 중 searchStr의 시작(index) 위치를 반환.
+ *
+ * 입력값 중 null이 있을 경우 -1을 반환.
+ *
+ *
+ * StringUtil.indexOf(null, *) = -1
+ * StringUtil.indexOf(*, null) = -1
+ * StringUtil.indexOf("", "") = 0
+ * StringUtil.indexOf("aabaabaa", "a") = 0
+ * StringUtil.indexOf("aabaabaa", "b") = 2
+ * StringUtil.indexOf("aabaabaa", "ab") = 1
+ * StringUtil.indexOf("aabaabaa", "") = 0
+ *
+ *
+ * @param str 검색 문자열
+ * @param searchStr 검색 대상문자열
+ * @return 검색 문자열 중 검색 대상문자열이 있는 시작 위치 검색대상 문자열이 없거나 null인 경우 -1
+ */
+ public static int indexOf(String str, String searchStr) {
+ if (str == null || searchStr == null) {
+ return -1;
+ }
+
+ return str.indexOf(searchStr);
+ }
+
+ /**
+ * 오라클의 decode 함수와 동일한 기능을 가진 메서드이다.
+ * sourStr과 compareStr의 값이 같으면
+ * returStr을 반환하며, 다르면 defaultStr을 반환한다.
+ *
+ *
+ *
+ * StringUtil.decode(null, null, "foo", "bar")= "foo"
+ * StringUtil.decode("", null, "foo", "bar") = "bar"
+ * StringUtil.decode(null, "", "foo", "bar") = "bar"
+ * StringUtil.decode("하이", "하이", null, "bar") = null
+ * StringUtil.decode("하이", "하이 ", "foo", null) = null
+ * StringUtil.decode("하이", "하이", "foo", "bar") = "foo"
+ * StringUtil.decode("하이", "하이 ", "foo", "bar") = "bar"
+ *
+ *
+ * @param sourceStr 비교할 문자열
+ * @param compareStr 비교 대상 문자열
+ * @param returnStr sourceStr와 compareStr의 값이 같을 때 반환할 문자열
+ * @param defaultStr sourceStr와 compareStr의 값이 다를 때 반환할 문자열
+ * @return sourceStr과 compareStr의 값이 동일(equal)할 때 returnStr을 반환하며,
+ *
다르면 defaultStr을 반환한다.
+ */
+ public static String decode(String sourceStr, String compareStr, String returnStr, String defaultStr) {
+ if (sourceStr == null && compareStr == null) {
+ return returnStr;
+ }
+
+ if (sourceStr == null && compareStr != null) {
+ return defaultStr;
+ }
+
+ if (sourceStr.trim().equals(compareStr)) {
+ return returnStr;
+ }
+
+ return defaultStr;
+ }
+
+ /**
+ * 오라클의 decode 함수와 동일한 기능을 가진 메서드이다.
+ * sourStr과 compareStr의 값이 같으면
+ * returStr을 반환하며, 다르면 sourceStr을 반환한다.
+ *
+ *
+ *
+ * StringUtil.decode(null, null, "foo") = "foo"
+ * StringUtil.decode("", null, "foo") = ""
+ * StringUtil.decode(null, "", "foo") = null
+ * StringUtil.decode("하이", "하이", "foo") = "foo"
+ * StringUtil.decode("하이", "하이 ", "foo") = "하이"
+ * StringUtil.decode("하이", "바이", "foo") = "하이"
+ *
+ *
+ * @param sourceStr 비교할 문자열
+ * @param compareStr 비교 대상 문자열
+ * @param returnStr sourceStr와 compareStr의 값이 같을 때 반환할 문자열
+ * @return sourceStr과 compareStr의 값이 동일(equal)할 때 returnStr을 반환하며,
+ *
다르면 sourceStr을 반환한다.
+ */
+ public static String decode(String sourceStr, String compareStr, String returnStr) {
+ return decode(sourceStr, compareStr, returnStr, sourceStr);
+ }
+
+ /**
+ * 객체가 null인지 확인하고 null인 경우 "" 로 바꾸는 메서드
+ * @param object 원본 객체
+ * @return resultVal 문자열
+ */
+ public static String isNullToString(Object object) {
+ String string = "";
+
+ if (object != null) {
+ string = object.toString().trim();
+ }
+
+ return string;
+ }
+
+ /**
+ *
+ * 인자로 받은 String이 null일 경우 ""로 리턴한다.
+ * @param src null값일 가능성이 있는 String 값.
+ * @return 만약 String이 null 값일 경우 ""로 바꾼 String 값.
+ *
+ */
+ public static String nullConvert(Object src) {
+ //if (src != null && src.getClass().getName().equals("java.math.BigDecimal")) {
+ if (src != null && src instanceof java.math.BigDecimal) {
+ return ((BigDecimal) src).toString();
+ }
+
+ if (src == null || src.equals("null")) {
+ return "";
+ } else {
+ return ((String) src).trim();
+ }
+ }
+
+ /**
+ *
+ * 인자로 받은 String이 null일 경우 ""로 리턴한다.
+ * @param src null값일 가능성이 있는 String 값.
+ * @return 만약 String이 null 값일 경우 ""로 바꾼 String 값.
+ *
+ */
+ public static String nullConvert(String src) {
+
+ if (src == null || src.equals("null") || "".equals(src) || " ".equals(src)) {
+ return "";
+ } else {
+ return src.trim();
+ }
+ }
+
+ /**
+ *
+ * 인자로 받은 String이 null일 경우 "0"로 리턴한다.
+ * @param src null값일 가능성이 있는 String 값.
+ * @return 만약 String이 null 값일 경우 "0"로 바꾼 String 값.
+ *
+ */
+ public static int zeroConvert(Object src) {
+
+ if (src == null || src.equals("null")) {
+ return 0;
+ } else {
+ return Integer.parseInt(((String) src).trim());
+ }
+ }
+
+ /**
+ *
+ * 인자로 받은 String이 null일 경우 ""로 리턴한다.
+ * @param src null값일 가능성이 있는 String 값.
+ * @return 만약 String이 null 값일 경우 ""로 바꾼 String 값.
+ *
+ */
+ public static int zeroConvert(String src) {
+
+ if (src == null || src.equals("null") || "".equals(src) || " ".equals(src)) {
+ return 0;
+ } else {
+ return Integer.parseInt(src.trim());
+ }
+ }
+
+ /**
+ * 문자열에서 {@link Character#isWhitespace(char)}에 정의된
+ * 모든 공백문자를 제거한다.
+ *
+ *
+ * StringUtil.removeWhitespace(null) = null
+ * StringUtil.removeWhitespace("") = ""
+ * StringUtil.removeWhitespace("abc") = "abc"
+ * StringUtil.removeWhitespace(" ab c ") = "abc"
+ *
+ *
+ * @param str 공백문자가 제거도어야 할 문자열
+ * @return the 공백문자가 제거된 문자열, null이 입력되면 null이 리턴
+ */
+ public static String removeWhitespace(String str) {
+ if (isEmpty(str)) {
+ return str;
+ }
+ int sz = str.length();
+ char[] chs = new char[sz];
+ int count = 0;
+ for (int i = 0; i < sz; i++) {
+ if (!Character.isWhitespace(str.charAt(i))) {
+ chs[count++] = str.charAt(i);
+ }
+ }
+ if (count == sz) {
+ return str;
+ }
+
+ return new String(chs, 0, count);
+ }
+
+ /**
+ * Html 코드가 들어간 문서를 표시할때 태그에 손상없이 보이기 위한 메서드
+ *
+ * @param strString
+ * @return HTML 태그를 치환한 문자열
+ */
+ public static String checkHtmlView(String strString) {
+ String strNew = "";
+
+ StringBuffer strTxt = new StringBuffer("");
+
+ char chrBuff;
+ int len = strString.length();
+
+ for (int i = 0; i < len; i++) {
+ chrBuff = (char) strString.charAt(i);
+
+ switch (chrBuff) {
+ case '<':
+ strTxt.append("<");
+ break;
+ case '>':
+ strTxt.append(">");
+ break;
+ case '"':
+ strTxt.append(""");
+ break;
+ case 10:
+ strTxt.append("
");
+ break;
+ case ' ':
+ strTxt.append(" ");
+ break;
+ //case '&' :
+ //strTxt.append("&");
+ //break;
+ default:
+ strTxt.append(chrBuff);
+ }
+ }
+
+ strNew = strTxt.toString();
+
+ return strNew;
+ }
+
+ /**
+ * 문자열을 지정한 분리자에 의해 배열로 리턴하는 메서드.
+ * @param source 원본 문자열
+ * @param separator 분리자
+ * @return result 분리자로 나뉘어진 문자열 배열
+ */
+ public static String[] split(String source, String separator) throws NullPointerException {
+ String[] returnVal = null;
+ int cnt = 1;
+
+ int index = source.indexOf(separator);
+ int index0 = 0;
+ while (index >= 0) {
+ cnt++;
+ index = source.indexOf(separator, index + 1);
+ }
+ returnVal = new String[cnt];
+ cnt = 0;
+ index = source.indexOf(separator);
+ while (index >= 0) {
+ returnVal[cnt] = source.substring(index0, index);
+ index0 = index + 1;
+ index = source.indexOf(separator, index + 1);
+ cnt++;
+ }
+ returnVal[cnt] = source.substring(index0);
+
+ return returnVal;
+ }
+
+ /**
+ * {@link String#toLowerCase()}를 이용하여 소문자로 변환한다.
+ *
+ *
+ * StringUtil.lowerCase(null) = null
+ * StringUtil.lowerCase("") = ""
+ * StringUtil.lowerCase("aBc") = "abc"
+ *
+ *
+ * @param str 소문자로 변환되어야 할 문자열
+ * @return 소문자로 변환된 문자열, null이 입력되면 null 리턴
+ */
+ public static String lowerCase(String str) {
+ if (str == null) {
+ return null;
+ }
+
+ return str.toLowerCase();
+ }
+
+ /**
+ * {@link String#toUpperCase()}를 이용하여 대문자로 변환한다.
+ *
+ *
+ * StringUtil.upperCase(null) = null
+ * StringUtil.upperCase("") = ""
+ * StringUtil.upperCase("aBc") = "ABC"
+ *
+ *
+ * @param str 대문자로 변환되어야 할 문자열
+ * @return 대문자로 변환된 문자열, null이 입력되면 null 리턴
+ */
+ public static String upperCase(String str) {
+ if (str == null) {
+ return null;
+ }
+
+ return str.toUpperCase();
+ }
+
+ /**
+ * 입력된 String의 앞쪽에서 두번째 인자로 전달된 문자(stripChars)를 모두 제거한다.
+ *
+ *
+ * StringUtil.stripStart(null, *) = null
+ * StringUtil.stripStart("", *) = ""
+ * StringUtil.stripStart("abc", "") = "abc"
+ * StringUtil.stripStart("abc", null) = "abc"
+ * StringUtil.stripStart(" abc", null) = "abc"
+ * StringUtil.stripStart("abc ", null) = "abc "
+ * StringUtil.stripStart(" abc ", null) = "abc "
+ * StringUtil.stripStart("yxabc ", "xyz") = "abc "
+ *
+ *
+ * @param str 지정된 문자가 제거되어야 할 문자열
+ * @param stripChars 제거대상 문자열
+ * @return 지정된 문자가 제거된 문자열, null이 입력되면 null 리턴
+ */
+ public static String stripStart(String str, String stripChars) {
+ int strLen;
+ if (str == null || (strLen = str.length()) == 0) {
+ return str;
+ }
+ int start = 0;
+ if (stripChars == null) {
+ while ((start != strLen) && Character.isWhitespace(str.charAt(start))) {
+ start++;
+ }
+ } else if (stripChars.length() == 0) {
+ return str;
+ } else {
+ while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {
+ start++;
+ }
+ }
+
+ return str.substring(start);
+ }
+
+ /**
+ * 입력된 String의 뒤쪽에서 두번째 인자로 전달된 문자(stripChars)를 모두 제거한다.
+ *
+ *
+ * StringUtil.stripEnd(null, *) = null
+ * StringUtil.stripEnd("", *) = ""
+ * StringUtil.stripEnd("abc", "") = "abc"
+ * StringUtil.stripEnd("abc", null) = "abc"
+ * StringUtil.stripEnd(" abc", null) = " abc"
+ * StringUtil.stripEnd("abc ", null) = "abc"
+ * StringUtil.stripEnd(" abc ", null) = " abc"
+ * StringUtil.stripEnd(" abcyx", "xyz") = " abc"
+ *
+ *
+ * @param str 지정된 문자가 제거되어야 할 문자열
+ * @param stripChars 제거대상 문자열
+ * @return 지정된 문자가 제거된 문자열, null이 입력되면 null 리턴
+ */
+ public static String stripEnd(String str, String stripChars) {
+ int end;
+ if (str == null || (end = str.length()) == 0) {
+ return str;
+ }
+
+ if (stripChars == null) {
+ while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
+ end--;
+ }
+ } else if (stripChars.length() == 0) {
+ return str;
+ } else {
+ while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
+ end--;
+ }
+ }
+
+ return str.substring(0, end);
+ }
+
+ /**
+ * 입력된 String의 앞, 뒤에서 두번째 인자로 전달된 문자(stripChars)를 모두 제거한다.
+ *
+ *
+ * StringUtil.strip(null, *) = null
+ * StringUtil.strip("", *) = ""
+ * StringUtil.strip("abc", null) = "abc"
+ * StringUtil.strip(" abc", null) = "abc"
+ * StringUtil.strip("abc ", null) = "abc"
+ * StringUtil.strip(" abc ", null) = "abc"
+ * StringUtil.strip(" abcyx", "xyz") = " abc"
+ *
+ *
+ * @param str 지정된 문자가 제거되어야 할 문자열
+ * @param stripChars 제거대상 문자열
+ * @return 지정된 문자가 제거된 문자열, null이 입력되면 null 리턴
+ */
+ public static String strip(String str, String stripChars) {
+ if (isEmpty(str)) {
+ return str;
+ }
+
+ String srcStr = str;
+ srcStr = stripStart(srcStr, stripChars);
+
+ return stripEnd(srcStr, stripChars);
+ }
+
+ /**
+ * 문자열을 지정한 분리자에 의해 지정된 길이의 배열로 리턴하는 메서드.
+ * @param source 원본 문자열
+ * @param separator 분리자
+ * @param arraylength 배열 길이
+ * @return 분리자로 나뉘어진 문자열 배열
+ */
+ public static String[] split(String source, String separator, int arraylength) throws NullPointerException {
+ String[] returnVal = new String[arraylength];
+ int cnt = 0;
+ int index0 = 0;
+ int index = source.indexOf(separator);
+ while (index >= 0 && cnt < (arraylength - 1)) {
+ returnVal[cnt] = source.substring(index0, index);
+ index0 = index + 1;
+ index = source.indexOf(separator, index + 1);
+ cnt++;
+ }
+ returnVal[cnt] = source.substring(index0);
+ if (cnt < (arraylength - 1)) {
+ for (int i = cnt + 1; i < arraylength; i++) {
+ returnVal[i] = "";
+ }
+ }
+
+ return returnVal;
+ }
+
+ /**
+ * 문자열 A에서 Z사이의 랜덤 문자열을 구하는 기능을 제공 시작문자열과 종료문자열 사이의 랜덤 문자열을 구하는 기능
+ *
+ * @param startChr - 첫 문자
+ * @param endChr - 마지막문자
+ * @return 랜덤문자
+ * @exception MyException
+ * @see
+ */
+ public static String getRandomStr(char startChr, char endChr) {
+
+ int randomInt;
+ String randomStr = null;
+
+ // 시작문자 및 종료문자를 아스키숫자로 변환한다.
+ int startInt = Integer.valueOf(startChr);
+ int endInt = Integer.valueOf(endChr);
+
+ // 시작문자열이 종료문자열보가 클경우
+ if (startInt > endInt) {
+ throw new IllegalArgumentException("Start String: " + startChr + " End String: " + endChr);
+ }
+
+ // 랜덤 객체 생성
+ SecureRandom rnd = new SecureRandom();
+
+ do {
+ // 시작문자 및 종료문자 중에서 랜덤 숫자를 발생시킨다.
+ randomInt = rnd.nextInt(endInt + 1);
+ } while (randomInt < startInt); // 입력받은 문자 'A'(65)보다 작으면 다시 랜덤 숫자 발생.
+
+ // 랜덤 숫자를 문자로 변환 후 스트링으로 다시 변환
+ randomStr = (char) randomInt + "";
+
+ // 랜덤문자열를 리턴
+ return randomStr;
+ }
+
+ /**
+ * 문자열을 다양한 문자셋(EUC-KR[KSC5601],UTF-8..)을 사용하여 인코딩하는 기능 역으로 디코딩하여 원래의 문자열을
+ * 복원하는 기능을 제공함 String temp = new String(문자열.getBytes("바꾸기전 인코딩"),"바꿀 인코딩");
+ * String temp = new String(문자열.getBytes("8859_1"),"KSC5601"); => UTF-8 에서
+ * EUC-KR
+ *
+ * @param srcString - 문자열
+ * @param srcCharsetNm - 원래 CharsetNm
+ * @param charsetNm - CharsetNm
+ * @return 인(디)코딩 문자열
+ * @exception MyException
+ * @see
+ */
+ public static String getEncdDcd(String srcString, String srcCharsetNm, String cnvrCharsetNm) {
+
+ String rtnStr = null;
+
+ if (srcString == null)
+ return null;
+
+ try {
+ rtnStr = new String(srcString.getBytes(srcCharsetNm), cnvrCharsetNm);
+ } catch (UnsupportedEncodingException e) {
+ rtnStr = null;
+ }
+
+ return rtnStr;
+ }
+
+ /**
+ * 특수문자를 웹 브라우저에서 정상적으로 보이기 위해 특수문자를 처리('<' -> & lT)하는 기능이다
+ * @param srcString - '<'
+ * @return 변환문자열('<' -> "<"
+ * @exception MyException
+ * @see
+ */
+ public static String getSpclStrCnvr(String srcString) {
+
+ String rtnStr = null;
+
+ StringBuffer strTxt = new StringBuffer("");
+
+ char chrBuff;
+ int len = srcString.length();
+
+ for (int i = 0; i < len; i++) {
+ chrBuff = (char) srcString.charAt(i);
+
+ switch (chrBuff) {
+ case '<':
+ strTxt.append("<");
+ break;
+ case '>':
+ strTxt.append(">");
+ break;
+ case '&':
+ strTxt.append("&");
+ break;
+ default:
+ strTxt.append(chrBuff);
+ }
+ }
+
+ rtnStr = strTxt.toString();
+
+ return rtnStr;
+ }
+
+ /**
+ * 응용어플리케이션에서 고유값을 사용하기 위해 시스템에서17자리의TIMESTAMP값을 구하는 기능
+ *
+ * @param
+ * @return Timestamp 값
+ * @exception MyException
+ * @see
+ */
+ public static String getTimeStamp() {
+
+ String rtnStr = null;
+
+ // 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초))
+ String pattern = "yyyyMMddhhmmssSSS";
+
+ SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA);
+ Timestamp ts = new Timestamp(System.currentTimeMillis());
+
+ rtnStr = sdfCurrent.format(ts.getTime());
+
+ return rtnStr;
+ }
+
+ /**
+ * html의 특수문자를 표현하기 위해
+ *
+ * @param srcString
+ * @return String
+ * @exception Exception
+ * @see
+ */
+ public static String getHtmlStrCnvr(String srcString) {
+
+ String tmpString = srcString;
+
+ tmpString = tmpString.replaceAll("<", "<");
+ tmpString = tmpString.replaceAll(">", ">");
+ tmpString = tmpString.replaceAll("&", "&");
+ tmpString = tmpString.replaceAll(" ", " ");
+ tmpString = tmpString.replaceAll("'", "\'");
+ tmpString = tmpString.replaceAll(""", "\"");
+
+ return tmpString;
+
+ }
+
+ /**
+ * 날짜 형식의 문자열 내부에 마이너스 character(-)를 추가한다.
+ *
+ *
+ * StringUtil.addMinusChar("20100901") = "2010-09-01"
+ *
+ *
+ * @param date 입력받는 문자열
+ * @return " - "가 추가된 입력문자열
+ */
+ public static String addMinusChar(String date) {
+ if (date.length() == 8) {
+ return date.substring(0, 4).concat("-").concat(date.substring(4, 6)).concat("-").concat(date.substring(6, 8));
+ } else {
+ return "";
+ }
+ }
+}
diff --git a/src/main/java/egovframework/com/utl/sim/service/EgovFileMntrg.java b/src/main/java/egovframework/com/utl/sim/service/EgovFileMntrg.java
new file mode 100644
index 0000000..57720b8
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/sim/service/EgovFileMntrg.java
@@ -0,0 +1,333 @@
+/**
+ * Class Name : EgovFileMntrg.java
+ * Description : 시스템 네트워크 정보를 확인하여 제공하는 Business class
+ * Modification Information
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.01.13 조재영 최초 생성
+ * 2017.03.06 조성원 시큐어코딩(ES)-Null Pointer 역참조[CWE-476]
+ *
+ * @author 공통 서비스 개발팀 조재영
+ * @since 2009. 01. 13
+ * @version 1.0
+ * @see
+ *
+ * Copyright (C) 2009 by EGOV All right reserved.
+ */
+package egovframework.com.utl.sim.service;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import egovframework.com.cmm.util.EgovBasicLogger;
+import egovframework.com.cmm.util.EgovResourceCloseHelper;
+
+public class EgovFileMntrg extends Thread {
+
+ /**
+ *
+ * 해당 파일의 변경 유무를 체크하기 위한 Default 초의 stati final 변수, 기본 적용은 값은 60초
+ *
+ */
+ //static final public long DEFAULT_DELAY = 60000; // 60초
+ static final public long DEFAULT_DELAY = 30000; // 30초
+
+ /**
+ * 최대 문자길이
+ **/
+ static final int MAX_STR_LEN = 1024;
+
+ /**
+ *
+ * 파일의 변경 유무를 체크하기 위한 해당파일명 변수
+ *
+ */
+ protected String filename;
+
+ /**
+ *
+ * 해당 파일의 변경 유무를 체크하기 위한 Default 초의 stati final 변수, 기본 적용은 값은 60초{@link
+ * #DEFAULT_DELAY}.
+ *
+ */
+ protected long delay = DEFAULT_DELAY;
+
+ File file; // 타겟(감시대상) 디렉토리
+ File logFile; // 감시정보보관용 로그파일
+ long lastModif = 0;
+ boolean warnedAlready = false;
+ boolean interrupted = false;
+ List realOriginalList = new ArrayList(); // 최초의 원본리스트
+ List originalList = new ArrayList(); // 직전리스트는 주기적으로 직전목록정보로 갱신된다.
+ List currentList = new ArrayList(); // 직전리스트와 비교할 현시점 리스트
+ List changedList = new ArrayList(); // 직전리스트와 비교한 시점에 발생된 변경리스트
+ List totalChangedList = new ArrayList(); // 최초리스트와 비교한 변경 리스트
+ // totalChangedList는 필요시 checkAndConfigure함수 내에서 주석해제후 사용(부하량을 고려하여 사용)
+ int cnt = 0;
+
+ /**
+ *
+ * 감시 하고자 하는 파일명을 파라메타로 받는 기본 컨스트럭터(Constructor).
+ *
+ *
+ * @param filename
+ */
+ protected EgovFileMntrg(String filename, File logFile) {
+ //log.debug("EgovFileMntrg start");
+ this.logFile = logFile;
+ this.filename = filename;
+ file = new File(filename);
+ // 1. 최초생성시 현재 디렉토리의 하위정보를 ArrayList에 보관한다. 보관정보 ==> 절대경로 + "," + 최종수정일시 + "," + 사이즈
+ File[] fList = file.listFiles();
+ //2017.03.06 조성원 시큐어코딩(ES)-Null Pointer 역참조[CWE-476]
+ if(fList == null){
+ fList = new File[0];
+ }
+ for (int i = 0; i < fList.length; i++) {
+ realOriginalList.add(fList[i].getAbsolutePath() + "$" + getLastModifiedTime(fList[i]) + "$" + ((fList[i].length() / 1024) > 0 ? (fList[i].length() / 1024) : 1) + "KB");
+ writeLog("ORI_" + fList[i].getAbsolutePath() + "$" + getLastModifiedTime(fList[i]) + "$" + ((fList[i].length() / 1024) > 0 ? (fList[i].length() / 1024) : 1) + "KB");
+ }
+
+ originalList = new ArrayList(realOriginalList);
+ writeLog("START");
+ setDaemon(true);
+ checkAndConfigure();
+ //log.debug("EgovFileMntrg end");
+ }
+
+ /**
+ *
+ * 감시 하고자 하는 파일의 변경 유무를 체크 하고자 하는 delay 초를 set.
+ *
+ *
+ * @param delay 감시 주기 초
+ */
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+ /**
+ *
+ * 해당 파일의 변경시 작업 할 내용을 기술 할 추상(abstract) 메소드
+ *
+ */
+ //abstract protected void doOnChange();
+ protected void doOnChange(List changedList) {
+ //log.debug("doOnChange() start");
+ for (int i = 0; i < changedList.size(); i++) {
+ writeLog((String) changedList.get(i));
+ }
+ changedList.clear(); //직전리스트와 비교해서 변경된 내역은 로그처리한 후 초기화한다.
+ originalList = new ArrayList(currentList); //현재리스트가 직전리스트가 된다.(새로 생성해야 함!)
+ cnt++;
+
+ //log.debug("doOnChange() end");
+ }
+
+ /**
+ *
+ * 파일의 변경 유무를 체크하는 메소드
+ *
+ */
+ protected void checkAndConfigure() {
+ //log.debug("checkAndConfigure start");
+ try {
+ currentList.clear();
+ file = new File(filename);
+ // 현재정보를 ArrayList에 담는다.
+ File[] fList = file.listFiles();
+ //2017.03.06 조성원 시큐어코딩(ES)-Null Pointer 역참조[CWE-476]
+ if(fList == null){
+ fList = new File[0];
+ }
+
+ for (int i = 0; i < fList.length; i++) {
+ currentList.add(fList[i].getAbsolutePath() + "$" + getLastModifiedTime(fList[i]) + "$" + ((fList[i].length() / 1024) > 0 ? (fList[i].length() / 1024) : 1) + "KB");
+ }
+ /*
+ for(int i = 0; i 0) {
+ //log.debug("change occur , changed file check count:"+cnt+ " , changed file count:"+changedList.size());
+ doOnChange(changedList);
+ }
+
+ if (isEnd()) {
+ //log.debug("Thread Process END !!! (CNT :"+cnt+")");
+ interrupted = true;
+ }
+ //log.debug("checkAndConfigure end"+changedList.size());
+ }
+
+ /**
+ *
+ * 파일의 변경 유무의 체크를 주기적 초 단위로 실행 시키는 메소드
+ *
+ */
+ public void run() {
+ while (!interrupted) {
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ EgovBasicLogger.ignore("Interrupted Exception", e);
+ }
+ checkAndConfigure();
+ }
+ if (interrupted) {
+ this.interrupt();
+ }
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 최종 수정시간를 확인한다.(기본로케일 java.util.Locale.KOREA 기준)
+ *
+ * @param File f 수정일자를 확인할 대상파일
+ * @return String result 최종수정일자를 문자열로 리턴한다.
+ */
+ public static String getLastModifiedTime(File f) {
+ long date = f.lastModified();
+ java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd:HH:mm:ss", java.util.Locale.KOREA);
+ return dateFormat.format(new java.util.Date(date));
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 로그정보를 기록한다.
+ *
+ * @param String logStr 추가할 로그정보(라인단위)
+ * @return boolean result 로그추가 성공여부
+ */
+ public boolean writeLog(String logStr) {
+ boolean result = false;
+
+ FileWriter fWriter = null;
+ BufferedWriter bWriter = null;
+ BufferedReader br = null;
+ try {
+ fWriter = new FileWriter(logFile, true);
+ bWriter = new BufferedWriter(fWriter);
+ br = new BufferedReader(new StringReader(logStr));
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line.length() <= MAX_STR_LEN) {
+ bWriter.write(line + "\n", 0, line.length() + 1);
+ }
+ }
+ result = true;
+ } catch (IOException e) {
+ throw new RuntimeException("File IO exception", e);
+ } finally {
+ EgovResourceCloseHelper.close(br, bWriter, fWriter);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리감시 종료여부를 확인한다. 해당 디렉토리에 대한 로그파일이 삭제된 경우는 감시를 종료한다.
+ *
+ * @return boolean isEnd 감시종료여부 중단하려면 true 리턴, 계속하려면 false 리턴
+ */
+ public boolean isEnd() {
+ //log.debug("isEnd start");
+ boolean isEnd = false;
+ String lastStr = "";
+ BufferedReader br = null;
+ FileReader fr = null;
+
+ try {
+ if (logFile.exists()) {
+ //로그파일을 읽어서 마지막 끝에 END가 있으면 종료된것임
+
+ fr = new FileReader(logFile);
+ br = new BufferedReader(fr);
+ //int ch = 0;
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line.length() <= MAX_STR_LEN) {
+ lastStr = line;
+ }
+ }
+ if (lastStr.equals("END")) {
+ isEnd = true;
+ }
+ } else {
+ //로그파일이 없는 경우(삭제된 경우)도 종료한다.
+ isEnd = true;
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("File IO exception", e);
+ } finally {
+ EgovResourceCloseHelper.close(br, fr);
+ }
+ return isEnd;
+ }
+}
diff --git a/src/main/java/egovframework/com/utl/sim/service/EgovFileScrty.java b/src/main/java/egovframework/com/utl/sim/service/EgovFileScrty.java
new file mode 100644
index 0000000..a227f60
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/sim/service/EgovFileScrty.java
@@ -0,0 +1,307 @@
+/**
+ * Class Name : EgovFileScrty.java
+ * Description : Base64인코딩/디코딩 방식을 이용한 데이터를 암호화/복호화하는 Business Interface class
+ * Modification Information
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.02.04 박지욱 최초 생성
+ * 2017.02.07 이정은 시큐어코딩(ES)-솔트 없이 일방향 해쉬함수 사용[CWE-759]
+ *
+ * @author 공통 서비스 개발팀 박지욱
+ * @since 2009. 02. 04
+ * @version 1.0
+ * @see
+ *
+ * Copyright (C) 2009 by MOPAS All right reserved.
+ */
+package egovframework.com.utl.sim.service;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.security.MessageDigest;
+import java.security.SecureRandom;
+
+import egovframework.com.cmm.util.EgovResourceCloseHelper;
+
+import org.apache.commons.codec.binary.Base64;
+
+public class EgovFileScrty {
+
+ // 파일구분자
+ static final char FILE_SEPARATOR = File.separatorChar;
+
+ static final int BUFFER_SIZE = 1024;
+
+ /**
+ * 파일을 암호화하는 기능
+ *
+ * @param String source 암호화할 파일
+ * @param String target 암호화된 파일
+ * @return boolean result 암호화여부 True/False
+ * @exception Exception
+ */
+ public static boolean encryptFile(String source, String target) throws IOException {
+
+ // 암호화 여부
+ boolean result = false;
+
+ String sourceFile = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ String targetFile = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(sourceFile);
+
+ BufferedInputStream input = null;
+ BufferedOutputStream output = null;
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+
+ try {
+ if (srcFile.exists() && srcFile.isFile()) {
+
+ input = new BufferedInputStream(new FileInputStream(srcFile));
+ output = new BufferedOutputStream(new FileOutputStream(targetFile));
+
+ int length = 0;
+ while ((length = input.read(buffer)) >= 0) {
+ byte[] data = new byte[length];
+ System.arraycopy(buffer, 0, data, 0, length);
+ output.write(encodeBinary(data).getBytes());
+ output.write(System.getProperty("line.separator").getBytes());
+ }
+ result = true;
+ }
+ } finally {
+ EgovResourceCloseHelper.close(input, output);
+ }
+
+ return result;
+ }
+
+ /**
+ * 파일을 복호화하는 기능
+ *
+ * @param String source 복호화할 파일
+ * @param String target 복호화된 파일
+ * @return boolean result 복호화여부 True/False
+ * @exception Exception
+ */
+ public static boolean decryptFile(String source, String target) throws IOException {
+
+ // 복호화 여부
+ boolean result = false;
+
+ String sourceFile = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ String targetFile = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(sourceFile);
+
+ BufferedReader input = null;
+ BufferedOutputStream output = null;
+
+ //byte[] buffer = new byte[BUFFER_SIZE];
+ String line = null;
+
+ try {
+ if (srcFile.exists() && srcFile.isFile()) {
+
+ input = new BufferedReader(new InputStreamReader(new FileInputStream(srcFile)));
+ output = new BufferedOutputStream(new FileOutputStream(targetFile));
+
+ while ((line = input.readLine()) != null) {
+ byte[] data = line.getBytes();
+ output.write(decodeBinary(new String(data)));
+ }
+
+ result = true;
+ }
+ } finally {
+ EgovResourceCloseHelper.close(input, output);
+ }
+
+ return result;
+ }
+
+ /**
+ * 데이터를 암호화하는 기능
+ *
+ * @param byte[] data 암호화할 데이터
+ * @return String result 암호화된 데이터
+ * @exception Exception
+ */
+ public static String encodeBinary(byte[] data) throws IOException, RuntimeException {
+ if (data == null) {
+ return "";
+ }
+
+ return new String(Base64.encodeBase64(data));
+ }
+
+ /**
+ * 데이터를 암호화하는 기능
+ *
+ * @param String data 암호화할 데이터
+ * @return String result 암호화된 데이터
+ * @exception Exception
+ */
+ @Deprecated
+ public static String encode(String data) throws Exception {
+ return encodeBinary(data.getBytes());
+ }
+
+ /**
+ * 데이터를 복호화하는 기능
+ *
+ * @param String data 복호화할 데이터
+ * @return String result 복호화된 데이터
+ * @exception Exception
+ */
+ public static byte[] decodeBinary(String data) throws IOException, RuntimeException {
+ return Base64.decodeBase64(data.getBytes());
+ }
+
+ /**
+ * 데이터를 복호화하는 기능
+ *
+ * @param String data 복호화할 데이터
+ * @return String result 복호화된 데이터
+ * @exception Exception
+ */
+ @Deprecated
+ public static String decode(String data) throws Exception {
+ return new String(decodeBinary(data));
+ }
+
+ /**
+ * 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용).
+ *
+ * deprecated : 보안 강화를 위하여 salt로 ID를 지정하는 encryptPassword(password, id) 사용
+ *
+ * @param String data 암호화할 비밀번호
+ * @return String result 암호화된 비밀번호
+ * @exception Exception
+ */
+ @Deprecated
+ public static String encryptPassword(String data) throws Exception {
+
+ if (data == null) {
+ return "";
+ }
+
+ byte[] plainText = null; // 평문
+ byte[] hashValue = null; // 해쉬값
+ plainText = data.getBytes();
+
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+
+ //2017.02.07 이정은 시큐어코딩(ES)-솔트 없이 일방향 해쉬함수 사용[CWE-759]
+ // 변경 시 기존 hash 값에 검증 불가.. => deprecated 시키고 유지
+ // Random 방식의 salt 추가
+ SecureRandom ng = new SecureRandom();
+ byte[] randomBytes = new byte[16];
+ ng.nextBytes(randomBytes);
+
+ md.reset();
+ md.update(randomBytes);
+
+
+ hashValue = md.digest(plainText);
+
+ /*
+ BASE64Encoder encoder = new BASE64Encoder();
+ return encoder.encode(hashValue);
+ */
+ return new String(Base64.encodeBase64(hashValue));
+ }
+
+ /**
+ * 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용)
+ *
+ * @param password 암호화될 패스워드
+ * @param id salt로 사용될 사용자 ID 지정
+ * @return
+ * @throws Exception
+ */
+ public static String encryptPassword(String password, String id) throws Exception {
+
+ if (password == null) {
+ return "";
+ }
+
+ byte[] hashValue = null; // 해쉬값
+
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+
+ md.reset();
+ md.update(id.getBytes());
+
+ hashValue = md.digest(password.getBytes());
+
+ return new String(Base64.encodeBase64(hashValue));
+ }
+
+ /**
+ * 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용)
+ * @param data 암호화할 비밀번호
+ * @param salt Salt
+ * @return 암호화된 비밀번호
+ * @throws Exception
+ */
+ public static String encryptPassword(String data, byte[] salt) throws Exception {
+
+ if (data == null) {
+ return "";
+ }
+
+ byte[] hashValue = null; // 해쉬값
+
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+
+ md.reset();
+ md.update(salt);
+
+ hashValue = md.digest(data.getBytes());
+
+ return new String(Base64.encodeBase64(hashValue));
+ }
+
+ /**
+ * 비밀번호를 암호화된 패스워드 검증(salt가 사용된 경우만 적용).
+ *
+ * @param data 원 패스워드
+ * @param encoded 해쉬처리된 패스워드(Base64 인코딩)
+ * @return
+ * @throws Exception
+ */
+ public static boolean checkPassword(String data, String encoded, byte[] salt) throws Exception {
+ byte[] hashValue = null; // 해쉬값
+
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+
+ md.reset();
+ md.update(salt);
+ hashValue = md.digest(data.getBytes());
+
+ return MessageDigest.isEqual(hashValue, Base64.decodeBase64(encoded.getBytes()));
+ }
+
+ /*
+ public static void main(String[] args) {
+ try {
+ String password = "abc";
+ String salt = "def";
+
+ String first = encryptPassword(password, salt.getBytes());
+ String second = encryptPassword(password, salt.getBytes());
+ System.out.println(password + " => " + first + " : " + checkPassword(password, first, salt.getBytes()));
+ System.out.println(password + " => " + second + " : " + checkPassword(password, second, salt.getBytes()));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ */
+}
diff --git a/src/main/java/egovframework/com/utl/sim/service/EgovFileTool.java b/src/main/java/egovframework/com/utl/sim/service/EgovFileTool.java
new file mode 100644
index 0000000..fc6f5bb
--- /dev/null
+++ b/src/main/java/egovframework/com/utl/sim/service/EgovFileTool.java
@@ -0,0 +1,3034 @@
+/**
+ * Class Name : EgovFileTool.java
+ * Description : 시스템 디렉토리 정보를 확인하여 제공하는 Business class
+ * Modification Information
+ *
+ * 수정일 수정자 수정내용
+ * ------- -------- ---------------------------
+ * 2009.01.13 조재영 최초 생성
+ * 2017.03.03 조성원 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ * 2017.03.03 조성원 시큐어코딩(ES)-Null Pointer 역참조[CWE-476]
+ * 2018.03.19 신용호 createDirectories() 추가 : 여러 레벨의 디렉토리를 한번에 생성
+ *
+ *
+ * @author 공통 서비스 개발팀 조재영,박지욱
+ * @since 2009. 01. 13
+ * @version 1.0
+ * @see
+ *
+ * Copyright (C) 2009 by MOPAS All right reserved.
+ */
+package egovframework.com.utl.sim.service;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import egovframework.com.cmm.EgovWebUtil;
+import egovframework.com.cmm.service.EgovProperties;
+import egovframework.com.cmm.service.Globals;
+import egovframework.com.cmm.util.EgovResourceCloseHelper;
+import egovframework.com.utl.fcc.service.EgovStringUtil;
+
+public class EgovFileTool {
+
+ // 파일사이즈 1K
+ static final long BUFFER_SIZE = 1024L;
+ // 파일구분자
+ static final char FILE_SEPARATOR = File.separatorChar;
+ // 윈도우시스템 파일 접근권한
+ static final char ACCESS_READ = 'R'; // 읽기전용
+ static final char ACCESS_SYS = 'S'; // 시스템
+ static final char ACCESS_HIDE = 'H'; // 숨김
+ // 최대 문자길이
+ static final int MAX_STR_LEN = 1024;
+
+ // LOGGER
+ private static final Logger LOGGER = LoggerFactory.getLogger(EgovFileTool.class);
+
+ /**
+ *
+ * Comment : 디렉토리 존재여부를 확인한다. (단일디렉토리 확인용)
+ *
+ *
+ * @param String targetDirPath 존재여부를 확인할 디렉토리의 절대경로
+ * @return String result 존재하는 디렉토리 경로를 리턴한다.
+ */
+ public static boolean getExistDirectory(String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (targetDirPath == null || targetDirPath.equals("")) {
+ return false;
+ }
+
+ boolean result = false;
+ File f = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ if (f.exists() && f.isDirectory()) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리 존재여부를 확인한다. (하위디렉토리 확인용)
+ *
+ *
+ * @param String baseDirPath 존재여부를 확인할 디렉토리명의 기준경로
+ * @param String targetDirPath 확인할 대상 디렉토리. baseDirPath 하위에서 존재여부를 확인한다.
+ * @param int cnt 확인할 디렉토리 갯수 (0보다 큰값이 입력되어야 한다. -1 입력시 21474846까지 찾도록 지원함 )
+ * @return String result 존재하는 디렉토리 경로를 리턴한다.
+ */
+ public static List getExistDirectory(String baseDirPath, String targetDirPath, int cnt) throws Exception {
+
+ // 인자값 유효하지 않은 경우 빈 ArrayList 리턴
+ if (baseDirPath == null || baseDirPath.equals("") || targetDirPath == null || targetDirPath.equals("") || cnt == 0) {
+ return new ArrayList();
+ }
+ int dirCnt = 0;
+ if (cnt < 0) {
+ dirCnt = 21474846;
+ } else {
+ dirCnt = cnt;
+ }
+
+ // 찾은 결과를 전달할 ArrayList
+ List result = new ArrayList();
+ // 하위의 결과를 임시 보관할 ArrayList
+ List subResult = new ArrayList();
+ // 현재경로(baseDirPath)에서 발견된 targetDirPath 갯수
+ int dirFindCnt = 0;
+ boolean isExist = false;
+ String[] dirList = null;
+ String subDirPath = "";
+ File f = null;
+
+ f = new File(EgovWebUtil.filePathBlackList(baseDirPath));
+ isExist = f.exists();
+
+ if (isExist) {
+ dirList = f.list();
+ }
+
+ for (int i = 0; dirList != null && i < dirList.length; i++) {
+ //log.debug("dirList["+i+"]:"+dirList[i] +"--->"+baseDirPath+"/"+dirList[i]);
+ subDirPath = baseDirPath + "/" + dirList[i];
+ //log.debug("_"+targetDirPath+"_");
+ //log.debug("_"+dirList[i]+"_");
+
+ f = new File(EgovWebUtil.filePathBlackList(subDirPath));
+
+ //현재경로(baseDirPath)에서 검색
+ if (targetDirPath.equals(dirList[i])) {
+ // 중간에 발견하면 반복체크는 종료한다.(결과요청 갯수에 도달한 경우에 한해) - 이곳에서 종료되면 이후 하위에서 체크할 필요가 없다.
+ if (new File(EgovWebUtil.filePathBlackList(baseDirPath) + "/" + dirList[i]).isDirectory()) {
+ dirFindCnt++;
+ result.add(baseDirPath + "/" + dirList[i]);
+ if (dirFindCnt == dirCnt) {
+ break;
+ }
+ }
+ }
+
+ //현재경로(baseDirPath)에서 발견된 하위 경로에서 반복하여 재귀적으로 검색
+ int subCnt = dirCnt - dirFindCnt;
+ if (f.isDirectory()) {
+ //log.debug("f.isDirectory():"+f.isDirectory());
+ subResult = getExistDirectory(subDirPath, targetDirPath, subCnt);
+ // 하위에서 발견된 디렉토리 갯수를 현재까지 찾은 디렉토리갯수에 추가한다.
+ dirFindCnt = dirFindCnt + subResult.size();
+ // 하위에서 모두 발견된 경우 반복 체크는 종료한다.
+ if (dirCnt <= dirFindCnt) {
+ for (int j = 0; j < subResult.size(); j++) {
+ result.add((String) subResult.get(j));
+ }
+
+ break;
+ } else {
+ for (int j = 0; j < subResult.size(); j++) {
+ result.add((String) subResult.get(j));
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리 존재여부를 확인한다. (생성일자를 조건으로 조건구간내 포함되는지 확인)
+ *
+ *
+ * @param String targetDirPath 존재여부를 확인할 디렉토리의 절대경로
+ * @param String fromDate 생성일자 조건에 해당하는 시작일자(YYYYMMDD 형태로 입력)
+ * @param String toDate 생성일자 조건에 해당하는 종료일자(YYYYMMDD 형태로 입력)
+ * @return String result 존재하는 디렉토리 경로를 리턴한다.
+ */
+ public static boolean getExistDirectory(String targetDirPath, String fromDate, String toDate) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (targetDirPath == null || targetDirPath.equals("") || fromDate == null || fromDate.equals("") || toDate == null || toDate.equals("")) {
+ return false;
+ }
+
+ boolean result = false;
+ String lastModifyedDate = "";
+ File f = null;
+
+ f = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ lastModifyedDate = getLastModifiedDateFromFile(f);
+ //log.debug("getLastModifiedDateFromFile(f):"+lastModifyedDate);
+ if (Integer.parseInt(lastModifyedDate) >= Integer.parseInt(fromDate) && Integer.parseInt(lastModifyedDate) <= Integer.parseInt(toDate)) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리 존재여부를 확인한다. (생성자를 조건으로 일치하는지 확인)
+ *
+ *
+ * @param String targetDirPath 존재여부를 확인할 디렉토리의 절대경로
+ * @param String ownerName 생성자명(계정정보)
+ * @return String result 존재하는 디렉토리 경로를 리턴한다.
+ */
+ public static boolean getExistDirectory(String targetDirPath, String ownerName) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (targetDirPath == null || targetDirPath.equals("") || ownerName == null || ownerName.equals("")) {
+ return false;
+ }
+
+ boolean result = false;
+ //String tmp = "";
+
+ // 실행할 명령을 프로퍼티 파일에서 확인한다.
+ //Process p = null;
+
+ String realOwner = getOwner(targetDirPath);
+ if (ownerName.equals(realOwner)) {
+ result = true;
+ } else {
+ result = false;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 최종 수정일자를 확인한다. (기본로케일 java.util.Locale.KOREA 기준)
+ *
+ *
+ * @param File f 수정일자를 확인할 대상파일
+ * @return String result 최종수정일자를 문자열로 리턴한다.
+ */
+ public static String getLastModifiedDateFromFile(File f) {
+
+ String result = "";
+
+ if (f.exists()) {
+ long date = f.lastModified();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
+ result = dateFormat.format(new java.util.Date(date));
+ } else {
+ result = "";
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 최종 수정일자를 확인한다. (기본로케일 java.util.Locale.KOREA 기준)
+ *
+ *
+ * @param String filePath 수정일자를 확인할 대상파일경로
+ * @return String result 최종수정일자를 문자열로 리턴한다.
+ */
+ public static String getLastModifiedDateFromFile(String filePath) {
+
+ File f = null;
+ String result = "";
+ f = new File(EgovWebUtil.filePathBlackList(filePath));
+ result = getLastModifiedDateFromFile(f);
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 조건구간내에 생성된 디렉토리 목록을 조회한다.
+ *
+ *
+ * @param String filePath 하위디렉토리를 확인할 경로
+ * @param String fromDate 조건시작일
+ * @param String toDate 조건 종료일
+ * @return ArrayList result 조건구간내에 생성된 디렉토리 목록을 리턴한다.
+ */
+ public static List getLastDirectoryForModifiedDate(String baseDirPath, String fromDate, String toDate) {
+
+ // 인자값 유효하지 않은 경우 빈 ArrayList 리턴
+ if (baseDirPath == null || baseDirPath.equals("") || fromDate == null || fromDate.equals("") || toDate == null || toDate.equals("")) {
+ return new ArrayList();
+ }
+
+ File f = null;
+ File childFile = null;
+ String[] subDirList;
+ String subDirPath = "";
+ List childResult = null;
+ List result = new ArrayList();
+
+ f = new File(EgovWebUtil.filePathBlackList(baseDirPath));
+ subDirList = f.list();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (subDirList != null) {
+ for (int i = 0; i < subDirList.length; i++) {
+
+ subDirPath = baseDirPath + "/" + subDirList[i];
+ childFile = new File(EgovWebUtil.filePathBlackList(subDirPath));
+ if (childFile.isDirectory()) {
+ //childResult = getLastDirectoryForModifiedDate(subDirPath , fromDate, toDate);
+ String lastModifyedDate = getLastModifiedDateFromFile(childFile);
+ if (Integer.parseInt(lastModifyedDate) >= Integer.parseInt(fromDate) && Integer.parseInt(lastModifyedDate) <= Integer.parseInt(toDate)) {
+ result.add(baseDirPath + "/" + subDirList[i]);
+ }
+ childResult = getLastDirectoryForModifiedDate(baseDirPath + "/" + subDirList[i], fromDate, toDate);
+ // 하위디렉토리의 결과를 추가한다.
+ for (int j = 0; j < childResult.size(); j++) {
+ result.add((String) childResult.get(j));
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 읽기권한을 확인한다.
+ *
+ *
+ * @param String filePath 읽기권한을 확인할 대상파일경로
+ * @return boolean result 읽기가능하면 true를 리턴한다. 권한이 없어가 파일이 없는 경우는 false를 리턴한다.
+ */
+ public static boolean canRead(String filePath) {
+
+ // 인자값 유효하지 않은 경우 빈 false 리턴
+ if (filePath == null || filePath.equals("")) {
+ return false;
+ }
+
+ File f = null;
+ boolean result = false;
+ f = new File(EgovWebUtil.filePathBlackList(filePath));
+ if (f.exists()) {
+ result = f.canRead();
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 쓰기권한을 확인한다.(대상경로가 파일인 경우만 정보가 유효함)
+ *
+ *
+ * @param String filePath 쓰기권한을 확인할 대상파일경로
+ * @return boolean result 쓰기가능하면 true를 리턴한다. 권한이 없어가 파일이 없는 경우는 false를 리턴한다.
+ */
+ public static boolean canWrite(String filePath) {
+
+ // 인자값 유효하지 않은 경우 빈 false 리턴
+ if (filePath == null || filePath.equals("")) {
+ return false;
+ }
+
+ File f = null;
+ boolean result = false;
+ f = new File(EgovWebUtil.filePathBlackList(filePath));
+ if (f.exists()) {
+ result = f.canWrite();
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)의 이름을 확인한다.
+ *
+ *
+ * @param String filePath 이름을 확인할 대상경로
+ * @return String result 이름을 리턴한다. 존재하지 않는 경우는 블랭크를 리턴한다.
+ */
+ public static String getName(String filePath) {
+
+ // 인자값 유효하지 않은 경우 빈 false 리턴
+ if (filePath == null || filePath.equals("")) {
+ return "";
+ }
+
+ File f = null;
+ String result = "";
+
+ f = new File(EgovWebUtil.filePathBlackList(filePath));
+ if (f.exists()) {
+ result = f.getName();
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리(파일)를 삭제한다. (파일,디렉토리 구분없이 존재하는 경우 무조건 삭제한다)
+ *
+ *
+ * @param filePathToBeDeleted 삭제하고자 하는 파일의 절대경로 + 파일명
+ * @return 성공하면 삭제된 절대경로, 아니면블랭크
+ */
+
+ public static String deletePath(String filePath) {
+ File file = new File(EgovWebUtil.filePathBlackList(filePath));
+ String result = "";
+
+ if (file.exists()) {
+ result = file.getAbsolutePath();
+ if (!file.delete()) {
+ result = "";
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 생성한다.
+ *
+ *
+ * @param dirPath 생성하고자 하는 절대경로
+ * @return 성공하면 생성된 절대경로, 아니면 블랭크
+ */
+
+ public static String createDirectory(String dirPath) {
+ File file = new File(EgovWebUtil.filePathBlackList(dirPath));
+ String result = "";
+ try {
+ if (!file.exists()) {
+ //2017.02.08 이정은 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ if(file.createNewFile()){
+ LOGGER.debug("[file.createNewFile] file : Path Creation Success");
+ }else{
+ LOGGER.error("[file.createNewFile] file : Path Creation Fail");
+ }
+ file.getAbsolutePath();
+ }
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 생성한다. (여러 레벨의 경로를 동시에 생성)
+ *
+ *
+ * @param dirPath 생성하고자 하는 절대경로
+ * @return 성공하면 생성된 절대경로, 아니면 블랭크
+ */
+ public static String createDirectories(String dirPath) {
+ File file = new File(EgovWebUtil.filePathBlackList(dirPath));
+ String result = "";
+
+ if (!file.exists()) {
+ if(file.mkdirs()) {
+ LOGGER.debug("[file.mkdirs] file : Path Creation Success");
+ }else{
+ LOGGER.error("[file.mkdirs] file : Path Creation Fail");
+ }
+ file.getAbsolutePath();
+ }
+
+ return result;
+ }
+
+ /**
+ * 디렉토리에 파일이 존재하는지 체크하는 기능
+ *
+ * @param String dir 디렉토리
+ * @param String file 파일
+ * @return boolean result 존재여부 True / False
+ * @exception Exception
+ */
+ public static boolean checkFileExstByName(String dir, String file) throws Exception {
+
+ // 파일 존재 여부
+ boolean result = false;
+
+ // 디렉토리 오픈
+ String drctry = dir.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcDrctry = new File(EgovWebUtil.filePathBlackList(drctry));
+
+ // 디렉토리이면서, 존재하면
+ if (srcDrctry.exists() && srcDrctry.isDirectory()) {
+
+ // 디렉토리 안 목록을 조회한다. (파일명)
+ File[] fileArray = srcDrctry.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByName(fileArray, file);
+ if (list != null && list.size() > 0) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 확장자별로 디렉토리에 파일이 존재하는지 체크하는 기능
+ *
+ * @param String dir 디렉토리
+ * @param String eventn 확장자명(.txt 형태 입력)
+ * @return boolean result 존재여부 True / False
+ * @exception Exception
+ */
+ public static boolean checkFileExstByExtnt(String dir, String eventn) throws Exception {
+
+ // 파일 존재 여부
+ boolean result = false;
+
+ // 디렉토리 오픈
+ String drctry = dir.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcDrctry = new File(EgovWebUtil.filePathBlackList(drctry));
+
+ // 디렉토리이면서, 존재하면
+ if (srcDrctry.exists() && srcDrctry.isDirectory()) {
+
+ // 디렉토리 안 목록을 조회한다. (확장자별)
+ File[] fileArray = srcDrctry.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByExtnt(fileArray, eventn);
+ if (list != null && list.size() > 0) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 디렉토리에 생성자별 파일이 존재하는지 체크하는 기능
+ *
+ * @param String dir 디렉토리
+ * @param String owner 생성자
+ * @return boolean result 존재여부 True / False
+ * @exception Exception
+ */
+ public static boolean checkFileExstByOwner(String dir, String owner) throws Exception {
+
+ // 파일 존재 여부
+ boolean result = false;
+
+ // 디렉토리 오픈
+ String drctry = dir.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcDrctry = new File(EgovWebUtil.filePathBlackList(drctry));
+
+ // 디렉토리이면서, 존재하면
+ if (srcDrctry.exists() && srcDrctry.isDirectory()) {
+
+ // 디렉토리 안 목록을 조회한다. (생성자)
+ File[] fileArray = srcDrctry.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByOwner(fileArray, owner);
+ if (list != null && list.size() > 0) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 수정기간별로 디렉토리에 파일이 존재하는지 체크하는 기능
+ *
+ * @param String dir 디렉토리
+ * @param String updtFrom 수정일자From(YYYYMMDD 형태로 입력)
+ * @param String updtTo 수정일자To(YYYYMMDD 형태로 입력)
+ * @return boolean result 존재여부 True / False
+ * @exception Exception
+ */
+ public static boolean checkFileExstByUpdtPd(String dir, String updtFrom, String updtTo) throws Exception {
+
+ // 파일 존재 여부
+ boolean result = false;
+
+ // 디렉토리 오픈
+ String drctry = dir.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcDrctry = new File(EgovWebUtil.filePathBlackList(drctry));
+
+ // 디렉토리이면서, 존재하면
+ if (srcDrctry.exists() && srcDrctry.isDirectory()) {
+
+ // 디렉토리 안 목록을 조회한다. (수정기간별)
+ File[] fileArray = srcDrctry.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByUpdtPd(fileArray, updtFrom, updtTo);
+ if (list != null && list.size() > 0) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 사이즈별로 디렉토리에 파일이 존재하는지 체크하는 기능
+ *
+ * @param String dir 디렉토리
+ * @param long sizeFrom 사이즈From (KB)
+ * @param long sizeTo 사이즈To (KB)
+ * @return boolean result 존재여부 True / False
+ * @exception Exception
+ */
+ public static boolean checkFileExstBySize(String dir, long sizeFrom, long sizeTo) throws Exception {
+
+ // 파일 존재 여부
+ boolean result = false;
+
+ // 디렉토리 오픈
+ String drctry = dir.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcDrctry = new File(EgovWebUtil.filePathBlackList(drctry));
+
+ // 디렉토리이면서, 존재하면
+ if (srcDrctry.exists() && srcDrctry.isDirectory()) {
+
+ // 디렉토리 안 목록을 조회한다. (사이즈별)
+ File[] fileArray = srcDrctry.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesBySize(fileArray, sizeFrom, sizeTo);
+ if (list != null && list.size() > 0) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 디렉토리 내부 하위목록들 중에서 파일을 찾는 기능(모든 목록 조회)
+ *
+ * @param File[] fileArray 파일목록
+ * @return ArrayList list 파일목록(절대경로)
+ * @exception Exception
+ */
+ public static List getSubFilesByAll(File[] fileArray) throws Exception {
+
+ ArrayList list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ list.addAll(getSubFilesByAll(tmpArray));
+ // 파일이면 담는다.
+ } else {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 디렉토리 내부 하위목록들 중에서 파일을 찾는 기능(파일명)
+ *
+ * @param File[] fileArray 파일목록
+ * @param String file 파일명
+ * @return ArrayList list 파일목록(절대경로)
+ * @exception Exception
+ */
+ public static List getSubFilesByName(File[] fileArray, String file) throws Exception {
+
+ List list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ list.addAll(getSubFilesByName(tmpArray, file));
+ // 파일이면 파일명이 같은지 비교한다.
+ } else {
+ if (fileArray[i].getName().equals(file)) {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 디렉토리 내부 하위목록들 중에서 파일을 찾는 기능(확장자별)
+ *
+ * @param File[] fileArray 파일목록
+ * @param String extnt 확장자
+ * @return ArrayList list 파일목록(절대경로)
+ * @exception Exception
+ */
+ public static List getSubFilesByExtnt(File[] fileArray, String extnt) throws Exception {
+
+ List list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ list.addAll(getSubFilesByExtnt(tmpArray, extnt));
+ // 파일이면 확장자명이 들어있는지 비교한다.
+ } else {
+ if (fileArray[i].getName().indexOf(extnt) != -1) {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 디렉토리 내부 하위목록들 중에서 파일을 찾는 기능(최종수정기간별)
+ *
+ * @param File[] fileArray 파일목록
+ * @param String updtFrom 수정일자From(YYYYMMDD 형태로 입력)
+ * @param String updtTo 수정일자To(YYYYMMDD 형태로 입력)
+ * @return ArrayList list 파일목록(절대경로)
+ * @exception Exception
+ */
+ public static List getSubFilesByUpdtPd(File[] fileArray, String updtFrom, String updtTo) throws Exception {
+
+ List list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ list.addAll(getSubFilesByUpdtPd(tmpArray, updtFrom, updtTo));
+ // 파일이면 수정기간내에 존재하는지 비교한다.
+ } else {
+ // 파일의 최종수정일자 조회
+ long date = fileArray[i].lastModified();
+ java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
+ String lastUpdtDate = dateFormat.format(new java.util.Date(date));
+ // 수정기간 내에 존재하는지 확인
+ if (Integer.parseInt(lastUpdtDate) >= Integer.parseInt(updtFrom) && Integer.parseInt(lastUpdtDate) <= Integer.parseInt(updtTo)) {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 디렉토리 내부 하위목록들 중에서 파일을 찾는 기능(사이즈별)
+ *
+ * @param File[] fileArray 파일목록
+ * @param long sizeFrom 사이즈From(KB)
+ * @param long sizeTo 사이즈To(KB)
+ * @return ArrayList list 파일목록(절대경로)
+ * @exception Exception
+ */
+ public static List getSubFilesBySize(File[] fileArray, long sizeFrom, long sizeTo) throws Exception {
+
+ List list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ list.addAll(getSubFilesBySize(tmpArray, sizeFrom, sizeTo));
+ // 파일이면, 사이즈내에 존재하는지 비교한다.
+ } else {
+ // 파일의 사이즈 조회
+ long size = fileArray[i].length();
+ // 사이즈 내에 존재하는지 확인
+ if (size >= (sizeFrom * BUFFER_SIZE) && size <= (sizeTo * BUFFER_SIZE)) {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 디렉토리 내부 하위목록들 중에서 파일을 찾는 기능(생성자별)
+ *
+ * @param File[] fileArray 파일목록
+ * @param String creator 생성자
+ * @return ArrayList list 파일목록(절대경로)
+ * @exception Exception
+ */
+ public static List getSubFilesByOwner(File[] fileArray, String owner) throws Exception {
+
+ List list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ List list1 = getSubFilesByOwner(tmpArray, owner);
+ if (list1 != null)
+ list.addAll(list1);
+
+ // 파일이면, 생성자가 같은지 비교한다.
+ } else {
+ // 파일 생성자 조회
+ String fullpath = EgovWebUtil.filePathBlackList(fileArray[i].getAbsolutePath());
+ Process p = null;
+ if (Globals.OS_TYPE.equals("UNIX")) {
+ String[] command = { EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".getDrctryByOwner"),
+ fullpath.substring(0, fullpath.lastIndexOf("/")), fullpath.substring(fullpath.lastIndexOf("/"), fullpath.length()), owner };
+ p = Runtime.getRuntime().exec(command);
+ p.waitFor();
+ } else if (Globals.OS_TYPE.equals("WINDOWS")) {
+ String command = EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".getDrctryByOwner");
+ p = Runtime.getRuntime().exec(command);
+ p.waitFor();
+ }
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ BufferedReader b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ try {
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err);
+ }
+ }
+ //프로세스 실행 성공시 결과 확인
+ else {
+ BufferedReader b_out = null;
+ try {
+ //2017.03.03 조성원 시큐어코딩(ES)-Null Pointer 역참조[CWE-476]
+ if(p != null){
+ b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (b_out.ready()) {
+ // 결과문자가 있으면 생성자가 일치하는 파일이 존재한다는 의미
+ String tmpStr = b_out.readLine();
+ if (tmpStr != null && "".equals(tmpStr) && tmpStr.length() <= MAX_STR_LEN) {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_out);
+ }
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 생성한다.
+ *
+ *
+ * @param dirPath 생성하고자 하는 절대경로
+ * @return 성공하면 새성된 절대경로, 아니면 블랭크
+ */
+
+ public static String createNewDirectory(String dirPath) {
+
+ // 인자값 유효하지 않은 경우 블랭크 리턴
+ if (dirPath == null || dirPath.equals("")) {
+ return "";
+ }
+
+ File file = new File(EgovWebUtil.filePathBlackList(dirPath));
+ String result = "";
+ // 없으면 생성
+ if (file.exists()) {
+ // 혹시 존재해도 파일이면 생성 - 생성되지 않는다.(아래는 실질적으로는 진행되지 않음)
+ if (file.isFile()) {
+ //new File(file.getParent()).mkdirs();
+ if (file.mkdirs()) {
+ result = file.getAbsolutePath();
+ }
+ } else {
+ result = file.getAbsolutePath();
+ }
+ } else {
+ // 존해하지 않으면 생성
+ if (file.mkdirs()) {
+ result = file.getAbsolutePath();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 파일을 생성한다.
+ *
+ *
+ * @param String fileName 파일의 절대경로 +파일명
+ * @param String content 저장할 문자열입니다. c:/test/test1/test44.txt
+ *
+ */
+ public static String createNewFile(String filePath) {
+
+ // 인자값 유효하지 않은 경우 블랭크 리턴
+ if (filePath == null || filePath.equals("")) {
+ return "";
+ }
+
+ File file = new File(EgovWebUtil.filePathBlackList(filePath));
+ String result = "";
+ try {
+ if (file.exists()) {
+ result = filePath;
+ } else {
+ // 존재하지 않으면 생성함
+ //2017.02.08 이정은 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ if(new File(file.getParent()).mkdirs()){
+ LOGGER.debug("[file.mkdirs] file : File Creation Success");
+ }else{
+ LOGGER.error("[file.mkdirs] file : File Creation Fail");
+ }
+
+ if (file.createNewFile()) {
+ result = file.getAbsolutePath();
+ }
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 삭제한다.
+ *
+ *
+ * @param dirDeletePath 삭제하고자 하는디렉토리의 절대경로(파일의 경로가 들어오는 경우 삭제하지 않음)
+ * @return 성공하면 삭제된 절대경로, 아니면블랭크
+ */
+
+ public static String deleteDirectory(String dirDeletePath) {
+
+ // 인자값 유효하지 않은 경우 블랭크 리턴
+ if (dirDeletePath == null || dirDeletePath.equals("")) {
+ return "";
+ }
+ String result = "";
+ File file = new File(EgovWebUtil.filePathBlackList(dirDeletePath));
+ if (file.isDirectory()) {
+ String[] fileList = file.list();
+ //소속된 파일을 모두 삭제
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileList != null) {
+ for (int i = 0; i < fileList.length; i++) {
+
+ //log.debug("fileList["+i+"] : "+ dirDeletePath +"/"+fileList[i]);
+ File f = new File(EgovWebUtil.filePathBlackList(dirDeletePath) + "/" + fileList[i]);
+ if (f.isFile()) {
+ //디렉토리에 속한 파일들을 모두 삭제한다.
+ //2017.02.08 이정은 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ if(f.delete()){
+ LOGGER.debug("[file.delete] f : File Deletion Success");
+ }else{
+ LOGGER.error("[file.delete] f : File Deletion Fail");
+ }
+ } else {
+ //디렉토리에 속한 하위 디렉토리들에 대한 삭제 명령을 재귀적으로 호출시킨다.
+ deleteDirectory(dirDeletePath + "/" + fileList[i]);
+ }
+ }
+ }
+ // 디렉토리에 속한 파일들과 하위 디렉토리가 삭제되었으면 디렉토리 자신을 삭제한다.
+ result = deletePath(dirDeletePath);
+ } else {
+ result = "";
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 파일을 삭제한다.
+ *
+ *
+ * @param fileDeletePath 삭제하고자 하는파일의 절대경로
+ * @return 성공하면 삭제된 파일의 절대경로, 아니면블랭크
+ */
+
+ public static String deleteFile(String fileDeletePath) {
+
+ // 인자값 유효하지 않은 경우 블랭크 리턴
+ if (fileDeletePath == null || fileDeletePath.equals("")) {
+ return "";
+ }
+ String result = "";
+ File file = new File(EgovWebUtil.filePathBlackList(fileDeletePath));
+ if (file.isFile()) {
+ result = deletePath(fileDeletePath);
+ } else {
+ result = "";
+ }
+
+ return result;
+ }
+
+ /**
+ * 파일의 읽기권한을 체크한다.
+ *
+ * @param String file 파일
+ * @return boolean result 읽기권한 True / False
+ * @exception Exception
+ */
+ public static boolean checkReadAuth(String file) throws Exception {
+
+ // 읽기가능여부
+ boolean result = false;
+
+ // 전달받은 경로를 통해 파일 인스턴스를 생성한다.
+ String file1 = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(file1));
+
+ // 존재하는지 확인한다.
+ if (srcFile.exists()) {
+ // 읽기 가능한지 체크한다.
+ result = srcFile.canRead();
+ }
+
+ return result;
+ }
+
+ /**
+ * 파일의 쓰기권한을 체크한다.
+ *
+ * @param String file 파일
+ * @return boolean result 쓰기권한 True / False
+ * @exception Exception
+ */
+ public static boolean checkWriteAuth(String file) throws Exception {
+
+ // 쓰기가능여부
+ boolean result = false;
+
+ // 전달받은 경로를 통해 파일 인스턴스를 생성한다.
+ String file1 = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(file1));
+
+ // 존재하는지 확인한다.
+ if (srcFile.exists()) {
+ // 쓰기 가능한지 체크한다.
+ result = srcFile.canWrite();
+ }
+
+ return result;
+ }
+
+ /**
+ * 파일의 최종수정일자별 파일목록 조회하는 기능
+ *
+ * @param String drctry 디렉토리
+ * @param String updtDate 최종수정일자(YYYYMMDD 형태로 입력)
+ * @return ArrayList list 파일목록
+ * @exception Exception
+ */
+ public static List getFileListByDate(String drctry, String updtDate) throws Exception {
+
+ // 결과 목록
+ List list = null;
+
+ // 디렉토리 오픈
+ String drctry1 = drctry.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file = new File(EgovWebUtil.filePathBlackList(drctry1));
+
+ // 디렉토리이며, 존재하면 최종수정일자가 같은 파일목록 조회 시작
+ if (file.exists() && file.isDirectory()) {
+ File[] fileArray = file.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ list = getSubFilesByDate(fileArray, updtDate);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 파일의 최종수정기간내 파일목록 조회하는 기능
+ *
+ * @param String drctry 디렉토리
+ * @param String updtFrom 최종수정일자From(YYYYMMDD 형태로 입력)
+ * @param String updtTo 최종수정일자To(YYYYMMDD 형태로 입력)
+ * @return ArrayList list 파일목록
+ * @exception Exception
+ */
+ public static List getFileListByUpdtPd(String drctry, String updtFrom, String updtTo) throws Exception {
+
+ // 결과 목록
+ List list = null;
+
+ // 디렉토리 오픈
+ String drctry1 = drctry.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file = new File(EgovWebUtil.filePathBlackList(drctry1));
+
+ // 디렉토리이며, 최종수정기간내 존재하는 파일목록 조회 시작
+ if (file.exists() && file.isDirectory()) {
+ File[] fileArray = file.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ list = getSubFilesByUpdtPd(fileArray, updtFrom, updtTo);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 하위디렉토리 포함 최종수정일자가 같은 파일목록을 찾는 기능
+ *
+ * @param File fileArray 파일목록
+ * @param String updtDate 최종수정일자(YYYYMMDD 형태로 입력)
+ * @return ArrayList list 파일목록
+ * @exception Exception
+ */
+ public static List getSubFilesByDate(File[] fileArray, String updtDate) throws Exception {
+
+ List list = new ArrayList();
+
+ for (int i = 0; i < fileArray.length; i++) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ if (fileArray[i].isDirectory()) {
+ File[] tmpArray = fileArray[i].listFiles();
+ list.addAll(getSubFilesByDate(tmpArray, updtDate));
+ // 파일이면 파일명이 같은지 비교한다.
+ } else {
+ // 파일의 최종수정일자 조회
+ long date = fileArray[i].lastModified();
+ java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
+ String lastUpdtDate = dateFormat.format(new java.util.Date(date));
+ if (Integer.parseInt(lastUpdtDate) == Integer.parseInt(updtDate)) {
+ list.add(fileArray[i].getAbsolutePath());
+ }
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * 파일을 특정 구분자(',', '|', 'TAB')로 파싱하는 기능
+ *
+ * @param String parFile 파일
+ * @param String parChar 구분자(',', '|', 'TAB')
+ * @param int parField 필드수
+ * @return Vector parResult 파싱결과 구조체
+ * @exception Exception
+ */
+ public static Vector> parsFileByChar(String parFile, String parChar, int parField) throws Exception {
+
+ // 파싱결과 구조체
+ Vector> parResult = new Vector>();
+
+ // 파일 오픈
+ String parFile1 = parFile.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file = new File(EgovWebUtil.filePathBlackList(parFile1));
+ BufferedReader br = null;
+ try {
+ // 파일이며, 존재하면 파싱 시작
+ if (file.exists() && file.isFile()) {
+
+ // 1. 파일 텍스트 내용을 읽어서 StringBuffer에 쌓는다.
+ br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ StringBuffer strBuff = new StringBuffer();
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line.length() < MAX_STR_LEN)
+ strBuff.append(line);
+ }
+
+ // 2. 쌓은 내용을 특정 구분자로 파싱하여 String 배열로 얻는다.
+ String[] strArr = EgovStringUtil.split(strBuff.toString(), parChar);
+
+ // 3. 필드 수 만큼 돌아가며 Vector 형태로 만든다.
+ int filedCnt = 1;
+ List arr = new ArrayList();
+ for (int i = 0; i < strArr.length; i++) {
+
+ if (parField != 1) {
+ if ((filedCnt % parField) == 1) {
+ if (strArr[i] != null) {
+ arr.add(strArr[i]);
+ }
+ if (i == (strArr.length - 1)) {
+ parResult.add(arr);
+ }
+ } else if ((filedCnt % parField) == 0) {
+ if (strArr[i] != null) {
+ arr.add(strArr[i]);
+ parResult.add(arr);
+ }
+ } else {
+ if (strArr[i] != null) {
+ arr.add(strArr[i]);
+ if (i == (strArr.length - 1)) {
+ parResult.add(arr);
+ }
+ }
+ }
+ } else {
+ arr = new ArrayList();
+ if (strArr[i] != null) {
+ arr.add(strArr[i]);
+ }
+ parResult.add(arr);
+ }
+
+ filedCnt++;
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(br);
+ }
+
+ return parResult;
+ }
+
+ /**
+ * 파일을 특정 구분자(',', '|', 'TAB')로 파싱하는 기능
+ *
+ * @param String parFile 파일
+ * @param String parChar 구분자(',', '|', 'TAB')
+ * @param int parField 필드수
+ * @return Vector parResult 파싱결과 구조체
+ * @exception Exception
+ */
+ public static ArrayList parsFileByChar2(String parFile) throws Exception {
+
+ // 파싱결과 구조체
+ ArrayList parResultList = new ArrayList();
+
+ // 파일 오픈
+ String parFile1 = parFile.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file = new File(EgovWebUtil.filePathBlackList(parFile1));
+ BufferedReader br = null;
+ try {
+ // 파일이며, 존재하면 파싱 시작
+ if (file.exists() && file.isFile()) {
+
+ // 1. 파일 텍스트 내용을 읽어서 StringBuffer에 쌓는다.
+ br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line.length() < MAX_STR_LEN)
+ parResultList.add(line);
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(br);
+ }
+
+ return parResultList;
+ }
+
+ /**
+ * 파일을 일정 길이로 파싱하는 기능
+ *
+ * @param String parFile 파일
+ * @param int[] parLen 각 필드의 길이
+ * @param int parLine 읽어낼 라인수
+ * @return Vector parResult 파싱결과 구조체
+ * @exception Exception
+ */
+ public static Vector> parsFileBySize(String parFile, int[] parLen, int parLine) throws Exception {
+
+ // 파싱결과 구조체
+ Vector> parResult = new Vector>();
+
+ // 파일 오픈
+ String parFile1 = parFile.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file = new File(EgovWebUtil.filePathBlackList(parFile1));
+ BufferedReader br = null;
+ try {
+ // 파일이며, 존재하면 파싱 시작
+ if (file.exists() && file.isFile()) {
+
+ // 1. 입력된 라인수만큼 파일 텍스트 내용을 읽어서 String[]에 쌓는다.
+ br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ if (parLine < 0) {
+ parLine = 0;
+ }
+ String[] strArr = new String[parLine];
+ String line = "";
+ int readCnt = 0;
+ while ((line = br.readLine()) != null && readCnt < parLine) {
+ if (line.length() <= MAX_STR_LEN)
+ strArr[readCnt++] = line;
+ }
+
+ // 2. Vector 형태로 만든다.
+ for (int i = 0; i < strArr.length; i++) {
+ String text = strArr[i];
+ List arr = new ArrayList();
+ int idx = 0;
+ boolean result = false;
+ for (int j = 0; j < parLen.length; j++) {
+ if (!result) { //if(result != true){
+ String split = "";
+ if (text.length() < (idx + parLen[j])) {
+ split = text.substring(idx, text.length());
+ result = true;
+ } else {
+ split = text.substring(idx, idx + parLen[j]);
+ }
+ arr.add(split);
+ idx = idx + parLen[j];
+ }
+ }
+ parResult.add(arr);
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(br);
+ }
+
+ return parResult;
+ }
+
+ /**
+ * 두 파일의 사이즈를 비교하는 기능 (KB 단위 비교)
+ *
+ * @param String cmprFile1 파일1
+ * @param String cmprFile2 파일2
+ * @return boolean result 동일여부 True / False
+ * @exception Exception
+ */
+ public static boolean cmprFilesBySize(String cmprFile1, String cmprFile2) throws Exception {
+
+ // 파일 동일 여부
+ boolean result = false;
+
+ // 파일 오픈
+ String cmprFile11 = cmprFile1.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ String cmprFile22 = cmprFile2.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file1 = new File(EgovWebUtil.filePathBlackList(cmprFile11));
+ File file2 = new File(EgovWebUtil.filePathBlackList(cmprFile22));
+
+ // 파일이며, 존재하면 파일 사이즈 비교
+ if (file1.exists() && file2.exists() && file1.isFile() && file2.isFile()) {
+
+ // 파일1 사이즈
+ long size1 = file1.length();
+
+ // 파일2 사이즈
+ long size2 = file2.length();
+
+ // 사이즈 비교
+ if (size1 == size2) {
+ result = true;
+ }
+
+ }
+
+ return result;
+ }
+
+ /**
+ * 두 파일의 수정일자를 비교하는 기능
+ *
+ * @param String cmprFile1 파일1
+ * @param String cmprFile2 파일2
+ * @return boolean result 동일여부 True / False
+ * @exception Exception
+ */
+ public static boolean cmprFilesByUpdtPd(String cmprFile1, String cmprFile2) throws Exception {
+
+ // 파일 동일 여부
+ boolean result = false;
+
+ // 파일 오픈
+ String cmprFile11 = cmprFile1.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ String cmprFile22 = cmprFile2.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file1 = new File(EgovWebUtil.filePathBlackList(cmprFile11));
+ File file2 = new File(EgovWebUtil.filePathBlackList(cmprFile22));
+
+ // 파일이며, 존재하면 파일 수정일자 비교
+ if (file1.exists() && file2.exists() && file1.isFile() && file2.isFile()) {
+
+ // 파일1 수정일자
+ long date1 = file1.lastModified();
+ java.text.SimpleDateFormat dateFormat1 = new java.text.SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
+ String lastUpdtDate1 = dateFormat1.format(new java.util.Date(date1));
+
+ // 파일2 수정일자
+ long date2 = file2.lastModified();
+ java.text.SimpleDateFormat dateFormat2 = new java.text.SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
+ String lastUpdtDate2 = dateFormat2.format(new java.util.Date(date2));
+
+ // 수정일자 비교
+ if (lastUpdtDate1.equals(lastUpdtDate2)) {
+ result = true;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 두 파일의 내용을 비교하는 기능 (TEXT파일만 가능)
+ *
+ * @param String cmprFile1 파일1
+ * @param String cmprFile2 파일2
+ * @return boolean result 동일여부 True / False
+ * @exception Exception
+ */
+ public static boolean cmprFilesByContent(String cmprFile1, String cmprFile2) throws Exception {
+
+ // 파일 동일 여부
+ boolean result = false;
+
+ // 파일 오픈
+ String cmprFile11 = cmprFile1.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ String cmprFile22 = cmprFile2.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File file1 = new File(EgovWebUtil.filePathBlackList(cmprFile11));
+ File file2 = new File(EgovWebUtil.filePathBlackList(cmprFile22));
+
+ BufferedReader br1 = null;
+ BufferedReader br2 = null;
+
+ try {
+ // 파일이며, 존재하면 파일 내용 비교
+ if (file1.exists() && file2.exists() && file1.isFile() && file2.isFile()) {
+
+ List cmprText1 = new ArrayList();
+ List cmprText2 = new ArrayList();
+
+ // 파일1 텍스트 내용
+ br1 = new BufferedReader(new InputStreamReader(new FileInputStream(file1)));
+ String line1 = "";
+ while ((line1 = br1.readLine()) != null) {
+ if (line1.length() < MAX_STR_LEN)
+ cmprText1.add(line1);
+ }
+
+ // 파일2 텍스트 내용
+ br2 = new BufferedReader(new InputStreamReader(new FileInputStream(file2)));
+ String line2 = "";
+ while ((line2 = br2.readLine()) != null) {
+ if (line2.length() <= MAX_STR_LEN)
+ cmprText2.add(line2);
+ }
+
+ // 내용 비교
+ boolean isWrong = false;
+ for (int i = 0; i < cmprText1.size(); i++) {
+ if (!isWrong) { // if(isWrong != true){
+ String text1 = cmprText1.get(i);
+ String text2 = cmprText2.get(i);
+
+ if (!text1.equals(text2)) {
+ isWrong = true;
+ }
+ }
+ }
+
+ if (!isWrong) {
+ result = true;
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(br1, br2);
+ }
+
+ return result;
+ }
+
+ /**
+ * 두 파일의 생성자를 비교하는 기능
+ *
+ * @param String cmprFile1 파일1
+ * @param String cmprFile2 파일2
+ * @return boolean result 동일여부 True / False
+ * @exception Exception
+ */
+ public static boolean cmprFilesByOwner(String cmprFile1, String cmprFile2) throws Exception {
+
+ // 파일 동일 여부
+ boolean result = false;
+
+ // 파일1 생성자
+ String owner1 = getOwner(cmprFile1);
+
+ // 파일2 생성자
+ String owner2 = getOwner(cmprFile2);
+
+ if (owner1 != null && owner2 != null && !"".equals(owner1) && !"".equals(owner2) && owner1.equals(owner2)) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ /**
+ * 단일 파일을 다른 파일에 복사(Copy)한다.
+ *
+ * @param String source 원본파일
+ * @param String target 타겟파일
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean copyFile(String source, String target) throws Exception {
+
+ // 복사여부
+ boolean result = false;
+
+ // 원본 파일
+ String src = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+
+ // 타켓 파일
+ String tar = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ // 원본 파일이 존재하는지 확인한다.
+ if (srcFile.exists()) {
+
+ // 복사될 target 파일 생성
+ tar = createNewFile(tar);
+ //log.debug("tar:"+tar);
+ File tarFile = new File(EgovWebUtil.filePathBlackList(tar));
+ //log.debug("tarFile:"+tarFile.getAbsolutePath());
+ // 복사
+ result = execCopyFile(srcFile, tarFile);
+ }
+
+ return result;
+ }
+
+ /**
+ * 여러 파일을 다른 디렉토리에 복사(Copy)한다.
+ *
+ * @param String source 원본파일들
+ * @param String target 타겟디렉토리
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean copyFiles(String[] source, String target) throws Exception {
+
+ // 복사여부
+ boolean result = true;
+
+ // 복사 이전에 복사할 파일들의 경로가 올바른지 확인한다.
+ for (int i = 0; i < source.length; i++) {
+ String src = source[i].replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File chkFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (!chkFile.exists()) {
+ //log.debug("+++ 원본 파일이 존재하지 않습니다.");
+ return result;
+ }
+ }
+
+ String tar = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ // 복사를 시작한다.
+ for (int j = 0; j < source.length; j++) {
+
+ if (result) { //result != false
+
+ // 타겟파일이름 명명
+ File chkFile = new File(EgovWebUtil.filePathBlackList(source[j]));
+ String tarTemp = tar + FILE_SEPARATOR + chkFile.getName();
+
+ // 복사될 target 파일 생성
+ tarTemp = createNewFile(tarTemp);
+ File tarFile = new File(EgovWebUtil.filePathBlackList(tarTemp));
+
+ // 복사
+ result = execCopyFile(chkFile, tarFile);
+ }
+ } // end for
+
+ return result;
+ }
+
+ /**
+ * 확장자별 파일들을 다른 디렉토리에 복사(Copy)한다.
+ *
+ * @param String source 원본디렉토리
+ * @param String extnt 확장자(.txt 형태 입력)
+ * @param String target 타겟디렉토리
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean copyFilesByExtnt(String source, String extnt, String target) throws Exception {
+
+ // 복사여부
+ boolean result = true;
+
+ // 원본 파일
+ String src = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+
+ // 원본 디렉토리가 존재하는지 확인한다.
+ if (srcFile.exists() && srcFile.isDirectory()) {
+
+ String tar = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ // 원본 디렉토리 안에서 확장자가 일치하는 파일목록을 가져온다.
+ File[] fileArray = srcFile.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByExtnt(fileArray, extnt);
+
+ // 복사를 시작한다.
+ for (int i = 0; i < list.size(); i++) {
+ if (result) { //f(result != false){
+ // 원본파일 절대경로
+ String abspath = (String) list.get(i);
+
+ // 타겟파일이름 명명
+ File chkFile = new File(EgovWebUtil.filePathBlackList(abspath));
+ String tarTemp = tar + FILE_SEPARATOR + chkFile.getName();
+
+ // 복사될 target 파일 생성
+ tarTemp = createNewFile(tarTemp);
+ File tarFile = new File(EgovWebUtil.filePathBlackList(tarTemp));
+
+ // 복사
+ result = execCopyFile(chkFile, tarFile);
+ }
+ } // end for
+ }
+ else {
+ result = false;
+ }
+
+ }
+
+ return result;
+ }
+
+ /**
+ * 수정기간내 파일들을 다른 디렉토리에 복사(Copy)한다.
+ *
+ * @param String source 원본디렉토리
+ * @param String updtFrom 수정시작일자(YYYYMMDD 형태로 입력)
+ * @param String updtTo 수정종료일자(YYYYMMDD 형태로 입력)
+ * @param String target 타겟디렉토리
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean copyFilesByUpdtPd(String source, String updtFrom, String updtTo, String target) throws Exception {
+
+ // 복사여부
+ boolean result = true;
+
+ // 원본 파일
+ String src = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+
+ // 원본 디렉토리가 존재하는지 확인한다.
+ if (srcFile.exists() && srcFile.isDirectory()) {
+
+ String tar = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ // 원본 디렉토리 안에서 수정기간내 존재하는 파일목록을 가져온다.
+ File[] fileArray = srcFile.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByUpdtPd(fileArray, updtFrom, updtTo);
+
+ // 복사를 시작한다.
+ for (int i = 0; i < list.size(); i++) {
+
+ if (result) { //f(result != false){
+
+ // 원본파일 절대경로
+ String abspath = (String) list.get(i);
+
+ // 타겟파일이름 명명
+ File chkFile = new File(EgovWebUtil.filePathBlackList(abspath));
+ String tarTemp = tar + FILE_SEPARATOR + chkFile.getName();
+
+ // 복사될 target 파일 생성
+ tarTemp = createNewFile(tarTemp);
+ File tarFile = new File(tarTemp);
+
+ // 복사
+ result = execCopyFile(chkFile, tarFile);
+ }
+ } // end for
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 사이즈내 파일들을 다른 디렉토리에 복사(Copy)한다.
+ *
+ * @param String source 원본디렉토리
+ * @param Long sizeFrom 최소사이즈(KB)
+ * @param Long sizeTo 최대사이즈(KB)
+ * @param String target 타겟디렉토리
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean copyFilesBySize(String source, long sizeFrom, long sizeTo, String target) throws Exception {
+
+ // 복사여부
+ boolean result = true;
+
+ // 원본 파일
+ String src = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+
+ // 원본 디렉토리가 존재하는지 확인한다.
+ if (srcFile.exists() && srcFile.isDirectory()) {
+
+ String tar = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ // 원본 디렉토리 안에서 사이즈내 존재하는 파일목록을 가져온다.
+ File[] fileArray = srcFile.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesBySize(fileArray, sizeFrom, sizeTo);
+
+ // 복사를 시작한다.
+ for (int i = 0; i < list.size(); i++) {
+
+ if (result) { //result != false
+ // 원본파일 절대경로
+ String abspath = (String) list.get(i);
+
+ // 타겟파일이름 명명
+ File chkFile = new File(EgovWebUtil.filePathBlackList(abspath));
+ String tarTemp = tar + FILE_SEPARATOR + chkFile.getName();
+
+ // 복사될 target 파일 생성
+ tarTemp = createNewFile(tarTemp);
+ File tarFile = new File(EgovWebUtil.filePathBlackList(tarTemp));
+
+ // 복사
+ result = execCopyFile(chkFile, tarFile);
+ if (result) {
+ break;
+ }
+ }
+ } // end for
+ }
+
+ }
+
+ return result;
+ }
+
+ /**
+ * 생성자별 파일들을 다른 디렉토리에 복사(Copy)한다.
+ *
+ * @param String source 원본디렉토리
+ * @param String owner 생성자
+ * @param String target 타겟디렉토리
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean copyFilesByOwner(String source, String owner, String target) throws Exception {
+
+ // 복사여부
+ boolean result = true;
+
+ // 원본 파일
+ String src = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+
+ // 원본 디렉토리가 존재하는지 확인한다.
+ if (srcFile.exists() && srcFile.isDirectory()) {
+
+ String tar = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ // 원본 디렉토리 안에서 생성자별 일치하는 파일목록을 가져온다.
+ File[] fileArray = srcFile.listFiles();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (fileArray != null) {
+ List list = getSubFilesByOwner(fileArray, owner);
+
+ // 복사를 시작한다.
+ for (int i = 0; i < list.size(); i++) {
+
+ if (result) { //result != false
+
+ // 원본파일 절대경로
+ String abspath = (String) list.get(i);
+
+ // 타겟파일이름 명명
+ File chkFile = new File(EgovWebUtil.filePathBlackList(abspath));
+ String tarTemp = tar + FILE_SEPARATOR + chkFile.getName();
+
+ // 복사될 target 파일 생성
+ tarTemp = createNewFile(tarTemp);
+ File tarFile = new File(EgovWebUtil.filePathBlackList(tarTemp));
+
+ // 복사
+ result = execCopyFile(chkFile, tarFile);
+
+ if (!result) {
+ break;
+ }
+ }
+ } // end for
+ }
+
+ }
+
+ return result;
+ }
+
+ /**
+ * 복사를 수행하는 기능
+ *
+ * @param File srcFile 원본파일
+ * @param File tarFile 타겟파일
+ * @return boolean result 복사여부 True / False
+ * @exception Exception
+ */
+ public static boolean execCopyFile(File srcFile, File tarFile) throws Exception {
+
+ // 결과
+ boolean result = false;
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+ try {
+ // 복사
+ fis = new FileInputStream(srcFile);
+
+ //예외상황에 따른 처리 추가함. -> 만약 tarFile 이 디렉토리명인 경우 디렉토리 밑으로 새로 파일을 생성해서 복사한다.. like DOS
+ File tarFile1 = tarFile;
+ if (tarFile1.isDirectory()) {
+ tarFile1 = new File(EgovWebUtil.filePathBlackList(tarFile1.getAbsolutePath()) + "/" + srcFile.getName());
+ }
+ fos = new FileOutputStream(tarFile1);
+ byte[] buffer = new byte[(int) BUFFER_SIZE];
+ int i = 0;
+ if (fis != null && fos != null) {
+ while ((i = fis.read(buffer)) != -1) {
+ fos.write(buffer, 0, i);
+ }
+ }
+
+ result = true;
+ } finally {
+ EgovResourceCloseHelper.close(fis, fos);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 삭제한다. (소유자 정보를 통해 삭제)
+ *
+ *
+ * @param dirDeletePath 삭제하고자 하는디렉토리의 절대경로(파일의 경로가 들어오는 경우 삭제하지 않음)
+ * @param owner 디렉토리의 삭제조건 생성자
+ * @return 성공하면 삭제된 절대경로, 아니면블랭크
+ */
+
+ public static String deleteDirectory(String dirDeletePath, String dirOwner) {
+
+ // 인자값 유효하지 않은 경우 블랭크 리턴
+ if (dirDeletePath == null || dirDeletePath.equals("") || dirOwner == null || dirOwner.equals("")) {
+ return "";
+ }
+
+ // 찾은 결과를 전달할 ArrayList
+ String result = "";
+
+ try {
+ File file = new File(EgovWebUtil.filePathBlackList(dirDeletePath));//KISA 보안약점 조치 (2018-10-29, 윤창원)
+
+ // 추가된 삭제조건 옵션에 합당한지 확인
+ boolean isInCondition = false;
+ String realOwner = getOwner(dirDeletePath);
+ //log.debug("realOwner:"+realOwner);
+ if (dirOwner.equals(realOwner)) {
+ isInCondition = true;
+ }
+ // 삭제조건에 부합되면 디렉토리 삭제조치함
+ if (file.isDirectory() && isInCondition) {
+ result = deleteDirectory(dirDeletePath);
+ } else {
+ result = realOwner;
+ }
+ } catch (NullPointerException e) {//KISA 보안약점 조치 (2018-10-29, 윤창원)
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 삭제한다. (생성일자 조건으로 삭제)
+ *
+ *
+ * @param dirDeletePath 삭제하고자 하는디렉토리의 절대경로(파일의 경로가 들어오는 경우 삭제하지 않음)
+ * @param fromDate 디렉토리의 삭제조건 시작일자
+ * @param toDate 디렉토리의 삭제조건 종료일자
+ * @return 성공하면 삭제된 절대경로, 아니면블랭크
+ */
+ public static String deleteDirectory(String dirDeletePath, String fromDate, String toDate) {
+
+ // 인자값 유효하지 않은 경우 블랭크 리턴
+ if (dirDeletePath == null || dirDeletePath.equals("") || fromDate == null || fromDate.equals("") || toDate == null || toDate.equals("")) {
+ return "";
+ }
+
+ // 찾은 결과를 전달할 ArrayList
+ String result = "";
+ File file = new File(EgovWebUtil.filePathBlackList(dirDeletePath));
+
+ // 추가된 삭제조건 옵션에 합당한지 확인
+ boolean isInCondition = false;
+ String lastModifyedDate = getLastModifiedDateFromFile(file);
+ //log.debug("lastModifyedDate:"+lastModifyedDate);
+
+ if (Integer.parseInt(lastModifyedDate) >= Integer.parseInt(fromDate) && Integer.parseInt(lastModifyedDate) <= Integer.parseInt(toDate)) {
+ isInCondition = true;
+ }
+
+ // 삭제조건에 부합되면 디렉토리 삭제조치함
+ if (file.isDirectory() && isInCondition) {
+ result = deleteDirectory(dirDeletePath);
+ }
+
+ return result;
+ }
+
+ /**
+ * 파일(디렉토리)가 존재하는 파일시스템(마운트된 위치)을 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String mountLc 마운트위치
+ * @exception Exception
+ */
+ public static String getMountLc(String file) throws Exception {
+
+ // 디스크명
+ String diskName = "";
+
+ //String drctryName = "";
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+
+ // 유닉스 파일시스템명 조회 (df -k $1 | grep $2 | awk -F" " '{print $7}')
+ if (Globals.OS_TYPE.equals("UNIX")) {
+ Process p = null;
+ String[] command = { EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".getMountLc"), src, "/" };
+ p = Runtime.getRuntime().exec(command);
+ //p.waitFor();
+
+ //boolean result = false;
+ BufferedReader b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ try {
+ while (true) {
+ String str = b_out.readLine();
+ if (str == null || "".equals(str)) {
+ break;
+ }
+ if (str.length() <= MAX_STR_LEN) {
+ diskName = str;
+ } else {
+ diskName = str.substring(0, MAX_STR_LEN);
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_out);
+ }
+
+ if (p != null) {
+ p.destroy();
+ }
+
+ // 윈도우 파일시스템명 조회
+ } else if (Globals.OS_TYPE.equals("WINDOWS")) {
+
+ diskName = src.substring(0, 1).toUpperCase();
+ //log.debug(diskName);
+ }
+ }
+
+ return diskName;
+ }
+
+ /**
+ * 파일(디렉토리)가 존재하는 디렉토리(Parent)를 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String drctryName 디렉토리
+ * @exception Exception
+ */
+ public static String getDrctryName(String file) throws Exception {
+
+ String drctryName = "";
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+ drctryName = srcFile.getParent();
+ }
+
+ return drctryName;
+ }
+
+ /**
+ * 파일(디렉토리)가 존재하는 파일명을 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String fileName 파일명
+ * @exception Exception
+ */
+ public static String getFileName(String file) throws Exception {
+
+ String fileName = "";
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+ fileName = srcFile.getName();
+ }
+
+ return fileName;
+ }
+
+ /**
+ * 파일(디렉토리)의 최종수정일자를 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String updtDate 최종수정일자(YYYYMMDD 형태)
+ * @exception Exception
+ */
+ public static String getUpdtDate(String file) throws Exception {
+
+ String updtDate = "";
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+ long date = srcFile.lastModified();
+ java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
+ updtDate = dateFormat.format(new java.util.Date(date));
+ }
+
+ return updtDate;
+ }
+
+ /**
+ * 파일(디렉토리)의 생성자를 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String owner 생성자
+ * @exception Exception
+ */
+ public static String getOwner(String file) throws Exception {
+
+ String owner = "";
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ BufferedReader b_err = null;
+ BufferedReader b_out = null;
+ try {
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+
+ // 파일 생성자 조회
+ String parentPath = srcFile.getParent();
+ String fname = srcFile.getName();
+
+ Process p = null;
+ String cmdStr = EgovStringUtil.isNullToString(EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".getDrctryOwner"));
+ String[] command = { cmdStr.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR), parentPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR),
+ fname };
+ p = Runtime.getRuntime().exec(command);
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ } else { //프로세스 실행 성공시 결과 확인
+ boolean result = false;
+ b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (b_out.ready()) {
+ if (!result) { // result != true
+ // 결과문자가 있으면 생성자가 있다는 의미
+ owner = b_out.readLine();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (owner != null) {
+ if (owner.length() <= MAX_STR_LEN) {
+ if (!"".equals(owner)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err, b_out);
+ }
+
+ return owner;
+ }
+
+ /**
+ * 파일(디렉토리)의 접근권한을 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String access 접근권한(유닉스=777, 666, 윈도우=Read, Write, Read Only)
+ * @exception Exception
+ */
+ public static String getAccess(String file) throws Exception {
+
+ String access = "";
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+ BufferedReader b_err = null;
+ BufferedReader b_out = null;
+ try {
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+
+ // 접근권한 조회
+ String parentPath = EgovWebUtil.filePathBlackList(srcFile.getParent());
+ String fname = EgovWebUtil.filePathBlackList(srcFile.getName());
+
+ Process p = null;
+ if (Globals.OS_TYPE.equals("UNIX")) {
+ String[] command = { EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".getDrctryAccess"), parentPath, fname };
+ p = Runtime.getRuntime().exec(command);
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ b_err.close();
+ }
+ //프로세스 실행 성공시 결과 확인
+ else {
+ boolean result = false;
+ b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (b_out.ready()) {
+ if (!result) { //result != true
+ access = b_out.readLine();
+ if (access != null && !"".equals(access) && access.length() <= MAX_STR_LEN) {
+ result = true;
+ break;
+ }
+ }
+ }
+ b_out.close();
+ }
+ } else if (Globals.OS_TYPE.equals("WINDOWS")) {
+ String[] command = { "cmd", "/c", "attrib", src };
+ p = Runtime.getRuntime().exec(command);
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ } else { //프로세스 실행 성공시 결과 확인
+ boolean result = false;
+ b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (b_out.ready()) {
+ if (!result) { //result != true
+ access = b_out.readLine();
+ if (access != null && !"".equals(access) && access.length() <= MAX_STR_LEN) {
+ access = access.toUpperCase().replace(src.toUpperCase(), "");
+ access = access.replace(" ", "");
+ result = true;
+ if (result) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (result) {
+ String acs = "";
+ boolean read = false;
+ boolean write = true;
+ boolean system = false;
+ boolean hidden = false;
+
+ for (int i = 0; i < access.length(); i++) {
+ char chr = access.charAt(i);
+ switch (chr) {
+ case ACCESS_READ:
+ read = true;
+ write = false;
+ break;
+ case ACCESS_SYS:
+ system = true;
+ break;
+ case ACCESS_HIDE:
+ hidden = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (read) {
+ acs += "READ-ONLY|";
+ } else {
+ acs += "READ|";
+ }
+ if (write) {
+ acs += "WRITE|";
+ }
+ if (system) {
+ acs += "SYSTEM|";
+ }
+ if (hidden) {
+ acs += "HIDDEN|";
+ }
+ access = acs;
+ }
+ }
+ }
+
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err, b_out);
+ }
+
+ return access;
+ }
+
+ /**
+ * 파일(디렉토리)의 사이즈를 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return Long size 사이즈(Byte)
+ * @exception Exception
+ */
+ public static long getSize(String file) throws Exception {
+
+ long size = 0L;
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+ size = srcFile.length();
+ }
+
+ return size;
+ }
+
+ /**
+ * 파일(디렉토리)의 포맷을 조회하는 기능
+ *
+ * @param String file 파일(디렉토리)
+ * @return String format 포맷
+ * @exception Exception
+ */
+ public static String getFormat(String file) throws Exception {
+
+ // 포맷, 타입
+ String format = "";
+ String type = "";
+
+ String src = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
+
+ File srcFile = new File(EgovWebUtil.filePathBlackList(src));
+ if (srcFile.exists()) {
+
+ String[] strArr = src.split("\\.");
+ if (strArr.length >= 2) {
+ format = strArr[strArr.length - 1].toLowerCase();
+ type = EgovProperties.getProperty(Globals.FILE_FORMAT_PATH, format);
+ }
+ }
+
+ return type;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 복사한다.
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @return boolean result 복사가 성공하면 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean copyDirectory(String originalDirPath, String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("")) {
+ return false;
+ }
+ boolean result = false;
+ File f = null;
+
+ f = new File(EgovWebUtil.filePathBlackList(originalDirPath));
+ // 원본이 유효해야 진행한다.
+ if (f.exists() && f.isDirectory()) {
+
+ //타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ String targetDirPath1 = createNewDirectory(targetDirPath);
+ if (targetDirPath1.equals("")) {
+ result = false;
+ } else {
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath1));
+ //2017.02.08 이정은 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ if(targetDir.mkdirs()){
+ LOGGER.debug("[file.mkdirs] targetDir : Directory Creation Success");
+ }else{
+ LOGGER.error("[file.mkdirs] targetDir : Directory Creation Fail");
+ }
+
+ // 디렉토리에 속한 파일들을 복사한다.
+ String[] originalFileList = f.list();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (originalFileList != null) {
+ if (originalFileList.length > 0) {
+ for (int i = 0; i < originalFileList.length; i++) {
+ File subF = new File(EgovWebUtil.filePathBlackList(originalDirPath) + FILE_SEPARATOR + originalFileList[i]);
+ if (subF.isFile()) {
+ //하위목록이 파일이면 파일복사실행 -> 실패 발생하는 경우 복사를 중단한다.
+ result = copyFile(originalDirPath + FILE_SEPARATOR + originalFileList[i], targetDir.getAbsolutePath() + FILE_SEPARATOR + originalFileList[i]);
+ } else {
+ //하위목록이 디렉토리이면 복사를 재귀적으로 호출한다.
+ result = copyDirectory(originalDirPath + "/" + originalFileList[i], targetDirPath1 + "/" + originalFileList[i]);
+ }
+ }
+ } else {
+ result = true;
+ }
+ }
+ }
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 복사한다. (생성일자 조건으로 복사)
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param fromDate 디렉토리의 복사조건 시작일자
+ * @param toDate 디렉토리의 복사조건 종료일자
+ * @return boolean result 복사가 성공함변 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean copyDirectory(String originalDirPath, String targetDirPath, String fromDate, String toDate) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("") || fromDate == null || fromDate.equals("") || toDate == null
+ || toDate.equals("")) {
+ return false;
+ }
+ boolean result = false;
+ File f = null;
+
+ f = new File(EgovWebUtil.filePathBlackList(originalDirPath));
+ boolean isInCondition = false;
+ String lastModifyedDate = getLastModifiedDateFromFile(f);
+ if (Integer.parseInt(lastModifyedDate) >= Integer.parseInt(fromDate) && Integer.parseInt(lastModifyedDate) <= Integer.parseInt(toDate)) {
+ isInCondition = true;
+ }
+
+ // 원본이 유효하고 조건에 부합되야 진행한다.
+ if (f.exists() && f.isDirectory() && isInCondition) {
+
+ //타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ String targetDirPath1 = createNewDirectory(targetDirPath);
+ if (targetDirPath1.equals("")) {
+ result = false;
+ } else {
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath1));
+ //2017.02.08 이정은 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ if(targetDir.mkdirs()){
+ LOGGER.debug("[file.mkdirs] targetDir : Directory Creation Success");
+ }else{
+ LOGGER.error("[file.mkdirs] targetDir : Directory Creation Fail");
+ }
+
+ // 디렉토리에 속한 파일들을 복사한다.
+ String[] originalFileList = f.list();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (originalFileList != null) {
+ if (originalFileList.length > 0) {
+ for (int i = 0; i < originalFileList.length; i++) {
+ File subF = new File(EgovWebUtil.filePathBlackList(originalDirPath) + FILE_SEPARATOR + originalFileList[i]);
+ if (subF.isFile()) {
+ //하위목록이 파일이면 파일복사실행 -> 실패 발생하는 경우 복사를 중단한다.
+ result = copyFile(originalDirPath + FILE_SEPARATOR + originalFileList[i], targetDir.getAbsolutePath() + FILE_SEPARATOR + originalFileList[i]);
+ } else {
+ //하위목록이 디렉토리이면 복사를 재귀적으로 호출한다.
+ //하위목록에 해당하는 폴더에 대해서는 생성일자 검사를 하지 않는다.(현재 폴더가 복사대상이면 현재폴더의 하위는 제외없이 복사함)
+ result = copyDirectory(originalDirPath + "/" + originalFileList[i], targetDirPath1 + "/" + originalFileList[i]);
+ }
+ }
+ } else {
+ result = true;
+ }
+ }
+ }
+
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 복사한다. (생성자 조건으로복사)
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param String owner 디렉토리의 복사조건생성자
+ * @return boolean result 복사가 성공함변 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean copyDirectory(String originalDirPath, String targetDirPath, String owner) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("") || owner == null || owner.equals("")) {
+ return false;
+ }
+ boolean result = false;
+ File f = null;
+
+ f = new File(EgovWebUtil.filePathBlackList(originalDirPath));
+ boolean isInCondition = false;
+ String realOwner = getOwner(originalDirPath);
+ if (realOwner.equals(owner)) {
+ isInCondition = true;
+ }
+
+ // 원본이 유효하고 조건에 부합되야 진행한다.
+ if (f.exists() && f.isDirectory() && isInCondition) {
+
+ String targetDirPath1 = createNewDirectory(targetDirPath);
+ if (targetDirPath1.equals("")) {
+ //타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ result = false;
+ } else {
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath1));
+
+ //2017.02.08 이정은 시큐어코딩(ES)-부적절한 예외 처리[CWE-253, CWE-440, CWE-754]
+ if(targetDir.mkdirs()){
+ LOGGER.debug("[file.mkdirs] targetDir : Directory Creation Success");
+ }else{
+ LOGGER.error("[file.mkdirs] targetDir : Directory Creation Fail");
+ }
+
+ // 디렉토리에 속한 파일들을 복사한다.
+ String[] originalFileList = f.list();
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (originalFileList != null) {
+ if (originalFileList.length > 0) {
+ for (int i = 0; i < originalFileList.length; i++) {
+ File subF = new File(EgovWebUtil.filePathBlackList(originalDirPath) + FILE_SEPARATOR + originalFileList[i]);
+ if (subF.isFile()) {
+ //하위목록이 파일이면 파일복사실행 -> 실패 발생하는 경우 복사를 중단한다.
+ result = copyFile(originalDirPath + FILE_SEPARATOR + originalFileList[i], targetDir.getAbsolutePath() + FILE_SEPARATOR + originalFileList[i]);
+ } else {
+ //하위목록이 디렉토리이면 복사를 재귀적으로 호출한다.
+ //하위목록에 해당하는 폴더에 대해서는 생성일자 검사를 하지 않는다.(현재 폴더가 복사대상이면 현재폴더의 하위는 제외없이 복사함)
+ result = copyDirectory(originalDirPath + "/" + originalFileList[i], targetDirPath1 + "/" + originalFileList[i]);
+ }
+ }
+ } else {
+ result = false;
+ }
+ }
+ }
+
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+
+ return result;
+ }
+
+ /**
+ * 디렉토리의 사이즈를 조회한다.
+ *
+ * @param String targetDirPath 디렉토리
+ * @return long size 디렉토리사이즈
+ * @exception Exception
+ */
+ public static long getDirectorySize(String targetDirPath) throws Exception {
+
+ File f = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ if (!f.exists()) {
+ return 0;
+ }
+ if (f.isFile()) {
+ return f.length();
+ }
+
+ File[] list = f.listFiles();
+ long size = 0;
+ long fileSize = 0;
+
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ if (list != null) {
+ for (int i = 0; i < list.length; i++) {
+
+ if (list[i].isDirectory()) {
+ // 디렉토리 안에 디렉토리면 그 안의 파일목록에서 찾도록 재귀호출한다.
+ fileSize = getDirectorySize(list[i].getAbsolutePath());
+ } else {
+ // 파일의 사이즈 조회
+ fileSize = list[i].length();
+ }
+ size = size + fileSize;
+ }
+ }
+ return size;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 이동한다.
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @return boolean result 이동이 성공하면 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean moveFile(String originalDirPath, String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("")) {
+ return false;
+ }
+ boolean result = false;
+ File f = null;
+ BufferedReader b_err = null;
+ BufferedReader b_out = null;
+ try {
+ f = new File(EgovWebUtil.filePathBlackList(originalDirPath));
+ // 원본은 유효하고 대상이 신규로 생성가능한 상태인경우만 진행한다.
+ //if(f.exists() && f.isDirectory() ){ // 디렉토리만 이동할수 있도록 제한하는 경우
+
+ if (f.exists()) {
+ // 타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ if (targetDir.exists()) {
+ // 타겟경로가 이미 있는 경우는 종료
+ result = false;
+ } else {
+ // 새로 생성되는 경우만 진행한다. (이동쉘을 실행시킨다.)
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ String cmdStr = EgovStringUtil.isNullToString(EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".moveDrctry"));
+ String[] command = { cmdStr.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR),
+ EgovWebUtil.filePathBlackList(originalDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)),
+ EgovWebUtil.filePathBlackList(targetDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)) };
+ Process p = Runtime.getRuntime().exec(command);
+ //String access = "";
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ b_err.close();
+ }
+ //프로세스 실행 성공시 결과 확인
+ else {
+ result = true;
+ }
+ }
+
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err, b_out);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 이동한다.
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @return boolean result 이동이 성공하면 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean moveFile2(String originalDirPath, String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("")) {
+ return false;
+ }
+ boolean result = false;
+ File f = null;
+ BufferedReader b_err = null;
+ BufferedReader b_out = null;
+ try {
+ f = new File(EgovWebUtil.filePathBlackList(originalDirPath));
+ // 원본은 유효하고 대상이 신규로 생성가능한 상태인경우만 진행한다.
+ //if(f.exists() && f.isDirectory() ){ // 디렉토리만 이동할수 있도록 제한하는 경우
+
+ System.out.println("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
+ System.out.println("f.exists() = "+f.exists());
+ if (f.exists()) {
+ // 타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ System.out.println("targetDirPath = "+targetDirPath);
+ System.out.println("targetDir = "+targetDir);
+ System.out.println("targetDir.exists() = "+targetDir.exists());
+ if (!targetDir.exists()) {
+ // 타겟경로가 이미 있는 경우는 종료
+ result = false;
+ } else {
+ // 새로 생성되는 경우만 진행한다. (이동쉘을 실행시킨다.)
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ String cmdStr = EgovStringUtil.isNullToString(targetDir);
+ String[] command = { cmdStr.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR),
+ EgovWebUtil.filePathBlackList(originalDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)),
+ EgovWebUtil.filePathBlackList(targetDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)) };
+ Process p = Runtime.getRuntime().exec(command);
+ //String access = "";
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ b_err.close();
+ }
+ //프로세스 실행 성공시 결과 확인
+ else {
+ result = true;
+ }
+ }
+
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err, b_out);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 이동한다. (생성일자 조건으로 이동)
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param fromDate 디렉토리의이동조건 시작일자
+ * @param toDate 디렉토리의 이동조건 종료일자
+ * @return boolean result 이동이 성공하면 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean moveFile(String originalDirPath, String targetDirPath, String fromDate, String toDate) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("") || fromDate == null || fromDate.equals("") || toDate == null
+ || toDate.equals("")) {
+ return false;
+ }
+ boolean result = false;
+ File f = null;
+ BufferedReader b_err = null;
+ BufferedReader b_out = null;
+ try {
+ f = new File(originalDirPath);
+ // 원본은 유효하고 대상이 신규로 생성가능한 상태인경우만 진행한다.
+ //if(f.exists() && f.isDirectory() ){ // 디렉토리만 이동할수 있도록 제한하는 경우
+ if (f.exists()) {
+ // 타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ if (targetDir.exists()) {
+ // 타겟경로가 이미 있는 경우는 종료
+ result = false;
+ } else {
+ // 새로 생성되는 경우만 진행한다. (이동쉘을 실행시킨다.)
+ boolean isInCondition = false;
+ String lastModifyedDate = getLastModifiedDateFromFile(f);
+ if (Integer.parseInt(lastModifyedDate) >= Integer.parseInt(fromDate) && Integer.parseInt(lastModifyedDate) <= Integer.parseInt(toDate)) {
+ isInCondition = true;
+ }
+
+ if (isInCondition) {
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ String cmdStr = EgovStringUtil.isNullToString(EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".moveDrctry"));
+ String[] command = { cmdStr.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR),
+ EgovWebUtil.filePathBlackList(originalDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)),
+ EgovWebUtil.filePathBlackList(targetDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)) };
+ Process p = Runtime.getRuntime().exec(command);
+ String access = "";
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ }
+ //프로세스 실행 성공시 결과 확인
+ else {
+ result = false;
+ b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (b_out.ready()) {
+ if (!result) { // result != true
+ access = b_out.readLine();
+ if (access != null && !"".equals(access) && access.length() <= MAX_STR_LEN) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err, b_out);;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리를 이동한다. (생성자 조건으로 이동)
+ *
+ *
+ * @param String originalDirPath 원본 디렉토리 의 절대경로
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param String owner 디렉토리의 이동조건생성자
+ * @return boolean result 이동이 성공하면 true, 실패하면 false를 리턴한다.
+ */
+ public static boolean moveFile(String originalDirPath, String targetDirPath, String owner) throws Exception {
+
+ // 인자값 유효하지 않은 경우 공백 리턴
+ if (originalDirPath == null || originalDirPath.equals("") || targetDirPath == null || targetDirPath.equals("") || owner == null || owner.equals("")) {
+ return false;
+ }
+ //log.debug("originalDirPath:"+originalDirPath);
+ //log.debug("targetDirPath:"+targetDirPath);
+ boolean result = false;
+ File f = null;
+ BufferedReader b_err = null;
+ BufferedReader b_out = null;
+ try {
+ f = new File(originalDirPath);
+ // 원본은 유효하고 대상이 신규로 생성가능한 상태인경우만 진행한다.
+ //if(f.exists() && f.isDirectory() ){ // 디렉토리만 이동할수 있도록 제한하는 경우
+ if (f.exists()) {
+ // 타겟으로 설정한 경로가 유효한지 확인(중간경로에 파일명 이 포함되어있으면 유효하지 못하므로 진행안함.
+ File targetDir = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ if (targetDir.exists()) {
+ // 타겟경로가 이미 있는 경우는 종료
+ result = false;
+ } else {
+ // 새로 생성되는 경우만 진행한다. (이동쉘을 실행시킨다.)
+ boolean isInCondition = false;
+ String realOwner = getOwner(originalDirPath);
+ if (realOwner.equals(owner)) {
+ isInCondition = true;
+ }
+
+ if (isInCondition) {
+ //KISA 보안약점 조치 (2018-10-29, 윤창원)
+ String cmdStr = EgovStringUtil.isNullToString(EgovProperties.getProperty(Globals.SHELL_FILE_PATH, "SHELL." + Globals.OS_TYPE + ".moveDrctry"));
+ String[] command = { cmdStr.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR),
+ EgovWebUtil.filePathBlackList(originalDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)),
+ EgovWebUtil.filePathBlackList(targetDirPath.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR)) };
+ Process p = Runtime.getRuntime().exec(command);
+ String access = "";
+ p.waitFor();
+ //프로세스 에러시 종료
+ if (p != null && p.exitValue() != 0) {
+ b_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ while (b_err.ready()) {
+ //String line = b_err.readLine();
+ //if (line.length() <= MAX_STR_LEN) log.debug("ERR\n" + line);
+ }
+ }
+ //프로세스 실행 성공시 결과 확인
+ else {
+ result = false;
+ b_out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (b_out.ready()) {
+
+ if (!result) { //result != true
+ access = b_out.readLine();
+ if (access != null && !"".equals(access) && access.length() <= MAX_STR_LEN) {
+ result = true;
+ if (result) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // 원본자체가 유효하지 않은 경우는 false 리턴하고 종료
+ result = false;
+ }
+ } finally {
+ EgovResourceCloseHelper.close(b_err, b_out);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리감시를 시작한다. 모니터링 시작시 해당 디렉토리의 이름으로 생성된 로그파일에 START기입하고 종료시END기입한다.
+ * (로그파일이 이미 존재하는 경우는 모니터링이 현재 진행중인 상태이므로 새로 감시기능을 시작하지 않는다.)
+ *
+ *
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param String logFile 모니터링정보를 보관할 로그파일경로
+ * @param String eventPrg 이벤트 발생시 동작할 프로그램
+ * @return boolean result 모니터링 시작 여부를 리턴한다. (모니터링 시작했으면 true, 모니터링이 시작되지 않았으면 false)
+ */
+ public static boolean startDirectoryMonitering(String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 false 리턴
+ if (targetDirPath == null || targetDirPath.equals("")) {
+ return false;
+ }
+
+ boolean result = false;
+ FileReader fr = null;
+ BufferedReader br = null;
+ try {
+ // 로그파일을 생성한다. 만약 로그파일이 존재하면 이미 감시 프로세스가 동작중이므로 새로 시작하지 않는다.
+
+ File targetF = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ File logF = new File(EgovWebUtil.filePathBlackList(Globals.CONF_PATH) + "/" + targetF.getName() + ".log");
+
+ if (targetF.exists() && targetF.isDirectory()) {
+
+ if (logF.exists()) {
+ // 이미 감시 프로세스 동작중임
+ result = true;
+ //로그파일에서 중단여부 확인하여 중단된 상태이면 재실행함
+ String lastStr = "";
+ fr = new FileReader(logF);
+ br = new BufferedReader(fr);
+ //int ch = 0;
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line.length() < MAX_STR_LEN)
+ lastStr = line;
+ }
+ //log.debug("lastStr:"+lastStr);
+ if (lastStr.equals("END")) {
+ EgovFileMntrg t = new EgovFileMntrg(EgovWebUtil.filePathBlackList(targetDirPath), logF);
+ t.start();
+ }
+ } else {
+ result = logF.createNewFile();
+ EgovFileMntrg t = new EgovFileMntrg(targetDirPath, logF);
+ t.start();
+ }
+ }
+ } finally {
+ EgovResourceCloseHelper.close(fr, br);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리감시를 종료한다. 모니터링 시작시 해당 디렉토리의 이름으로 생성된 로그파일에 START기입하고 종료시END기입한다.
+ * (로그파일이 존재하지 않는 경우는 모니터링이 아직 시작되지 않은 상태이므로별도로 종료하지 않는다.)
+ *
+ *
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param String logFile 모니터링정보를 보관할 로그파일경로(감시프로세스 확인의 키값으로 사용된다)
+ * @return boolean result 모니터링 시작 여부를 리턴한다. (모니터링 시작했으면 true, 모니터링이 시작되지 않았으면 false)
+ */
+ public static boolean stopDirectoryMonitering(String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 false 리턴
+ if (targetDirPath == null || targetDirPath.equals("")) {
+ return false;
+ }
+
+ boolean result = false;
+ FileReader fr = null;
+ BufferedReader br = null;
+ FileWriter fWriter = null;
+ BufferedWriter bWriter = null;
+ try {
+ File targetF = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ File logF = new File(EgovWebUtil.filePathBlackList(Globals.CONF_PATH) + "/" + targetF.getName() + ".log");
+ if (logF.exists()) {
+
+ //로그파일 최종라인 확인 : END 여부 확인
+ String lastStr = "";
+ fr = new FileReader(logF);
+ br = new BufferedReader(fr);
+ //int ch = 0;
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ if (line.length() < MAX_STR_LEN)
+ lastStr = line;
+ }
+ br.close();
+
+ // if(lastStr.equals("END")){
+ // // 로그파일이 존재하고 이미 종료요청이 된 상태이므로 작업없음
+ // //log.debug("Already Ending Requested Status");
+ // }else{
+ if (!lastStr.equals("END")) {
+ fWriter = new FileWriter(logF, true);
+ bWriter = new BufferedWriter(fWriter);
+ br = new BufferedReader(new StringReader("END"));
+ while ((line = br.readLine()) != null && !lastStr.equals("END")) {
+ if (line.length() < MAX_STR_LEN) {
+ bWriter.write(line + "\n", 0, line.length() + 1);
+ }
+ }
+ }
+ result = true;
+ } else {
+ result = false;
+ }
+
+ } finally {
+ EgovResourceCloseHelper.close(fr, br, fWriter, bWriter);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * Comment : 디렉토리감시정보를 로그파일로부터 읽어온다.
+ *
+ *
+ * @param String targetDirPath 타겟 디렉토리 의 절대경로
+ * @param String logFile 모니터링정보를 보관하는 로그파일경로
+ * @return ArrayList result 로그파일의 정보를 라인단위로 담아서 리턴한다.
+ */
+ public static StringBuffer getDirectoryMoniteringInfo(String targetDirPath) throws Exception {
+
+ // 인자값 유효하지 않은 경우 빈 ArrayList 리턴
+ if (targetDirPath == null || targetDirPath.equals("")) {
+ return new StringBuffer();
+ }
+
+ StringBuffer result = new StringBuffer();
+ FileReader fr = null;
+ try {
+ File targetF = new File(EgovWebUtil.filePathBlackList(targetDirPath));
+ File logF = new File(EgovWebUtil.filePathBlackList(Globals.CONF_PATH) + "/" + targetF.getName() + ".log");
+ if (!logF.exists()) {
+ result = new StringBuffer();
+ }
+ fr = new FileReader(logF);
+ int ch = 0;
+ while ((ch = fr.read()) != -1) {
+ result.append((char) ch);
+ }
+ } finally {
+ EgovResourceCloseHelper.close(fr);
+ }
+
+ return result;
+ }
+
+}
diff --git a/src/main/java/egovframework/itgcms/common/CommentRestController.java b/src/main/java/egovframework/itgcms/common/CommentRestController.java
new file mode 100644
index 0000000..fc0539d
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/CommentRestController.java
@@ -0,0 +1,196 @@
+package egovframework.itgcms.common;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.util.HtmlUtils;
+
+import egovframework.itgcms.core.comment.service.CommentService;
+import egovframework.itgcms.core.comment.service.CommentVO;
+import egovframework.itgcms.util.CommUtil;
+import egovframework.rte.psl.dataaccess.util.EgovMap;
+import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
+
+@Controller
+public class CommentRestController {
+
+ private static final int PAGE_SIZE = 10;
+
+ @Resource(name="commentService")
+ private CommentService commentService;
+
+
+ @RequestMapping(value="/comment/list/{bdIdx}/{page}.do", method=RequestMethod.GET)
+ @ResponseBody
+ public EgovMap reqCommentList(@PathVariable("bdIdx") int bdIdx, @PathVariable("page") int page) throws IOException, SQLException, RuntimeException {
+
+ EgovMap result = new EgovMap();
+
+ CommentVO searchVo = new CommentVO();
+
+ /** paging setting */
+ PaginationInfo paginationInfo = new PaginationInfo();
+ paginationInfo.setCurrentPageNo(page);
+ paginationInfo.setRecordCountPerPage(searchVo.getPageUnit());
+ paginationInfo.setPageSize(searchVo.getPageSize());
+
+ searchVo.setFirstIndex(paginationInfo.getFirstRecordIndex());
+ searchVo.setLastIndex(paginationInfo.getLastRecordIndex());
+ searchVo.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
+
+ searchVo.setBdIdx(bdIdx);
+
+ int totCnt = commentService.countCommentTotalCount(bdIdx);
+
+ List resultList = commentService.commentListByBdIdx(searchVo);
+ result.put("list", resultList);
+
+ Map pageInfo = new HashMap<>();
+
+ pageInfo.put("totCnt", totCnt);
+ pageInfo.put("currentPage", page);
+ pageInfo.put("pageSize", PAGE_SIZE);
+ pageInfo.put("startPage", ((int) (page-1) / PAGE_SIZE)*PAGE_SIZE +1);
+ pageInfo.put("lastPage", ((int) totCnt / searchVo.getPageUnit())+1);
+
+ result.put("pageInfo", pageInfo);
+
+ return result;
+ }
+
+
+ @RequestMapping(value="/comment/com/{bdIdx}.do", method=RequestMethod.POST)
+ @ResponseBody
+ public int registComment(@PathVariable("bdIdx") int bdIdx, @RequestParam("content") String contents, @RequestParam("id") String id, HttpSession session, HttpServletRequest request) throws IOException, SQLException, RuntimeException {
+
+ ItgMap licenseVO = CommUtil.getSystemLicenseVO(request, "license");
+ int result = -1;
+
+ if (!sessionIdCheck(session, id)) { return 0;}
+ if (!(bdIdx > 0)) {return 0;}
+
+
+ contents = CommUtil.getAntiHtml(contents, "");
+ if ("".equals(contents)) { return result; }
+
+
+ CommentVO com = new CommentVO();
+
+ if (CommUtil.isNull(licenseVO.getValue(0), "").equals(id)) {com.setcWriter("슈퍼관리자");}
+
+ com.setcContents(HtmlUtils.htmlEscape(contents));
+ com.setRegMemId(id);
+ com.setBdIdx(bdIdx);
+
+ if (commentService.registComment(com) >0) {
+ result = commentService.countCommentTotalCount(bdIdx);
+ result = ((int) result / com.getPageUnit())+1;
+ }
+
+ return result;
+ }
+
+ @RequestMapping(value="/comment/com/{bdIdx}/{reIdx}.do", method=RequestMethod.POST)
+ @ResponseBody
+ public int registReComment(@PathVariable("bdIdx") int bdIdx, @PathVariable("reIdx") int reIdx,
+ @RequestParam("content") String contents, @RequestParam("id") String id, @RequestParam("recomId") String reComId, HttpSession session, HttpServletRequest request) throws IOException, SQLException, RuntimeException {
+
+ ItgMap licenseVO = CommUtil.getSystemLicenseVO(request, "license");
+ int result = -1;
+
+ if (!sessionIdCheck(session, id)) { return 0; }
+ if (!(bdIdx > 0)) {return 0;}
+ if (!(reIdx > 0)) {return 0;}
+ if ("".equals(reComId)) {return 0;}
+
+ contents = CommUtil.getAntiHtml(contents, "");
+ if ("".equals(contents)) { return result; }
+
+ CommentVO com = new CommentVO();
+ if (CommUtil.isNull(licenseVO.getValue(0), "").equals(id)) {com.setcWriter("슈퍼관리자");}
+
+ com.setcReIdx(reIdx);
+ com.setBdIdx(bdIdx);
+ com.setcContents(HtmlUtils.htmlEscape(contents));
+ com.setRegMemId(id);
+ com.setcReComId(reComId);
+
+ result = commentService.registReComment(com);
+
+ return result;
+ }
+
+ @RequestMapping(value="/comment/com/mod/{cIdx}.do", method=RequestMethod.POST)
+ @ResponseBody
+ public int modifyComment(@PathVariable("cIdx") int cIdx, @RequestParam("id") String id, @RequestParam("content") String contents, HttpSession session, HttpServletRequest request) throws IOException, SQLException, RuntimeException {
+
+ ItgMap licenseVO = CommUtil.getSystemLicenseVO(request, "license");
+ int result = -1;
+
+ if (!sessionIdCheck(session, id)) { return 0; }
+ if (!(cIdx > 0)) {return 0;}
+
+ contents = CommUtil.getAntiHtml(contents, "");
+ if ("".equals(contents)) { return result; }
+
+ CommentVO com = new CommentVO();
+
+ if (CommUtil.isNull(licenseVO.getValue(0), "").equals(id)) {com.setcWriter("슈퍼관리자");}
+
+ com.setCIdx(cIdx);
+ com.setcContents(HtmlUtils.htmlEscape(contents));
+ com.setUpdMemId(id);
+
+ result = commentService.modifyComment(com);
+
+ return result;
+ }
+
+ @RequestMapping(value="/comment/com/del{cIdx}.do", method=RequestMethod.POST)
+ @ResponseBody
+ public int deleteComment(@PathVariable("cIdx") int cIdx, @RequestParam("id") String id, @RequestParam("regId") String regId, HttpSession session) throws IOException, SQLException, RuntimeException {
+
+ int result = -1;
+
+ if (!sessionIdCheck(session, id)) { return 0; }
+ if (!sessionIdCheck(session, regId)) { return 0; }
+ if (!(cIdx > 0)) {return 0;}
+
+ CommentVO com = new CommentVO();
+
+ com.setCIdx(cIdx);
+ com.setDelMemId(id);
+
+ result = commentService.deleteComment(com);
+
+ return result;
+ }
+
+
+ boolean sessionIdCheck(HttpSession session, String id){
+ UserSessionVO userSession = (UserSessionVO)session.getAttribute("userSessionVO");
+ if (userSession != null && userSession.getId().equals(id)) {
+ return true;
+ }
+
+ MngrSessionVO mngrSessionVO = (MngrSessionVO)session.getAttribute("mngrSessionVO");
+ if (mngrSessionVO != null) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/egovframework/itgcms/common/CommonController.java b/src/main/java/egovframework/itgcms/common/CommonController.java
new file mode 100644
index 0000000..c50d2be
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/CommonController.java
@@ -0,0 +1,349 @@
+package egovframework.itgcms.common;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+
+import egovframework.itgcms.core.menu.service.MngrMenuService;
+//import egovframework.itgcms.core.slides.service.MngrSlidesService;
+//import egovframework.itgcms.core.systemconfig.service.SystemconfigVO;
+import egovframework.itgcms.util.CommUtil;
+
+
+@Controller
+public class CommonController {
+
+
+ /** MngrMenuService */
+ @Resource(name = "mngrMenuService")
+ private MngrMenuService mngrMenuService;
+
+ /** MngrSlidesService */
+// @Resource(name = "mngrSlidesService")
+// private MngrSlidesService mngrSlidesService;
+
+ private static final Logger logger = LogManager.getLogger(CommonController.class);
+
+ /**
+ * 파일명과 코드로 직접 이미지를 출력함
+ * f=암호화된 파일명 c=파일 인덱스
+ * @param request
+ * @param response
+ * @throws IOException, SQLException, RuntimeException
+ */
+ @RequestMapping(value="/comm/download.do")
+ public void download(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException, RuntimeException{
+ String f = CommUtil.isNull(request.getParameter("f"),""); //f 구조는 index::폴더명::저장파일명::원본파일명
+
+ if("".equals(f) ){
+ return;
+ }
+
+ String []arrFile = CommUtil.getFileDec(f).split("::");
+ if(arrFile.length < 3 ){
+ return;
+ }
+ String downIndex = arrFile[0];
+ String downFolder = arrFile[1];
+ String downFileName = arrFile[2];
+ String orgFileName = arrFile[3];
+ File file = new File(CommUtil.getFileRoot()+ System.getProperty("file.separator") + downFolder + System.getProperty("file.separator") + downFileName);
+
+ if (!file.exists()) {
+ logger.debug(file.getAbsolutePath());
+ response.setContentType("text/html;charset=UTF-8");
+ java.io.PrintWriter out = response.getWriter();
+ out.println(CommUtil.getAlertHtml("파일이 없습니다.","history.back();"));
+ return;
+ }
+
+ if (!file.isFile()) {
+ logger.debug(file.getAbsolutePath());
+ response.setContentType("text/html;charset=UTF-8");
+ java.io.PrintWriter out = response.getWriter();
+ out.println(CommUtil.getAlertHtml("파일이 없습니다.","history.back();"));
+ return;
+ }
+
+
+// if(!"".equals(c)){
+// HashMap hmParam = new HashMap();
+// hmParam.put("F_SAVENAME", downFileName);
+// hmParam.put("F_IDX",c);
+// HashMap result = commonService.selectFileuploadView(hmParam);
+// if(result != null && !"".equals(CommUtil.isNull(result.get("F_ORGNAME"),""))){
+// orgFileName = CommUtil.isNull(result.get("F_ORGNAME"),"");
+// }
+// }
+
+ int fSize = (int)file.length();
+ if (fSize > 0) {
+ BufferedInputStream in = null;
+ FileInputStream fi = null;
+
+ try {
+ fi = new FileInputStream(file);
+ in = new BufferedInputStream(fi);
+
+// response.setHeader("Content-Disposition", "attachment; filename=" + ("".equals(orgFileName) ? downFileName : orgFileName)); //new String(orgFileName.getBytes("euc-kr"),"8859_1"))
+ response.setContentType("application/unknown");
+ response.setHeader("Content-Disposition", "attachment; filename=" + ("".equals(orgFileName) ? downFileName : new String(orgFileName.getBytes("euc-kr"),"8859_1")));
+ response.setContentLength(fSize);
+ FileCopyUtils.copy(in, response.getOutputStream());
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException ignore) {
+ logger.error("예외 상황 발생");
+ }
+ }
+ fi.close();
+ }
+ response.getOutputStream().flush();
+ response.getOutputStream().close();
+ }
+ }
+ /**
+ * 파일명과 코드로 직접 이미지를 출력함
+ * f=파일명 c=코드명(tb_ 제외)
+ * @param request
+ * @param response
+ * @throws IOException, SQLException, RuntimeException
+ */
+ @RequestMapping(value="/comm/viewImage.do")
+ public void viewImage(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException, RuntimeException{
+ String f = CommUtil.isNull(request.getParameter("f"),""); //f 구조는 index::폴더명::저장파일명::원본파일명
+
+ if("".equals(f) ){
+ return;
+ }
+
+ String []arrFile = CommUtil.getFileDec(f).split("::");
+ if(arrFile.length < 3 ){
+ return;
+ }
+ String downIndex = arrFile[0];
+ String downFolder = arrFile[1];
+ String downFileName = arrFile[2];
+ String orgFileName = arrFile[3];
+
+ File file = new File(CommUtil.getFileRoot()+ System.getProperty("file.separator") + downFolder + System.getProperty("file.separator") + downFileName);
+
+ if (!file.exists()) {
+ logger.debug("이미지 파일 오류" + CommUtil.getFileRoot()+ System.getProperty("file.separator") + downFolder + System.getProperty("file.separator") + downFileName);
+ return ;//throw new FileNotFoundException(CommUtil.getFileRoot()+ System.getProperty("file.separator") + downFolder + System.getProperty("file.separator") + downFileName);
+ }
+
+ if (!file.isFile()) {
+ logger.debug("이미지 파일 오류" + CommUtil.getFileRoot()+ System.getProperty("file.separator") + downFolder + System.getProperty("file.separator") + downFileName);
+ return ;//throw new FileNotFoundException(CommUtil.getFileRoot()+ System.getProperty("file.separator") + downFolder + System.getProperty("file.separator") + downFileName);
+ }
+
+ int fSize = (int)file.length();
+ if (fSize > 0) {
+ BufferedInputStream in = null;
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(file);
+ in = new BufferedInputStream(fis);
+ String ext = (downFileName.substring(downFileName.lastIndexOf(".") + 1));
+ String mimetype = "application/octet-stream"; //"application/x-msdownload"
+ if(CommUtil.regEx("(jpg|jpeg|gif|png|bmp)", ext.toLowerCase())){
+ mimetype = "image/"+ext.toLowerCase();
+ }else{
+ return ; //이미지 보여주는 메소드이므로 이미지가 아니면 리턴.
+ }
+ response.setBufferSize(fSize);
+ response.setContentType(mimetype);
+ response.setHeader("Content-Disposition", "attachment; filename=" + downFileName);
+ response.setContentLength(fSize);
+ FileCopyUtils.copy(in, response.getOutputStream());
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException ignore) {
+ logger.error("예외 상황 발생");
+ }
+ }
+ fis.close();
+ }
+ response.getOutputStream().flush();
+ response.getOutputStream().close();
+ }
+ }
+
+ public String readContentFrom(String textFileName) throws IOException, SQLException, RuntimeException {
+ java.io.BufferedReader bufferedTextFileReader = new java.io.BufferedReader(new java.io.FileReader(textFileName));
+ StringBuilder contentReceiver = new StringBuilder();
+
+ String line = null;
+ try{
+ while ((line = bufferedTextFileReader.readLine()) != null) {
+ contentReceiver.append(line+"\n");
+ }
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }finally{
+ bufferedTextFileReader.close();
+ }
+
+ return contentReceiver.toString();
+ }
+
+ public void createFile(String textFileName, String content) throws IOException, SQLException, RuntimeException{
+ java.io.FileWriter fw = null;
+ java.io.BufferedWriter bufferedWriter = null;
+ try{
+ fw = new java.io.FileWriter(textFileName);
+ bufferedWriter = new java.io.BufferedWriter(fw);
+ bufferedWriter.write(content);
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }finally{
+ bufferedWriter.close();
+ fw.close();
+ }
+ }
+
+ @RequestMapping(value="/comm/sessionKeep.do")
+ public void sessionKeep(HttpServletRequest request, HttpServletResponse response, ModelMap model, HttpSession session) throws IOException, SQLException, RuntimeException{
+ //세션 유지를 위한 가상페이지.
+ //등록 페이지에 10분마다 요청하도록함. 실제로 아무일도 하지않음.
+ }
+
+ @RequestMapping(value="/post.do")
+ public void post(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, SQLException, RuntimeException{
+ String path = "c:\\post\\";
+ File folder = new File(path);
+ File []files = folder.listFiles();
+ StringBuffer sb = new StringBuffer();
+ long z_no = 0l;
+ for(File file : files){
+
+ java.io.File file1 = null;
+ java.io.FileInputStream file1is = null;
+ java.io.InputStreamReader isr = null;
+ BufferedReader in = null;
+
+ try{
+ file1 = new java.io.File(path + file.getName());
+
+ file1is = new java.io.FileInputStream(file1);
+ isr = new java.io.InputStreamReader(file1is,"euc-kr");
+ in = new BufferedReader(isr);
+
+ String s = null;
+ int i = 0;
+ while ( (s = in.readLine()) != null ) {
+ if(i>0){
+ z_no++;
+ String []str = s.split("\\|");
+ HashMap hmParam = new HashMap();//#Z_NO#,#Z_ZIPCODE#,#Z_SIDO#,#Z_GUGUN#,#Z_UPMYUN#,#Z_ROAD#,#Z_BUILDING#,#Z_BUILDING_SUB#,#Z_DELIVER#
+ //우편번호|우편일련번호|시도|시도영문|시군구|시군구영문|읍면|읍면영문|도로명코드|도로명|도로명영문|지하여부|건물번호본번|건물번호부번|건물관리번호|다량배달처명|시군구용건물명|법정동코드|법정동명|리|산여부|지번본번|읍면동일련번호|지번부번
+ // 135807| 022| 서울특별시|Seoul|강남구|Gangnam-gu|||116803122001|개포로|Gaepo-ro|0|303|0|1168010300106530000019474|현대1차아파트|현대1차아파트|1168010300|개포동||0|653|01|0
+ hmParam.put("Z_NO", z_no);
+ hmParam.put("Z_ZIPCODE", str[0]);
+ hmParam.put("Z_SIDO", str[2]);
+ hmParam.put("Z_GUGUN", str[4]);
+ hmParam.put("Z_UPMYUN", str[6]);
+ hmParam.put("Z_ROAD", str[9]);
+ hmParam.put("Z_BUILDING", str[12]);
+ hmParam.put("Z_BUILDING_SUB", str[13]);
+ hmParam.put("Z_DELIVER", str[14]);
+ //commService.insertKoh("common.insertTestZip", hmParam);
+ //break;
+ }
+ i++;
+
+ }
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }finally{
+ file1is.close();
+ isr.close();
+ in.close();
+ }
+
+ }
+ }
+
+ @RequestMapping(value="/comm/qr.do")
+ public void qr(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException, RuntimeException, WriterException{
+ //response.sendRedirect("/web/main/index.do");
+ QRCodeWriter qrCodeWriter = new QRCodeWriter();
+ String port = "";
+ if(!"80".equals(request.getServerPort())) port = ":" + request.getServerPort();
+ String text = "MECARD:URL:" + request.getParameter("url");
+ /*
+ MECARD:N:이름;
+ ORG:회사;
+ TEL:전화;
+ EMAIL:이메일;
+ NOTE:노트(설명);
+ URL:링크주소;
+ ADR:주소;
+ */
+ text = new String(text.getBytes("UTF-8"), "ISO-8859-1");
+ BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, 200, 200);
+ response.setContentType("image/png; charset=UTF-8");
+ response.setHeader("Content-Disposition", "filename=noename.png");
+ //out.clear();
+ //out = pageContext.pushBody();
+ MatrixToImageWriter.writeToStream(bitMatrix, "png", response.getOutputStream());
+ }
+
+
+ /**
+ * 슬라이드 셋 인클루드 처리
+ * @param mngrProgramSearchVO
+ * @param model
+ * @param programVO
+ * @return
+ * @throws IOException, SQLException, RuntimeException
+ */
+ @RequestMapping(value = "/module/slides/userInclude_SLIDES.do")
+ public ModelAndView userInclude_SLIDES(HttpServletRequest request, HttpSession session) throws IOException, SQLException, RuntimeException {
+
+ ModelAndView mav = new ModelAndView();
+ mav.setViewName("itgcms/global/slides/userInclude_SLIDES");
+
+ String root = request.getParameter("siteCode");
+
+// SystemconfigVO systemconfigVO = CommUtil.getSystemconfigVO(request, "systemconfig"+root);
+
+ ItgMap paramVO = new ItgMap();
+// paramVO.put("slidesIdx", CommUtil.isNull(systemconfigVO.getSlidesIdx(),"0"));
+ paramVO.put("useyn", "Y");
+// List slidesItemList = mngrSlidesService.mngrSlideItemList(paramVO);
+// mav.addObject("slidesItemList", slidesItemList);
+
+ return mav;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/common/CommonRestcontroller.java b/src/main/java/egovframework/itgcms/common/CommonRestcontroller.java
new file mode 100644
index 0000000..27e324b
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/CommonRestcontroller.java
@@ -0,0 +1,78 @@
+package egovframework.itgcms.common;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import egovframework.itgcms.core.menu.service.MngrMenuService;
+import egovframework.itgcms.core.site.service.MngrSiteService;
+import egovframework.itgcms.core.site.service.MngrSiteVO;
+import egovframework.itgcms.core.systemconfig.service.SystemconfigVO;
+import egovframework.itgcms.core.templeteconfig.service.TempleteconfigService;
+import egovframework.itgcms.util.CommUtil;
+import egovframework.rte.psl.dataaccess.util.EgovMap;
+
+@RestController
+public class CommonRestcontroller {
+
+ @Resource(name = "mngrSiteService")
+ private MngrSiteService mngrSiteService;
+ @Resource(name = "mngrMenuService")
+ private MngrMenuService mngrMenuService;
+ @Resource(name = "templeteconfigService")
+ private TempleteconfigService tempService;
+
+ @RequestMapping(value = "/_mngr_/mainBoardCheck.do", method={RequestMethod.GET,RequestMethod.POST})
+ public Map mngrCheck(HttpServletRequest request, @RequestParam("siteCode") String siteCode, @RequestParam("templCode") String templCode) throws IOException, SQLException, RuntimeException {
+
+ Map resultData = new HashMap<>();
+ List siteList = mngrSiteService.mngrSiteList();
+ siteCode = CommUtil.isNull(siteCode, "");
+
+ if("".equals(siteCode)){
+ siteCode = siteList.get(0).getSiteCode();
+ }
+
+ List tmplList = tempService.templeteconfigList();
+
+ EgovMap tmp = null;
+ for ( EgovMap map : tmplList) {
+ if(map.get("tempCode").equals(templCode)){
+ tmp = map;
+ break;
+ }
+ }
+
+ if (tmp == null) tmplList.get(0);
+
+ SystemconfigVO systemConf;
+
+ try {
+ systemConf = (SystemconfigVO) CommUtil.getFileObject(request, "systemconfig".concat(siteCode));
+ } catch(NullPointerException|ClassCastException e){
+ CommUtil.setFileObject(request, new SystemconfigVO(), "systemconfig".concat(siteCode));
+ systemConf = (SystemconfigVO) CommUtil.getFileObject(request, "systemconfig".concat(siteCode));
+ }
+ EgovMap paramMap = new EgovMap();
+ paramMap.put("siteCode", siteCode);
+
+ resultData.put("boardNum", (String) tmp.get("recentBdCnt"));
+ resultData.put("menuDesc", mngrMenuService.getBoardListbySitecode(paramMap));
+
+ if (systemConf.getRecentBoardMap() != null && systemConf.getRecentBoardByTempCode(templCode) != null) {
+ resultData.put("selectedMenu", systemConf.getRecentBoardByTempCode(templCode));
+ }
+
+ return resultData;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/common/CustomDateHandler.java b/src/main/java/egovframework/itgcms/common/CustomDateHandler.java
new file mode 100644
index 0000000..c73797b
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/CustomDateHandler.java
@@ -0,0 +1,45 @@
+package egovframework.itgcms.common;
+
+import java.sql.CallableStatement;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+
+public class CustomDateHandler extends BaseTypeHandler{
+
+ @Override
+ public Date getNullableResult(ResultSet rs, String columnName) throws SQLException {
+ Timestamp sqlTimestamp = rs.getTimestamp(columnName);
+ if (sqlTimestamp != null) {
+ return new Date(sqlTimestamp.getTime());
+ }
+ return null;
+ }
+
+ @Override
+ public void setNonNullParameter(PreparedStatement ps, int i, Date parameter, JdbcType jdbcType)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ ps.setDate(i, parameter);
+ }
+
+ @Override
+ public Date getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return rs.getDate(columnIndex);
+ }
+
+ @Override
+ public Date getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return cs.getDate(columnIndex);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/egovframework/itgcms/common/DefaultVO.java b/src/main/java/egovframework/itgcms/common/DefaultVO.java
new file mode 100644
index 0000000..6f77df7
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/DefaultVO.java
@@ -0,0 +1,403 @@
+/*
+ * Copyright 2008-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package egovframework.itgcms.common;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+
+import egovframework.itgcms.util.CommUtil;
+
+/**
+ * @파일명 : DefaultVO.java
+ * @파일정보 : 게시판 공통 VO, 게시판에 사용되는 VO는 이 클래스를 상속 받는다.
+ * @수정이력
+ * @수정자 수정일 수정내용
+ * @------- ------------ ----------------
+ * @woonee 2014. 9. 4. 최초생성
+ * @---------------------------------------
+ * @author (주)아이티굿 개발팀
+ * @since 2009. 01.14
+ * @version 1.0 Copyright (C) ITGOOD All right reserved.
+ */
+public class DefaultVO implements Serializable {
+ /**
+ * serialVersion UID
+ */
+ private static final long serialVersionUID = -858838578081269359L;
+
+ private static final Logger logger = LogManager.getLogger(DefaultVO.class);
+ //======================== 검색용 변수 ===============================
+
+ /** 검색key */
+ private String schId = ""; //검색조건 유지
+
+ /** 검색조건 */
+ private String schFld = ""; //검색조건 유지
+
+ /** 검색Keyword */
+ private String schStr = "";//검색조건 유지
+
+ /** 검색사용여부 */
+ private String schUseYn = "";//검색조건 유지
+
+ /** 멤버아이디 */
+ private String schMemid = "";//검색조건 유지
+
+ /** 검색옵션1 */
+ private String schOpt1 = "";//검색조건 유지
+
+ /** 검색옵션2 */
+ private String schOpt2 = "";//검색조건 유지
+
+ /** 검색옵션3 */
+ private String schOpt3 = "";//검색조건 유지
+
+ /** 검색옵션4 */
+ private String schOpt4 = "";//검색조건 유지
+
+ /** 검색옵션5 */
+ private String schOpt5 = "";//검색조건 유지
+
+ /** 검색옵션6 */
+ private String schOpt6 = "";//검색조건 유지
+
+ /** 검색옵션7 */
+ private String schOpt7 = "";//검색조건 유지
+
+ /** 검색옵션8 */
+ private String schOpt8 = "";//검색조건 유지
+
+ /** 검색옵션9 */
+ private String schOpt9 = "";//검색조건 유지
+
+ /** 검색옵션10 */
+ private String schOpt10 = "";//검색조건 유지
+
+ /** 로그인멤버아이디 */
+ private String logMemid = "";//검색조건 유지
+
+ /** 현재페이지 */
+ private String page = "1";//검색조건 유지
+
+ /** 정렬 필드 */
+ private String ordFld = "";//검색조건 유지
+
+ /** 정렬 구분, desc:내림, asc:올림 */
+ private String ordBy = "";//검색조건 유지
+
+ /** 상태 */
+ private String act = "";
+
+ /** 기타1 */
+ private String etc1 = "";
+
+ /** 기타2 */
+ private String etc2 = "";
+
+ /** 목록 갯수 */
+ private String viewCount = "10";//검색조건 유지
+
+ /** 사이트코드 */
+ private String schSitecode = "";
+
+ /** 라이센스타입 */
+ private String schLicenseType = "";
+
+ /** 목록에서 게시물 다중선택 */
+ private String[] chkId;
+
+ private String schM = "";
+
+ private String excelDown = ""; // 일반 목록은 "", 엑셀다운은 excel, list쿼리에서 일반 목록과 엑셀다운목록을 구분하기 위해.
+ //======================== 설정용 변수 ===============================
+ /** 페이지갯수 페이지에 보여줄 게시물 갯수 */
+ private int pageUnit = 10;
+
+ /** 페이지사이즈 한 페이지에 보여줄 페이지 갯수 5 = << < 1 2 3 4 5 > >> */
+ private int pageSize = 10;
+
+ /** firstIndex */
+ private int firstIndex = 1;
+
+ /** lastIndex */
+ private int lastIndex = 1;
+
+ /** recordCountPerPage 페이지에 보여줄 게시물 갯수 pageUnit과 동일*/
+ private int recordCountPerPage = 10;
+
+ public String getSchId() {
+ return schId;
+ }
+ public void setSchId(String schId) {
+ this.schId = schId;
+ }
+ public String getSchFld() {
+ return schFld;
+ }
+ public void setSchFld(String schFld) {
+ this.schFld = schFld;
+ }
+ public String getSchStr() {
+ return CommUtil.stripXss(schStr);
+ }
+ public void setSchStr(String schStr) {
+ this.schStr = CommUtil.stripXss(schStr);
+ }
+ public String getSchUseYn() {
+ return schUseYn;
+ }
+ public void setSchUseYn(String schUseYn) {
+ this.schUseYn = schUseYn;
+ }
+ public String getSchMemid() {
+ return schMemid;
+ }
+ public void setSchMemid(String schMemid) {
+ this.schMemid = schMemid;
+ }
+ public String getSchOpt1() {
+ return schOpt1;
+ }
+ public void setSchOpt1(String schOpt1) {
+ this.schOpt1 = schOpt1;
+ }
+ public String getSchOpt2() {
+ return schOpt2;
+ }
+ public void setSchOpt2(String schOpt2) {
+ this.schOpt2 = schOpt2;
+ }
+ public String getSchOpt3() {
+ return schOpt3;
+ }
+ public void setSchOpt3(String schOpt3) {
+ this.schOpt3 = schOpt3;
+ }
+ public String getSchOpt4() {
+ return schOpt4;
+ }
+ public void setSchOpt4(String schOpt4) {
+ this.schOpt4 = schOpt4;
+ }
+ public String getSchOpt5() {
+ return schOpt5;
+ }
+ public void setSchOpt5(String schOpt5) {
+ this.schOpt5 = schOpt5;
+ }
+ public String getSchOpt6() {
+ return schOpt6;
+ }
+ public String getSchOpt7() {
+ return schOpt7;
+ }
+ public String getSchOpt8() {
+ return schOpt8;
+ }
+ public String getSchOpt9() {
+ return schOpt9;
+ }
+ public String getSchOpt10() {
+ return schOpt10;
+ }
+ public void setSchOpt6(String schOpt6) {
+ this.schOpt6 = schOpt6;
+ }
+ public void setSchOpt7(String schOpt7) {
+ this.schOpt7 = schOpt7;
+ }
+ public void setSchOpt8(String schOpt8) {
+ this.schOpt8 = schOpt8;
+ }
+ public void setSchOpt9(String schOpt9) {
+ this.schOpt9 = schOpt9;
+ }
+ public void setSchOpt10(String schOpt10) {
+ this.schOpt10 = schOpt10;
+ }
+ public String getLogMemid() {
+ return logMemid;
+ }
+ public void setLogMemid(String logMemid) {
+ this.logMemid = logMemid;
+ }
+ public String getPage() {
+ return page;
+ }
+ public void setPage(String page) {
+ if(!"".equals(CommUtil.isNull(page, ""))
+ && !CommUtil.regEx("[^0-9]", page) //빈값 또는 0-9중의 숫자가 아닌경우 전달받은 변수를 대입하지 않는다(기본값을 그냥 사용)
+ ){
+ this.page = page;
+ }
+ }
+ public String getSchSitecode() {
+ return schSitecode;
+ }
+ public void setSchSitecode(String schSitecode) {
+ this.schSitecode = schSitecode;
+ }
+ public int getPageUnit() {
+ return pageUnit;
+ }
+ public void setPageUnit(int pageUnit) {
+ this.pageUnit = pageUnit;
+ }
+ public int getPageSize() {
+ return pageSize;
+ }
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+ public int getFirstIndex() {
+ return firstIndex;
+ }
+ public void setFirstIndex(int firstIndex) {
+ this.firstIndex = firstIndex;
+ }
+ public int getLastIndex() {
+ return lastIndex;
+ }
+ public void setLastIndex(int lastIndex) {
+ this.lastIndex = lastIndex;
+ }
+ public int getRecordCountPerPage() {
+ return recordCountPerPage;
+ }
+ public void setRecordCountPerPage(int recordCountPerPage) {
+ this.recordCountPerPage = recordCountPerPage;
+ }
+ public String getOrdFld() {
+ return ordFld;
+ }
+ public void setOrdFld(String ordFld) {
+ this.ordFld = ordFld;
+ if(ordFld != null && !"".equals(ordFld)){
+ if(CommUtil.regEx("[^a-zA-Z0-9_.]", ordFld)){
+ this.ordFld = "";
+ }
+ }
+ }
+ public String getOrdBy() {
+ return ordBy;
+ }
+ public void setOrdBy(String ordBy) {
+ this.ordBy = ordBy;
+ if(ordBy != null && !"".equals(ordBy)){
+ if(!"asc".equals(ordBy.toLowerCase()) && !"desc".equals(ordBy.toLowerCase())){
+ this.ordBy = "";
+ }
+ }
+ }
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+ public String getAct() {
+ return act;
+ }
+ public void setAct(String act) {
+ this.act = act;
+ }
+ public String getEtc1() {
+ return etc1;
+ }
+ public void setEtc1(String etc1) {
+ this.etc1 = etc1;
+ }
+ public String getEtc2() {
+ return etc2;
+ }
+ public void setEtc2(String etc2) {
+ this.etc2 = etc2;
+ }
+ public String getViewCount() {
+ return viewCount;
+ }
+ public void setViewCount(String viewCount) {
+ if(!"".equals(CommUtil.isNull(viewCount, ""))
+ && !CommUtil.regEx("[^0-9]", viewCount) //빈값 또는 0-9중의 숫자가 아닌경우 전달받은 변수를 대입하지 않는다(기본값을 그냥 사용)
+ ){
+ this.viewCount = viewCount;
+ }
+ }
+ public String[] getChkId() {
+ String[] ret = null;
+ if (this.chkId != null) {
+ ret = new String[chkId.length];
+ for (int i = 0; i < chkId.length; i++) {
+ ret[i] = this.chkId[i];
+ }
+ }
+ return ret;
+ }
+ public void setChkId(String[] chkId) {
+ this.chkId = new String[chkId.length];
+ for(int i = 0; i < chkId.length; ++i) this.chkId[i] = chkId[i];
+ }
+ public String getSchM() {
+ return schM;
+ }
+ public void setSchM(String schM) {
+ this.schM = schM;
+ }
+ public String getSchLicenseType() {
+ return schLicenseType;
+ }
+ public void setSchLicenseType(String schLicenseType) {
+ this.schLicenseType = schLicenseType;
+ }
+ public String getExcelDown() {
+ return excelDown;
+ }
+ public void setExcelDown(String excelDown) {
+ this.excelDown = excelDown;
+ }
+ public String queryString(){
+ String query = "";
+ try{
+ if(!"".equals(java.net.URLEncoder.encode(this.schId, "UTF-8"))){ query += "&schId=" + java.net.URLEncoder.encode(this.schId, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schFld, "UTF-8"))){ query += "&schFld=" + java.net.URLEncoder.encode(this.schFld, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schStr, "UTF-8"))){ query += "&schStr=" + java.net.URLEncoder.encode(this.schStr, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schUseYn, "UTF-8"))){ query += "&schUseYn=" + java.net.URLEncoder.encode(this.schUseYn, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schMemid, "UTF-8"))){ query += "&schMemid=" + java.net.URLEncoder.encode(this.schMemid, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt1, "UTF-8"))){ query += "&schOpt1=" + java.net.URLEncoder.encode(this.schOpt1, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt2, "UTF-8"))){ query += "&schOpt2=" + java.net.URLEncoder.encode(this.schOpt2, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt3, "UTF-8"))){ query += "&schOpt3=" + java.net.URLEncoder.encode(this.schOpt3, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt4, "UTF-8"))){ query += "&schOpt4=" + java.net.URLEncoder.encode(this.schOpt4, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt5, "UTF-8"))){ query += "&schOpt5=" + java.net.URLEncoder.encode(this.schOpt5, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt6, "UTF-8"))){ query += "&schOpt6=" + java.net.URLEncoder.encode(this.schOpt6, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt7, "UTF-8"))){ query += "&schOpt7=" + java.net.URLEncoder.encode(this.schOpt7, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt8, "UTF-8"))){ query += "&schOpt8=" + java.net.URLEncoder.encode(this.schOpt8, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt9, "UTF-8"))){ query += "&schOpt9=" + java.net.URLEncoder.encode(this.schOpt9, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schOpt10, "UTF-8"))){ query += "&schOpt10=" + java.net.URLEncoder.encode(this.schOpt10, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schSitecode, "UTF-8"))){ query += "&schSitecode=" + java.net.URLEncoder.encode(this.schSitecode, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schLicenseType, "UTF-8"))){ query += "&schLicenseType=" + java.net.URLEncoder.encode(this.schLicenseType, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.schM, "UTF-8"))){ query += "&schM=" + java.net.URLEncoder.encode(this.schM, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.act, "UTF-8"))){ query += "&act=" + java.net.URLEncoder.encode(this.act, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.page, "UTF-8"))){ query += "&page=" + java.net.URLEncoder.encode(this.page, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.ordFld, "UTF-8"))){ query += "&ordFld=" + java.net.URLEncoder.encode(this.ordFld, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.ordBy, "UTF-8"))){ query += "&ordBy=" + java.net.URLEncoder.encode(this.ordBy, "UTF-8");}
+ if(!"".equals(java.net.URLEncoder.encode(this.viewCount, "UTF-8"))){ query += "&viewCount=" + java.net.URLEncoder.encode(this.viewCount, "UTF-8");}
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }
+ return query;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/common/ItgMap.java b/src/main/java/egovframework/itgcms/common/ItgMap.java
new file mode 100644
index 0000000..1de9851
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/ItgMap.java
@@ -0,0 +1,15 @@
+package egovframework.itgcms.common;
+
+import egovframework.rte.psl.dataaccess.util.EgovMap;
+
+public class ItgMap extends EgovMap {
+
+ public Object replace(Object key, Object value){
+ Object curValue;
+ if (((curValue = get(key)) != null) || containsKey(key)) {
+ curValue = super.put(key, value);
+ }
+ return curValue;
+ }
+
+}
diff --git a/src/main/java/egovframework/itgcms/common/MngrManagerLogAOP.java b/src/main/java/egovframework/itgcms/common/MngrManagerLogAOP.java
new file mode 100644
index 0000000..77a3c96
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/MngrManagerLogAOP.java
@@ -0,0 +1,91 @@
+package egovframework.itgcms.common;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.aspectj.lang.JoinPoint;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import egovframework.itgcms.core.managerlog.service.MngrManagerLogService;
+import egovframework.itgcms.core.managerlog.service.MngrManagerLogVO;
+import egovframework.itgcms.util.CommUtil;
+public class MngrManagerLogAOP {
+ @Autowired
+ HttpServletRequest request;
+
+ /** MngrAuthorityService */
+ @Resource(name = "mngrManagerLogService")
+ private MngrManagerLogService mngrManagerLogService;
+
+ private static final Logger logger = LogManager.getLogger(MngrManagerLogAOP.class);
+
+ public void mngrAopSelect(JoinPoint thisJoinPoint) throws IOException, SQLException{
+ if("".equals(CommUtil.getMngrMemId())) return; //관리자 아이디가 없으면 로그저장 안함
+ try {
+ MngrManagerLogVO mngrManagerLogVO = getManagerLog(thisJoinPoint, "R");
+ if(CommUtil.isNull(mngrManagerLogVO.getMlogUrl(), "null").indexOf("_mngr_") != -1){
+ mngrManagerLogService.mngrManagerLogInsert(mngrManagerLogVO);
+ }
+ } catch (IOException e) {
+ logger.error("예외 상황 발생");;
+ }
+ }
+ public void mngrAopInsert(JoinPoint thisJoinPoint) throws IOException, SQLException{
+// if("".equals(CommUtil.getMngrMemId())) return; //관리자 아이디가 없으면 로그저장 안함
+ if("".equals("")) return;
+ try {
+ MngrManagerLogVO mngrManagerLogVO = getManagerLog(thisJoinPoint, "C");
+ if(CommUtil.isNull(mngrManagerLogVO.getMlogUrl(), "null").indexOf("_mngr_") != -1){
+ mngrManagerLogService.mngrManagerLogInsert(mngrManagerLogVO);
+ }
+ } catch (IOException e) {
+ logger.error("예외 상황 발생");;
+ }
+ }
+ public void mngrAopUpdate(JoinPoint thisJoinPoint) throws IOException, SQLException{
+ if("".equals(CommUtil.getMngrMemId())) return; //관리자 아이디가 없으면 로그저장 안함
+ try {
+ MngrManagerLogVO mngrManagerLogVO = getManagerLog(thisJoinPoint, "U");
+ if(CommUtil.isNull(mngrManagerLogVO.getMlogUrl(), "null").indexOf("_mngr_") != -1){
+ mngrManagerLogService.mngrManagerLogInsert(mngrManagerLogVO);
+ }
+ } catch (IOException e) {
+ logger.error("예외 상황 발생");;
+ }
+ }
+ public void mngrAopDelete(JoinPoint thisJoinPoint) throws IOException, SQLException{
+ if("".equals(CommUtil.getMngrMemId())) return; //관리자 아이디가 없으면 로그저장 안함
+ try {
+ MngrManagerLogVO mngrManagerLogVO = getManagerLog(thisJoinPoint, "D");
+ if(CommUtil.isNull(mngrManagerLogVO.getMlogUrl(), "null").indexOf("_mngr_") != -1){
+ mngrManagerLogService.mngrManagerLogInsert(mngrManagerLogVO);
+ }
+ } catch (IOException e) {
+ logger.error("예외 상황 발생");;
+ }
+ }
+
+ private MngrManagerLogVO getManagerLog(JoinPoint thisJoinPoint, String logType) throws IOException, SQLException{
+ MngrManagerLogVO mngrManagerLogVO = new MngrManagerLogVO();
+ mngrManagerLogVO.setMlogClass( thisJoinPoint.getTarget().getClass().getName() );
+ mngrManagerLogVO.setMlogMethod( thisJoinPoint.getSignature().getName() );
+ mngrManagerLogVO.setMlogType(logType);
+ mngrManagerLogVO.setMngId(CommUtil.getMngrMemId());
+ mngrManagerLogVO.setMngName(CommUtil.getMngrSessionVO().getName());
+ mngrManagerLogVO.setMlogIp(CommUtil.getClientIP(request));
+ mngrManagerLogVO.setMlogReferer(request.getHeader("REFERER"));
+
+ String url = request.getRequestURL().toString();
+ if(url != null && request.getQueryString() != null){
+ url += "?" + request.getQueryString();
+ }
+ mngrManagerLogVO.setMlogUrl(url);
+
+ return mngrManagerLogVO;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/common/MngrSessionVO.java b/src/main/java/egovframework/itgcms/common/MngrSessionVO.java
new file mode 100644
index 0000000..3a29cb1
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/MngrSessionVO.java
@@ -0,0 +1,116 @@
+package egovframework.itgcms.common;
+
+import java.io.Serializable;
+
+public class MngrSessionVO implements Serializable{
+
+ /**
+ * 관리자 세션 정보
+ */
+ private static final long serialVersionUID = 2770149179317205761L;
+ /** 아이디 */
+ String id = "";
+ /** 이름 */
+ String name = "";
+ /** 이메일 */
+ String email = "";
+ /** 전화번호 */
+ String phone = "";
+ /** 부서 */
+ String group = "";
+ /** 직위 */
+ String position = "";
+ /** 컨텐츠권한 */
+ String authority = "";
+ /** 관리자 구분 */
+ String type = "";
+ /** 그룹명 */
+ String groupName = "";
+ /** 직위명 */
+ String positionName = "";
+ /** 관리권한(관리메뉴)*/
+ String mngPower = "";
+ /** 관리자 등급*/
+ String mngAuth = "";
+ /** 관리자 등급*/
+ String licenseType = "";
+
+ public String getLicenseType() {
+ return licenseType;
+ }
+ public void setLicenseType(String licenseType) {
+ this.licenseType = licenseType;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getEmail() {
+ return email;
+ }
+ public void setEmail(String email) {
+ this.email = email;
+ }
+ public String getPhone() {
+ return phone;
+ }
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+ public String getGroup() {
+ return group;
+ }
+ public void setGroup(String group) {
+ this.group = group;
+ }
+ public String getPosition() {
+ return position;
+ }
+ public void setPosition(String position) {
+ this.position = position;
+ }
+ public String getAuthority() {
+ return authority;
+ }
+ public void setAuthority(String authority) {
+ this.authority = authority;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getGroupName() {
+ return groupName;
+ }
+ public void setGroupName(String groupName) {
+ this.groupName = groupName;
+ }
+ public String getPositionName() {
+ return positionName;
+ }
+ public void setPositionName(String positionName) {
+ this.positionName = positionName;
+ }
+ public String getMngPower() {
+ return mngPower;
+ }
+ public void setMngPower(String mngPower) {
+ this.mngPower = mngPower;
+ }
+ public String getMngAuth() {
+ return mngAuth;
+ }
+ public void setMngAuth(String mngAuth) {
+ this.mngAuth = mngAuth;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/common/SystemInit.java b/src/main/java/egovframework/itgcms/common/SystemInit.java
new file mode 100644
index 0000000..34b2542
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/SystemInit.java
@@ -0,0 +1,43 @@
+package egovframework.itgcms.common;
+
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
+import org.springframework.context.annotation.Configuration;
+
+import egovframework.itgcms.util.CommUtil;
+
+public class SystemInit extends javax.servlet.http.HttpServlet {
+ public SystemInit(){
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p("");
+ CommUtil.p(super.getServletContext());
+
+ }
+
+}
diff --git a/src/main/java/egovframework/itgcms/common/UserAOP.java b/src/main/java/egovframework/itgcms/common/UserAOP.java
new file mode 100644
index 0000000..949dec2
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/UserAOP.java
@@ -0,0 +1,78 @@
+package egovframework.itgcms.common;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import egovframework.itgcms.core.menu.service.MngrMemIpManageVO;
+import egovframework.itgcms.core.menu.service.impl.MngrMemIPManageMapper;
+
+@Component
+@Aspect
+public class UserAOP {
+
+ private static final Logger logger = LogManager.getLogger(UserAOP.class);
+
+ public UserAOP() {
+// logger.info("UserAOP 생성");
+ }
+
+ @Resource(name="mngrMemIPManageMapper")
+ private MngrMemIPManageMapper mngrMemIPManageMapper;
+
+ @Autowired
+ HttpServletRequest request;
+
+ /*
+ * 회원 IP를 확인하는 AOP
+ * user 패키지의 모든 컨트롤러
+ * 해당 AOP의 결과값을 제대로 리턴 받기 위해서는 해당 JoinPoint에 HttpServletResponse를 파라미터에 포함시켜야함.
+ */
+ @Around("execution(* egovframework.itgcms.user.*.web.*Controller.*(..))")
+ private Object aroundUserPackageCheckIP(ProceedingJoinPoint joinPoint) throws Throwable{
+
+ String siteCode = request.getRequestURI().split("/")[1];
+ String userIp = request.getRemoteAddr();
+
+ HttpSession session = request.getSession();
+ MngrMemIpManageVO ipManager = null;
+ boolean ipCheck = false;
+ HttpServletResponse response = null;
+
+ // DB 쿼리 숫자를 줄여주기 위해 세션에 IP체크 여부를 저장하여 사용
+ if (session.getAttribute("ipCheck")==null) {
+ ipManager =mngrMemIPManageMapper.mngrIPManageBySiteCode(siteCode);
+ if (ipManager!=null) {
+ ipCheck = ipManager.checkVaildIP(userIp);
+ session.setAttribute("ipCheck", ipCheck);
+ }
+ }
+
+ Object returnVal = joinPoint.proceed();
+
+ if (!(boolean)session.getAttribute("ipCheck")) {
+ // joinPoint(컨트롤러 메소드)의 파라미터 중 response 객체를 추출함
+ for (Object obj : joinPoint.getArgs()) {
+ if (obj instanceof HttpServletResponse) {
+ response = (HttpServletResponse)obj;
+ }
+ }
+ // 추출한 response에 404에러를 보냄
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ return returnVal;
+ }
+
+
+
+}
diff --git a/src/main/java/egovframework/itgcms/common/UserSessionVO.java b/src/main/java/egovframework/itgcms/common/UserSessionVO.java
new file mode 100644
index 0000000..144c15d
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/UserSessionVO.java
@@ -0,0 +1,103 @@
+package egovframework.itgcms.common;
+
+import java.io.Serializable;
+
+public class UserSessionVO implements Serializable{
+
+ /**
+ * 사용자 세션 정보
+ */
+ private static final long serialVersionUID = -2654714480050608809L;
+
+ /** 아이디 */
+ String id = "";
+ /** 이름 */
+ String name = "";
+ /** 이메일 */
+ String email = "";
+ /** 전화번호 */
+ String phone = "";
+ /** REG ID */
+ String regId = "";
+ /** 차량번호 */
+ String vhcleNo = "";
+ /** 차대번호 */
+ String vin = "";
+ /** 차량 관리번호 */
+ String vhmno = "";
+ /** 회원번호 */
+ String mberNo = "";
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public String getRegId() {
+ return regId;
+ }
+
+ public String getVhcleNo() {
+ return vhcleNo;
+ }
+
+ public String getVin() {
+ return vin;
+ }
+
+ public String getVhmno() {
+ return vhmno;
+ }
+
+ public String getMberNo() {
+ return mberNo;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public void setRegId(String regId) {
+ this.regId = regId;
+ }
+
+ public void setVhcleNo(String vhcleNo) {
+ this.vhcleNo = vhcleNo;
+ }
+
+ public void setVin(String vin) {
+ this.vin = vin;
+ }
+
+ public void setVhmno(String vhmno) {
+ this.vhmno = vhmno;
+ }
+
+ public void setMberNo(String mberNo) {
+ this.mberNo = mberNo;
+ }
+
+}
diff --git a/src/main/java/egovframework/itgcms/common/del_ExcelDownLoad.java b/src/main/java/egovframework/itgcms/common/del_ExcelDownLoad.java
new file mode 100644
index 0000000..e80f990
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/common/del_ExcelDownLoad.java
@@ -0,0 +1,750 @@
+package egovframework.itgcms.common;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.ModelAndView;
+
+import egovframework.itgcms.core.board.service.BoardService;
+import egovframework.itgcms.core.board.service.BoardVO;
+import egovframework.itgcms.core.boardconfig.service.MngrBoardconfigService;
+import egovframework.itgcms.core.boardconfig.service.MngrBoardconfigVO;
+//import egovframework.itgcms.core.member.service.MemberService;
+import egovframework.itgcms.core.member.service.MemberVO;
+//import egovframework.itgcms.core.stats.service.MngrCountVO;
+//import egovframework.itgcms.core.stats.service.MngrStatsService;
+import egovframework.itgcms.util.CommUtil;
+import egovframework.itgcms.util.ExcelDownloadView;
+
+@Controller
+public class del_ExcelDownLoad {
+
+ /** MngrSiteService */
+// @Resource(name = "mngrStatsService")
+// private MngrStatsService mngrStatsService;
+//
+//// /** MemberService */
+//// @Resource(name = "memberService")
+//// private MemberService memberService;
+//
+// @Resource(name="boardService")
+// private BoardService boardService;
+//
+// @Resource(name="mngrBoardconfigService")
+// private MngrBoardconfigService boardConfigService;
+// /**
+// * 엑셀 파일명 규칙
+// * ex) //adminStatus.do
+// *
+// * 1. method : aStatusExcelDownload
+// * 2. URL : /excel/aStatusExcelDownload.do
+// * 3. 엑셀파일명 : admin.aStatusExcelDownload.xls
+// * 4. 템플릿이름 : admin
+// *
+// **/
+//
+//
+// /**
+// * 회원정보 엑셀 다운로드
+// * @param searchVO
+// * @return
+// */
+// @RequestMapping(value = "/excel/mngrMemberExcelDown.do", method = RequestMethod.POST)
+// public ModelAndView mngrMemberExcelDownload(@ModelAttribute("memberVO") MemberVO searchVO, HttpServletRequest request) {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+// Map paramMap = CommUtil.getParameterMap(request);
+//
+// /************************ 출력목록 ************************/
+//// paramMap.put("dataList",memberService.selectMemberList(searchVO));
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "회원내역_" + CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// searchVO.setSchExcel("N");
+// return mav;
+// }
+//
+// /**
+// * 관리자 - 날짜별 접속자 현황 목록 엑셀다운로드
+// * @param
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsDateExcelDown.do")
+// public ModelAndView mngrStatsDateExcelDown(MngrCountVO paramCountVO, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+//
+// /************************ 출력목록 ************************/
+//
+// if("".equals(paramCountVO.getSchOption())){
+// paramCountVO.setSchOption("DAY_M");
+// }
+//
+// //String schDate = CommUtil.getDatePattern("yyyy-MM-dd hh");
+//
+// String schDate = CommUtil.isNull(paramCountVO.getSchDate(), "");
+// if("".equals(schDate)){
+// schDate = CommUtil.getDatePattern("yyyy-MM-dd");
+//
+// }
+//
+// String date = CommUtil.getDateforStat(schDate, paramCountVO.getSchOption());
+// String cntOptName="";
+//
+// String dateArr[] = date.split("-");
+//
+// if("HOUR".equals(paramCountVO.getSchOption())){
+// cntOptName = "시간단위";
+// paramCountVO.setCntOption("HOUR");
+// paramCountVO.setCntYear(dateArr[0]);
+// paramCountVO.setCntMonth(dateArr[1]);
+// paramCountVO.setCntDay(dateArr[2]);
+// paramCountVO.setSchDate(dateArr[0]+"-"+dateArr[1]+"-"+dateArr[2]);
+///* }else if("DAY_W".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setCntYear(dateArr[0]);
+// paramCountVO.setCntMonth(dateArr[1]);*/
+// }else if("DAY_M".equals(paramCountVO.getSchOption())){
+// cntOptName = "일단위";
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setCntYear(dateArr[0]);
+// paramCountVO.setCntMonth(dateArr[1]);
+// paramCountVO.setSchDate(dateArr[0]+"-"+dateArr[1]);
+// }else if("MONTH".equals(paramCountVO.getSchOption())){
+// cntOptName = "월단위";
+// paramCountVO.setCntOption("MONTH");
+// paramCountVO.setCntYear(dateArr[0]);
+// paramCountVO.setSchDate(dateArr[0]);
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// cntOptName = "년단위";
+// paramCountVO.setCntOption("YEAR");
+// }
+//
+// List resultList = mngrStatsService.mngrDateCountList(paramCountVO);
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+//
+// paramMap.put("dataList",resultList);
+//
+// //시작일~종료일
+// paramMap.put("schDate",paramCountVO.getSchDate());
+// paramMap.put("cntOptName",cntOptName);
+//
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "날짜("+paramCountVO.getCntOption()+")별 접속통계_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+// /**
+// * 관리자 - 기간별 접속자 현황 목록 엑셀다운로드
+// * @param
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsTermExcelDown.do")
+// public ModelAndView mngrStatsTermExcelDown(MngrCountVO paramCountVO, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+//
+// /************************ S: 출력목록 ************************/
+//
+// if("".equals(paramCountVO.getSchOption())){
+// paramCountVO.setSchOption("DAY_M");
+// }
+//
+// String schDateFrom = CommUtil.isNull(paramCountVO.getSchDateFrom(), "");
+// if("".equals(schDateFrom)){
+// schDateFrom = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String schDateEnd = CommUtil.isNull(paramCountVO.getSchDateEnd(), "");
+// if("".equals(schDateEnd)){
+// schDateEnd = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String dateFrom = CommUtil.getDateforStat(schDateFrom, paramCountVO.getSchOption());
+// String dateEnd = CommUtil.getDateforStat(schDateEnd, paramCountVO.getSchOption());
+// String cntOptName="";
+// String cntOptTitle="";
+//
+// paramCountVO.setSchDateFrom(dateFrom);
+// paramCountVO.setSchDateEnd(dateEnd);
+//
+// String dateFromArr[] = dateFrom.split("-");
+// String dateEndArr[] = dateEnd.split("-");
+//
+// if("HOUR".equals(paramCountVO.getSchOption())){
+// cntOptName = "시간단위";
+// cntOptTitle = "시간";
+// paramCountVO.setCntOption("HOUR");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]+"-"+dateFromArr[2]);
+//
+// int lastDate = Integer.parseInt(dateEndArr[2])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+dateEndArr[1]+"-"+lastDateStr);
+// }else if("DAY_M".equals(paramCountVO.getSchOption())){
+// cntOptName = "일단위";
+// cntOptTitle = "일자";
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]);
+// int lastDate = Integer.parseInt(dateEndArr[1])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+lastDateStr);
+// } else if("DAY_W".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]);
+// cntOptName = "요일 단위";
+// cntOptTitle = "요일";
+// int lastDate = Integer.parseInt(dateEndArr[1])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+lastDateStr);
+// }else if("MONTH".equals(paramCountVO.getSchOption())){
+// cntOptName = "월단위";
+// cntOptTitle = "월";
+// paramCountVO.setCntOption("MONTH");
+// paramCountVO.setStartDate(dateFromArr[0]);
+// int lastDate = Integer.parseInt(dateEndArr[0])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(lastDateStr);
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// cntOptName = "년단위";
+// cntOptTitle = "년";
+// paramCountVO.setCntOption("YEAR");
+// paramCountVO.setStartDate(dateFromArr[0]);
+// String lastDateStr =""+(Integer.parseInt(dateEndArr[0])+1);
+// paramCountVO.setEndDate(lastDateStr);
+// }
+//
+// List resultList = mngrStatsService.mngrTermCountList(paramCountVO);
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+// paramMap.put("dataList",resultList);
+//
+// //시작일~종료일
+// paramMap.put("startDate",dateFrom);
+// paramMap.put("endDate",dateEnd);
+// paramMap.put("cntOptName",cntOptName);
+// paramMap.put("cntOptTitle",cntOptTitle);
+//
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "기간("+paramCountVO.getCntOption()+")별 접속통계_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+// /**
+// * 관리자 - 옵션별 접속자 현황 목록 엑셀다운로드
+// * @param
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsOptExcelDown.do")
+// public ModelAndView mngrStatsOptExcelDown(MngrCountVO paramCountVO, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+// String optNm = "";
+// //"DEVICE","OS","BROWSER","SEARCHENGINE"
+//
+// if("DEVICE".equals(paramCountVO.getSchOption()))optNm = "단말기";
+// else if("OS".equals(paramCountVO.getSchOption()))optNm = "운영체제";
+// else if("BROWSER".equals(paramCountVO.getSchOption()))optNm = "브라우저";
+// else if("SEARCHENGINE".equals(paramCountVO.getSchOption()))optNm = "검색엔진";
+// /************************ 출력목록 ************************/
+//
+// paramCountVO.setCntOption(paramCountVO.getSchOption());
+//
+// List resultList = mngrStatsService.mngrOptionCountList(paramCountVO);
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+//
+// paramMap.put("dataList",resultList);
+// paramMap.put("optNm",optNm);
+//
+//
+//
+//
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, optNm+"별 접속통계_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+// /**
+// * 관리자 - 기간별 접속자 현황 목록 엑셀다운로드
+// * @param
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsMenuExcelDown.do")
+// public ModelAndView mngrStatsMenuExcelDown(MngrCountVO paramCountVO, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+//
+// /************************ S: 출력목록 ************************/
+//
+// String schDateFrom = CommUtil.isNull(paramCountVO.getSchDateFrom(), "");
+// if("".equals(schDateFrom)){
+// schDateFrom = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String schDateEnd = CommUtil.isNull(paramCountVO.getSchDateEnd(), "");
+// if("".equals(schDateEnd)){
+// schDateEnd = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String dateFrom ="";
+// String dateEnd = "";
+//
+// if("DAY".equals(paramCountVO.getSchOption())){
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "HOUR");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "HOUR");
+// }else if("MONTH".equals(paramCountVO.getSchOption())){
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "DAY_M");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "DAY_M");
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "MONTH");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "MONTH");
+// }else {
+// paramCountVO.setSchOption("DAY");
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "HOUR");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "HOUR");
+// }
+//
+// paramCountVO.setSchDateFrom(dateFrom);
+// paramCountVO.setSchDateEnd(dateEnd);
+//
+// String dateFromArr[] = dateFrom.split("-");
+// String dateEndArr[] = dateEnd.split("-");
+//
+//
+// if("DAY".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]+"-"+dateFromArr[2]);
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+dateEndArr[1]+"-"+dateEndArr[2]);
+// }else if("MONTH".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("MONTH");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]);
+// int lastDate = Integer.parseInt(dateEndArr[1])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+lastDateStr);
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("YEAR");
+// paramCountVO.setStartDate(dateFromArr[0]);
+// int lastDate = Integer.parseInt(dateEndArr[0])+1;
+// String lastDateStr = ""+lastDate;
+// paramCountVO.setEndDate(lastDateStr);
+// }
+//
+// List resultList = mngrStatsService.mngrMenuCountList(paramCountVO);
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+// paramMap.put("dataList",resultList);
+//
+// //시작일~종료일
+// paramMap.put("startDate",dateFrom);
+// paramMap.put("endDate",dateEnd);
+// //paramMap.put("cntOptName",cntOptName);
+// //paramMap.put("cntOptTitle",cntOptTitle);
+//
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "메뉴("+paramCountVO.getCntOption()+")별 접속통계_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+// /**
+// * 관리자 - 기간별 접속자 현황 목록 엑셀다운로드(보고용)
+// * @param
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsReportMenuExcelDown.do")
+// public ModelAndView mngrStatsReportMenuExcelDown(MngrCountVO paramCountVO, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+//
+// /************************ S: 출력목록 ************************/
+//
+// String schDateFrom = CommUtil.isNull(paramCountVO.getSchDateFrom(), "");
+// if("".equals(schDateFrom)){
+// schDateFrom = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String schDateEnd = CommUtil.isNull(paramCountVO.getSchDateEnd(), "");
+// if("".equals(schDateEnd)){
+// schDateEnd = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String dateFrom ="";
+// String dateEnd = "";
+//
+// if("DAY".equals(paramCountVO.getSchOption())){
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "HOUR");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "HOUR");
+// }else if("MONTH".equals(paramCountVO.getSchOption())){
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "DAY_M");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "DAY_M");
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "MONTH");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "MONTH");
+// }else {
+// paramCountVO.setSchOption("DAY");
+// dateFrom = CommUtil.getDateforStat(schDateFrom, "HOUR");
+// dateEnd = CommUtil.getDateforStat(schDateEnd, "HOUR");
+// }
+//
+// paramCountVO.setSchDateFrom(dateFrom);
+// paramCountVO.setSchDateEnd(dateEnd);
+//
+// String dateFromArr[] = dateFrom.split("-");
+// String dateEndArr[] = dateEnd.split("-");
+//
+//
+// if("DAY".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]+"-"+dateFromArr[2]);
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+dateEndArr[1]+"-"+dateEndArr[2]);
+// }else if("MONTH".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("MONTH");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]);
+// int lastDate = Integer.parseInt(dateEndArr[1])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+lastDateStr);
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("YEAR");
+// paramCountVO.setStartDate(dateFromArr[0]);
+// int lastDate = Integer.parseInt(dateEndArr[0])+1;
+// String lastDateStr = ""+lastDate;
+// paramCountVO.setEndDate(lastDateStr);
+// }
+//
+// List resultList = new ArrayList();
+//
+// String mname ="";
+//
+// if("lifecycle".equals(request.getParameter("gubun"))){ //생애주기별 통계
+// resultList = mngrStatsService.mngrReportLifeCycleMenuCountList(paramCountVO);
+// mname ="생애주기별 통계";
+// } else if("no15".equals(request.getParameter("gubun"))){ //15위통계
+// resultList = mngrStatsService.mngrReportNo15MenuCountList(paramCountVO);
+// mname ="15위 통계";
+// } else{ //기존꺼에 중복 제거와 전체임
+// resultList = mngrStatsService.mngrReportMenuCountList(paramCountVO);
+// mname ="대메뉴 제외 통계";
+// }
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+// paramMap.put("dataList",resultList);
+//
+// //시작일~종료일
+// paramMap.put("startDate",dateFrom);
+// paramMap.put("endDate",dateEnd);
+// //paramMap.put("cntOptName",cntOptName);
+// //paramMap.put("cntOptTitle",cntOptTitle);
+//
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "메뉴("+paramCountVO.getCntOption()+")별 접속통계(보고용)_"+mname+"_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+// /**
+// * 게시판별 통계 엑셀다운로드
+// * @param siteCode
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsBoardExcelDown.do")
+// public ModelAndView mngrStatsBoardExcelDown(@RequestParam(value="siteCode", required=false) String siteCode, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+// //"DEVICE","OS","BROWSER","SEARCHENGINE"
+//
+// if ("".equals(siteCode) || siteCode == null) {
+// siteCode = "web";
+// }
+//
+// /************************ 출력목록 ************************/
+//
+// List resultList = mngrStatsService.mngrBoardStats(siteCode);
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+//
+// paramMap.put("dataList",resultList);
+//
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "게시판 통계_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+//
+// /**
+// * 연령대별 통계 엑셀다운로드
+// * @param siteCode
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/excel/mngrStatsAgeExcelDown.do")
+// public ModelAndView mngrStatsAgeExcelDown(MngrCountVO paramCountVO, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+// String optNm = "";
+// //"DEVICE","OS","BROWSER","SEARCHENGINE"
+//
+// if("".equals(paramCountVO.getSchOption())){
+// paramCountVO.setSchOption("DAY_M");
+// }
+//
+// String schDateFrom = CommUtil.isNull(paramCountVO.getSchDateFrom(), "");
+// if("".equals(schDateFrom)){
+// schDateFrom = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+//
+// String schDateEnd = CommUtil.isNull(paramCountVO.getSchDateEnd(), "");
+// if("".equals(schDateEnd)){
+// schDateEnd = CommUtil.getDatePattern("yyyy-MM-dd");
+// }
+// /*
+// String dateFrom = CommUtil.getDateforStat(schDateFrom, paramCountVO.getSchOption());
+// String dateEnd = CommUtil.getDateforStat(schDateEnd, paramCountVO.getSchOption());
+// */
+//
+// paramCountVO.setSchDateFrom(schDateFrom);
+// paramCountVO.setSchDateEnd(schDateEnd);
+//
+// String dateFromArr[] = paramCountVO.getSchDateFrom().split("-");
+// String dateEndArr[] = paramCountVO.getSchDateEnd().split("-");
+//
+// if("DAY_M".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("DAY");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]+"-"+dateFromArr[2]);
+// int lastDate = Integer.parseInt(dateEndArr[2])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+dateEndArr[1]+"-"+lastDateStr);
+// } else if("MONTH".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("MONTH");
+// paramCountVO.setStartDate(dateFromArr[0]+"-"+dateFromArr[1]);
+// int lastDate = Integer.parseInt(dateEndArr[1])+1;
+// String lastDateStr = "";
+// if(lastDate<10){
+// lastDateStr += "0"+lastDate;
+// }else{
+// lastDateStr += lastDate;
+// }
+// paramCountVO.setEndDate(dateEndArr[0]+"-"+lastDateStr);
+// }else if("YEAR".equals(paramCountVO.getSchOption())){
+// paramCountVO.setCntOption("YEAR");
+// paramCountVO.setStartDate(dateFromArr[0]);
+// String lastDateStr =""+(Integer.parseInt(dateEndArr[0])+1);
+// paramCountVO.setEndDate(lastDateStr);
+// }
+//
+//
+// /************************ 출력목록 ************************/
+//
+// List resultList = mngrStatsService.mngrStatsAgeList(paramCountVO);
+//
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+//
+// paramMap.put("dataList",resultList);
+// paramMap.put("startDate", paramCountVO.getSchDateFrom());
+// paramMap.put("endDate", paramCountVO.getSchDateEnd());
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, CommUtil.getExcelTemplateName(request, "mngr"));
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, "연령대별 통계_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+//
+// }
+//
+//
+// /**
+// * 연령대별 통계 엑셀다운로드
+// * @param siteCode
+// * @param model
+// * @return
+// * @throws IOException, SQLException
+// */
+// @RequestMapping(value="/bbsExcel/{siteCode}/{bbsBcId}.do")
+// public ModelAndView mngrDownBBSExcel(@PathVariable("siteCode") String siteCode, @PathVariable("bbsBcId") String bbsBcId, HttpServletRequest request) throws IOException, SQLException {
+//
+// ModelAndView mav = new ModelAndView(ExcelDownloadView.EXCEL_DOWN);
+//
+// Map paramMap = CommUtil.getParameterMap(request);
+//
+// /************************ 출력목록 ************************/
+//
+// List resultList = boardService.selectBBSExcelData(bbsBcId);
+//
+//
+// for(int i=0; i < resultList.size(); i++) {
+// String bdContent = resultList.get(i).getBdContent();
+// String newBdContent = CommUtil.getAntiHtml(bdContent, "");
+// resultList.get(i).setBdContent(newBdContent);
+// }
+//
+// MngrBoardconfigVO boardconfigVO = new MngrBoardconfigVO();
+// boardconfigVO.setId(bbsBcId);
+//
+// boardconfigVO = boardConfigService.mngrBoardconfigView(boardconfigVO);
+// /************************ E: 출력목록 ************************/
+//
+//
+// /************************ S: 엑셀출력목록저장 ************************/
+// paramMap.put("dataList",resultList);
+// paramMap.put("totalNum",resultList.size());
+// paramMap.put("bbsTitle", boardconfigVO.getBcName());
+// //엑셀 템플릿에 넘겨줄 데이타
+// mav.addObject("data", paramMap);
+//
+// String temp = CommUtil.getExcelTemplateName(request, "mngr");
+//
+// //다운로드에 사용되어질 엑셀파일 템플릿
+// mav.addObject(ExcelDownloadView.DOWN_EXCEL_TEMPLATE, "mngr.boardData");
+// //다운로드시 표시될 파일명 (확장자는 자동으로 xls로 지정된다.)
+// mav.addObject(ExcelDownloadView.DOWN_FILE_NM, boardconfigVO.getBcName()+"_"+ CommUtil.getDatePattern("yyyy-MM-dd"));
+//
+// return mav;
+// }
+
+
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthoritySearchVO.java b/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthoritySearchVO.java
new file mode 100644
index 0000000..511a707
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthoritySearchVO.java
@@ -0,0 +1,49 @@
+package egovframework.itgcms.core.authority.service;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import egovframework.itgcms.common.DefaultVO;;
+
+public class MngrAuthoritySearchVO extends DefaultVO {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5358593433818756365L;
+ private static final Logger logger = LogManager.getLogger(MngrAuthoritySearchVO.class);
+
+ /** 관리자 아이디 */
+ String id = ""; //검색조건 유지
+ String menuCodes = "";
+
+ String query = "";
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+
+ public String getMenuCodes() {
+ return menuCodes;
+ }
+
+ public void setMenuCodes(String menuCodes) {
+ this.menuCodes = menuCodes;
+ }
+
+ public String getQuery() {
+ String query = super.queryString();
+ try{
+ query += "&id=" + java.net.URLEncoder.encode(this.id, "UTF-8");
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }
+ return query;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthorityService.java b/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthorityService.java
new file mode 100644
index 0000000..135d1f2
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthorityService.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package egovframework.itgcms.core.authority.service;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @파일명 : MngrAuthorityService.java
+ * @파일정보 : 관리자관리 서비스 interface
+ * @수정이력
+ * @수정자 수정일 수정내용
+ * @------- ------------ ----------------
+ * @woonee 2014. 9. 5. 최초생성
+ * @---------------------------------------
+ * @author (주)아이티굿 개발팀
+ * @since 2009. 01.14
+ * @version 1.0 Copyright (C) ITGOOD All right reserved.
+ */
+public interface MngrAuthorityService {
+
+ List> selectMngrRoleList()throws IOException, SQLException;
+
+ List> selectMngrPowerList()throws IOException, SQLException;
+
+ void insertMngrAuthorityRegistProc(MngrRoleVO mngrRoleVO, String menuCodes)throws IOException, SQLException;
+
+ void insertMngrAuthorityPowerRegistProc(MngrPowerVO mngrPowerVO, String menuCodes)throws IOException, SQLException;
+
+ List> selectMngrAuthorityViewAjax(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException;
+
+ List> selectMngrAuthorityPowerViewAjax(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException;
+
+ MngrRoleVO mSelectMngrRoleView(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException;
+
+ MngrPowerVO selectMngrPowerView(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException;
+
+ void updateMngrAuthorityUpdateProc(MngrRoleVO mngrRoleVO, String menuCodes)throws IOException, SQLException;
+
+ void updateMngrAuthorityPowerUpdateProc(MngrPowerVO mngrPowerVO, String menuCodes)throws IOException, SQLException;
+
+ void deleteMngrAuthorityDeleteProc(MngrRoleVO mngrRoleVO,MngrAuthorityVO mngrAuthorityVO)throws IOException, SQLException;
+
+ void deleteMngrAuthorityPowerDeleteProc(MngrPowerVO mngrPowerVO,MngrAuthorityVO mngrAuthorityVO)throws IOException, SQLException;
+
+ void updateMngrAuthorityUpdateManagerAuth(MngrAuthorityVO mngrAuthorityVO)throws IOException, SQLException;
+
+ void updateMngrAuthorityPowerUpdateManagerAuth(MngrPowerVO mngrPowerVO)throws IOException, SQLException;
+
+ int mngrPowerCodeCheck(MngrPowerVO mngrPowerVO) throws IOException, SQLException;
+
+ void insertMngrLevelRegistProc(MngrPowerVO mngrPowerVO)throws IOException, SQLException;
+
+ void updateMngrLevelRegistProc(MngrPowerVO mngrPowerVO, HttpServletRequest request) throws IOException, SQLException;
+
+ void deleteMngrLevelRegistProc(MngrPowerVO mngrPowerVO)throws IOException, SQLException;
+
+ MngrPowerVO selectMngrPowerView(MngrPowerVO mngrPowerVO) throws IOException, SQLException;
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthorityVO.java b/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthorityVO.java
new file mode 100644
index 0000000..f4cb005
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/MngrAuthorityVO.java
@@ -0,0 +1,103 @@
+package egovframework.itgcms.core.authority.service;
+
+
+public class MngrAuthorityVO extends MngrAuthoritySearchVO{
+
+ private static final long serialVersionUID = 1517554024024657795L;
+
+ String roleIdx = "";
+ String powerIdx = "";
+ String authType = "";
+ String menuCode = "";
+ String mngId = "";
+ String regdt = "";
+ String upddt = "";
+ String deldt = "";
+ String regmemid = "";
+ String updmemid = "";
+ String delmemid = "";
+ String delyn = "";
+
+ String authIdx = "";
+
+ public String getRoleIdx() {
+ return roleIdx;
+ }
+ public void setRoleIdx(String roleIdx) {
+ this.roleIdx = roleIdx;
+ }
+ public String getPowerIdx() {
+ return powerIdx;
+ }
+ public void setPowerIdx(String powerIdx) {
+ this.powerIdx = powerIdx;
+ }
+ public String getAuthType() {
+ return authType;
+ }
+ public void setAuthType(String authType) {
+ this.authType = authType;
+ }
+ public String getMenuCode() {
+ return menuCode;
+ }
+ public void setMenuCode(String menuCode) {
+ this.menuCode = menuCode;
+ }
+ public String getMngId() {
+ return mngId;
+ }
+ public void setMngId(String mngId) {
+ this.mngId = mngId;
+ }
+ public String getRegdt() {
+ return regdt;
+ }
+ public void setRegdt(String regdt) {
+ this.regdt = regdt;
+ }
+ public String getUpddt() {
+ return upddt;
+ }
+ public void setUpddt(String upddt) {
+ this.upddt = upddt;
+ }
+ public String getDeldt() {
+ return deldt;
+ }
+ public void setDeldt(String deldt) {
+ this.deldt = deldt;
+ }
+ public String getRegmemid() {
+ return regmemid;
+ }
+ public void setRegmemid(String regmemid) {
+ this.regmemid = regmemid;
+ }
+ public String getUpdmemid() {
+ return updmemid;
+ }
+ public void setUpdmemid(String updmemid) {
+ this.updmemid = updmemid;
+ }
+ public String getDelmemid() {
+ return delmemid;
+ }
+ public void setDelmemid(String delmemid) {
+ this.delmemid = delmemid;
+ }
+ public String getDelyn() {
+ return delyn;
+ }
+ public void setDelyn(String delyn) {
+ this.delyn = delyn;
+ }
+ public String getAuthIdx() {
+ return authIdx;
+ }
+ public void setAuthIdx(String authIdx) {
+ this.authIdx = authIdx;
+ }
+
+
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/MngrPowerVO.java b/src/main/java/egovframework/itgcms/core/authority/service/MngrPowerVO.java
new file mode 100644
index 0000000..43ee78c
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/MngrPowerVO.java
@@ -0,0 +1,87 @@
+package egovframework.itgcms.core.authority.service;
+
+import java.util.HashMap;
+
+
+public class MngrPowerVO extends MngrAuthoritySearchVO{
+ private static final long serialVersionUID = 3520051843842653012L;
+
+ String powerIdx = "";
+ String powerName = "";
+ String powerCode = "";
+ String regdt = "";
+ String upddt = "";
+ String deldt = "";
+ String regmemid = "";
+ String updmemid = "";
+ String delmemid = "";
+ String delyn = "";
+ String managerCount = "";
+
+ public String getPowerIdx() {
+ return powerIdx;
+ }
+ public void setPowerIdx(String powerIdx) {
+ this.powerIdx = powerIdx;
+ }
+ public String getPowerName() {
+ return powerName;
+ }
+ public void setPowerName(String powerName) {
+ this.powerName = powerName;
+ }
+ public String getPowerCode() {
+ return powerCode;
+ }
+ public void setPowerCode(String powerCode) {
+ this.powerCode = powerCode;
+ }
+ public String getRegdt() {
+ return regdt;
+ }
+ public void setRegdt(String regdt) {
+ this.regdt = regdt;
+ }
+ public String getUpddt() {
+ return upddt;
+ }
+ public void setUpddt(String upddt) {
+ this.upddt = upddt;
+ }
+ public String getDeldt() {
+ return deldt;
+ }
+ public void setDeldt(String deldt) {
+ this.deldt = deldt;
+ }
+ public String getRegmemid() {
+ return regmemid;
+ }
+ public void setRegmemid(String regmemid) {
+ this.regmemid = regmemid;
+ }
+ public String getUpdmemid() {
+ return updmemid;
+ }
+ public void setUpdmemid(String updmemid) {
+ this.updmemid = updmemid;
+ }
+ public String getDelmemid() {
+ return delmemid;
+ }
+ public void setDelmemid(String delmemid) {
+ this.delmemid = delmemid;
+ }
+ public String getDelyn() {
+ return delyn;
+ }
+ public void setDelyn(String delyn) {
+ this.delyn = delyn;
+ }
+ public String getManagerCount() {
+ return managerCount;
+ }
+ public void setManagerCount(String managerCount) {
+ this.managerCount = managerCount;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/MngrRoleSearchVO.java b/src/main/java/egovframework/itgcms/core/authority/service/MngrRoleSearchVO.java
new file mode 100644
index 0000000..7f03309
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/MngrRoleSearchVO.java
@@ -0,0 +1,41 @@
+package egovframework.itgcms.core.authority.service;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import egovframework.itgcms.common.DefaultVO;;
+
+public class MngrRoleSearchVO extends DefaultVO {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5358593433818756365L;
+
+ private static final Logger logger = LogManager.getLogger(MngrRoleSearchVO.class);
+
+ /** 관리자 아이디 */
+ String id = ""; //검색조건 유지
+
+ String query = "";
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+
+ public String getQuery() {
+ String query = super.queryString();
+ try{
+ query += "&id=" + java.net.URLEncoder.encode(this.id, "UTF-8");
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }
+ return query;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/MngrRoleVO.java b/src/main/java/egovframework/itgcms/core/authority/service/MngrRoleVO.java
new file mode 100644
index 0000000..6e13427
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/MngrRoleVO.java
@@ -0,0 +1,80 @@
+package egovframework.itgcms.core.authority.service;
+
+
+public class MngrRoleVO extends MngrAuthoritySearchVO{
+ private static final long serialVersionUID = 3520051843842653012L;
+
+ String roleIdx = "";
+ String roleName = "";
+ String regdt = "";
+ String upddt = "";
+ String deldt = "";
+ String regmemid = "";
+ String updmemid = "";
+ String delmemid = "";
+ String delyn = "";
+ String managerCount = "";
+
+ public String getRoleIdx() {
+ return roleIdx;
+ }
+ public void setRoleIdx(String roleIdx) {
+ this.roleIdx = roleIdx;
+ }
+ public String getRoleName() {
+ return roleName;
+ }
+ public void setRoleName(String roleName) {
+ this.roleName = roleName;
+ }
+ public String getRegdt() {
+ return regdt;
+ }
+ public void setRegdt(String regdt) {
+ this.regdt = regdt;
+ }
+ public String getUpddt() {
+ return upddt;
+ }
+ public void setUpddt(String upddt) {
+ this.upddt = upddt;
+ }
+ public String getDeldt() {
+ return deldt;
+ }
+ public void setDeldt(String deldt) {
+ this.deldt = deldt;
+ }
+ public String getRegmemid() {
+ return regmemid;
+ }
+ public void setRegmemid(String regmemid) {
+ this.regmemid = regmemid;
+ }
+ public String getUpdmemid() {
+ return updmemid;
+ }
+ public void setUpdmemid(String updmemid) {
+ this.updmemid = updmemid;
+ }
+ public String getDelmemid() {
+ return delmemid;
+ }
+ public void setDelmemid(String delmemid) {
+ this.delmemid = delmemid;
+ }
+ public String getDelyn() {
+ return delyn;
+ }
+ public void setDelyn(String delyn) {
+ this.delyn = delyn;
+ }
+ public String getManagerCount() {
+ return managerCount;
+ }
+ public void setManagerCount(String managerCount) {
+ this.managerCount = managerCount;
+ }
+
+
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/impl/MngrAuthorityMapper.java b/src/main/java/egovframework/itgcms/core/authority/service/impl/MngrAuthorityMapper.java
new file mode 100644
index 0000000..13b4d7a
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/impl/MngrAuthorityMapper.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2011 MOPAS(Ministry of Public Mngristration and Security).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package egovframework.itgcms.core.authority.service.impl;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import egovframework.itgcms.core.authority.service.MngrAuthorityVO;
+import egovframework.itgcms.core.authority.service.MngrPowerVO;
+import egovframework.itgcms.core.authority.service.MngrRoleVO;
+import egovframework.itgcms.core.site.service.MngrSiteVO;
+import egovframework.rte.psl.dataaccess.mapper.Mapper;
+
+/**
+ * authority에 관한 데이터처리 매퍼 클래스
+ *
+ * @author 표준프레임워크센터
+ * @since 2014.01.24
+ * @version 1.0
+ * @see
+ * == 개정이력(Modification Information) ==
+ *
+ * 수정일 수정자 수정내용
+ * ---------------- ------------ ---------------------------
+ * 2014.01.24 표준프레임워크센터 최초 생성
+ *
+ *
+ */
+@Mapper("mngrAuthorityMapper")
+public interface MngrAuthorityMapper {
+
+ /*
+
+ *//**
+ * 글 목록을 조회한다.
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ *//*
+ List> mngrAuthorityList(MngrAuthoritySearchVO searchVO) throws SQLException;
+
+ *//**
+ * 글 총 갯수를 조회한다.
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 총 갯수
+ * @exception
+ *//*
+ int mngrAuthorityListTotCnt(MngrAuthoritySearchVO searchVO) throws SQLException;
+
+ void mngrAuthorityRegistProc(MngrAuthorityVO authorityVO) throws SQLException;
+
+ MngrAuthorityVO mngrAuthorityView(MngrAuthoritySearchVO searchVO) throws SQLException;
+
+ void mngrAuthorityUpdateProc(MngrAuthorityVO authorityVO) throws SQLException;
+
+ void mngrAuthorityDelProc(MngrAuthorityVO authorityVO)throws SQLException;
+
+ void mngrAuthorityChkDelProc(MngrAuthorityVO authorityVO)throws SQLException;
+
+ int mngrAuthorityCheckId(MngrAuthoritySearchVO mngrAuthoritySearchVO)throws SQLException;
+
+ void mngrAuthorityInitPass(MngrAuthorityVO authorityVO)throws SQLException;
+
+ void increaseMngPassTryCnt(MngrAuthorityVO authorityVO)throws SQLException;
+
+ List mngrAuthorityListAjax(MngrAuthoritySearchVO mngrAuthoritySearchVO)throws SQLException;*/
+
+ List> mngrRoleList()throws SQLException;
+
+ List> mngrPowerList()throws SQLException;
+
+ String mngrRoleMaxIdx()throws SQLException;
+
+ String mngrPowerMaxIdx()throws SQLException;
+
+ void mngrRoleRegist(MngrRoleVO mngrRoleVO)throws SQLException;
+
+ void mngrPowerRegist(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ void mngrAuthorityRegist(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ void mngrAuthorityPowerRegist(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ List> mngrAuthorityViewAjax(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ List> mngrAuthorityPowerViewAjax(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ MngrRoleVO mngrRoleView(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ MngrPowerVO mngrPowerView(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ void mngrRoleUpdate(MngrRoleVO mngrRoleVO)throws SQLException;
+
+ void mngrPowerUpdate(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ void mngrAuthorityDelete(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ void mngrAuthorityPowerDelete(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ void mngrAuthorityChkDelete(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ void mngrRoleDelete(MngrRoleVO mngrRoleVO)throws SQLException;
+
+ void mngrPowerDelete(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ void mngrAuthorityUpdateManagerAuth(MngrAuthorityVO mngrAuthorityVO)throws SQLException;
+
+ void mngrAuthorityPowerUpdateManagerAuth(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ void mngrAuthorityDelAllSiteMenu(MngrSiteVO mngrSiteVO);
+
+ void mngrAuthorityDelAllManager(MngrSiteVO mngrSiteVO);
+
+ int mngrPowerCodeCheck(MngrPowerVO mngrPowerVO) throws SQLException ;
+
+ void MngrLevelRegistProc(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ void MngrLevelUpdateProc(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ void MngrLevelDeleteProc(MngrPowerVO mngrPowerVO)throws SQLException;
+
+ MngrPowerVO mngrPowerView(MngrPowerVO mngrPowerVO) throws SQLException;
+}
diff --git a/src/main/java/egovframework/itgcms/core/authority/service/impl/MngrAuthorityServiceImpl.java b/src/main/java/egovframework/itgcms/core/authority/service/impl/MngrAuthorityServiceImpl.java
new file mode 100644
index 0000000..4071199
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/authority/service/impl/MngrAuthorityServiceImpl.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2008-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package egovframework.itgcms.core.authority.service.impl;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import egovframework.itgcms.core.authority.service.MngrAuthorityService;
+import egovframework.itgcms.core.authority.service.MngrAuthorityVO;
+import egovframework.itgcms.core.authority.service.MngrPowerVO;
+import egovframework.itgcms.core.authority.service.MngrRoleVO;
+import egovframework.itgcms.util.CommUtil;
+import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
+
+/**
+ * @파일명 : AuthorityServiceImpl.java
+ * @파일정보 : 게시판관리 서비스 구현 클래스
+ * @수정이력
+ * @수정자 수정일 수정내용
+ * @------- ------------ ----------------
+ * @woonee 2014. 9. 5. 최초생성
+ * @---------------------------------------
+ * @author (주)아이티굿 개발팀
+ * @since 2009. 01.14
+ * @version 1.0 Copyright (C) ITGOOD All right reserved.
+ */
+
+@Service("mngrAuthorityService")
+public class MngrAuthorityServiceImpl extends EgovAbstractServiceImpl implements MngrAuthorityService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MngrAuthorityServiceImpl.class);
+
+ /** AuthorityDAO */
+ // ibatis 사용
+ /*@Resource(name="AuthorityDAO")
+ private AuthorityDAO authorityDAO;*/
+ // mybatis 사용
+ @Resource(name="mngrAuthorityMapper")
+ private MngrAuthorityMapper mngrAuthorityMapper;
+ /** MngrAuthorityService */
+ @Resource(name = "mngrAuthorityService")
+ private MngrAuthorityService mngrAuthorityService;
+
+ @Override
+ public List> selectMngrRoleList() throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrRoleList();
+ }
+ @Override
+ public List> selectMngrPowerList() throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrPowerList();
+ }
+ @Override
+ public void insertMngrAuthorityRegistProc(MngrRoleVO mngrRoleVO, String menuCodes) throws IOException, SQLException {
+ String roleIdx = mngrAuthorityMapper.mngrRoleMaxIdx(); //인덱스 조회
+ mngrRoleVO.setRoleIdx(roleIdx);//인덱스 설정
+ mngrAuthorityMapper.mngrRoleRegist(mngrRoleVO);//insert role
+ String[] arrCodes = menuCodes.split(",");
+
+ MngrAuthorityVO mngrAuthorityVO = new MngrAuthorityVO();
+ mngrAuthorityVO.setRoleIdx(roleIdx);
+ mngrAuthorityVO.setAuthType("1"); // 롤권한이 있음
+
+ mngrAuthorityVO.setRegmemid(CommUtil.getMngrMemId());
+ for(int i = 0; i < arrCodes.length; i++){
+ mngrAuthorityVO.setMenuCode(arrCodes[i]);
+ mngrAuthorityMapper.mngrAuthorityRegist(mngrAuthorityVO);
+ }
+ }
+ @Override
+ public void insertMngrAuthorityPowerRegistProc(MngrPowerVO mngrPowerVO, String menuCodes) throws IOException, SQLException {
+ //String powerIdx = mngrAuthorityMapper.mngrPowerMaxIdx(); //인덱스 조회
+ //mngrPowerVO.setPowerIdx(powerIdx);//인덱스 설정
+ mngrAuthorityMapper.mngrPowerRegist(mngrPowerVO);//insert role
+ String[] arrCodes = menuCodes.split(",");
+
+ MngrAuthorityVO mngrAuthorityVO = new MngrAuthorityVO();
+ mngrAuthorityVO.setPowerIdx(mngrPowerVO.getPowerIdx());
+ mngrAuthorityVO.setAuthType("1"); // 롤권한이 있음
+ mngrAuthorityVO.setRegmemid(CommUtil.getMngrMemId());
+
+ for(int i = 0; i < arrCodes.length; i++){
+ mngrAuthorityVO.setMenuCode(arrCodes[i]);
+ mngrAuthorityMapper.mngrAuthorityPowerRegist(mngrAuthorityVO);
+ }
+ }
+ @Override
+ public List> selectMngrAuthorityViewAjax(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrAuthorityViewAjax(mngrAuthorityVO);
+ }
+ @Override
+ public List> selectMngrAuthorityPowerViewAjax(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrAuthorityPowerViewAjax(mngrAuthorityVO);
+ }
+ @Override
+ public MngrRoleVO mSelectMngrRoleView(MngrAuthorityVO mngrAuthorityVO)throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrRoleView(mngrAuthorityVO);
+ }
+ @Override
+ public MngrPowerVO selectMngrPowerView(MngrAuthorityVO mngrAuthorityVO)throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrPowerView(mngrAuthorityVO);
+ }
+ @Override
+ public void updateMngrAuthorityUpdateProc(MngrRoleVO mngrRoleVO, String menuCodes) throws IOException, SQLException {
+ mngrAuthorityMapper.mngrRoleUpdate(mngrRoleVO);//update role
+
+ String[] arrCodes = menuCodes.split(",");
+
+ MngrAuthorityVO mngrAuthorityVO = new MngrAuthorityVO();
+ mngrAuthorityVO.setRoleIdx(mngrRoleVO.getRoleIdx());
+ mngrAuthorityVO.setAuthType("1"); // 롤권한이 있음
+
+ mngrAuthorityMapper.mngrAuthorityDelete(mngrAuthorityVO); //기존 메뉴 권한 삭제
+
+ //삭제후 등록
+ mngrAuthorityVO.setRegmemid(CommUtil.getMngrMemId());
+ for(int i = 0; i < arrCodes.length; i++){
+ mngrAuthorityVO.setMenuCode(arrCodes[i]);
+ mngrAuthorityMapper.mngrAuthorityRegist(mngrAuthorityVO);
+ }
+ }
+ @Override
+ public void updateMngrAuthorityPowerUpdateProc(MngrPowerVO mngrPowerVO, String menuCodes) throws IOException, SQLException {
+ mngrAuthorityMapper.mngrPowerUpdate(mngrPowerVO);//update role
+
+ String[] arrCodes = menuCodes.split(",");
+
+ MngrAuthorityVO mngrAuthorityVO = new MngrAuthorityVO();
+ mngrAuthorityVO.setPowerIdx(mngrPowerVO.getPowerIdx());
+ mngrAuthorityVO.setAuthType("1"); // 롤권한이 있음
+
+ mngrAuthorityMapper.mngrAuthorityPowerDelete(mngrAuthorityVO); //기존 메뉴 권한 삭제
+
+ //삭제후 등록
+ mngrAuthorityVO.setRegmemid(CommUtil.getMngrMemId());
+ for(int i = 0; i < arrCodes.length; i++){
+ mngrAuthorityVO.setMenuCode(arrCodes[i]);
+ mngrAuthorityMapper.mngrAuthorityPowerRegist(mngrAuthorityVO);
+ }
+ }
+ @Override
+ public void deleteMngrAuthorityDeleteProc(MngrRoleVO mngrRoleVO,MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException {
+ mngrAuthorityVO.setAuthType("1"); // 롤권한이 있음
+ mngrAuthorityMapper.mngrAuthorityDelete(mngrAuthorityVO);
+ mngrAuthorityMapper.mngrRoleDelete(mngrRoleVO);
+ }
+ @Override
+ public void deleteMngrAuthorityPowerDeleteProc(MngrPowerVO mngrPowerVO,MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException {
+ mngrAuthorityVO.setAuthType("1"); // 롤권한이 있음
+ mngrAuthorityMapper.mngrAuthorityPowerDelete(mngrAuthorityVO);
+ mngrAuthorityMapper.mngrPowerDelete(mngrPowerVO);
+ }
+ @Override
+ public void updateMngrAuthorityUpdateManagerAuth(MngrAuthorityVO mngrAuthorityVO) throws IOException, SQLException {
+ mngrAuthorityMapper.mngrAuthorityUpdateManagerAuth(mngrAuthorityVO);
+ }
+ @Override
+ public void updateMngrAuthorityPowerUpdateManagerAuth(MngrPowerVO mngrPowerVO) throws IOException, SQLException {
+ mngrAuthorityMapper.mngrAuthorityPowerUpdateManagerAuth(mngrPowerVO);
+ }
+ @Override
+ public int mngrPowerCodeCheck(MngrPowerVO mngrPowerVO) throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrPowerCodeCheck(mngrPowerVO);
+ }
+ @Override
+ public void insertMngrLevelRegistProc(MngrPowerVO mngrPowerVO) throws IOException, SQLException {
+ mngrAuthorityMapper.MngrLevelRegistProc(mngrPowerVO);//insert
+ }
+ @Override
+ public void updateMngrLevelRegistProc(MngrPowerVO mngrPowerVO, HttpServletRequest request) throws IOException, SQLException {
+ /*List tmpList = (List) mngrAuthorityService.selectMngrPowerList();
+ for (int i = 1; i < tmpList.size(); i++) { //itgood을 빼고 update하기위해 1부터.
+ String matchName = tmpList.get(i).getName();
+ String[] powers = request.getParameterValues(matchName+"power");
+ mngrPowerVO.setPower(Arrays.toString(powers).replace("[","").replace("]",""));
+ mngrPowerVO.setName(matchName);
+ mngrAuthorityMapper.MngrLevelUpdateProc(mngrPowerVO);
+ }*/
+ }
+ @Override
+ public void deleteMngrLevelRegistProc(MngrPowerVO mngrPowerVO) throws IOException, SQLException {
+ mngrAuthorityMapper.MngrLevelDeleteProc(mngrPowerVO);//insert
+ }
+ @Override
+ public MngrPowerVO selectMngrPowerView(MngrPowerVO mngrPowerVO)throws IOException, SQLException {
+ return mngrAuthorityMapper.mngrPowerView(mngrPowerVO);
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/BoardAuthVO.java b/src/main/java/egovframework/itgcms/core/board/service/BoardAuthVO.java
new file mode 100644
index 0000000..6cdbf66
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/BoardAuthVO.java
@@ -0,0 +1,51 @@
+package egovframework.itgcms.core.board.service;
+
+
+public class BoardAuthVO {
+
+ private boolean list = false;
+ private boolean view = false;
+ private boolean regist = false;
+ private boolean reply = false;
+ private boolean update = false;
+ private boolean delete = false;
+
+ public boolean isList() {
+ return list;
+ }
+ public void setList(boolean list) {
+ this.list = list;
+ }
+ public boolean isView() {
+ return view;
+ }
+ public void setView(boolean view) {
+ this.view = view;
+ }
+ public boolean isRegist() {
+ return regist;
+ }
+ public void setRegist(boolean regist) {
+ this.regist = regist;
+ }
+ public boolean isUpdate() {
+ return update;
+ }
+ public void setUpdate(boolean update) {
+ this.update = update;
+ }
+ public boolean isDelete() {
+ return delete;
+ }
+ public void setDelete(boolean delete) {
+ this.delete = delete;
+ }
+ public boolean isReply() {
+ return reply;
+ }
+ public void setReply(boolean reply) {
+ this.reply = reply;
+ }
+
+
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/BoardReactionSearchVO.java b/src/main/java/egovframework/itgcms/core/board/service/BoardReactionSearchVO.java
new file mode 100644
index 0000000..e046e13
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/BoardReactionSearchVO.java
@@ -0,0 +1,83 @@
+package egovframework.itgcms.core.board.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class BoardReactionSearchVO extends BoardVO {
+
+
+ private Date regDt;
+ private Date recentDt;
+ private String recentName;
+ private String menuCode;
+ private String siteName;
+ private String boardName;
+ private int cnt = 0;
+ private List reationList = null;
+
+
+
+ public int getCnt() {
+ return cnt;
+ }
+ public void setCnt(int cnt) {
+ this.cnt = cnt;
+ }
+ public List getReationList() {
+ if (reationList != null) {
+ ArrayList arrRet = new ArrayList();
+ arrRet.addAll(reationList);
+ return arrRet;
+ }else{
+ return null;
+ }
+ }
+ public void setReationList(List reationList) {
+ if (reationList != null) {
+ this.reationList = new ArrayList<>(reationList);
+ }
+ }
+ public Date getRegDt() {
+ return regDt;
+ }
+ public void setRegDt(Date regDt) {
+ this.regDt = regDt;
+ }
+ public Date getRecentDt() {
+ return recentDt;
+ }
+ public void setRecentDt(Date recentDt) {
+ this.recentDt = recentDt;
+ }
+ public String getMenuCode() {
+ return menuCode;
+ }
+ public void setMenuCode(String menuCode) {
+ this.menuCode = menuCode;
+ }
+ public String getSiteName() {
+ return siteName;
+ }
+ public void setSiteName(String siteName) {
+ this.siteName = siteName;
+ }
+ public void setRecentName(String recentName) {
+ this.recentName = recentName;
+ }
+ public String getRecentName() {
+ return recentName;
+ }
+ public void setBoardName(String boardName) {
+ this.boardName = boardName;
+ }
+ public String getBoardName() {
+ return boardName;
+ }
+
+ @Override
+ public int getPageUnit(){
+ return 10;
+
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/BoardSearchVO.java b/src/main/java/egovframework/itgcms/core/board/service/BoardSearchVO.java
new file mode 100644
index 0000000..fce5f9b
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/BoardSearchVO.java
@@ -0,0 +1,170 @@
+package egovframework.itgcms.core.board.service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import egovframework.itgcms.common.DefaultVO;
+import egovframework.itgcms.core.boardconfig.service.MngrBoardconfigVO;
+import egovframework.itgcms.core.site.service.MngrSiteVO;
+
+public class BoardSearchVO extends DefaultVO {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5358593433818756365L;
+
+ private static final Logger logger = LogManager.getLogger(BoardSearchVO.class);
+
+ /** 관리자 아이디 */
+ String id = ""; //검색조건 유지
+ String uid = ""; //url아이디
+ String schBcid = ""; //게시판아이디
+ String root = ""; // 게시판 사용영역
+
+ String schBdcode = ""; //카테고리 검색
+
+ String query = "";
+
+ MngrBoardconfigVO mngrBoardconfigVO = new MngrBoardconfigVO();
+
+ String schRegmemid = ""; //게시글 작성자 아이디
+ String schGroupCode = ""; //게시글 작성자 부서코드
+ String schMngType = ""; //관리자 권한
+ String schSecritPw = ""; //게시글 비번
+
+ List schSiteList = new ArrayList(); //검색할 사이트 (단일 or 전체)
+
+ String schSite = "";
+ String siteCode = "";
+
+ public BoardSearchVO(){
+ super.setViewCount("0");// 생성시 빈값
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getUid() {
+ return uid;
+ }
+
+ public void setUid(String uid) {
+ this.uid = uid;
+ }
+
+ public String getSchBcid() {
+ return schBcid;
+ }
+
+ public void setSchBcid(String schBcid) {
+ this.schBcid = schBcid;
+ }
+
+ public String getRoot() {
+ return root;
+ }
+
+ public void setRoot(String root) {
+ this.root = root;
+ }
+
+ public String getSchBdcode() {
+ return schBdcode;
+ }
+
+ public void setSchBdcode(String schBdcode) {
+ this.schBdcode = schBdcode;
+ }
+
+ public MngrBoardconfigVO getMngrBoardconfigVO() {
+ return mngrBoardconfigVO;
+ }
+
+ public void setMngrBoardconfigVO(MngrBoardconfigVO mngrBoardconfigVO) {
+ this.mngrBoardconfigVO = mngrBoardconfigVO;
+ }
+
+ public String getSchRegmemid() {
+ return schRegmemid;
+ }
+
+ public void setSchRegmemid(String schRegmemid) {
+ this.schRegmemid = schRegmemid;
+ }
+
+ public String getSchGroupCode() {
+ return schGroupCode;
+ }
+
+ public void setSchGroupCode(String schGroupCode) {
+ this.schGroupCode = schGroupCode;
+ }
+
+
+ public String getSchMngType() {
+ return schMngType;
+ }
+
+ public void setSchMngType(String schMngType) {
+ this.schMngType = schMngType;
+ }
+
+ public String getSchSecritPw() {
+ return schSecritPw;
+ }
+
+ public void setSchSecritPw(String schSecritPw) {
+ this.schSecritPw = schSecritPw;
+ }
+
+ public List getSchSiteList() {
+ if (schSiteList != null) {
+ ArrayList arrRet = new ArrayList();
+ arrRet.addAll(schSiteList);
+ return arrRet;
+ }else{
+ return null;
+ }
+ }
+
+ public void setSchSiteList(List schSiteList) {
+ if (schSiteList != null) {
+ this.schSiteList = new ArrayList(schSiteList);
+ }
+ }
+
+ public String getSchSite() {
+ return schSite;
+ }
+
+ public void setSchSite(String schSite) {
+ this.schSite = schSite;
+ }
+
+ public String getQuery() {
+ String query = super.queryString();
+ try{
+ query += "&id=" + java.net.URLEncoder.encode(this.id, "UTF-8");
+ query += "&schBdcode=" + java.net.URLEncoder.encode(this.schBdcode, "UTF-8");
+ query += "&schGroupCode=" + java.net.URLEncoder.encode(this.schGroupCode, "UTF-8");
+ }catch(IOException e){
+ logger.error("예외 상황 발생");
+ }
+ return query;
+ }
+ public void setSiteCode(String siteCode) {
+ this.siteCode = siteCode;
+ }
+ public String getSiteCode() {
+ return siteCode;
+ }
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/BoardService.java b/src/main/java/egovframework/itgcms/core/board/service/BoardService.java
new file mode 100644
index 0000000..4e12b7d
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/BoardService.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2008-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package egovframework.itgcms.core.board.service;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.ui.ModelMap;
+
+import egovframework.itgcms.core.boardconfig.service.MngrBoardconfigVO;
+
+/**
+ * @파일명 : BoardService.java
+ * @파일정보 : 관리자관리 서비스 interface
+ * @수정이력
+ * @수정자 수정일 수정내용
+ * @------- ------------ ----------------
+ * @woonee 2014. 9. 5. 최초생성
+ * @---------------------------------------
+ * @author (주)아이티굿 개발팀
+ * @since 2009. 01.14
+ * @version 1.0 Copyright (C) ITGOOD All right reserved.
+ */
+public interface BoardService {
+
+ String selectBoardList(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String selectBoardRegist(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String selectBoardView(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String insertBoardRegistProc(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String updateBoardUpdateProc(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String updateBoardDeleteProc(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String updateBoardChkDelProc(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String selectBoardReply(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ String insertBoardReplyProc(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ BoardVO selectBoardRegInfo(BoardSearchVO boardSearchVO) throws IOException, SQLException;
+
+ List selectBoardMainList(BoardSearchVO boardSearchVO)throws IOException, SQLException;
+
+ void updateIncreaseReadnum(BoardSearchVO boardSearchVO)throws IOException, SQLException;
+
+ String searchAll(ModelMap model, MngrBoardconfigVO mngrBoardconfigVO,
+ BoardSearchVO boardSearchVO, BoardVO boardVO,
+ HttpServletRequest request, HttpServletResponse response,
+ String returnPage) throws IOException, SQLException;
+
+ List getBoardList(String root, String menuCode, int limitNum) throws IOException, SQLException;
+ List getBoardList(String root, String menuCode) throws IOException, SQLException;
+
+ List selectBBSExcelData(String menuCode) throws IOException, SQLException;
+
+ Map redirectNoticePage(String boardCode, String siteCode) throws IOException, SQLException;
+
+ boolean boardPassCheck(String bdIndx, String passwd) throws IOException, SQLException;
+
+ MngrBoardconfigVO getBoardconfigViewByMenuCode(String menuCode) throws IOException, SQLException;
+
+ MainBoardVO latestBbsMenuSchBcid(String menuCode, String root) throws IOException, SQLException;
+
+ int getReplyTotCnt(BoardReactionSearchVO searchVO) throws IOException, SQLException;
+
+ List selectReplyList(BoardReactionSearchVO searchVO) throws IOException, SQLException;
+
+ int getCommentTotCnt(BoardReactionSearchVO searchVO) throws IOException, SQLException;
+
+ List selectCommentList(BoardReactionSearchVO searchVO) throws IOException, SQLException;
+
+ void postingSocialMedia(BoardVO boardVO, BoardSearchVO boardSearchVO, HttpServletRequest request) throws IOException, SQLException;
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/BoardVO.java b/src/main/java/egovframework/itgcms/core/board/service/BoardVO.java
new file mode 100644
index 0000000..2c404c0
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/BoardVO.java
@@ -0,0 +1,426 @@
+package egovframework.itgcms.core.board.service;
+
+
+public class BoardVO extends BoardSearchVO{
+ private static final long serialVersionUID = 7992967475788187625L;
+ String bdIdx = "";
+ String bcId = "";
+ String bdCode = "";
+ String bdWriter = "";
+ String bdTitle = "";
+ String bdContent = "";
+ String bdReadnum = "";
+ String bdNotice = "0"; //공지여부 0 : 미사용 1: 전체 사이트 2: 내 사이트 3 : 해당 게시판
+ String bdNoticeTermyn = "N"; //게시기간 사용여부
+ String bdNoticeSdt = ""; // 공지기간 시작일
+ String bdNoticeEdt = ""; // 공지기간 종료일
+ String noticeOrder = "0"; //공지기간사용여부 체크, 공지기간 체크 후에 공지로 올려야 하면 1, 공지체크됐지만, 기간이 안되면 0이고, 공지체크안되면 0.
+
+ String bdUseyn = "Y"; //게시여부
+ String bdUseTermyn = "N"; //게시기간 사용여부
+ String bdUseSdt = ""; //게시기간 시작일
+ String bdUseEdt = ""; //게시기간 종료일
+
+ String bdPushyn = "N"; //푸쉬 발송 여부
+
+ String bdIp = "";
+ String bdReidx = "";
+ String bdRelevel = "";
+ String bdReorder = "";
+ String regdt = "";
+ String upddt = "";
+ String deldt = "";
+ String regmemid = "";
+ String updmemid = "";
+ String delmemid = "";
+ String delyn = "N";
+ String bdKogluseyn = "";
+ String bdKogltype1 = "";
+ String bdKogltype2 = "";
+
+ String groupCode = "";
+
+ String bdCodeName = "";
+
+ String bdThumb1 = "";
+ String bdThumb2 = "";
+ String bdThumb3 = "";
+
+ String bdThumb1Alt = "";
+ String bdThumb2Alt = "";
+ String bdThumb3Alt = "";
+
+ String fileId = "";
+ String fileCnt = "0";
+
+ // 썸네일 이전파일명
+ String oldBdThumb1 = "";
+ String oldBdThumb2 = "";
+ String oldBdThumb3 = "";
+
+ // 썸네일 삭제
+ String thum1Del = "N";
+ String thum2Del = "N";
+ String thum3Del = "N";
+
+ //답변 내용, 답변 등록자 명
+ String bdAnswer = "";
+ String bdAnswerwriter = "";
+
+ //게시글연관아이디
+ String ownId = "";
+
+ //동영상게시판 업로드 관련
+ String howUpload = "0"; //동영상 첨부 방법
+ String bdMovie = ""; //동영상 파일명 or 동영상 URL 링크
+ String olgBdMovie = ""; //동영상 이전 파일명 or 이전 URL
+
+ String bdSpare1 = "";//여분컬럼
+ String bdSpare2 = "";
+ String bdSpare3 = "";
+ String bdSpare4 = "";
+
+ public String getBdIdx() {
+ return bdIdx;
+ }
+ public void setBdIdx(String bdIdx) {
+ this.bdIdx = bdIdx;
+ }
+ public String getBcId() {
+ return bcId;
+ }
+ public void setBcId(String bcId) {
+ this.bcId = bcId;
+ }
+ public String getBdCode() {
+ return bdCode;
+ }
+ public void setBdCode(String bdCode) {
+ this.bdCode = bdCode;
+ }
+ public String getBdWriter() {
+ return bdWriter;
+ }
+ public void setBdWriter(String bdWriter) {
+ this.bdWriter = bdWriter;
+ }
+ public String getBdTitle() {
+ return bdTitle;
+ }
+ public void setBdTitle(String bdTitle) {
+ this.bdTitle = bdTitle;
+ }
+ public String getBdContent() {
+ return bdContent;
+ }
+ public void setBdContent(String bdContent) {
+ this.bdContent = bdContent;
+ }
+ public String getBdReadnum() {
+ return bdReadnum;
+ }
+ public void setBdReadnum(String bdReadnum) {
+ this.bdReadnum = bdReadnum;
+ }
+ public String getBdNotice() {
+ return bdNotice;
+ }
+ public void setBdNotice(String bdNotice) {
+ this.bdNotice = bdNotice;
+ }
+ public String getBdNoticeTermyn() {
+ return bdNoticeTermyn;
+ }
+ public void setBdNoticeTermyn(String bdNoticeTermyn) {
+ this.bdNoticeTermyn = bdNoticeTermyn;
+ }
+ public String getBdNoticeSdt() {
+ return bdNoticeSdt;
+ }
+ public void setBdNoticeSdt(String bdNoticeSdt) {
+ this.bdNoticeSdt = bdNoticeSdt;
+ }
+ public String getBdNoticeEdt() {
+ return bdNoticeEdt;
+ }
+ public void setBdNoticeEdt(String bdNoticeEdt) {
+ this.bdNoticeEdt = bdNoticeEdt;
+ }
+ public String getNoticeOrder() {
+ return noticeOrder;
+ }
+ public void setNoticeOrder(String noticeOrder) {
+ this.noticeOrder = noticeOrder;
+ }
+ public String getBdUseyn() {
+ return bdUseyn;
+ }
+ public void setBdUseyn(String bdUseyn) {
+ this.bdUseyn = bdUseyn;
+ }
+ public String getBdUseTermyn() {
+ return bdUseTermyn;
+ }
+ public void setBdUseTermyn(String bdUseTermyn) {
+ this.bdUseTermyn = bdUseTermyn;
+ }
+ public String getBdUseSdt() {
+ return bdUseSdt;
+ }
+ public void setBdUseSdt(String bdUseSdt) {
+ this.bdUseSdt = bdUseSdt;
+ }
+ public String getBdUseEdt() {
+ return bdUseEdt;
+ }
+ public void setBdUseEdt(String bdUseEdt) {
+ this.bdUseEdt = bdUseEdt;
+ }
+ public String getBdPushyn() {
+ return bdPushyn;
+ }
+ public void setBdPushyn(String bdPushyn) {
+ this.bdPushyn = bdPushyn;
+ }
+ public String getBdIp() {
+ return bdIp;
+ }
+ public void setBdIp(String bdIp) {
+ this.bdIp = bdIp;
+ }
+ public String getBdReidx() {
+ return bdReidx;
+ }
+ public void setBdReidx(String bdReidx) {
+ this.bdReidx = bdReidx;
+ }
+ public String getBdRelevel() {
+ return bdRelevel;
+ }
+ public void setBdRelevel(String bdRelevel) {
+ this.bdRelevel = bdRelevel;
+ }
+ public String getBdReorder() {
+ return bdReorder;
+ }
+ public void setBdReorder(String bdReorder) {
+ this.bdReorder = bdReorder;
+ }
+ public String getRegdt() {
+ return regdt;
+ }
+ public void setRegdt(String regdt) {
+ this.regdt = regdt;
+ }
+ public String getUpddt() {
+ return upddt;
+ }
+ public void setUpddt(String upddt) {
+ this.upddt = upddt;
+ }
+ public String getDeldt() {
+ return deldt;
+ }
+ public void setDeldt(String deldt) {
+ this.deldt = deldt;
+ }
+ public String getRegmemid() {
+ return regmemid;
+ }
+ public void setRegmemid(String regmemid) {
+ this.regmemid = regmemid;
+ }
+ public String getUpdmemid() {
+ return updmemid;
+ }
+ public void setUpdmemid(String updmemid) {
+ this.updmemid = updmemid;
+ }
+ public String getDelmemid() {
+ return delmemid;
+ }
+ public void setDelmemid(String delmemid) {
+ this.delmemid = delmemid;
+ }
+ public String getDelyn() {
+ return delyn;
+ }
+ public void setDelyn(String delyn) {
+ this.delyn = delyn;
+ }
+ public String getBdKogluseyn() {
+ return bdKogluseyn;
+ }
+ public void setBdKogluseyn(String bdKogluseyn) {
+ this.bdKogluseyn = bdKogluseyn;
+ }
+ public String getBdKogltype1() {
+ return bdKogltype1;
+ }
+ public void setBdKogltype1(String bdKogltype1) {
+ this.bdKogltype1 = bdKogltype1;
+ }
+ public String getBdKogltype2() {
+ return bdKogltype2;
+ }
+ public void setBdKogltype2(String bdKogltype2) {
+ this.bdKogltype2 = bdKogltype2;
+ }
+ public String getGroupCode() {
+ return groupCode;
+ }
+ public void setGroupCode(String groupCode) {
+ this.groupCode = groupCode;
+ }
+ public String getBdCodeName() {
+ return bdCodeName;
+ }
+ public void setBdCodeName(String bdCodeName) {
+ this.bdCodeName = bdCodeName;
+ }
+ public String getBdThumb1() {
+ return bdThumb1;
+ }
+ public void setBdThumb1(String bdThumb1) {
+ this.bdThumb1 = bdThumb1;
+ }
+ public String getBdThumb2() {
+ return bdThumb2;
+ }
+ public void setBdThumb2(String bdThumb2) {
+ this.bdThumb2 = bdThumb2;
+ }
+ public String getBdThumb3() {
+ return bdThumb3;
+ }
+ public void setBdThumb3(String bdThumb3) {
+ this.bdThumb3 = bdThumb3;
+ }
+ public String getBdThumb1Alt() {
+ return bdThumb1Alt;
+ }
+ public void setBdThumb1Alt(String bdThumb1Alt) {
+ this.bdThumb1Alt = bdThumb1Alt;
+ }
+ public String getBdThumb2Alt() {
+ return bdThumb2Alt;
+ }
+ public void setBdThumb2Alt(String bdThumb2Alt) {
+ this.bdThumb2Alt = bdThumb2Alt;
+ }
+ public String getBdThumb3Alt() {
+ return bdThumb3Alt;
+ }
+ public void setBdThumb3Alt(String bdThumb3Alt) {
+ this.bdThumb3Alt = bdThumb3Alt;
+ }
+ public String getFileId() {
+ return fileId;
+ }
+ public void setFileId(String fileId) {
+ this.fileId = fileId;
+ }
+ public String getFileCnt() {
+ return fileCnt;
+ }
+ public void setFileCnt(String fileCnt) {
+ this.fileCnt = fileCnt;
+ }
+ public String getOldBdThumb1() {
+ return oldBdThumb1;
+ }
+ public void setOldBdThumb1(String oldBdThumb1) {
+ this.oldBdThumb1 = oldBdThumb1;
+ }
+ public String getOldBdThumb2() {
+ return oldBdThumb2;
+ }
+ public void setOldBdThumb2(String oldBdThumb2) {
+ this.oldBdThumb2 = oldBdThumb2;
+ }
+ public String getOldBdThumb3() {
+ return oldBdThumb3;
+ }
+ public void setOldBdThumb3(String oldBdThumb3) {
+ this.oldBdThumb3 = oldBdThumb3;
+ }
+ public String getThum1Del() {
+ return thum1Del;
+ }
+ public void setThum1Del(String thum1Del) {
+ this.thum1Del = thum1Del;
+ }
+ public String getThum2Del() {
+ return thum2Del;
+ }
+ public void setThum2Del(String thum2Del) {
+ this.thum2Del = thum2Del;
+ }
+ public String getThum3Del() {
+ return thum3Del;
+ }
+ public void setThum3Del(String thum3Del) {
+ this.thum3Del = thum3Del;
+ }
+ public String getBdAnswer() {
+ return bdAnswer;
+ }
+ public void setBdAnswer(String bdAnswer) {
+ this.bdAnswer = bdAnswer;
+ }
+ public String getBdAnswerwriter() {
+ return bdAnswerwriter;
+ }
+ public void setBdAnswerwriter(String bdAnswerwriter) {
+ this.bdAnswerwriter = bdAnswerwriter;
+ }
+ public String getOwnId() {
+ return ownId;
+ }
+ public void setOwnId(String ownId) {
+ this.ownId = ownId;
+ }
+ public String getHowUpload() {
+ return howUpload;
+ }
+ public void setHowUpload(String howUpload) {
+ this.howUpload = howUpload;
+ }
+ public String getBdMovie() {
+ return bdMovie;
+ }
+ public void setBdMovie(String bdMovie) {
+ this.bdMovie = bdMovie;
+ }
+ public String getOlgBdMovie() {
+ return olgBdMovie;
+ }
+ public void setOlgBdMovie(String olgBdMovie) {
+ this.olgBdMovie = olgBdMovie;
+ }
+ public String getBdSpare1() {
+ return bdSpare1;
+ }
+ public void setBdSpare1(String bdSpare1) {
+ this.bdSpare1 = bdSpare1;
+ }
+ public String getBdSpare2() {
+ return bdSpare2;
+ }
+ public void setBdSpare2(String bdSpare2) {
+ this.bdSpare2 = bdSpare2;
+ }
+ public String getBdSpare3() {
+ return bdSpare3;
+ }
+ public void setBdSpare3(String bdSpare3) {
+ this.bdSpare3 = bdSpare3;
+ }
+ public String getBdSpare4() {
+ return bdSpare4;
+ }
+ public void setBdSpare4(String bdSpare4) {
+ this.bdSpare4 = bdSpare4;
+ }
+
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/MainBoardVO.java b/src/main/java/egovframework/itgcms/core/board/service/MainBoardVO.java
new file mode 100644
index 0000000..2aa039e
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/MainBoardVO.java
@@ -0,0 +1,58 @@
+package egovframework.itgcms.core.board.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MainBoardVO {
+
+ private String anchorHref;
+ private String boardTitle;
+ private String boardSkin;
+ private String boardMemo;
+
+ private List boardList;
+
+
+ public String getAnchorHref() {
+ return anchorHref;
+ }
+
+ public void setAnchorHref(String anchorHref) {
+ this.anchorHref = anchorHref;
+ }
+
+ public String getBoardTitle() {
+ return boardTitle;
+ }
+
+ public void setBoardTitle(String boardTitle) {
+ this.boardTitle = boardTitle;
+ }
+
+ public List getBoardList() {
+ if (this.boardList != null) {
+ return new ArrayList<>(this.boardList);
+ }
+ return null;
+ }
+
+ public void setBoardList(List boardList) {
+ this.boardList = new ArrayList(boardList);
+ }
+ public void setBoardSkin(String boardSkin) {
+ this.boardSkin = boardSkin;
+ }
+ public String getBoardSkin() {
+ return boardSkin;
+ }
+
+ public String getBoardMemo() {
+ return boardMemo;
+ }
+
+ public void setBoardMemo(String boardMemo) {
+ this.boardMemo = boardMemo;
+ }
+
+
+}
diff --git a/src/main/java/egovframework/itgcms/core/board/service/impl/BoardMapper.java b/src/main/java/egovframework/itgcms/core/board/service/impl/BoardMapper.java
new file mode 100644
index 0000000..8362e4a
--- /dev/null
+++ b/src/main/java/egovframework/itgcms/core/board/service/impl/BoardMapper.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2011 MOPAS(Ministry of Public Mngristration and Security).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package egovframework.itgcms.core.board.service.impl;
+
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+import egovframework.itgcms.core.board.service.BoardReactionSearchVO;
+import egovframework.itgcms.core.board.service.BoardSearchVO;
+import egovframework.itgcms.core.board.service.BoardVO;
+import egovframework.itgcms.core.board.service.MainBoardVO;
+import egovframework.itgcms.core.boardconfig.service.MngrBoardconfigVO;
+import egovframework.rte.psl.dataaccess.mapper.Mapper;
+
+/**
+ * board에 관한 데이터처리 매퍼 클래스
+ *
+ * @author 표준프레임워크센터
+ * @since 2014.01.24
+ * @version 1.0
+ * @see
+ * == 개정이력(Modification Information) ==
+ *
+ * 수정일 수정자 수정내용
+ * ---------------- ------------ ---------------------------
+ * 2014.01.24 표준프레임워크센터 최초 생성
+ *
+ *
+ */
+@Mapper("boardMapper")
+public interface BoardMapper {
+
+
+
+ /**
+ * 글 목록을 조회한다.
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ List> boardList(BoardSearchVO searchVO) throws SQLException;
+
+ /**
+ * 공지글 목록을 조회한다.
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ List> noticeList(BoardSearchVO searchVO) throws SQLException;
+
+ /**
+ * 글 총 갯수를 조회한다.
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 총 갯수
+ * @exception
+ */
+ int boardListTotCnt(BoardSearchVO searchVO) throws SQLException;
+
+ void boardRegistProc(BoardVO boardVO) throws SQLException;
+
+ BoardVO boardView(BoardSearchVO searchVO) throws SQLException;
+
+ void boardUpdateProc(BoardVO boardVO) throws SQLException;
+
+ void boardDeleteProc(BoardVO boardVO)throws SQLException;
+
+ void boardChkDelProc(BoardVO boardVO)throws SQLException;
+
+ void boardChkDelProcJFile(BoardVO boardVO)throws SQLException;
+
+ BoardVO getPrevBoardVO(BoardSearchVO boardSearchVO)throws SQLException;
+
+ BoardVO getNextBoardVO(BoardSearchVO boardSearchVO)throws SQLException;
+
+ void increaseReadnum(BoardSearchVO boardSearchVO)throws SQLException;
+
+ void boardReplyProc(BoardVO boardVO)throws SQLException;
+
+ void boardReplyUpdateReorder(BoardVO boardVO)throws SQLException;
+
+ List boardMainList(BoardSearchVO boardSearchVO)throws SQLException;
+
+ BoardVO boardRegInfo(BoardSearchVO searchVO) throws SQLException;
+
+ /**
+ * 통합검색
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ List> searchAll(BoardSearchVO searchVO) throws SQLException;
+
+ String searchAllCnt(BoardSearchVO searchVO) throws SQLException;
+
+ /**
+ * 글 목록을 조회한다.(글번호만 조회)
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ List boardListAll(MngrBoardconfigVO mngrBoardconfigVO) throws SQLException;
+
+ /**
+ * 체크된 게시판의 글 목록을 조회한다.(글번호만 조회)
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ List chkBoardListAll(MngrBoardconfigVO mngrBoardconfigVO) throws SQLException;
+
+ /**
+ * 게시판삭제에 의한 게시글 삭제처리
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ void boardAutoDeleteProc(MngrBoardconfigVO mngrBoardconfigVO)throws SQLException;
+
+ /**
+ * 체크박스 게시판삭제에 의한 게시글 삭제처리
+ * @param searchVO - 조회할 정보가 담긴 VO
+ * @return 글 목록
+ * @exception Exception
+ */
+ void boardChkAutoDeleteProc(MngrBoardconfigVO mngrBoardconfigVO)throws SQLException;
+
+ /**
+ * RSS 글 목록
+ * @param queryData 쿼리 데이터
+ * @return 글 목록
+ * @exception Exception
+ */
+ List rssBoardList(Map queryData) throws SQLException;
+
+ /**
+ * 게시글 엑셀 목록
+ * @param menuCode 메뉴코드
+ * @return 글 목록
+ * @exception Exception
+ */
+ List mngrBoardListForExcel(String menuCode) throws SQLException;
+
+ /**
+ * 게시판 비밀번호 확인
+ * @param paramMap 쿼리 데이터
+ * @return 비밀번호 확인 결과
+ * @exception Exception
+ */
+ BoardVO boardPassCheck(Map paramMap) throws SQLException;
+
+ /**
+ * 메인페이지 게시판 설정 값
+ * @param paramMap 쿼리 데이터
+ * @return 게시판 설정 값
+ * @exception Exception
+ */
+ MainBoardVO mainContentsMenuCode(Map