diff --git a/document/database/knowledge.a5er b/document/database/knowledge.a5er index 00fb73dcb..491d3b184 100755 --- a/document/database/knowledge.a5er +++ b/document/database/knowledge.a5er @@ -46,14 +46,57 @@ SqlSeparator=0 ShowTag=1 ShowCommonAttributes=0 +[Relation] +Entity1=KNOWLEDGES +Entity2=KNOWLEDGE_HISTORIES +RelationType1=2 +RelationType2=3 +Fields1=KNOWLEDGE_ID +Fields2=KNOWLEDGE_ID +Cardinarity1= +Cardinarity2= +Position="MAIN",1,1504,5355,8088,R,R +Dependence=1 +Caption= +PName= +LineMode=1 +Bar1=150 +Bar2=536 +Bar3=809 +TermPos1=R +TermPos2=R + +[Entity] +PName=KNOWLEDGE_HISTORIES +LName=繝翫Ξ繝�ず譖エ譁ー螻・豁エ +Comment= +TableOption= +Page=MAIN +Left=710 +Top=1570 +Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" +Field="螻・豁エ逡ェ蜿キ","HISTORY_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,"" +Field="繧ソ繧、繝医Ν","TITLE","@VARCHAR(1024)","NOT NULL",,"","",$FFFFFFFF,"" +Field="蜀�ョケ","CONTENT","text",,,"","",$FFFFFFFF,"" +Field="蜈ャ髢句玄蛻�","PUBLIC_FLAG","@INT",,,"","",$FFFFFFFF,"" +Field="繧ソ繧ーID荳隕ァ","TAG_IDS","@VARCHAR(1024)",,,"","",$FFFFFFFF,"" +Field="繧ソ繧ー蜷咲ァー荳隕ァ","TAG_NAMES","text",,,"","",$FFFFFFFF,"" +Field="縺�>縺ュ莉カ謨ー","LIKE_COUNT","bigint",,,"","",$FFFFFFFF,"" +Field="繧ウ繝。繝ウ繝井サカ謨ー","COMMENT_COUNT","@INT",,,"","",$FFFFFFFF,"" +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20150507141708 +Position="MAIN",710,1570 + [Entity] PName=NOTIFY_QUEUES LName=騾夂衍蠕�■繧ュ繝・繝シ Comment= TableOption= Page=MAIN -Left=120 -Top=1700 +Left=80 +Top=1460 Field="HASH","HASH","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" Field="遞ョ鬘�","TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,"" Field="騾夂衍縺吶k遞ョ鬘槭�ID","ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" @@ -61,7 +104,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150331055404 -Position="MAIN",120,1700 +Position="MAIN",80,1460 [Relation] Entity1=USERS @@ -117,14 +160,14 @@ Fields1=COMMENT_NO Fields2=COMMENT_NO Cardinarity1= Cardinarity2= -Position="MAIN",0,8317,1335,4689,R,R +Position="MAIN",0,7469,4072,5955,R,R Dependence=0 Caption= PName= LineMode=0 -Bar1=832 -Bar2=134 -Bar3=469 +Bar1=747 +Bar2=407 +Bar3=596 TermPos1=R TermPos2=R @@ -196,8 +239,8 @@ LName=縺�>縺ュ Comment= TableOption= Page=MAIN -Left=580 -Top=1470 +Left=570 +Top=1350 Field="NO","NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Index=IDX_LIKES_KNOWLEDGE_ID=0,KNOWLEDGE_ID @@ -205,7 +248,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416233511 -Position="MAIN",580,1470 +Position="MAIN",570,1350 [Relation] Entity1=KNOWLEDGES @@ -216,14 +259,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,8619,2544,1724,R,R +Position="MAIN",0,8619,5745,1724,R,R Dependence=1 Caption= PName= ModifiedDateTime=20141222155941 LineMode=0 Bar1=862 -Bar2=254 +Bar2=574 Bar3=172 TermPos1=R TermPos2=R @@ -234,8 +277,8 @@ LName=繧ウ繝。繝ウ繝� Comment= TableOption= Page=MAIN -Left=1890 -Top=1540 +Left=1990 +Top=1620 Field="繧ウ繝。繝ウ繝育分蜿キ","COMMENT_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="繧ウ繝。繝ウ繝�","COMMENT","text",,,"","",$FFFFFFFF,"" @@ -243,8 +286,8 @@ Index=IDX_COMMENTS_KNOWLEDGE_ID=0,KNOWLEDGE_ID EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150416233710 -Position="MAIN",1890,1540 +ModifiedDateTime=20150506050206 +Position="MAIN",1990,1620 [Relation] Entity1=KNOWLEDGES @@ -255,13 +298,13 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,7100,4465,3064,R,R +Position="MAIN",0,7100,6784,3064,R,R Dependence=0 Caption= PName= LineMode=0 Bar1=710 -Bar2=446 +Bar2=678 Bar3=306 TermPos1=R TermPos2=R @@ -272,8 +315,8 @@ LName=謚慕・ィ Comment= TableOption= Page=MAIN -Left=1890 -Top=1390 +Left=1980 +Top=1380 Field="VOTE_NO","VOTE_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,"" Field="謚慕・ィ蛹コ蛻�","VOTE_KIND","@INT","NOT NULL",,"","",$FFFFFFFF,"" @@ -282,7 +325,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416233659 -Position="MAIN",1890,1390,435,89 +Position="MAIN",1980,1380,435,89 [Relation] Entity1=KNOWLEDGES @@ -332,14 +375,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,5645,5725,3590,R,R +Position="MAIN",0,5645,5725,5124,R,R Dependence=1 Caption= PName= LineMode=0 Bar1=564 Bar2=572 -Bar3=359 +Bar3=512 TermPos1=R TermPos2=R @@ -349,7 +392,7 @@ LName=繧ケ繝医ャ繧ッ縺励◆繝翫Ξ繝�ず Comment= TableOption= Page=MAIN -Left=1890 +Left=1940 Top=1240 Field="USER_ID","USER_ID","@INT","NOT NULL",0,"","",$FFFFFFFF,"" Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint","NOT NULL",1,"","",$FFFFFFFF,"" @@ -358,7 +401,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20141222154849 -Position="MAIN",1890,1240 +Position="MAIN",1940,1240 [Relation] Entity1=KNOWLEDGES @@ -479,15 +522,15 @@ LName=繝翫Ξ繝�ず縺梧戟縺、繧ソ繧ー Comment= TableOption= Page=MAIN -Left=580 -Top=1310 +Left=570 +Top=1240 Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="繧ソ繧ー_ID","TAG_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20141222154737 -Position="MAIN",580,1310 +Position="MAIN",570,1240 [Entity] PName=TAGS @@ -496,14 +539,14 @@ Comment= TableOption= Page=MAIN Left=70 -Top=1310 +Top=1240 Field="繧ソ繧ー_ID","TAG_ID","SERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="繧ソ繧ー蜷咲ァー","TAG_NAME","@VARCHAR(128)","NOT NULL",,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416233544 -Position="MAIN",70,1310 +Position="MAIN",70,1240 [Relation] Entity1=KNOWLEDGES @@ -514,15 +557,15 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4350,5662,4751,R,R +Position="MAIN",0,7158,5662,5114,R,R Dependence=1 Caption= PName= ModifiedDateTime=20141222154815 LineMode=0 -Bar1=435 +Bar1=716 Bar2=566 -Bar3=475 +Bar3=511 TermPos1=R TermPos2=R @@ -532,8 +575,8 @@ LName=豺サ莉倥ヵ繧。繧、繝ォ Comment= TableOption= Page=MAIN -Left=1140 -Top=1520 +Left=1280 +Top=1590 Field="豺サ莉倥ヵ繧。繧、繝ォ逡ェ蜿キ","FILE_NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,"" Field="繝翫Ξ繝�ずID","KNOWLEDGE_ID","bigint",,,"","",$FFFFFFFF,"" Field="繧ウ繝。繝ウ繝育分蜿キ","COMMENT_NO","bigint",,,"","",$FFFFFFFF,"" @@ -546,7 +589,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20150416234328 -Position="MAIN",1140,1520 +Position="MAIN",1280,1590 [Entity] PName=KNOWLEDGES @@ -567,7 +610,7 @@ Field="繧ウ繝。繝ウ繝井サカ謨ー","COMMENT_COUNT","@INT",,,"","",$FFFFFFFF,"" EffectMode=None Color=$000000 BkColor=$FFFFFF -ModifiedDateTime=20150416233526 +ModifiedDateTime=20150506050220 Position="MAIN",1160,1150 [Comment] diff --git a/pom.xml b/pom.xml index 670c9cf64..83a35de0e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ <groupId>org.support-project</groupId> <artifactId>knowledge</artifactId> <packaging>war</packaging> - <version>0.5.0</version> + <version>0.5.1-SNAPSHOT</version> <name>webapp for knowledge</name> <url>https://support-project.org/</url> @@ -16,7 +16,7 @@ <dependency> <groupId>org.support-project</groupId> <artifactId>web</artifactId> - <version>0.5.0</version> + <version>0.5.1-SNAPSHOT</version> </dependency> <dependency> @@ -86,13 +86,19 @@ <artifactId>mail</artifactId> <version>1.4.7</version> </dependency> - + <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.3-1103-jdbc41</version> </dependency> + <dependency> + <groupId>com.googlecode.java-diff-utils</groupId> + <artifactId>diffutils</artifactId> + <version>1.2.1</version> + </dependency> + </dependencies> <repositories> diff --git a/src/main/java/org/support/project/knowledge/bat/AbstractBat.java b/src/main/java/org/support/project/knowledge/bat/AbstractBat.java index 6ea50b4df..ef7f635e4 100644 --- a/src/main/java/org/support/project/knowledge/bat/AbstractBat.java +++ b/src/main/java/org/support/project/knowledge/bat/AbstractBat.java @@ -10,5 +10,8 @@ public void dbInit() { DBConnenctionLogic.get().connectCustomConnection(); } - + protected void send(String msg) { + System.out.println("[SEND]" + msg); + } + } diff --git a/src/main/java/org/support/project/knowledge/bat/CreateExportDataBat.java b/src/main/java/org/support/project/knowledge/bat/CreateExportDataBat.java new file mode 100644 index 000000000..ff9633bb4 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/bat/CreateExportDataBat.java @@ -0,0 +1,148 @@ +package org.support.project.knowledge.bat; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; + +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.serialize.SerializeUtils; +import org.support.project.common.util.FileUtil; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.config.SystemConfig; +import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgeFilesDao; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgeFilesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.logic.CompressLogic; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.vo.ExportUser; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.entity.UsersEntity; + +public class CreateExportDataBat extends AbstractBat { + /** 繝ュ繧ー */ + private static Log LOG = LogFactory.getLog(CreateExportDataBat.class); + + public static final String DATA_DIR = "DataExport"; + + public static void main(String[] args) throws Exception { + LOG.trace("start"); + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + CreateExportDataBat bat = new CreateExportDataBat(); + bat.start(); + } + + + private void start() throws Exception { + super.dbInit(); + SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.DATA_EXPORT, AppConfig.SYSTEM_NAME); + if (entity == null) { + send("[Fail] create fail. please try again."); + return; + } + // 繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ繧呈�シ邏阪☆繧九ョ繧」繝ャ繧ッ繝医Μ + AppConfig config = AppConfig.get(); + File base = new File(config.getTmpPath()); + File dir = new File(base, DATA_DIR); + if (dir.exists()) { + FileUtil.delete(dir); + } + dir.mkdirs(); + File attach = new File(dir, "attach"); + attach.mkdirs(); + File userdir = new File(dir, "user"); + userdir.mkdirs(); + + //繝翫Ξ繝�ず繝��繧ソ繧貞叙蠕� + LoginedUser loginedUser = new LoginedUser() { + @Override + public boolean isAdmin() { + return true; + } + }; + KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); + CommentsDao commentsDao = CommentsDao.get(); + KnowledgeFilesDao knowledgeFilesDao = KnowledgeFilesDao.get(); + + List<KnowledgesEntity> knowledges = knowledgeLogic.searchKnowledge("", loginedUser, 0, 100); + for (KnowledgesEntity knowledgesEntity : knowledges) { + File f = new File(dir, "knowledge-" + StringUtils.zeroPadding(knowledgesEntity.getKnowledgeId(), 6) + ".xml"); + String xml = SerializeUtils.objectToXml(knowledgesEntity); + FileUtil.write(f, xml); + + // 繝翫Ξ繝�ず縺ョ繧ウ繝。繝ウ繝医r蜿門セ� + List<CommentsEntity> comments = commentsDao.selectOnKnowledgeId(knowledgesEntity.getKnowledgeId()); + for (CommentsEntity commentsEntity : comments) { + File c = new File(dir, "comment-" + StringUtils.zeroPadding(knowledgesEntity.getKnowledgeId(), 6) + "-" + + StringUtils.zeroPadding(commentsEntity.getKnowledgeId(), 6) + ".xml"); + xml = SerializeUtils.objectToXml(commentsEntity); + FileUtil.write(c, xml); + } + List<KnowledgeFilesEntity> files = knowledgeFilesDao.selectOnKnowledgeId(knowledgesEntity.getKnowledgeId()); + for (KnowledgeFilesEntity knowledgeFilesEntity : files) { + KnowledgeFilesEntity file = knowledgeFilesDao.selectOnKey(knowledgeFilesEntity.getFileNo()); + File a = new File(attach, "attach-" + StringUtils.zeroPadding(knowledgesEntity.getKnowledgeId(), 6) + "-" + + StringUtils.zeroPadding(knowledgeFilesEntity.getFileNo(), 6) + + knowledgeFilesEntity.getFileName()); + OutputStream outputStream = new FileOutputStream(a); + InputStream inputStream = file.getFileBinary(); + try { + FileUtil.copy(inputStream, outputStream); + } finally { + inputStream.close(); + outputStream.close(); + } + } + send("[Export] knowledge-" + knowledgesEntity.getKnowledgeId()); + } + + // 繝ヲ繝シ繧カ諠��ア繧貞叙蠕� + UsersDao usersDao = UsersDao.get(); + List<UsersEntity> users = usersDao.selectAll(); + for (UsersEntity usersEntity : users) { + ExportUser user = new ExportUser(); + PropertyUtil.copyPropertyValue(usersEntity, user); + File f = new File(userdir, "user-" + StringUtils.zeroPadding(user.getUserId(), 6) + ".xml"); + String xml = SerializeUtils.objectToXml(user); + FileUtil.write(f, xml); + send("[Export] user-" + user.getUserId()); + } + + // zip蝨ァ邵ョ + send("[Export] during the compression"); + String name = DATA_DIR + ".zip"; + File comp = new File(base, name); + + BufferedOutputStream output = null; + ZipArchiveOutputStream os = null; + try { + output = new BufferedOutputStream(new FileOutputStream(comp)); + os = new ZipArchiveOutputStream(output); + os.setEncoding("UTF-8"); + CompressLogic.get().addZip(os, dir, null); + } finally { + if (os != null) { + os.close(); + } + if (output != null) { + output.close(); + } + } + send("[Export] complete!"); + // 蝨ァ邵ョ縺ョ莠育エ�r蜑企勁 + SystemConfigsDao.get().physicalDelete(entity); + } + + +} diff --git a/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java b/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java index 649129309..cc5159411 100644 --- a/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java +++ b/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java @@ -18,6 +18,8 @@ public class DataTransferBat extends AbstractBat implements Runnable { public static void main(String[] args) throws Exception { LOG.trace("start"); + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + DataTransferBat bat = new DataTransferBat(); bat.start(); } @@ -50,32 +52,39 @@ public void run() { * @throws Exception */ private void start() throws Exception { - // 螟夐㍾襍キ蜍輔メ繧ァ繝�け - if (DataTransferLogic.get().isTransferStarted()) { - LOG.info("ALL Ready started."); - return; - } - // DB繧定オキ蜍� - Thread thread = new Thread(this); - thread.start(); - try { - // 繧オ繝シ繝舌�縺瑚オキ蜍輔☆繧九∪縺ァ蠕�ゥ� - while(!serverStarted) { - Thread.sleep(1000); + if (DataTransferLogic.get().isTransferRequested() || DataTransferLogic.get().isTransferBackRequested()) { + // 螟夐㍾襍キ蜍輔メ繧ァ繝�け + if (DataTransferLogic.get().isTransferStarted()) { + LOG.info("ALL Ready started."); + return; + } + + // DB繧定オキ蜍� + Thread thread = new Thread(this); + thread.start(); + try { + // 繧オ繝シ繝舌�縺瑚オキ蜍輔☆繧九∪縺ァ蠕�ゥ� + while(!serverStarted) { + Thread.sleep(1000); + } + // 繧ウ繝阪け繧キ繝ァ繝ウ縺ョ險ュ螳壹r隱ュ縺ソ霎シ縺ソ + ConnectionConfig defaultConnection = DBConnenctionLogic.get().getDefaultConnectionConfig(); + ConnectionConfig customConnection = DBConnenctionLogic.get().getCustomConnectionConfig(); + // 繝��繧ソ遘サ陦後r螳溯。鯉シ医☆縺斐¥譎る俣縺後°縺九k蜿ッ閭ス諤ァ縺ゅj�� + if (DataTransferLogic.get().isTransferBackRequested()) { + DataTransferLogic.get().transferData(customConnection, defaultConnection); + } else { + DataTransferLogic.get().transferData(defaultConnection, customConnection); + } + } catch (Exception e) { + LOG.error("ERROR", e); + } finally { + // 繝��繧ソ遘サ陦檎オゆコ� + DataTransferLogic.get().finishTransfer(); + // DB繧貞●豁「 + runing = false; + thread.join(); } - // 繧ウ繝阪け繧キ繝ァ繝ウ縺ョ險ュ螳壹r隱ュ縺ソ霎シ縺ソ - ConnectionConfig defaultConnection = DBConnenctionLogic.get().getDefaultConnectionConfig(); - ConnectionConfig customConnection = DBConnenctionLogic.get().getCustomConnectionConfig(); - // 繝��繧ソ遘サ陦後r螳溯。鯉シ医☆縺斐¥譎る俣縺後°縺九k蜿ッ閭ス諤ァ縺ゅj�� - DataTransferLogic.get().transferData(defaultConnection, customConnection); - } catch (Exception e) { - LOG.error("ERROR", e); - } finally { - // 繝��繧ソ遘サ陦檎オゆコ� - DataTransferLogic.get().finishTransfer(); - // DB繧貞●豁「 - runing = false; - thread.join(); } } diff --git a/src/main/java/org/support/project/knowledge/bat/FileParseBat.java b/src/main/java/org/support/project/knowledge/bat/FileParseBat.java index 39ec1aae7..dd8837172 100644 --- a/src/main/java/org/support/project/knowledge/bat/FileParseBat.java +++ b/src/main/java/org/support/project/knowledge/bat/FileParseBat.java @@ -45,6 +45,8 @@ public class FileParseBat extends AbstractBat { public static final String ID_PREFIX = "FILE-"; public static void main(String[] args) throws Exception { + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + FileParseBat bat = new FileParseBat(); bat.dbInit(); bat.start(); diff --git a/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java b/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java index 4bed9e4e1..d5eee382b 100644 --- a/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java +++ b/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java @@ -2,6 +2,7 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.dao.KnowledgeFilesDao; public class KnowledgeFileClearBat extends AbstractBat { @@ -11,6 +12,8 @@ public class KnowledgeFileClearBat extends AbstractBat { public static void main(String[] args) { LOG.trace("start"); + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + KnowledgeFileClearBat bat = new KnowledgeFileClearBat(); bat.dbInit(); bat.start(); diff --git a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java index 87061fe5c..b7c7ce616 100644 --- a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java +++ b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java @@ -22,6 +22,7 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.util.PasswordUtil; import org.support.project.common.util.StringUtils; +import org.support.project.knowledge.config.AppConfig; import org.support.project.web.dao.MailConfigsDao; import org.support.project.web.dao.MailsDao; import org.support.project.web.entity.MailConfigsEntity; @@ -50,6 +51,8 @@ public class MailSendBat extends AbstractBat { + "@" + "[a-zA-Z0-9][a-zA-Z0-9\\-]*(\\.[a-zA-Z0-9\\-]+)*$"; public static void main(String[] args) throws Exception { + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + MailSendBat bat = new MailSendBat(); bat.dbInit(); bat.start(); diff --git a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java index d8e64da3f..407e69bc1 100644 --- a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java +++ b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java @@ -44,13 +44,12 @@ public class NotifyMailBat extends AbstractBat { /** 繝ュ繧ー */ private static Log LOG = LogFactory.getLog(MailSendBat.class); - /** 蜷後§繝翫Ξ繝�ず縺ォ菴募コヲ繧ゅう繧、繝阪r謚シ縺励※繧る夂衍縺ッ1縺、縺ォ縺吶k縺溘a縺ォ菫晄戟縺吶k */ - private List<Long> likesKnowledges = new ArrayList<Long>(); - private static final String MAIL_CONFIG_DIR = "/org/support/project/knowledge/mail/"; private static final DateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); public static void main(String[] args) throws Exception { + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + NotifyMailBat bat = new NotifyMailBat(); bat.dbInit(); bat.start(); diff --git a/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java b/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java index c3b974051..5ff41a9fa 100644 --- a/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java +++ b/src/main/java/org/support/project/knowledge/bat/ReIndexingBat.java @@ -14,6 +14,8 @@ public class ReIndexingBat extends AbstractBat { public static void main(String[] args) throws Exception { + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + ReIndexingBat bat = new ReIndexingBat(); bat.dbInit(); //繧ォ繧ケ繧ソ繝槭う繧コDB縺瑚ィュ螳壹&繧後※縺�※縺ー縺昴l繧貞盾辣ァ bat.start(); diff --git a/src/main/java/org/support/project/knowledge/config/AppConfig.java b/src/main/java/org/support/project/knowledge/config/AppConfig.java index 3c7b030e1..30c761c33 100644 --- a/src/main/java/org/support/project/knowledge/config/AppConfig.java +++ b/src/main/java/org/support/project/knowledge/config/AppConfig.java @@ -4,6 +4,7 @@ import java.util.List; import org.support.project.common.config.ConfigLoader; +import org.support.project.common.util.StringUtils; import org.support.project.knowledge.vo.LabelValue; @@ -26,24 +27,17 @@ public static AppConfig get() { private List<LabelValue> languages = new ArrayList<>(); - /** * @return the indexPath */ public String getIndexPath() { + if (StringUtils.isEmpty(indexPath)) { + return ""; + } + if (!convIndexPath) { String path = indexPath; - if (path.indexOf("{user.home}") != -1) { - String userHome = System.getProperty("user.home"); - path = path.replace("{user.home}", userHome); - } - if (path.indexOf("{base.path}") != -1) { - path = path.replace("{base.path}", getBasePath()); - } - if (path.indexOf("\\") != -1) { - path = path.replaceAll("\\\\", "/"); - } - this.indexPath = path; + this.indexPath = convPath(path); convIndexPath = true; } return indexPath; diff --git a/src/main/java/org/support/project/knowledge/config/SystemConfig.java b/src/main/java/org/support/project/knowledge/config/SystemConfig.java index 0cafbf8b5..46f1ff9c7 100644 --- a/src/main/java/org/support/project/knowledge/config/SystemConfig.java +++ b/src/main/java/org/support/project/knowledge/config/SystemConfig.java @@ -27,5 +27,7 @@ public class SystemConfig { /** 繧、繝ウ繝�ャ繧ッ繧ケ蜀堺ス懈�縺ョ縺溘a縺ョ險ュ螳壼、 */ public static final String RE_INDEXING = "RE_INDEXING"; + /** 繧ィ繧ッ繧ケ繝昴�繝医�縺溘a縺ョ險ュ螳壼、 */ + public static final String DATA_EXPORT = "DATA_EXPORT"; } diff --git a/src/main/java/org/support/project/knowledge/control/IndexControl.java b/src/main/java/org/support/project/knowledge/control/IndexControl.java index 6cd6fc954..145dfbbca 100644 --- a/src/main/java/org/support/project/knowledge/control/IndexControl.java +++ b/src/main/java/org/support/project/knowledge/control/IndexControl.java @@ -4,20 +4,10 @@ import org.support.project.common.log.LogFactory; import org.support.project.di.DI; import org.support.project.di.Instance; -import org.support.project.web.bean.MessageResult; -import org.support.project.web.boundary.Boundary; -import org.support.project.web.config.MessageStatus; @DI(instance=Instance.Prototype) public class IndexControl extends Control { /** 繝ュ繧ー */ private static Log log = LogFactory.getLog(IndexControl.class); - public Boundary msg() { - MessageResult result = new MessageResult(); - result.setStatus(MessageStatus.Success.getValue()); - result.setMessage("OK"); - return send(result); - } - } diff --git a/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java b/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java index e101c8707..86a008911 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/ConfigControl.java @@ -11,6 +11,8 @@ import org.support.project.web.annotation.Auth; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpUtil; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.MailConfigsDao; import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.entity.MailConfigsEntity; @@ -23,6 +25,7 @@ public class ConfigControl extends Control { * * @return */ + @Get @Auth(roles = "admin") public Boundary config() { SystemConfigsDao dao = SystemConfigsDao.get(); @@ -49,6 +52,7 @@ public Boundary config() { * * @return */ + @Post @Auth(roles = "admin") public Boundary save() { List<ValidateError> errors = new ArrayList<>(); @@ -89,6 +93,7 @@ public Boundary save() { * * @return */ + @Get @Auth(roles = "admin") public Boundary system() { SystemConfigsDao dao = SystemConfigsDao.get(); @@ -108,6 +113,7 @@ public Boundary system() { * * @return */ + @Post @Auth(roles = "admin") public Boundary save_params() { List<ValidateError> errors = new ArrayList<>(); diff --git a/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java b/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java index ea8ffab0e..1b7c270ec 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/DatabaseControl.java @@ -1,7 +1,11 @@ package org.support.project.knowledge.control.admin; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.sql.SQLException; import java.util.List; @@ -14,6 +18,7 @@ import org.support.project.common.serialize.SerializeUtils; import org.support.project.common.wrapper.FileInputStreamWithDeleteWrapper; import org.support.project.di.Container; +import org.support.project.knowledge.bat.CreateExportDataBat; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; import org.support.project.knowledge.control.Control; @@ -29,6 +34,8 @@ import org.support.project.ormapping.transaction.TransactionManager; import org.support.project.web.annotation.Auth; import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.logic.DBConnenctionLogic; @@ -39,6 +46,7 @@ public class DatabaseControl extends Control { * @see org.support.project.web.control.Control#index() */ @Override + @Get public Boundary index() { H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); boolean active = h2dbServerLogic.isActive(); @@ -51,6 +59,7 @@ public Boundary index() { * @return */ @Auth(roles="admin") + @Get public Boundary start() { H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); h2dbServerLogic.start(); @@ -75,6 +84,7 @@ public Boundary start() { * @throws SQLException */ @Auth(roles="admin") + @Get public Boundary stop() throws ORMappingException, SQLException { // 邨�∩霎シ縺ソDB繧剃スソ縺」縺ヲ縺�k蝣エ蜷医√さ繝阪け繧キ繝ァ繝ウ隗」髯、 if (DBConnenctionLogic.get().getCustomConnectionConfig() == null) { @@ -99,6 +109,7 @@ public Boundary stop() throws ORMappingException, SQLException { * @throws IOException */ @Auth(roles="admin") + @Get public Boundary backup() throws IOException { HttpServletResponse res = getResponse(); @@ -118,6 +129,7 @@ public Boundary backup() throws IOException { * @throws IOException */ @Auth(roles="admin") + @Post public Boundary restore() throws IOException { H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); boolean active = h2dbServerLogic.isActive(); @@ -146,6 +158,7 @@ public Boundary restore() throws IOException { * 繝��繧ソ繝吶�繧ケ縺ォ謗・邯� * @return */ + @Get @Auth(roles="admin") public Boundary connect() { ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); @@ -156,7 +169,7 @@ public Boundary connect() { setAttribute("custom", Boolean.FALSE); } else { setAttribute("custom", Boolean.TRUE); - if (DataTransferLogic.get().isTransferRequested()) { + if (DataTransferLogic.get().isTransferRequested() || DataTransferLogic.get().isTransferBackRequested()) { setAttribute("transfer", Boolean.TRUE); } else { setAttribute("transfer", Boolean.FALSE); @@ -173,6 +186,7 @@ public Boundary connect() { * @return * @throws Exception */ + @Post @Auth(roles="admin") public Boundary custom_save() throws Exception { ConnectionConfig connectionConfig = super.getParamOnProperty(ConnectionConfig.class); @@ -208,6 +222,7 @@ public Boundary custom_save() throws Exception { * 繧ウ繝阪け繧キ繝ァ繝ウ縺ョ繧ォ繧ケ繧ソ繝�險ュ螳壹r蜑企勁 * @return */ + @Get @Auth(roles="admin") public Boundary custom_delete() { ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); @@ -216,6 +231,12 @@ public Boundary custom_delete() { DBConnenctionLogic.get().removeCustomConnectionConfig(); } + // 繧ゅ@繝�ヵ繧ゥ繝ォ繝医�H2縺後→縺セ縺」縺ヲ縺�l縺ー襍キ蜍� + H2DBServerLogic h2dbServerLogic = H2DBServerLogic.get(); + if (!h2dbServerLogic.isActive()) { + h2dbServerLogic.start(); + } + // 繧ォ繧ケ繧ソ繝�險ュ螳壹r蜑企勁縺励◆縺ョ縺ァ縲√ョ繝輔か繝ォ繝医r蛻�j譖ソ縺� ConnectionConfigLoader loader = Container.getComp("XML", ConnectionConfigLoader.class); connectionConfig = loader.load(ORMappingParameter.CONNECTION_SETTING); @@ -232,18 +253,46 @@ public Boundary custom_delete() { * @return * @throws IOException */ + @Get @Auth(roles="admin") public Boundary data_transfer() throws IOException { - DataTransferLogic.get().requestTransfer(); - addMsgSuccess("knowledge.connection.msg.custom.transfer.request"); + ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); + if (connectionConfig != null) { + DataTransferLogic.get().requestTransfer(); + addMsgSuccess("knowledge.connection.msg.custom.transfer.request"); + } return connect(); } + /** + * 繝��繧ソ遘サ陦後�繝ェ繧ッ繧ィ繧ケ繝医r縺�¢繧� + * (繧ォ繧ケ繧ソ繝�DB縺九i邨�∩霎シ縺ソDB縺ク) + * 邨�∩霎シ縺ソDB縺ッ繝繧ヲ繝ウ繝ュ繝シ繝峨〒縺阪k縺ョ縺ァ縲√ョ繝シ繧ソ縺ョ繝舌ャ繧ッ繧「繝��縺ォ菴ソ縺医k + * @return + * @throws IOException + */ + @Get + @Auth(roles="admin") + public Boundary data_transfer_back() throws IOException { + ConnectionConfig connectionConfig = DBConnenctionLogic.get().getCustomConnectionConfig(); + if (connectionConfig != null) { + if (!DataTransferLogic.get().isTransferBackRequested()) { + // 邨�∩霎シ縺ソ縺ョH2Database縺ッDropTable/CreateTable繧堤ケー繧願ソ斐☆縺ィ縲√↑縺懊°螳ケ驥上′螟ァ縺阪¥縺ェ繧� + // 螳悟�蛻晄悄蛹悶@縺滓婿縺御スソ縺�d縺吶>縺ョ縺ァ縲∵里蟄倥�DB縺ッ繝舌ャ繧ッ繧「繝��縺吶k + DataTransferLogic.get().backupAndInitH2(); + + DataTransferLogic.get().requestTransferBack(); + addMsgSuccess("knowledge.connection.msg.custom.transfer.request"); + } + } + return connect(); + } /** * 繧、繝ウ繝�ャ繧ッ繧ケ蜀咲函諤ァ縺ョ繝壹�繧ク繧定。ィ遉コ * @return */ + @Get @Auth(roles="admin") public Boundary reindexing() { SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.RE_INDEXING, AppConfig.SYSTEM_NAME); @@ -259,6 +308,7 @@ public Boundary reindexing() { * 繧、繝ウ繝�ャ繧ッ繧ケ蜀咲函諤ァ縺ョ繝ェ繧ッ繧ィ繧ケ繝医r縺�¢繧� * @return */ + @Post @Auth(roles="admin") public Boundary start_reindexing() { SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.RE_INDEXING, AppConfig.SYSTEM_NAME); @@ -266,7 +316,6 @@ public Boundary start_reindexing() { addMsgInfo("message.allready.started"); return reindexing(); } - Long start = getParam("start", Long.class); Long end = getParam("end", Long.class); String val = "start=" + start + ",end=" + end; @@ -275,11 +324,64 @@ public Boundary start_reindexing() { entity.setSystemName(AppConfig.SYSTEM_NAME); entity.setConfigName(SystemConfig.RE_INDEXING); entity.setConfigValue(val); - SystemConfigsDao.get().save(entity); - return reindexing(); } + /** + * 繝��繧ソ繧ィ繧ッ繧ケ繝昴�繝医�逕サ髱「繧定。ィ遉コ + * @return + */ + @Get + @Auth(roles="admin") + public Boundary export() { + SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.DATA_EXPORT, AppConfig.SYSTEM_NAME); + if (entity != null) { + setAttribute("start_export", Boolean.TRUE); + } else { + setAttribute("start_export", Boolean.FALSE); + } + + return forward("export.jsp"); + } + /** + * 繝��繧ソ繧ィ繧ッ繧ケ繝昴�繝医�繝ェ繧ッ繧ィ繧ケ繝医r蜿励¢繧� + * @return + */ + @Get + @Auth(roles="admin") + public Boundary export_data_create() { + SystemConfigsEntity entity = SystemConfigsDao.get().selectOnKey(SystemConfig.DATA_EXPORT, AppConfig.SYSTEM_NAME); + if (entity != null) { + addMsgInfo("message.allready.started"); + return export(); + } + entity = new SystemConfigsEntity(); + entity.setSystemName(AppConfig.SYSTEM_NAME); + entity.setConfigName(SystemConfig.DATA_EXPORT); + entity.setConfigValue("START"); + SystemConfigsDao.get().save(entity); + return export(); + } + + /** + * 繝��繧ソ繧ィ繧ッ繧ケ繝昴�繝医�繝ェ繧ッ繧ィ繧ケ繝医r蜿励¢繧� + * @return + * @throws FileNotFoundException + */ + @Get + @Auth(roles="admin") + public Boundary download() throws FileNotFoundException { + AppConfig config = AppConfig.get(); + File base = new File(config.getTmpPath()); + String name = CreateExportDataBat.DATA_DIR + ".zip"; + File comp = new File(base, name); + InputStream inputStream = new FileInputStream(comp); + return download(name, inputStream, comp.length()); + } + + + + } diff --git a/src/main/java/org/support/project/knowledge/control/admin/MailControl.java b/src/main/java/org/support/project/knowledge/control/admin/MailControl.java index 512266e73..a44cb9cd8 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/MailControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/MailControl.java @@ -17,6 +17,8 @@ import org.support.project.knowledge.control.Control; import org.support.project.web.annotation.Auth; import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.MailConfigsDao; import org.support.project.web.entity.MailConfigsEntity; @@ -26,6 +28,7 @@ public class MailControl extends Control { * 繝。繝シ繝ォ縺ョ險ュ螳夂判髱「繧定。ィ遉コ * @return */ + @Get @Auth(roles="admin") public Boundary config() { MailConfigsDao dao = MailConfigsDao.get(); @@ -50,6 +53,7 @@ public Boundary config() { * @throws NoSuchAlgorithmException * @throws InvalidKeyException */ + @Post @Auth(roles="admin") public Boundary save() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { List<ValidateError> errors = new ArrayList<>(); @@ -97,6 +101,7 @@ public Boundary save() throws InvalidKeyException, NoSuchAlgorithmException, NoS * 繝。繝シ繝ォ縺ョ險ュ螳壹r蜑企勁 * @return */ + @Post @Auth(roles="admin") public Boundary delete() { MailConfigsDao dao = MailConfigsDao.get(); diff --git a/src/main/java/org/support/project/knowledge/control/admin/UsersControl.java b/src/main/java/org/support/project/knowledge/control/admin/UsersControl.java index 44cbafdaa..e05157e76 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/UsersControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/UsersControl.java @@ -16,9 +16,10 @@ import org.support.project.knowledge.vo.Roles; import org.support.project.web.annotation.Auth; import org.support.project.web.boundary.Boundary; -import org.support.project.web.common.HttpStatus; import org.support.project.web.common.HttpUtil; import org.support.project.web.config.CommonWebParameter; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.ProvisionalRegistrationsDao; import org.support.project.web.dao.RolesDao; import org.support.project.web.dao.UsersDao; @@ -37,6 +38,7 @@ public class UsersControl extends Control { * @return * @throws InvalidParamException */ + @Get @Auth(roles="admin") public Boundary list() throws InvalidParamException { Integer offset = super.getPathInteger(0); @@ -53,6 +55,7 @@ public Boundary list() throws InvalidParamException { * @param keyword * @return */ + @Get @Auth(roles="admin") private Boundary list(Integer offset, String keyword) { UsersDao dao = UsersDao.get(); @@ -78,6 +81,7 @@ private Boundary list(Integer offset, String keyword) { * 逋サ骭イ逕サ髱「繧定。ィ遉コ縺吶k * @return */ + @Get @Auth(roles="admin") public Boundary view_add() { String offset = super.getParam("offset", String.class); @@ -136,6 +140,7 @@ private void setSystemRoles(UsersEntity user) { * @return * @throws InvalidParamException */ + @Get @Auth(roles="admin") public Boundary view_edit() throws InvalidParamException { String offset = super.getParam("offset", String.class); @@ -167,6 +172,7 @@ public Boundary view_edit() throws InvalidParamException { * 繝ヲ繝シ繧カ繧定ソス蜉� * @return */ + @Post @Auth(roles="admin") public Boundary create() { String offset = super.getParam("offset", String.class); @@ -216,6 +222,7 @@ public Boundary create() { * 繝ヲ繝シ繧カ繧呈峩譁ー * @return */ + @Post @Auth(roles="admin") public Boundary save() { String offset = super.getParam("offset", String.class); @@ -280,6 +287,7 @@ public Boundary save() { * @return * @throws Exception */ + @Post @Auth(roles="admin") public Boundary delete() throws Exception { String offset = super.getParam("offset", String.class); @@ -302,6 +310,7 @@ public Boundary delete() throws Exception { * 繝ヲ繝シ繧カ逋サ骭イ謇ソ隱榊セ�■縺ョ荳隕ァ陦ィ遉コ * @return */ + @Get @Auth(roles="admin") public Boundary accept_list() { ProvisionalRegistrationsDao dao = ProvisionalRegistrationsDao.get(); @@ -315,6 +324,7 @@ public Boundary accept_list() { * 繝ヲ繝シ繧カ逋サ骭イ謇ソ隱� * @return */ + @Get @Auth(roles="admin") public Boundary accept() { String id = getPathInfo(); diff --git a/src/main/java/org/support/project/knowledge/control/open/AccountControl.java b/src/main/java/org/support/project/knowledge/control/open/AccountControl.java index 51f8d1285..006697a9b 100644 --- a/src/main/java/org/support/project/knowledge/control/open/AccountControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/AccountControl.java @@ -8,6 +8,7 @@ import org.support.project.knowledge.dao.AccountImagesDao; import org.support.project.knowledge.entity.AccountImagesEntity; import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; import org.support.project.web.exception.InvalidParamException; @DI(instance=Instance.Prototype) @@ -17,6 +18,7 @@ public class AccountControl extends Control { * @return * @throws InvalidParamException */ + @Get public Boundary icon() throws InvalidParamException { Integer userId = getPathInteger(-1); diff --git a/src/main/java/org/support/project/knowledge/control/open/FileControl.java b/src/main/java/org/support/project/knowledge/control/open/FileControl.java index 0184f2db1..23e2c404d 100644 --- a/src/main/java/org/support/project/knowledge/control/open/FileControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/FileControl.java @@ -9,6 +9,7 @@ import org.support.project.knowledge.logic.UploadedFileLogic; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.service.Get; @DI(instance=Instance.Prototype) public class FileControl extends Control { @@ -17,6 +18,7 @@ public class FileControl extends Control { private UploadedFileLogic fileLogic = UploadedFileLogic.get(); + @Get public Boundary download() { LOG.trace("download()"); diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index 4cbc984e9..ef5dacf81 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -10,17 +10,19 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.common.util.StringUtils; -import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.control.KnowledgeControlBase; import org.support.project.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgeHistoriesDao; import org.support.project.knowledge.dao.LikesDao; import org.support.project.knowledge.dao.TagsDao; import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgeHistoriesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.LikesEntity; import org.support.project.knowledge.entity.TagsEntity; +import org.support.project.knowledge.logic.DiffLogic; import org.support.project.knowledge.logic.KnowledgeLogic; import org.support.project.knowledge.logic.TagLogic; import org.support.project.knowledge.logic.TargetLogic; @@ -28,11 +30,11 @@ import org.support.project.knowledge.vo.LabelValue; import org.support.project.knowledge.vo.LikeCount; import org.support.project.knowledge.vo.UploadFile; -import org.support.project.knowledge.websocket.NotifyAction; import org.support.project.web.bean.LoginedUser; -import org.support.project.web.bean.MessageResult; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.UsersEntity; import org.support.project.web.exception.InvalidParamException; @@ -52,6 +54,7 @@ public class KnowledgeControl extends KnowledgeControlBase { * @return * @throws InvalidParamException */ + @Get public Boundary view() throws InvalidParamException { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -137,6 +140,7 @@ public Boundary view() throws InvalidParamException { * @return * @throws Exception */ + @Get public Boundary list() throws Exception { LOG.trace("Call list"); Integer offset = super.getPathInteger(0); @@ -237,6 +241,7 @@ public Boundary list() throws Exception { * @return * @throws InvalidParamException */ + @Get public Boundary like() throws InvalidParamException { Long knowledgeId = super.getPathLong(Long.valueOf(-1)); KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); @@ -258,6 +263,7 @@ public Boundary like() throws InvalidParamException { * @throws ScanException * @throws PolicyException */ + @Post public Boundary escape(KnowledgesEntity entity) throws PolicyException, ScanException { super.setSendEscapeHtml(false); entity.setTitle(doSamy(entity.getTitle())); @@ -269,6 +275,7 @@ public Boundary escape(KnowledgesEntity entity) throws PolicyException, ScanExce * 讀懃エ「逕サ髱「繧定。ィ遉コ * @return */ + @Get public Boundary search() { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -280,6 +287,7 @@ public Boundary search() { * @return * @throws InvalidParamException */ + @Get public Boundary likes() throws InvalidParamException { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -315,6 +323,79 @@ public Boundary likes() throws InvalidParamException { return forward("likes.jsp"); } + @Get + public Boundary histories() throws InvalidParamException { + // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� + setViewParam(); + + Long knowledgeId = super.getPathLong(Long.valueOf(-1)); + setAttribute("knowledgeId", knowledgeId); + // 讓ゥ髯舌メ繧ァ繝�け(縺�▲縺溘s繧「繧ッ繧サ繧ケ縺ァ縺阪k繝ヲ繝シ繧カ縺ッ蜈ィ縺ヲ陦ィ遉コ) + KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); + KnowledgesEntity entity = knowledgeLogic.select(knowledgeId, getLoginedUser()); + if (entity == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); + } + + Integer page = 0; + String p = getParamWithDefault("page", ""); + if (StringUtils.isInteger(p)) { + page = Integer.parseInt(p); + } + int previous = page -1; + if (previous < 0) { + previous = 0; + } + setAttribute("page", page); + setAttribute("previous", previous); + setAttribute("next", page + 1); + + // 螻・豁エ繧貞叙蠕� + KnowledgeHistoriesDao historiesDao = KnowledgeHistoriesDao.get(); + List<KnowledgeHistoriesEntity> histories = historiesDao.selectOnKnowledge(knowledgeId, page * PAGE_LIMIT, PAGE_LIMIT); + setAttribute("histories", histories); + + return forward("histories.jsp"); + } + + + @Get + public Boundary history() throws InvalidParamException { + // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� + setViewParam(); + + Long knowledgeId = super.getPathLong(Long.valueOf(-1)); + setAttribute("knowledgeId", knowledgeId); + // 讓ゥ髯舌メ繧ァ繝�け(縺�▲縺溘s繧「繧ッ繧サ繧ケ縺ァ縺阪k繝ヲ繝シ繧カ縺ッ蜈ィ縺ヲ陦ィ遉コ) + KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); + KnowledgesEntity entity = knowledgeLogic.select(knowledgeId, getLoginedUser()); + if (entity == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); + } + + Integer page = 0; + String p = getParamWithDefault("page", ""); + if (StringUtils.isInteger(p)) { + page = Integer.parseInt(p); + } + setAttribute("page", page); + + Integer historyNo = 0; + String h = getParamWithDefault("history_no", ""); + if (StringUtils.isInteger(h)) { + historyNo = Integer.parseInt(h); + } + + KnowledgeHistoriesDao historiesDao = KnowledgeHistoriesDao.get(); + KnowledgeHistoriesEntity history = historiesDao.selectOnKey(historyNo, knowledgeId); + setAttribute("history", history); + setAttribute("now", entity); + + List<String> changes = DiffLogic.get().diff(history.getContent(), entity.getContent()); + setAttribute("changes", changes); + + return forward("history.jsp"); + } } diff --git a/src/main/java/org/support/project/knowledge/control/open/LangControl.java b/src/main/java/org/support/project/knowledge/control/open/LangControl.java index efcce76cb..279ecfbc3 100644 --- a/src/main/java/org/support/project/knowledge/control/open/LangControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/LangControl.java @@ -2,16 +2,17 @@ import java.util.Locale; -import org.apache.taglibs.standard.tag.common.fmt.SetLocaleSupport; import org.support.project.common.util.StringUtils; import org.support.project.knowledge.control.Control; import org.support.project.web.bean.LoginedUser; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpUtil; +import org.support.project.web.control.service.Get; import org.support.project.web.exception.InvalidParamException; public class LangControl extends Control { + @Get public Boundary en() { Locale locale = Locale.ENGLISH; HttpUtil.setLocale(super.getRequest(), locale); @@ -20,6 +21,7 @@ public Boundary en() { } + @Get public Boundary ja() { Locale locale = Locale.JAPANESE; HttpUtil.setLocale(super.getRequest(), locale); @@ -35,6 +37,7 @@ private void setLocale(LoginedUser loginedUser, Locale locale) { } + @Get public Boundary select() throws InvalidParamException { String LocaleID = getPathString(); if (StringUtils.isEmpty(LocaleID)) { diff --git a/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java b/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java index 3b60a01fc..be3737ee6 100644 --- a/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/PasswordInitializationControl.java @@ -13,6 +13,8 @@ import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.common.HttpUtil; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.PasswordResetsDao; import org.support.project.web.entity.PasswordResetsEntity; import org.support.project.web.exception.InvalidParamException; @@ -23,6 +25,7 @@ public class PasswordInitializationControl extends Control { * 繝代せ繝ッ繝シ繝牙ソ倥l縺ョ逕サ髱「繧定。ィ遉コ * @return */ + @Get public Boundary view() { return forward("forgot_pass_request.jsp"); } @@ -31,6 +34,7 @@ public Boundary view() { * 繝代せ繝ッ繝シ繝牙�譛溷喧縺ョ繝ェ繧ッ繧ィ繧ケ繝医�蜿嶺サ� * @return */ + @Post public Boundary request() { String email = getParam("username"); @@ -73,6 +77,7 @@ public Boundary request() { * @return * @throws InvalidParamException */ + @Get public Boundary init() throws InvalidParamException { String key = getPathString(); PasswordResetsDao resetsDao = PasswordResetsDao.get(); @@ -95,6 +100,7 @@ public Boundary init() throws InvalidParamException { * 繝代せ繝ッ繝シ繝峨�蛻晄悄蛹� * @return */ + @Post public Boundary change() { String key = getParam("key"); PasswordResetsDao resetsDao = PasswordResetsDao.get(); diff --git a/src/main/java/org/support/project/knowledge/control/open/SignupControl.java b/src/main/java/org/support/project/knowledge/control/open/SignupControl.java index 14d96f67f..49fdd13a8 100644 --- a/src/main/java/org/support/project/knowledge/control/open/SignupControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/SignupControl.java @@ -18,6 +18,9 @@ import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.common.HttpUtil; +import org.support.project.web.config.HttpMethod; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.ProvisionalRegistrationsDao; import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.dao.UsersDao; @@ -33,6 +36,7 @@ public class SignupControl extends Control { * 繝ヲ繝シ繧カ縺ョ繧オ繧、繝ウ繧「繝��逕サ髱「繧定。ィ遉コ * @return */ + @Get public Boundary view() { return forward("signup.jsp"); } @@ -41,6 +45,7 @@ public Boundary view() { * 譁ー隕冗匳骭イ蜃ヲ逅�r菫晏ュ� * @return */ + @Post public Boundary save() { SystemConfigsDao systemConfigsDao = SystemConfigsDao.get(); SystemConfigsEntity userAddType = systemConfigsDao.selectOnKey(SystemConfig.USER_ADD_TYPE, AppConfig.SYSTEM_NAME); @@ -112,6 +117,7 @@ public Boundary save() { * 莉ョ逋サ骭イ * @return */ + @Post @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) private ProvisionalRegistrationsEntity addProvisionalRegistration() { ProvisionalRegistrationsEntity entity = super.getParams(ProvisionalRegistrationsEntity.class); @@ -177,6 +183,7 @@ private List<ValidateError> validate() { * 諡帛セ�Γ繝シ繝ォ縺九i縺ョ譛ャ逋サ骭イ * @return */ + @Get public Boundary activate() { String id = getPathInfo(); if (StringUtils.isEmpty(id)) { @@ -205,13 +212,12 @@ public Boundary activate() { mailLogic.sendNotifyAddUser(user); } - // 繝ュ繧ー繧、繝ウ蜃ヲ逅� AuthenticationLogic logic = Container.getComp(DefaultAuthenticationLogicImpl.class); logic.setSession(entity.getUserKey(), getRequest()); addMsgInfo("knowledge.signup.done"); - return devolution("Index/index"); + return devolution(HttpMethod.get, "Index/index"); } } diff --git a/src/main/java/org/support/project/knowledge/control/open/TagControl.java b/src/main/java/org/support/project/knowledge/control/open/TagControl.java index 8ca66a38e..7e139fef5 100644 --- a/src/main/java/org/support/project/knowledge/control/open/TagControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/TagControl.java @@ -8,6 +8,7 @@ import org.support.project.knowledge.entity.TagsEntity; import org.support.project.web.bean.LoginedUser; import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; import org.support.project.web.entity.GroupsEntity; import org.support.project.web.exception.InvalidParamException; @@ -20,6 +21,7 @@ public class TagControl extends Control { * @return * @throws InvalidParamException */ + @Get public Boundary list() throws InvalidParamException { Integer offset = super.getPathInteger(0); int userId = super.getLoginUserId(); diff --git a/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java b/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java index 4809c60c0..a4214ca2d 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/AccountControl.java @@ -25,6 +25,9 @@ import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.common.HttpUtil; +import org.support.project.web.config.HttpMethod; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.SystemConfigsEntity; @@ -39,6 +42,7 @@ public class AccountControl extends Control { /** * 繧「繧ォ繧ヲ繝ウ繝域ュ蝣ア陦ィ遉コ */ + @Get @Override public Boundary index() { SystemConfigsDao dao = SystemConfigsDao.get(); @@ -68,6 +72,7 @@ public Boundary index() { * 繝ヲ繝シ繧カ縺ョ諠��ア譖エ譁ー * @return */ + @Post public Boundary update() { SystemConfigsDao systemConfigsDao = SystemConfigsDao.get(); @@ -133,6 +138,7 @@ public Boundary update() { * 騾莨夂判髱「繧定。ィ遉コ * @return */ + @Get public Boundary withdrawal() { return forward("withdrawal.jsp"); } @@ -144,6 +150,7 @@ public Boundary withdrawal() { * @return * @throws Exception */ + @Post public Boundary delete() throws Exception { // 繧「繧ォ繧ヲ繝ウ繝亥炎髯、(騾莨壼�逅�) boolean knowledgeRemove = true; @@ -157,7 +164,7 @@ public Boundary delete() throws Exception { authenticationLogic.clearSession(getRequest()); addMsgInfo("knowledge.account.delete"); - return devolution("Index/index"); + return devolution(HttpMethod.get, "Index/index"); //return redirect(getRequest().getContextPath()); } @@ -166,6 +173,7 @@ public Boundary delete() throws Exception { * @return * @throws IOException */ + @Post public Boundary iconupload() throws IOException { AccountLogic logic = AccountLogic.get(); UploadResults results = new UploadResults(); @@ -216,6 +224,7 @@ private ValidateError checkFile(FileItem fileItem) { * 繝。繝シ繝ォ繧「繝峨Ξ繧ケ縺ョ螟画峩繝ェ繧ッ繧ィ繧ケ繝医r逋サ骭イ縺吶k逕サ髱「繧定。ィ遉コ * @return */ + @Get public Boundary changekey() { SystemConfigsDao dao = SystemConfigsDao.get(); SystemConfigsEntity userAddType = dao.selectOnKey(SystemConfig.USER_ADD_TYPE, AppConfig.SYSTEM_NAME); @@ -236,6 +245,7 @@ public Boundary changekey() { * 繝。繝シ繝ォ繧「繝峨Ξ繧ケ縺ョ螟画峩繝ェ繧ッ繧ィ繧ケ繝医r逋サ骭イ * @return */ + @Post public Boundary changerequest() { SystemConfigsDao dao = SystemConfigsDao.get(); SystemConfigsEntity userAddType = dao.selectOnKey(SystemConfig.USER_ADD_TYPE, AppConfig.SYSTEM_NAME); @@ -264,6 +274,7 @@ public Boundary changerequest() { * @return * @throws InvalidParamException */ + @Get public Boundary confirm_mail() throws InvalidParamException { // 繝。繝シ繝ォ繧「繝峨Ξ繧ケ螟画峩縺後〒縺阪k縺ョ縺ッ縲√ム繝悶Ν繧ェ繝励ヨ繧、繝ウ縺ァ繝ヲ繝シ繧カ逋サ骭イ縺吶k險ュ螳壹↓縺ェ縺」縺ヲ縺�k蝣エ蜷医�縺ソ SystemConfigsDao dao = SystemConfigsDao.get(); diff --git a/src/main/java/org/support/project/knowledge/control/protect/FileControl.java b/src/main/java/org/support/project/knowledge/control/protect/FileControl.java index 21d1cff38..498004673 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/FileControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/FileControl.java @@ -20,6 +20,8 @@ import org.support.project.web.boundary.JsonBoundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.common.HttpUtil; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; @DI(instance=Instance.Prototype) public class FileControl extends Control { @@ -34,6 +36,7 @@ public class FileControl extends Control { * @return * @throws Exception */ + @Post public Boundary upload() throws Exception { UploadResults results = new UploadResults(); List<UploadFile> files = new ArrayList<UploadFile>(); @@ -65,6 +68,7 @@ public Boundary upload() throws Exception { + @Get public JsonBoundary delete() { LOG.trace("delete()"); diff --git a/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java b/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java index 247292d50..80f7c6f7d 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/GroupControl.java @@ -17,6 +17,9 @@ import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; import org.support.project.web.config.CommonWebParameter; +import org.support.project.web.config.HttpMethod; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.dao.UserGroupsDao; import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.UserGroupsEntity; @@ -33,6 +36,7 @@ public class GroupControl extends Control { * @return * @throws InvalidParamException */ + @Get public Boundary mygroups() throws InvalidParamException { Integer offset = super.getPathInteger(0); @@ -57,6 +61,7 @@ public Boundary mygroups() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary list() throws InvalidParamException { Integer offset = super.getPathInteger(0); String keyword = super.getParam("keyword"); @@ -80,6 +85,7 @@ public Boundary list() throws InvalidParamException { * 繧ー繝ォ繝シ繝苓ソス蜉�縺ョ逕サ髱「繧定。ィ遉コ * @return */ + @Get public Boundary view_add() { return forward("add_group.jsp"); } @@ -88,6 +94,7 @@ public Boundary view_add() { * 繧ー繝ォ繝シ繝励r霑ス蜉� * @return */ + @Post public Boundary add() { // 蜈・蜉帙メ繧ァ繝�け GroupsEntity groupsEntity = new GroupsEntity(); @@ -117,6 +124,7 @@ public Boundary add() { * @return * @throws InvalidParamException */ + @Get public Boundary view() throws InvalidParamException { Integer groupId = super.getPathInteger(0); GroupLogic groupLogic = GroupLogic.get(); @@ -156,6 +164,7 @@ public Boundary view() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary view_edit() throws InvalidParamException { Integer groupId = super.getPathInteger(0); GroupLogic groupLogic = GroupLogic.get(); @@ -173,6 +182,7 @@ public Boundary view_edit() throws InvalidParamException { * 繧ー繝ォ繝シ繝励r譖エ譁ー * @return */ + @Post public Boundary update() { // 蜈・蜉帙メ繧ァ繝�け GroupsEntity groupsEntity = new GroupsEntity(); @@ -202,6 +212,7 @@ public Boundary update() { * @return * @throws InvalidParamException */ + @Get public Boundary delete() throws InvalidParamException { Integer groupId = -1; String id = getParam("groupId"); @@ -219,7 +230,7 @@ public Boundary delete() throws InvalidParamException { addMsgSuccess("message.success.delete"); // return redirect(""); - return super.devolution("protect.Group/list"); + return super.devolution(HttpMethod.get, "protect.Group/list"); } /** @@ -227,6 +238,7 @@ public Boundary delete() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary unsubscribe() throws InvalidParamException { Integer groupId = super.getPathInteger(0); GroupLogic groupLogic = GroupLogic.get(); @@ -259,6 +271,7 @@ public Boundary unsubscribe() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary subscribe() throws InvalidParamException { Integer groupId = super.getPathInteger(0); GroupLogic groupLogic = GroupLogic.get(); @@ -279,7 +292,7 @@ public Boundary subscribe() throws InvalidParamException { addMsgSuccess("message.success.insert"); - return super.devolution("protect.Group/view"); + return super.devolution(HttpMethod.get, "protect.Group/view"); } /** @@ -287,6 +300,7 @@ public Boundary subscribe() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary request() throws InvalidParamException { Integer groupId = super.getPathInteger(0); GroupLogic groupLogic = GroupLogic.get(); @@ -302,7 +316,7 @@ public Boundary request() throws InvalidParamException { userGroupsDao.save(userGroupsEntity); } addMsgSuccess("message.success.insert"); - return super.devolution("protect.Group/view"); + return super.devolution(HttpMethod.get, "protect.Group/view"); } /** @@ -310,6 +324,7 @@ public Boundary request() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary accept() throws InvalidParamException { Integer groupId = super.getPathInteger(0); String userIdstr = super.getParam("userId"); @@ -338,7 +353,7 @@ public Boundary accept() throws InvalidParamException { addMsgWarn("message.allready.updated"); } } - return super.devolution("protect.Group/view"); + return super.devolution(HttpMethod.get, "protect.Group/view"); } /** @@ -346,6 +361,7 @@ public Boundary accept() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Post public Boundary change() throws InvalidParamException { Integer groupId = super.getPathInteger(0); String userIdstr = super.getParam("userId"); @@ -377,7 +393,7 @@ public Boundary change() throws InvalidParamException { addMsgSuccess("message.success.delete"); } } - return super.devolution("protect.Group/view"); + return super.devolution(HttpMethod.get, "protect.Group/view"); } @@ -386,6 +402,7 @@ public Boundary change() throws InvalidParamException { * @return * @throws InvalidParamException */ + @Get public Boundary typeahead() throws InvalidParamException { String keyword = super.getParam("keyword"); int offset = 0; diff --git a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java index 575d3bb1a..1d834f579 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java @@ -12,9 +12,7 @@ import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.control.KnowledgeControlBase; -import org.support.project.knowledge.dao.CommentsDao; import org.support.project.knowledge.dao.KnowledgesDao; -import org.support.project.knowledge.entity.CommentsEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.TagsEntity; import org.support.project.knowledge.logic.KnowledgeLogic; @@ -24,6 +22,9 @@ import org.support.project.knowledge.vo.UploadFile; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpStatus; +import org.support.project.web.config.HttpMethod; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.exception.InvalidParamException; @DI(instance=Instance.Prototype) @@ -38,6 +39,7 @@ public class KnowledgeControl extends KnowledgeControlBase { * 逋サ骭イ逕サ髱「繧定。ィ遉コ縺吶k * @return */ + @Get public Boundary view_add() { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -55,6 +57,7 @@ public Boundary view_add() { * @return * @throws InvalidParamException */ + @Get public Boundary view_edit() throws InvalidParamException { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -94,6 +97,7 @@ public Boundary view_edit() throws InvalidParamException { * @return * @throws Exception */ + @Post public Boundary add(KnowledgesEntity entity) throws Exception { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -159,6 +163,7 @@ public Boundary add(KnowledgesEntity entity) throws Exception { * @return * @throws Exception */ + @Post public Boundary update(KnowledgesEntity entity) throws Exception { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -236,6 +241,7 @@ public Boundary update(KnowledgesEntity entity) throws Exception { * @return * @throws Exception */ + @Post public Boundary delete() throws Exception { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -263,7 +269,7 @@ public Boundary delete() throws Exception { knowledgeLogic.delete(knowledgeId, getLoginedUser()); addMsgSuccess("message.success.delete"); - return super.devolution("open.Knowledge/list"); + return super.devolution(HttpMethod.get, "open.Knowledge/list"); } /** @@ -271,6 +277,7 @@ public Boundary delete() throws Exception { * @return * @throws InvalidParamException */ + @Get public Boundary view() throws InvalidParamException { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� setViewParam(); @@ -284,6 +291,7 @@ public Boundary view() throws InvalidParamException { * @return * @throws Exception */ + @Post public Boundary comment() throws Exception { // 蜈ア騾壼�逅�他縺ョ陦ィ遉コ譚。莉カ縺ョ菫晄戟縺ョ蜻シ縺ウ蜃コ縺� String params = setViewParam(); @@ -301,6 +309,7 @@ public Boundary comment() throws Exception { * @return * @throws InvalidParamException */ + @Get public Boundary view_targets() throws InvalidParamException { Long knowledgeId = super.getPathLong(Long.valueOf(-1)); List<LabelValue> groups = TargetLogic.get().selectTargetsOnKnowledgeId(knowledgeId); diff --git a/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java b/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java index 6f26d2310..614613072 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java @@ -10,6 +10,8 @@ import org.support.project.knowledge.dao.NotifyConfigsDao; import org.support.project.knowledge.entity.NotifyConfigsEntity; import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; import org.support.project.web.exception.InvalidParamException; @DI(instance=Instance.Prototype) @@ -19,6 +21,7 @@ public class NotifyControl extends Control { * @see org.support.project.web.control.Control#index() */ @Override + @Get public Boundary index() { NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(getLoginUserId()); @@ -29,6 +32,7 @@ public Boundary index() { return super.index(); } + @Post public Boundary save() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { NotifyConfigsEntity entity = super.getParamOnProperty(NotifyConfigsEntity.class); NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); diff --git a/src/main/java/org/support/project/knowledge/control/protect/TargetControl.java b/src/main/java/org/support/project/knowledge/control/protect/TargetControl.java index 228ca6bd3..8fff174b6 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/TargetControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/TargetControl.java @@ -9,6 +9,7 @@ import org.support.project.knowledge.logic.TargetLogic; import org.support.project.knowledge.vo.LabelValue; import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; import org.support.project.web.exception.InvalidParamException; public class TargetControl extends Control { @@ -22,6 +23,7 @@ public class TargetControl extends Control { * @return * @throws InvalidParamException */ + @Get public Boundary typeahead() throws InvalidParamException { LOG.trace("call typeahead"); String keyword = super.getParam("keyword"); diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java new file mode 100644 index 000000000..9979646ec --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgeHistoriesDao.java @@ -0,0 +1,46 @@ +package org.support.project.knowledge.dao; + +import java.util.List; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.gen.GenKnowledgeHistoriesDao; +import org.support.project.knowledge.entity.KnowledgeHistoriesEntity; +import org.support.project.ormapping.common.SQLManager; + +/** + * 繝翫Ξ繝�ず譖エ譁ー螻・豁エ + */ +@DI(instance=Instance.Singleton) +public class KnowledgeHistoriesDao extends GenKnowledgeHistoriesDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * 繧、繝ウ繧ケ繧ソ繝ウ繧ケ蜿門セ� + * AOP縺ォ蟇セ蠢� + * @return 繧、繝ウ繧ケ繧ソ繝ウ繧ケ + */ + public static KnowledgeHistoriesDao get() { + return Container.getComp(KnowledgeHistoriesDao.class); + } + + /** + * 謖�ョ壹リ繝ャ繝�ず縺ョ譛螟ァ縺ョ螻・豁エ逡ェ蜿キ繧貞叙蠕� + * @param knowledgeId + * @return + */ + public int selectMaxHistoryNo(Long knowledgeId) { + String sql = "SELECT MAX(HISTORY_NO) FROM KNOWLEDGE_HISTORIES WHERE KNOWLEDGE_ID = ? "; + return executeQuerySingle(sql, Integer.class, knowledgeId); + } + + public List<KnowledgeHistoriesEntity> selectOnKnowledge(Long knowledgeId, int offset, int limit) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_selectOnKnowledge.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class, knowledgeId, limit, offset); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java new file mode 100644 index 000000000..f2dead690 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenKnowledgeHistoriesDao.java @@ -0,0 +1,325 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.KnowledgeHistoriesEntity; +import org.support.project.ormapping.dao.AbstractDao; +import org.support.project.ormapping.exception.ORMappingException; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.ormapping.common.DBUserPool; +import org.support.project.ormapping.common.IDGen; +import org.support.project.ormapping.config.ORMappingParameter; +import org.support.project.ormapping.connection.ConnectionManager; +import org.support.project.common.util.PropertyUtil; + +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.aop.Aspect; + +/** + * 繝翫Ξ繝�ず譖エ譁ー螻・豁エ + */ +@DI(instance=Instance.Singleton) +public class GenKnowledgeHistoriesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * 繧、繝ウ繧ケ繧ソ繝ウ繧ケ蜿門セ� + * AOP縺ォ蟇セ蠢� + * @return 繧、繝ウ繧ケ繧ソ繝ウ繧ケ + */ + public static GenKnowledgeHistoriesDao get() { + return Container.getComp(GenKnowledgeHistoriesDao.class); + } + + /** + * 蜈ィ縺ヲ蜿門セ�(蜑企勁繝輔Λ繧ー繧堤┌隕悶@縺ヲ蜿門セ�) + */ + public List<KnowledgeHistoriesEntity> physicalSelectAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class); + } + /** + * 繧ュ繝シ縺ァ1莉カ蜿門セ�(蜑企勁繝輔Λ繧ー繧堤┌隕悶@縺ヲ蜿門セ�) + */ + public KnowledgeHistoriesEntity physicalSelectOnKey(Integer historyNo, Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, KnowledgeHistoriesEntity.class, historyNo, knowledgeId); + } + /** + * 蜈ィ縺ヲ蜿門セ� + */ + public List<KnowledgeHistoriesEntity> selectAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class); + } + /** + * 繧ュ繝シ縺ァ1莉カ蜿門セ� + */ + public KnowledgeHistoriesEntity selectOnKey(Integer historyNo, Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_key.sql"); + return executeQuerySingle(sql, KnowledgeHistoriesEntity.class, historyNo, knowledgeId); + } + /** + * HISTORY_NO 縺ァ繝ェ繧ケ繝医r蜿門セ� + */ + public List<KnowledgeHistoriesEntity> selectOnHistoryNo(Integer historyNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_history_no.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class, historyNo); + } + /** + * KNOWLEDGE_ID 縺ァ繝ェ繧ケ繝医r蜿門セ� + */ + public List<KnowledgeHistoriesEntity> selectOnKnowledgeId(Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_knowledge_id.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class, knowledgeId); + } + /** + * HISTORY_NO 縺ァ繝ェ繧ケ繝医r蜿門セ� + */ + public List<KnowledgeHistoriesEntity> physicalSelectOnHistoryNo(Integer historyNo) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_history_no.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class, historyNo); + } + /** + * KNOWLEDGE_ID 縺ァ繝ェ繧ケ繝医r蜿門セ� + */ + public List<KnowledgeHistoriesEntity> physicalSelectOnKnowledgeId(Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_knowledge_id.sql"); + return executeQueryList(sql, KnowledgeHistoriesEntity.class, knowledgeId); + } + /** + * 逋サ骭イ(繝��繧ソ繧堤函縺ァ謫堺ス�/DB縺ョ謗。逡ェ讖溯�縺ョ繧ォ繝ゥ繝�繧り�蛻�〒繧サ繝�ヨ) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity rawPhysicalInsert(KnowledgeHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo() + , entity.getKnowledgeId() + , entity.getTitle() + , entity.getContent() + , entity.getPublicFlag() + , entity.getTagIds() + , entity.getTagNames() + , entity.getLikeCount() + , entity.getCommentCount() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; + } + /** + * 逋サ骭イ(繝��繧ソ繧堤函縺ァ謫堺ス�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity physicalInsert(KnowledgeHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_insert.sql"); + executeUpdate(sql, + entity.getHistoryNo() + , entity.getKnowledgeId() + , entity.getTitle() + , entity.getContent() + , entity.getPublicFlag() + , entity.getTagIds() + , entity.getTagNames() + , entity.getLikeCount() + , entity.getCommentCount() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + ); + return entity; + } + /** + * 逋サ骭イ(逋サ骭イ繝ヲ繝シ繧カ繧呈欠螳�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity insert(Integer user, KnowledgeHistoriesEntity entity) { + entity.setInsertUser(user); + entity.setInsertDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + entity.setDeleteFlag(0); + return physicalInsert(entity); + } + /** + * 逋サ骭イ + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity insert(KnowledgeHistoriesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * 譖エ譁ー(繝��繧ソ繧堤函縺ァ謫堺ス�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity physicalUpdate(KnowledgeHistoriesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_update.sql"); + executeUpdate(sql, + entity.getTitle() + , entity.getContent() + , entity.getPublicFlag() + , entity.getTagIds() + , entity.getTagNames() + , entity.getLikeCount() + , entity.getCommentCount() + , entity.getInsertUser() + , entity.getInsertDatetime() + , entity.getUpdateUser() + , entity.getUpdateDatetime() + , entity.getDeleteFlag() + , entity.getHistoryNo() + , entity.getKnowledgeId() + ); + return entity; + } + /** + * 譖エ譁ー(譖エ譁ー繝ヲ繝シ繧カ繧呈欠螳�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity update(Integer user, KnowledgeHistoriesEntity entity) { + KnowledgeHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getKnowledgeId()); + entity.setInsertUser(db.getInsertUser()); + entity.setInsertDatetime(db.getInsertDatetime()); + entity.setDeleteFlag(db.getDeleteFlag()); + entity.setUpdateUser(user); + entity.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + return physicalUpdate(entity); + } + /** + * 譖エ譁ー + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity update(KnowledgeHistoriesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * 菫晏ュ�(繝ヲ繝シ繧カ繧呈欠螳�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity save(Integer user, KnowledgeHistoriesEntity entity) { + KnowledgeHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getKnowledgeId()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * 菫晏ュ�(蟄伜惠縺励↑縺代l縺ー逋サ骭イ縲∝ュ伜惠縺吶l縺ー譖エ譁ー) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public KnowledgeHistoriesEntity save(KnowledgeHistoriesEntity entity) { + KnowledgeHistoriesEntity db = selectOnKey(entity.getHistoryNo(), entity.getKnowledgeId()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * 蜑企勁(繝��繧ソ繧堤函縺ァ謫堺ス�/迚ゥ逅�炎髯、) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Integer historyNo, Long knowledgeId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_delete.sql"); + executeUpdate(sql, historyNo, knowledgeId); + } + /** + * 蜑企勁(繝��繧ソ繧堤函縺ァ謫堺ス�/迚ゥ逅�炎髯、) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(KnowledgeHistoriesEntity entity) { + physicalDelete(entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * 蜑企勁(蜑企勁繝ヲ繝シ繧カ繧呈欠螳夲シ剰ォ也炊蜑企勁縺後≠繧後�隲也炊蜑企勁) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Integer historyNo, Long knowledgeId) { + KnowledgeHistoriesEntity db = selectOnKey(historyNo, knowledgeId); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + physicalUpdate(db); + } + /** + * 蜑企勁(隲也炊蜑企勁縺後≠繧後�隲也炊蜑企勁) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer historyNo, Long knowledgeId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, historyNo, knowledgeId); + } + /** + * 蜑企勁(蜑企勁繝ヲ繝シ繧カ繧呈欠螳夲シ剰ォ也炊蜑企勁縺後≠繧後�隲也炊蜑企勁) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, KnowledgeHistoriesEntity entity) { + delete(user, entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * 蜑企勁(隲也炊蜑企勁縺後≠繧後�隲也炊蜑企勁) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void delete(KnowledgeHistoriesEntity entity) { + delete(entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + 蠕ゥ蜈�(隲也炊蜑企勁縺輔l縺ヲ縺�◆繧ゅ�繧呈怏蜉ケ蛹�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Integer historyNo, Long knowledgeId) { + KnowledgeHistoriesEntity db = physicalSelectOnKey(historyNo, knowledgeId); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + physicalUpdate(db); + } + /** + * 蠕ゥ蜈�(隲也炊蜑企勁縺輔l縺ヲ縺�◆繧ゅ�繧呈怏蜉ケ蛹�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer historyNo, Long knowledgeId) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, historyNo, knowledgeId); + } + /** + * 蠕ゥ蜈�(隲也炊蜑企勁縺輔l縺ヲ縺�◆繧ゅ�繧呈怏蜉ケ蛹�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, KnowledgeHistoriesEntity entity) { + activation(user, entity.getHistoryNo(), entity.getKnowledgeId()); + + } + /** + * 蠕ゥ蜈�(隲也炊蜑企勁縺輔l縺ヲ縺�◆繧ゅ�繧呈怏蜉ケ蛹�) + */ + @Aspect(advice=org.support.project.ormapping.transaction.Transaction.class) + public void activation(KnowledgeHistoriesEntity entity) { + activation(entity.getHistoryNo(), entity.getKnowledgeId()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/deploy/InitDB.java b/src/main/java/org/support/project/knowledge/deploy/InitDB.java index e06e2b977..0dd391a6a 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitDB.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitDB.java @@ -10,6 +10,7 @@ import org.support.project.knowledge.deploy.v0_0_1.InitializeSystem; import org.support.project.knowledge.deploy.v0_4_4.Migrate_0_4_4; import org.support.project.knowledge.deploy.v0_5_0.Migrate_0_5_0; +import org.support.project.knowledge.deploy.v0_5_1.Migrate_0_5_1; import org.support.project.web.dao.SystemsDao; import org.support.project.web.entity.SystemsEntity; @@ -22,13 +23,14 @@ public class InitDB { private static final Map<String, Migrate> MAP = new LinkedHashMap<>(); private static final Migrate INIT = InitializeSystem.get(); - private static final String CURRENT = "0.5.0"; + public static final String CURRENT = "0.5.1"; public InitDB() { super(); MAP.put("0.3.1", INIT); // 蛻晄悄蜈ャ髢九ヰ繝シ繧ク繝ァ繝ウ MAP.put("0.4.4", Migrate_0_4_4.get()); // 繝翫Ξ繝�ず荳隕ァ縺ョ莉伜刈諠��ア繧偵リ繝ャ繝�ず繝��繝悶Ν縺ォ謖√▽ - MAP.put(CURRENT, Migrate_0_5_0.get()); // 騾夂衍險ュ螳� + MAP.put("0.5.0", Migrate_0_5_0.get()); // 騾夂衍險ュ螳� + MAP.put(CURRENT, Migrate_0_5_1.get()); // 繝翫Ξ繝�ず縺ョ譖エ譁ー螻・豁エ } public static void main(String[] args) throws Exception { diff --git a/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java b/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java index edffb311f..6d3f0ab92 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitializationListener.java @@ -5,7 +5,6 @@ import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; -import org.support.project.common.config.ConfigLoader; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.knowledge.config.AppConfig; @@ -43,8 +42,9 @@ public void contextInitialized(ServletContextEvent contextEvent) { LOG.info("idx directory created." + idxDir); } String path = contextEvent.getServletContext().getRealPath("/"); - LOG.info("Knowledge start on '" + path + "'"); - LOG.info(path); + LOG.info("Knowledge start"); + LOG.info("knowledge install path: '" + path + "'"); + LOG.info("knowledge home path: '" + appConfig.getBasePath() + "'"); appConfig.setWebRealPath(path); } diff --git a/src/main/java/org/support/project/knowledge/deploy/v0_5_1/Migrate_0_5_1.java b/src/main/java/org/support/project/knowledge/deploy/v0_5_1/Migrate_0_5_1.java new file mode 100644 index 000000000..82dfe1494 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v0_5_1/Migrate_0_5_1.java @@ -0,0 +1,36 @@ +package org.support.project.knowledge.deploy.v0_5_1; + +import java.util.List; + +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_0_5_1 implements Migrate { + + public static Migrate_0_5_1 get() { + return org.support.project.di.Container.getComp(Migrate_0_5_1.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v0_5_1/migrate.sql" + }; + initializeDao.initializeDatabase(sqlpaths); + + // 縺吶〒縺ォ逋サ骭イ貂医�繝翫Ξ繝�ず縺ォ譖エ譁ー螻・豁エ繧堤匳骭イ + List<KnowledgesEntity> entities = KnowledgesDao.get().selectAll(); + KnowledgeLogic logic = KnowledgeLogic.get(); + for (KnowledgesEntity knowledgesEntity : entities) { + logic.insertHistory(knowledgesEntity); + } + + return true; + } + + +} diff --git a/src/main/java/org/support/project/knowledge/entity/KnowledgeHistoriesEntity.java b/src/main/java/org/support/project/knowledge/entity/KnowledgeHistoriesEntity.java new file mode 100644 index 000000000..d2f1f2d9f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/KnowledgeHistoriesEntity.java @@ -0,0 +1,61 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenKnowledgeHistoriesEntity; + +import java.util.List; +import java.util.Map; + +import org.support.project.common.bean.ValidateError; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +import java.sql.Timestamp; + + +/** + * 繝翫Ξ繝�ず譖エ譁ー螻・豁エ + */ +@DI(instance=Instance.Prototype) +public class KnowledgeHistoriesEntity extends GenKnowledgeHistoriesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + private String userName; + + /** + * 繧、繝ウ繧ケ繧ソ繝ウ繧ケ蜿門セ� + * AOP縺ォ蟇セ蠢� + * @return 繧、繝ウ繧ケ繧ソ繝ウ繧ケ + */ + public static KnowledgeHistoriesEntity get() { + return Container.getComp(KnowledgeHistoriesEntity.class); + } + + /** + * 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ + */ + public KnowledgeHistoriesEntity() { + super(); + } + + /** + * 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ + * @param historyNo 螻・豁エ逡ェ蜿キ + * @param knowledgeId 繝翫Ξ繝�ずID + */ + + public KnowledgeHistoriesEntity(Integer historyNo, Long knowledgeId) { + super( historyNo, knowledgeId); + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java b/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java index 9406b7cd4..b9cadec29 100644 --- a/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/KnowledgesEntity.java @@ -29,16 +29,6 @@ public static KnowledgesEntity get() { * 逋サ骭イ閠��蜷咲ァー */ private String insertUserName; - /** - * 繧ソ繧ー - */ - private String tags; - - /** 縺�>縺ュ縺ョ繧ォ繧ヲ繝ウ繝� */ - private Long likeCount; - /** 繧ウ繝。繝ウ繝医�繧ォ繧ヲ繝ウ繝� */ - private int commentsCount; - /** * 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgeHistoriesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgeHistoriesEntity.java new file mode 100644 index 000000000..b1c501e0d --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenKnowledgeHistoriesEntity.java @@ -0,0 +1,492 @@ +package org.support.project.knowledge.entity.gen; + +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import java.sql.Timestamp; + + + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; + +/** + * 繝翫Ξ繝�ず譖エ譁ー螻・豁エ + */ +@DI(instance=Instance.Prototype) +public class GenKnowledgeHistoriesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * 繧、繝ウ繧ケ繧ソ繝ウ繧ケ蜿門セ� + * AOP縺ォ蟇セ蠢� + * @return 繧、繝ウ繧ケ繧ソ繝ウ繧ケ + */ + public static GenKnowledgeHistoriesEntity get() { + return Container.getComp(GenKnowledgeHistoriesEntity.class); + } + + /** + * 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ + */ + public GenKnowledgeHistoriesEntity() { + super(); + } + + /** + * 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ + * @param historyNo 螻・豁エ逡ェ蜿キ + * @param knowledgeId 繝翫Ξ繝�ずID + */ + + public GenKnowledgeHistoriesEntity(Integer historyNo, Long knowledgeId) { + super(); + this.historyNo = historyNo; + this.knowledgeId = knowledgeId; + } + /** 繝翫Ξ繝�ずID */ + private Long knowledgeId; + /** 螻・豁エ逡ェ蜿キ */ + private Integer historyNo; + /** 繧ソ繧、繝医Ν */ + private String title; + /** 蜀�ョケ */ + private String content; + /** 蜈ャ髢句玄蛻� */ + private Integer publicFlag; + /** 繧ソ繧ーID荳隕ァ */ + private String tagIds; + /** 繧ソ繧ー蜷咲ァー荳隕ァ */ + private String tagNames; + /** 縺�>縺ュ莉カ謨ー */ + private Long likeCount; + /** 繧ウ繝。繝ウ繝井サカ謨ー */ + private Integer commentCount; + /** 逋サ骭イ繝ヲ繝シ繧カ */ + private Integer insertUser; + /** 逋サ骭イ譌・譎� */ + private Timestamp insertDatetime; + /** 譖エ譁ー繝ヲ繝シ繧カ */ + private Integer updateUser; + /** 譖エ譁ー譌・譎� */ + private Timestamp updateDatetime; + /** 蜑企勁繝輔Λ繧ー */ + private Integer deleteFlag; + + /** + * 繝翫Ξ繝�ずID 繧貞叙蠕励☆繧� + */ + public Long getKnowledgeId() { + return this.knowledgeId; + } + /** + * 繝翫Ξ繝�ずID 繧定ィュ螳壹☆繧� + * @param knowledgeId 繝翫Ξ繝�ずID + */ + public GenKnowledgeHistoriesEntity setKnowledgeId(Long knowledgeId) { + this.knowledgeId = knowledgeId; + return this; + } + + /** + * 螻・豁エ逡ェ蜿キ 繧貞叙蠕励☆繧� + */ + public Integer getHistoryNo() { + return this.historyNo; + } + /** + * 螻・豁エ逡ェ蜿キ 繧定ィュ螳壹☆繧� + * @param historyNo 螻・豁エ逡ェ蜿キ + */ + public GenKnowledgeHistoriesEntity setHistoryNo(Integer historyNo) { + this.historyNo = historyNo; + return this; + } + + /** + * 繧ソ繧、繝医Ν 繧貞叙蠕励☆繧� + */ + public String getTitle() { + return this.title; + } + /** + * 繧ソ繧、繝医Ν 繧定ィュ螳壹☆繧� + * @param title 繧ソ繧、繝医Ν + */ + public GenKnowledgeHistoriesEntity setTitle(String title) { + this.title = title; + return this; + } + + /** + * 蜀�ョケ 繧貞叙蠕励☆繧� + */ + public String getContent() { + return this.content; + } + /** + * 蜀�ョケ 繧定ィュ螳壹☆繧� + * @param content 蜀�ョケ + */ + public GenKnowledgeHistoriesEntity setContent(String content) { + this.content = content; + return this; + } + + /** + * 蜈ャ髢句玄蛻� 繧貞叙蠕励☆繧� + */ + public Integer getPublicFlag() { + return this.publicFlag; + } + /** + * 蜈ャ髢句玄蛻� 繧定ィュ螳壹☆繧� + * @param publicFlag 蜈ャ髢句玄蛻� + */ + public GenKnowledgeHistoriesEntity setPublicFlag(Integer publicFlag) { + this.publicFlag = publicFlag; + return this; + } + + /** + * 繧ソ繧ーID荳隕ァ 繧貞叙蠕励☆繧� + */ + public String getTagIds() { + return this.tagIds; + } + /** + * 繧ソ繧ーID荳隕ァ 繧定ィュ螳壹☆繧� + * @param tagIds 繧ソ繧ーID荳隕ァ + */ + public GenKnowledgeHistoriesEntity setTagIds(String tagIds) { + this.tagIds = tagIds; + return this; + } + + /** + * 繧ソ繧ー蜷咲ァー荳隕ァ 繧貞叙蠕励☆繧� + */ + public String getTagNames() { + return this.tagNames; + } + /** + * 繧ソ繧ー蜷咲ァー荳隕ァ 繧定ィュ螳壹☆繧� + * @param tagNames 繧ソ繧ー蜷咲ァー荳隕ァ + */ + public GenKnowledgeHistoriesEntity setTagNames(String tagNames) { + this.tagNames = tagNames; + return this; + } + + /** + * 縺�>縺ュ莉カ謨ー 繧貞叙蠕励☆繧� + */ + public Long getLikeCount() { + return this.likeCount; + } + /** + * 縺�>縺ュ莉カ謨ー 繧定ィュ螳壹☆繧� + * @param likeCount 縺�>縺ュ莉カ謨ー + */ + public GenKnowledgeHistoriesEntity setLikeCount(Long likeCount) { + this.likeCount = likeCount; + return this; + } + + /** + * 繧ウ繝。繝ウ繝井サカ謨ー 繧貞叙蠕励☆繧� + */ + public Integer getCommentCount() { + return this.commentCount; + } + /** + * 繧ウ繝。繝ウ繝井サカ謨ー 繧定ィュ螳壹☆繧� + * @param commentCount 繧ウ繝。繝ウ繝井サカ謨ー + */ + public GenKnowledgeHistoriesEntity setCommentCount(Integer commentCount) { + this.commentCount = commentCount; + return this; + } + + /** + * 逋サ骭イ繝ヲ繝シ繧カ 繧貞叙蠕励☆繧� + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * 逋サ骭イ繝ヲ繝シ繧カ 繧定ィュ螳壹☆繧� + * @param insertUser 逋サ骭イ繝ヲ繝シ繧カ + */ + public GenKnowledgeHistoriesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * 逋サ骭イ譌・譎� 繧貞叙蠕励☆繧� + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * 逋サ骭イ譌・譎� 繧定ィュ螳壹☆繧� + * @param insertDatetime 逋サ骭イ譌・譎� + */ + public GenKnowledgeHistoriesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * 譖エ譁ー繝ヲ繝シ繧カ 繧貞叙蠕励☆繧� + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * 譖エ譁ー繝ヲ繝シ繧カ 繧定ィュ螳壹☆繧� + * @param updateUser 譖エ譁ー繝ヲ繝シ繧カ + */ + public GenKnowledgeHistoriesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * 譖エ譁ー譌・譎� 繧貞叙蠕励☆繧� + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * 譖エ譁ー譌・譎� 繧定ィュ螳壹☆繧� + * @param updateDatetime 譖エ譁ー譌・譎� + */ + public GenKnowledgeHistoriesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * 蜑企勁繝輔Λ繧ー 繧貞叙蠕励☆繧� + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * 蜑企勁繝輔Λ繧ー 繧定ィュ螳壹☆繧� + * @param deleteFlag 蜑企勁繝輔Λ繧ー + */ + public GenKnowledgeHistoriesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * 繧ュ繝シ縺ョ蛟、繧貞叙蠕� + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[2]; + keyValues[0] = this.historyNo; + keyValues[1] = this.knowledgeId; + return keyValues; + } + /** + * 繧ュ繝シ縺ョ蛟、繧定ィュ螳� + * @param historyNo 螻・豁エ逡ェ蜿キ + * @param knowledgeId 繝翫Ξ繝�ずID + */ + public void setKeyValues(Integer historyNo, Long knowledgeId) { + this.historyNo = historyNo; + this.knowledgeId = knowledgeId; + } + /** + * 繧ュ繝シ縺ァ豈碑シ� + */ + public boolean equalsOnKey(GenKnowledgeHistoriesEntity entity) { + Object[] keyValues1 = getKeyValues(); + Object[] keyValues2 = entity.getKeyValues(); + for (int i = 0; i < keyValues1.length; i++) { + Object val1 = keyValues1[i]; + Object val2 = keyValues2[i]; + if (val1 == null && val2 != null) { + return false; + } + if (val1 != null && val2 == null) { + return false; + } + if (val1 != null && val2 != null) { + if (!val1.equals(val2)) { + return false; + } + } + + } + return true; + } + /** + * ToString + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("historyNo = ").append(historyNo).append("\n"); + builder.append("knowledgeId = ").append(knowledgeId).append("\n"); + builder.append("title = ").append(title).append("\n"); + builder.append("content = ").append(content).append("\n"); + builder.append("publicFlag = ").append(publicFlag).append("\n"); + builder.append("tagIds = ").append(tagIds).append("\n"); + builder.append("tagNames = ").append(tagNames).append("\n"); + builder.append("likeCount = ").append(likeCount).append("\n"); + builder.append("commentCount = ").append(commentCount).append("\n"); + builder.append("insertUser = ").append(insertUser).append("\n"); + builder.append("insertDatetime = ").append(insertDatetime).append("\n"); + builder.append("updateUser = ").append(updateUser).append("\n"); + builder.append("updateDatetime = ").append(updateDatetime).append("\n"); + builder.append("deleteFlag = ").append(deleteFlag).append("\n"); + return builder.toString(); + } + /** + * 陦ィ遉コ逕ィ縺ョ蜷咲ァー繧貞、画鋤 + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + */ + public List<ValidateError> validate() { + List<ValidateError> errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.knowledgeId, convLabelName("Knowledge Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.historyNo, convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.historyNo, convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.title, convLabelName("Title")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.title, convLabelName("Title"), 1024); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.publicFlag, convLabelName("Public Flag")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.tagIds, convLabelName("Tag Ids"), 1024); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.commentCount, convLabelName("Comment Count")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.insertUser, convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.updateUser, convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.deleteFlag, convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + /** + * validate + */ + public List<ValidateError> validate(Map<String, String> values) { + List<ValidateError> errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("knowledgeId"), convLabelName("Knowledge Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("historyNo"), convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("historyNo"), convLabelName("History No")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("title"), convLabelName("Title")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("title"), convLabelName("Title"), 1024); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("publicFlag"), convLabelName("Public Flag")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("tagIds"), convLabelName("Tag Ids"), 1024); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("commentCount"), convLabelName("Comment Count")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("insertUser"), convLabelName("Insert User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("updateUser"), convLabelName("Update User")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("deleteFlag"), convLabelName("Delete Flag")); + if (error != null) { + errors.add(error); + } + return errors; + } + +} diff --git a/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java b/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java new file mode 100644 index 000000000..1a8af4f28 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.listener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.support.project.knowledge.config.AppConfig; + +public class GlobalInitializationListener implements ServletContextListener { + + @Override + public void contextInitialized(ServletContextEvent config) { + AppConfig.initEnvKey("KNOWLEDGE_HOME"); + } + + @Override + public void contextDestroyed(ServletContextEvent config) { + + } + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/CompressLogic.java b/src/main/java/org/support/project/knowledge/logic/CompressLogic.java new file mode 100644 index 000000000..4afc18619 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/CompressLogic.java @@ -0,0 +1,110 @@ +package org.support.project.knowledge.logic; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; +import org.apache.commons.compress.utils.IOUtils; +import org.apache.commons.fileupload.FileItem; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.StringUtils; +import org.support.project.di.Container; + +public class CompressLogic { + /** 繝ュ繧ー */ + private static Log LOG = LogFactory.getLog(CompressLogic.class); + + public static CompressLogic get() { + return Container.getComp(CompressLogic.class); + } + + /** + * 繝繧ヲ繝ウ繝ュ繝シ繝峨☆繧九ヵ繧。繧、繝ォ繧定ソス蜉�縺励※縺�¥ + * @param os + * @param file + * @throws IOException + * @throws FileNotFoundException + */ + public void addZip(ZipArchiveOutputStream os, File file, String basePath) throws IOException, FileNotFoundException { + StringBuilder builder = new StringBuilder(); + if (StringUtils.isNotEmpty(basePath)) { + builder.append(basePath); + } + builder.append(file.getName()); + if (file.isDirectory()) { + builder.append("/"); + ZipArchiveEntry zae = new ZipArchiveEntry(builder.toString()); + os.putArchiveEntry(zae); + LOG.debug("add zip: " + builder.toString()); + + os.closeArchiveEntry(); + File[] files = file.listFiles(); + for (File f : files) { + addZip(os, f, builder.toString()); + } + } else if (file.isFile()) { + ZipArchiveEntry zae = new ZipArchiveEntry(builder.toString()); + os.putArchiveEntry(zae); + + LOG.debug("add zip: " + builder.toString()); + InputStream is = new FileInputStream(file); + byte[] buffer = new byte[1024]; + while (true) { + int len = is.read(buffer); + if (len < 0) { + break; + } + os.write(buffer, 0, len); + } + is.close(); + os.closeArchiveEntry(); + } + } + + /** + * Zip繧定ァ」蜃� + * @param fileItem + * @param tmp + * @throws IOException + * @throws FileNotFoundException + */ + public void unZip(FileItem fileItem, File tmp) throws IOException, FileNotFoundException { + ZipArchiveInputStream archive = null; + try { + archive = new ZipArchiveInputStream(fileItem.getInputStream(), "UTF-8", true); + ZipArchiveEntry entry; + while ((entry = archive.getNextZipEntry()) != null) { + File file = new File(tmp, entry.getName()); + if (entry.isDirectory()) { + file.mkdirs(); + } else { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + OutputStream out = null; + try { + out = new FileOutputStream(file); + IOUtils.copy(archive, out); + } finally { + if (out != null) { + out.close(); + } + } + } + } + } finally { + if (archive != null) { + archive.close(); + } + fileItem.delete(); + } + } +} diff --git a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java index 99dba8960..4565b02a3 100644 --- a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java @@ -6,25 +6,34 @@ import java.io.OutputStream; import java.lang.reflect.Method; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import org.support.project.common.classanalysis.ClassSearch; import org.support.project.common.config.ConfigLoader; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.DateUtils; import org.support.project.di.Container; +import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.deploy.InitDB; import org.support.project.ormapping.config.ConnectionConfig; import org.support.project.ormapping.connection.ConnectionManager; import org.support.project.ormapping.dao.AbstractDao; import org.support.project.ormapping.tool.dao.InitializeDao; import org.support.project.ormapping.transaction.TransactionManager; -import org.support.project.web.config.AppConfig; +import org.support.project.web.dao.SystemsDao; +import org.support.project.web.entity.SystemsEntity; public class DataTransferLogic { private static final String TRANSFER_REQEST = "TRANSFER_REQEST"; + private static final String TRANSFER_REQEST_BACK = "TRANSFER_REQEST_BACK"; private static final String TRANSFER_STARTED = "TRANSFER_STARTED"; /** 繝ュ繧ー */ @@ -35,16 +44,31 @@ public static DataTransferLogic get() { } public void transferData(ConnectionConfig from, ConnectionConfig to) throws Exception { + // From縺ョDB縺ョDB縺ョ繝舌�繧ク繝ァ繝ウ繝√ぉ繝�け + ConnectionManager.getInstance().addConnectionConfig(from); + SystemsDao systemsDao = SystemsDao.get(); + SystemsEntity systemEntity = systemsDao.selectOnKey(AppConfig.SYSTEM_NAME); + if (systemEntity == null) { + // System繝舌�繧ク繝ァ繝ウ諠��ア縺檎┌縺�悴蛻晄悄蛹悶�DB縺九i繧ウ繝斐�縺励※繧ゅ@繧�≧縺後↑縺� + System.out.println("Data transfer is failed."); + return; + } + String version = systemEntity.getVersion(); + if (!InitDB.CURRENT.equals(version)) { + // 繧ウ繝斐�蜈��DB縺ョ繝舌�繧ク繝ァ繝ウ縺悟商縺�シ医↑繧薙°縺翫°縺励>�� + System.out.println("Data transfer is failed."); + return; + } + + // 繧ウ繝斐�蜈医�DB縺ョ蛻晄悄蛹� InitDB initDB = new InitDB(); ConnectionManager.getInstance().addConnectionConfig(to); InitializeDao initializeDao = InitializeDao.get(); initializeDao.setConnectionName(to.getName()); initializeDao.dropAllTable(); initDB.start(); - + ConnectionManager.getInstance().addConnectionConfig(from); - // 繧ウ繝斐�蜈�b蠢オ縺ョ縺溘a縲√ヰ繝シ繧ク繝ァ繝ウ繧貞粋繧上○繧九◆繧√↓蛻晄悄蛹悶r陦後≧�� -// initDB.start(); List<Class> targets = new ArrayList<Class>(); ClassSearch classSearch = Container.getComp(ClassSearch.class); @@ -137,6 +161,28 @@ public void requestTransfer() throws IOException { } } + /** + * 繝��繧ソ繧ウ繝斐�縺ョ繝ェ繧ッ繧ィ繧ケ繝医r逋サ骭イ + * (繧ォ繧ケ繧ソ繝�DB縺九i邨�∩霎シ縺ソDB縺ク) + * @throws IOException + */ + public void requestTransferBack() throws IOException { + if (!isTransferRequested()) { + AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + File base = new File(appConfig.getBasePath()); + File config = new File(base, TRANSFER_REQEST_BACK); + OutputStream out = null; + try { + out = new FileOutputStream(config); + out.write(new String("TRANSFER_REQEST_BACK").getBytes(Charset.forName("UTF-8"))); + } finally { + if (out != null) { + out.close(); + } + } + } + } + /** * 繧ウ繝斐�縺ョ繝ェ繧ッ繧ィ繧ケ繝医′縺ゅk縺九メ繧ァ繝�け * @return @@ -147,6 +193,17 @@ public boolean isTransferRequested() { File config = new File(base, TRANSFER_REQEST); return config.exists(); } + /** + * 繧ウ繝斐�縺ョ繝ェ繧ッ繧ィ繧ケ繝医′縺ゅk縺九メ繧ァ繝�け + * (繧ォ繧ケ繧ソ繝�DB縺九i邨�∩霎シ縺ソDB縺ク) + * @return + */ + public boolean isTransferBackRequested() { + AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); + File base = new File(appConfig.getBasePath()); + File config = new File(base, TRANSFER_REQEST_BACK); + return config.exists(); + } /** * 譌「縺ォ髢句ァ区ク医°縺ゥ縺�°繝√ぉ繝�け縺励�幕蟋区ク医〒縺ェ縺代l縺ー髢句ァ区ク医�繝輔Λ繧ー繧丹N @@ -185,6 +242,21 @@ public void finishTransfer() { if (config.exists()) { config.delete(); } + config = new File(base, TRANSFER_REQEST_BACK); + if (config.exists()) { + config.delete(); + } + } + + /** + * 繧オ繝シ繝舌�襍キ蜍墓凾縺ォ襍キ蜍輔@縺ヲ縺�kH2Database繧偵ヰ繝�け繧「繝��縺吶k�医Μ繝阪�繝�) + * @throws IOException + */ + public void backupAndInitH2() throws IOException { + AppConfig appConfig = AppConfig.get(); + Path source = Paths.get(appConfig.getDatabasePath()); + Path target = Paths.get(appConfig.getBasePath() + "/db_" + DateUtils.TRANSFER_DATETIME.format(new Date())); + Files.move(source, target, StandardCopyOption.REPLACE_EXISTING); } } diff --git a/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java b/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java index 335028062..5de20569a 100644 --- a/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java @@ -2,13 +2,8 @@ import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -17,10 +12,7 @@ import java.util.Date; import java.util.List; -import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; -import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; -import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.fileupload.FileItem; import org.support.project.common.bean.ValidateError; import org.support.project.common.config.ConfigLoader; @@ -28,7 +20,6 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.util.DateUtils; import org.support.project.common.util.FileUtil; -import org.support.project.common.util.StringUtils; import org.support.project.common.wrapper.FileInputStreamWithDeleteWrapper; import org.support.project.di.Container; import org.support.project.knowledge.config.AppConfig; @@ -61,8 +52,8 @@ public FileInputStreamWithDeleteWrapper getData() throws IOException { os.setEncoding("UTF-8"); File dbDir = new File(config.getDatabasePath()); File indexDir = new File(config.getIndexPath()); - addZip(os, dbDir, null); - addZip(os, indexDir, null); + CompressLogic.get().addZip(os, dbDir, null); + CompressLogic.get().addZip(os, indexDir, null); } finally { if (os != null) { os.close(); @@ -77,48 +68,7 @@ public FileInputStreamWithDeleteWrapper getData() throws IOException { } - /** - * 繝繧ヲ繝ウ繝ュ繝シ繝峨☆繧九ヵ繧。繧、繝ォ繧定ソス蜉�縺励※縺�¥ - * @param os - * @param file - * @throws IOException - * @throws FileNotFoundException - */ - private void addZip(ZipArchiveOutputStream os, File file, String basePath) throws IOException, FileNotFoundException { - StringBuilder builder = new StringBuilder(); - if (StringUtils.isNotEmpty(basePath)) { - builder.append(basePath); - } - builder.append(file.getName()); - if (file.isDirectory()) { - builder.append("/"); - ZipArchiveEntry zae = new ZipArchiveEntry(builder.toString()); - os.putArchiveEntry(zae); - LOG.debug("add zip: " + builder.toString()); - - os.closeArchiveEntry(); - File[] files = file.listFiles(); - for (File f : files) { - addZip(os, f, builder.toString()); - } - } else if (file.isFile()) { - ZipArchiveEntry zae = new ZipArchiveEntry(builder.toString()); - os.putArchiveEntry(zae); - - LOG.debug("add zip: " + builder.toString()); - InputStream is = new FileInputStream(file); - byte[] buffer = new byte[1024]; - while (true) { - int len = is.read(buffer); - if (len < 0) { - break; - } - os.write(buffer, 0, len); - } - is.close(); - os.closeArchiveEntry(); - } - } + @@ -141,7 +91,7 @@ public List<ValidateError> restore(FileItem fileItem) throws IOException { tmp.mkdirs(); //zip繝輔ぃ繧、繝ォ繧定ァ」蜃� - unZip(fileItem, tmp); + CompressLogic.get().unZip(fileItem, tmp); // 隗」蜃阪@縺滉クュ霄ォ縺ョ讀懆ィシ File[] children = tmp.listFiles(); @@ -196,43 +146,6 @@ public List<ValidateError> restore(FileItem fileItem) throws IOException { return errors; } - /** - * Zip繧定ァ」蜃� - * @param fileItem - * @param tmp - * @throws IOException - * @throws FileNotFoundException - */ - private void unZip(FileItem fileItem, File tmp) throws IOException, FileNotFoundException { - ZipArchiveInputStream archive = null; - try { - archive = new ZipArchiveInputStream(fileItem.getInputStream(), "UTF-8", true); - ZipArchiveEntry entry; - while ((entry = archive.getNextZipEntry()) != null) { - File file = new File(tmp, entry.getName()); - if (entry.isDirectory()) { - file.mkdirs(); - } else { - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - OutputStream out = null; - try { - out = new FileOutputStream(file); - IOUtils.copy(archive, out); - } finally { - if (out != null) { - out.close(); - } - } - } - } - } finally { - if (archive != null) { - archive.close(); - } - fileItem.delete(); - } - } + } diff --git a/src/main/java/org/support/project/knowledge/logic/DiffLogic.java b/src/main/java/org/support/project/knowledge/logic/DiffLogic.java new file mode 100644 index 000000000..2e97d538d --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/DiffLogic.java @@ -0,0 +1,67 @@ +package org.support.project.knowledge.logic; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; + +import difflib.Delta; +import difflib.DiffUtils; +import difflib.Patch; + +public class DiffLogic { + /** 繝ュ繧ー */ + private static Log LOG = LogFactory.getLog(DiffLogic.class); + + public static DiffLogic get() { + return Container.getComp(DiffLogic.class); + } + + public List<String> diff(String content, String content2) { + List<String> changes = new ArrayList<>(); + List<String> oldLines = loadLines(content); + List<String> newLines = loadLines(content2); + + Patch patch = DiffUtils.diff(oldLines, newLines); + for (Delta delta : patch.getDeltas()) { + StringBuilder builder = new StringBuilder(); + builder.append(String.format("[History (%d)]", delta.getOriginal().getPosition() + 1)); + builder.append("\n"); + for (Object line : delta.getOriginal().getLines()) { + builder.append(line); + builder.append("\n"); + } + + builder.append("\n"); + builder.append("竊�"); + builder.append("\n"); + + builder.append(String.format("[Now (%d)]", delta.getRevised().getPosition() + 1)); + builder.append("\n"); + for (Object line : delta.getRevised().getLines()) { + builder.append(line); + builder.append("\n"); + } + changes.add(builder.toString()); + } + return changes; + } + + private List<String> loadLines(String content) { + List<String> strings = new ArrayList<String>(); + String[] splits = content.split("\r\n"); + for (String string : splits) { + String[] split2 = string.split("\n"); + for (String string2 : split2) { + String[] split3 = string2.split("\r"); + for (String string3 : split3) { + strings.add(string3); + } + } + } + return strings; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index 86de4a951..8c419fe66 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -19,6 +19,7 @@ import org.support.project.knowledge.dao.CommentsDao; import org.support.project.knowledge.dao.KnowledgeFilesDao; import org.support.project.knowledge.dao.KnowledgeGroupsDao; +import org.support.project.knowledge.dao.KnowledgeHistoriesDao; import org.support.project.knowledge.dao.KnowledgeTagsDao; import org.support.project.knowledge.dao.KnowledgeUsersDao; import org.support.project.knowledge.dao.KnowledgesDao; @@ -28,6 +29,7 @@ import org.support.project.knowledge.entity.CommentsEntity; import org.support.project.knowledge.entity.KnowledgeFilesEntity; import org.support.project.knowledge.entity.KnowledgeGroupsEntity; +import org.support.project.knowledge.entity.KnowledgeHistoriesEntity; import org.support.project.knowledge.entity.KnowledgeTagsEntity; import org.support.project.knowledge.entity.KnowledgeUsersEntity; import org.support.project.knowledge.entity.KnowledgesEntity; @@ -128,11 +130,15 @@ public KnowledgesEntity insert(KnowledgesEntity entity, List<TagsEntity> tags, L // 荳隕ァ陦ィ遉コ逕ィ縺ョ諠��ア繧呈峩譁ー updateKnowledgeExInfo(entity); + // 螻・豁エ逋サ骭イ + insertHistory(entity); + // 騾夂衍��TODO 蛻・繧ケ繝ャ繝�ラ蛹悶r讀懆ィ趣シ� NotifyLogic.get().notifyOnKnowledgeInsert(entity); return entity; } + /** * 繝翫Ξ繝�ず繧呈峩譁ー @@ -167,13 +173,31 @@ public KnowledgesEntity update(KnowledgesEntity entity, List<TagsEntity> tags, L // 荳隕ァ陦ィ遉コ逕ィ縺ョ諠��ア繧呈峩譁ー updateKnowledgeExInfo(entity); + // 螻・豁エ逋サ骭イ + insertHistory(entity); + // 騾夂衍��TODO 蛻・繧ケ繝ャ繝�ラ蛹悶r讀懆ィ趣シ� NotifyLogic.get().notifyOnKnowledgeUpdate(entity); return entity; } - + /** + * 繝翫Ξ繝�ず縺ョ譖エ譁ー螻・豁エ繧堤匳骭イ + * @param entity + */ + public void insertHistory(KnowledgesEntity entity) { + // 譌「蟄倥�繝翫Ξ繝�ず諠��ア繧貞ア・豁エ縺ク繧ウ繝斐� + KnowledgesEntity origin = knowledgesDao.selectOnKey(entity.getKnowledgeId()); + KnowledgeHistoriesEntity history = new KnowledgeHistoriesEntity(); + PropertyUtil.copyPropertyValue(origin, history); + KnowledgeHistoriesDao historiesDao = KnowledgeHistoriesDao.get(); + int max = historiesDao.selectMaxHistoryNo(entity.getKnowledgeId()); + max++; + history.setHistoryNo(max); + historiesDao.physicalInsert(history); + } + /** * 繧ソ繧ー繧堤匳骭イ diff --git a/src/main/java/org/support/project/knowledge/vo/ExportUser.java b/src/main/java/org/support/project/knowledge/vo/ExportUser.java new file mode 100644 index 000000000..0d620d5e7 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/ExportUser.java @@ -0,0 +1,119 @@ +package org.support.project.knowledge.vo; + +import java.sql.Timestamp; + +public class ExportUser { + /** 繝ヲ繝シ繧カID */ + private Integer userId; + /** 繝ヲ繝シ繧カKEY 繝ヲ繝九�繧ッ */ + private String userKey; + /** 繝ヲ繝シ繧カ蜷� */ + private String userName; + /** 逋サ骭イ繝ヲ繝シ繧カ */ + private Integer insertUser; + /** 逋サ骭イ譌・譎� */ + private Timestamp insertDatetime; + /** 譖エ譁ー繝ヲ繝シ繧カ */ + private Integer updateUser; + /** 譖エ譁ー譌・譎� */ + private Timestamp updateDatetime; + /** 蜑企勁繝輔Λ繧ー */ + private Integer deleteFlag; + /** + * @return the userId + */ + public Integer getUserId() { + return userId; + } + /** + * @param userId the userId to set + */ + public void setUserId(Integer userId) { + this.userId = userId; + } + /** + * @return the userKey + */ + public String getUserKey() { + return userKey; + } + /** + * @param userKey the userKey to set + */ + public void setUserKey(String userKey) { + this.userKey = userKey; + } + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + /** + * @param userName the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } + /** + * @return the insertUser + */ + public Integer getInsertUser() { + return insertUser; + } + /** + * @param insertUser the insertUser to set + */ + public void setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + } + /** + * @return the insertDatetime + */ + public Timestamp getInsertDatetime() { + return insertDatetime; + } + /** + * @param insertDatetime the insertDatetime to set + */ + public void setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + } + /** + * @return the updateUser + */ + public Integer getUpdateUser() { + return updateUser; + } + /** + * @param updateUser the updateUser to set + */ + public void setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + } + /** + * @return the updateDatetime + */ + public Timestamp getUpdateDatetime() { + return updateDatetime; + } + /** + * @param updateDatetime the updateDatetime to set + */ + public void setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + } + /** + * @return the deleteFlag + */ + public Integer getDeleteFlag() { + return deleteFlag; + } + /** + * @param deleteFlag the deleteFlag to set + */ + public void setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + } + +} diff --git a/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java new file mode 100644 index 000000000..9e0d2627a --- /dev/null +++ b/src/main/java/org/support/project/knowledge/websocket/DataExportEndpoint.java @@ -0,0 +1,48 @@ +package org.support.project.knowledge.websocket; + +import java.io.IOException; + +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +import net.arnx.jsonic.JSONException; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.bat.CreateExportDataBat; +import org.support.project.web.websocket.CallBatchEndpoint; +import org.support.project.web.websocket.EndpointConfigurator; + + +@ServerEndpoint(value = "/exporting", configurator=EndpointConfigurator.class) +public class DataExportEndpoint extends CallBatchEndpoint { + /** 繝ュ繧ー */ + private static Log LOG = LogFactory.getLog(DataExportEndpoint.class); + + @OnOpen + public void onOpen(Session session) throws IOException { + if (super.isAdmin(session)) { + call(session, CreateExportDataBat.class); + } + } + + @OnClose + public void onClose(Session session) { + } + + @OnMessage + public void onMessage(String text) throws JSONException, IOException { + } + + @OnError + public void onError(Throwable t) { + LOG.warn("websocket on error." + t.getClass().getName() + " : " + t.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.warn("websocket error -> ", t); + } + } +} diff --git a/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java index 67d48d8e7..14fce5a6d 100644 --- a/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java +++ b/src/main/java/org/support/project/knowledge/websocket/DataTransferEndpoint.java @@ -26,8 +26,9 @@ import org.support.project.web.bean.LoginedUser; import org.support.project.web.bean.MessageResult; import org.support.project.web.logic.DBConnenctionLogic; +import org.support.project.web.websocket.EndpointConfigurator; -@ServerEndpoint(value = "/data_transfer", configurator=NotifyEndpointConfigurator.class) +@ServerEndpoint(value = "/data_transfer", configurator=EndpointConfigurator.class) public class DataTransferEndpoint { /** 繝ュ繧ー */ @@ -37,8 +38,8 @@ public class DataTransferEndpoint { @OnOpen public void onOpen(Session session) throws IOException { - if (session.getUserProperties().containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { - LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (session.getUserProperties().containsKey(EndpointConfigurator.LOCALE_KEY)) { + LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(EndpointConfigurator.LOGIN_USER_KEY); if (!loginuser.isAdmin()) { // 邂。逅��サ・螟悶�繧「繧ッ繧サ繧ケ蜃コ譚・縺ェ縺� session.close(); @@ -81,7 +82,7 @@ public void write(String message) { public void finish(JobResult result) { ConnectionManager.getInstance().addConnectionConfig(connectionConfig); //譁ー縺励>繧ウ繝阪け繧キ繝ァ繝ウ險ュ螳壹r繧サ繝�ヨ MessageResult message = new MessageResult(); - message.setMessage("Data Transfer is ended. [status]" + result.getResultCode()); + message.setMessage("Processing has been completed. [status]" + result.getResultCode()); try { session.getBasicRemote().sendText(JSON.encode(message)); session.close(); diff --git a/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java index 5d892074d..db25d6168 100644 --- a/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java +++ b/src/main/java/org/support/project/knowledge/websocket/NotifyEndpoint.java @@ -19,8 +19,9 @@ import org.support.project.common.log.LogFactory; import org.support.project.di.Container; import org.support.project.web.bean.LoginedUser; +import org.support.project.web.websocket.EndpointConfigurator; -@ServerEndpoint(value = "/notify", configurator=NotifyEndpointConfigurator.class) +@ServerEndpoint(value = "/notify", configurator=EndpointConfigurator.class) public class NotifyEndpoint { /** 繝ュ繧ー */ private static Log LOG = LogFactory.getLog(NotifyEndpoint.class); @@ -32,8 +33,8 @@ public class NotifyEndpoint { public void onOpen(Session session) { // 髢句ァ区凾 if (LOG.isInfoEnabled()) { - if (session.getUserProperties().containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { - LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (session.getUserProperties().containsKey(EndpointConfigurator.LOCALE_KEY)) { + LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(EndpointConfigurator.LOGIN_USER_KEY); LOG.info("websocket open: " + session.getId() + " : " + loginuser.getUserId()); } } @@ -58,8 +59,8 @@ public void onOpen(Session session) { public void onClose(Session session) { // 螳御コ�凾 if (LOG.isInfoEnabled()) { - if (session.getUserProperties().containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { - LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (session.getUserProperties().containsKey(EndpointConfigurator.LOCALE_KEY)) { + LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(EndpointConfigurator.LOGIN_USER_KEY); LOG.info("websocket close: " + session.getId() + " : " + loginuser.getUserId()); } } diff --git a/src/main/java/org/support/project/knowledge/websocket/NotifyEndpointConfigurator.java b/src/main/java/org/support/project/knowledge/websocket/NotifyEndpointConfigurator.java deleted file mode 100644 index 5066bbcde..000000000 --- a/src/main/java/org/support/project/knowledge/websocket/NotifyEndpointConfigurator.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.support.project.knowledge.websocket; - -import java.util.Locale; -import java.util.Map; - -import javax.servlet.http.HttpSession; -import javax.websocket.HandshakeResponse; -import javax.websocket.server.HandshakeRequest; -import javax.websocket.server.ServerEndpointConfig; -import javax.websocket.server.ServerEndpointConfig.Configurator; - -import org.support.project.common.log.Log; -import org.support.project.common.log.LogFactory; -import org.support.project.web.bean.LoginedUser; -import org.support.project.web.config.CommonWebParameter; - -public class NotifyEndpointConfigurator extends Configurator { - /** 繝ュ繧ー */ - private static Log LOG = LogFactory.getLog(NotifyEndpointConfigurator.class); - - public static final String LOCALE_KEY = "LOCALE_KEY"; - public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; - - @Override - public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) { - try { - super.modifyHandshake(config, request, response); - - // 繝ュ繧ー繧、繝ウ縺ョ諠��ア繧偵そ繝�ヨ縺吶k - Map<String, Object> prop = config.getUserProperties(); - if (prop == null) { - return; - } - - Locale locale = Locale.getDefault(); - if (request.getHttpSession() instanceof HttpSession) { - HttpSession session = (HttpSession) request.getHttpSession(); - if (session != null) { - locale = (Locale) session.getAttribute(CommonWebParameter.LOCALE_SESSION_KEY); - LoginedUser loginuser = (LoginedUser) session.getAttribute(CommonWebParameter.LOGIN_USER_INFO_SESSION_KEY); - if (loginuser != null) { - prop.put(LOGIN_USER_KEY, loginuser); - } - } - } - prop.put(LOCALE_KEY, locale); - } catch(Exception e) { - // 縺ェ縺懊°NullPointerException縺檎匱逕溘☆繧倶コ九′縺ゅk - LOG.info("Error", e); - } - } - -} diff --git a/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java b/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java index 55804b212..71a78cc6f 100644 --- a/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java +++ b/src/main/java/org/support/project/knowledge/websocket/ReindexingEndpoint.java @@ -23,18 +23,19 @@ import org.support.project.knowledge.config.AppConfig; import org.support.project.web.bean.LoginedUser; import org.support.project.web.bean.MessageResult; +import org.support.project.web.websocket.EndpointConfigurator; -@ServerEndpoint(value = "/reindexing", configurator=NotifyEndpointConfigurator.class) +@ServerEndpoint(value = "/reindexing", configurator=EndpointConfigurator.class) public class ReindexingEndpoint { /** 繝ュ繧ー */ - private static Log LOG = LogFactory.getLog(DataTransferEndpoint.class); + private static Log LOG = LogFactory.getLog(ReindexingEndpoint.class); private Thread thread; @OnOpen public void onOpen(Session session) throws IOException { - if (session.getUserProperties().containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { - LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (session.getUserProperties().containsKey(EndpointConfigurator.LOCALE_KEY)) { + LoginedUser loginuser = (LoginedUser) session.getUserProperties().get(EndpointConfigurator.LOGIN_USER_KEY); if (!loginuser.isAdmin()) { // 邂。逅��サ・螟悶�繧「繧ッ繧サ繧ケ蜃コ譚・縺ェ縺� session.close(); diff --git a/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java b/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java index c93fb3790..41f98dc83 100644 --- a/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java +++ b/src/main/java/org/support/project/knowledge/websocket/SessionObserver.java @@ -14,6 +14,7 @@ import org.support.project.knowledge.vo.Notify; import org.support.project.web.bean.LoginedUser; import org.support.project.web.bean.MessageResult; +import org.support.project.web.websocket.EndpointConfigurator; public class SessionObserver implements Observer { /** 繝ュ繧ー */ @@ -37,11 +38,11 @@ public void update(Observable o, Object message) { Map<String, Object> prop = session.getUserProperties(); LoginedUser loginuser = null; if (prop != null) { - if (prop.containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { - locale = (Locale) prop.get(NotifyEndpointConfigurator.LOCALE_KEY); + if (prop.containsKey(EndpointConfigurator.LOCALE_KEY)) { + locale = (Locale) prop.get(EndpointConfigurator.LOCALE_KEY); } - if (prop.containsKey(NotifyEndpointConfigurator.LOCALE_KEY)) { - loginuser = (LoginedUser) prop.get(NotifyEndpointConfigurator.LOGIN_USER_KEY); + if (prop.containsKey(EndpointConfigurator.LOCALE_KEY)) { + loginuser = (LoginedUser) prop.get(EndpointConfigurator.LOGIN_USER_KEY); } } diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index 630c5f0a9..b16b7e62a 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -50,10 +50,10 @@ message.success.accept.target={1} was Accepted. message.success.save.target={1} was Saved. message.allready.updated=Allready updated. -message.allready.started=縺吶〒縺ォ髢句ァ区ク医〒縺� +message.allready.started=Allready started. # Common Label -label.version=0.5.0 +label.version=0.5.1 pre1 label.login=Sign in label.previous = Previous label.next=Next @@ -85,9 +85,9 @@ label.upload=Upload label.backup=Backup label.restore=Restore label.back=Back -label.start=髢句ァ� -label.end=邨ゆコ� -label.stop=蛛懈ュ「 +label.start=Start +label.end=End +label.stop=Stop label.public.view=<i class="fa fa-globe"></i> [Public] label.protect.view=<i class="fa fa-gavel"></i> [Protection] @@ -124,8 +124,9 @@ knowledge.navbar.menu.knowledge.add=Add Knowledge knowledge.navbar.tag=Tag knowledge.navbar.data=Data knowledge.navbar.data.backup=Backup & Restore -knowledge.navbar.data.connect=繝��繧ソ繝吶�繧ケ縺ョ謗・邯壼�螟画峩 -knowledge.navbar.data.reindexing=讀懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ蜀肴ァ狗ッ� +knowledge.navbar.data.connect=Database change +knowledge.navbar.data.reindexing=Index reorganization +knowledge.navbar.data.export=Export knowledge.auth.description=Prompts for sign-in is required functions.<br/>(Such as knowledge of editing is required sign-in) knowledge.auth.signin=Sign In @@ -200,6 +201,12 @@ knowledge.likes.title=User list that was me press the "Like" knowledge.likes.list.label.empty=In this page, the user presses the "Like" did not have knowledge.likes.anonymous=Anonymous (not sign in user) +knowledge.histories.title=譖エ譁ー螻・豁エ +knowledge.histories.list.label.empty=繝��繧ソ縺悟ュ伜惠縺励∪縺帙s縲� +knowledge.histories.label.diff=迴セ蝨ィ縺ィ縺ョ蟾ョ蛻� +knowledge.histories.label.history=驕主悉縺ョ繝翫Ξ繝�ず縺ョ蜀�ョケ +knowledge.histories.label.now=迴セ蝨ィ縺ョ繝翫Ξ繝�ず縺ョ蜀�ョケ + knowledge.signup.title=Sign Up knowledge.signup.label.mail=Mail Address (will at the time of signin ID and / There is no published is that) knowledge.signup.label.name=User Name (The name that display in this service) @@ -218,9 +225,9 @@ knowledge.account.label.password.msg=(input to change password) knowledge.account.delete=Thank you for your use knowledge.account.change.email=Change E-mail knowledge.account.changekey.title=Change E-mail -knowledge.account.label.email=螟画峩縺励◆縺�Γ繝シ繝ォ繧「繝峨Ξ繧ケ�域欠螳壹�繧「繝峨Ξ繧ケ縺ォ螟画峩遒コ隱阪�縺溘a縺ョ繝。繝シ繝ォ繧帝√j縺セ縺呻シ� -knowledge.account.changekey.request=繝。繝シ繝ォ繧「繝峨Ξ繧ケ螟画峩縺ョ繝ェ繧ッ繧ィ繧ケ繝医r蜿励¢莉倥¢縺セ縺励◆縲よ眠縺励>繝。繝シ繝ォ繧「繝峨Ξ繧ケ縺ォ遒コ隱咲畑縺ョ繝。繝シ繝ォ繧帝√j縺セ縺励◆縺ョ縺ァ縲√Γ繝シ繝ォ繧貞女菫。縺励※縲√Γ繝シ繝ォ繧「繝峨Ξ繧ケ螟画峩蜃ヲ逅�r螳御コ�@縺ヲ縺上□縺輔>縲� -knowledge.account.changekey.complete=繝。繝シ繝ォ繧「繝峨Ξ繧ケ螟画峩縺悟ョ御コ�@縺セ縺励◆縲� +knowledge.account.label.email=Mail address after change (A mail for change confirmation is sent to the address of the designation.) +knowledge.account.changekey.request=A request of mail address change was accepted. A mail for confirmation was sent to the new mail address, so receive a mail, and please complete mail address change processing. +knowledge.account.changekey.complete=Mail address change has been completed. knowledge.withdrawal.title=Withdrawal knowledge.withdrawal.msg=You unsubscribe from Knowledge of service.<br/>How do you the knowledge that you have registered up to now?<br/> knowledge.withdrawal.label.remove=Remove @@ -311,7 +318,7 @@ knowledge.data.label.backup.msg=Download the service of data, you can back up da knowledge.data.label.restore=Restoration (data upload) knowledge.data.label.restore.msg=You will restore the data from the data of the local PC knowledge.data.label.restore.msg.danger=When you run the restore will overwrite the server's data. For this reason, there is a possibility that the current data disappears. -knowledge.data.label.restore.msg.info=縺薙�繝壹�繧ク縺ァ邂。逅�@縺ヲ縺�k繝��繧ソ縺ッ繝�ヵ繧ゥ繝ォ繝医�繝��繧ソ繝吶�繧ケ縺悟ッセ雎。縺ォ縺ェ繧翫∪縺吶ゅョ繝シ繧ソ繝吶�繧ケ縺ョ謗・邯壼�螟画峩縺ァ繝��繧ソ縺ョ譬シ邏榊�繧貞、画峩縺励※縺�k蝣エ蜷医∝ッセ雎。縺ォ縺ェ繧翫∪縺帙s縲ゅ◎縺ョ蝣エ蜷医√ヰ繝�け繧「繝��縺ェ縺ゥ縺ョ邂。逅��蛻ゥ逕ィ迺ー蠅�↓蜷医o縺帙※縺碑�霄ォ縺ァ螳滓命縺励※縺上□縺輔>縲� +knowledge.data.label.restore.msg.info=A data base of default is made the target for the data which is being managed by this page. When changing the stock destination of data by connection previous change in the data base, it isn't made the target. Please manage a backup according to the use environment by yourself in that case. knowledge.data.label.active=database server status knowledge.data.label.active.msg=You can change the operating status of the database server. And when you want to back up and restore, please stop the database before shutting down the service. knowledge.data.label.active.msg2=窶サPlease refer to the stop when you shut down in the case of use in Docker. @@ -334,22 +341,23 @@ knowledge.connection.label.password=password knowledge.connection.label.schema=schema knowledge.connection.label.maxConn=max connection knowledge.connection.label.autocommit=auto commit -knowledge.connection.label.custom=繝��繧ソ繝吶�繧ケ謗・邯壼�險ュ螳� -knowledge.connection.label.transfer=邨�∩霎シ縺ソDB縺ァ菫晏ュ倥@縺ヲ縺�◆繝��繧ソ繧偵き繧ケ繧ソ繝�險ュ螳壹�DB縺ォ繧ウ繝斐� -knowledge.connection.msg.custom.enable=迴セ蝨ィ縲√き繧ケ繧ソ繝�險ュ螳壹′譛牙柑縺ォ縺ェ縺」縺ヲ縺�∪縺� -knowledge.connection.msg.custom.disable=繧ォ繧ケ繧ソ繝�險ュ螳壹�蟄伜惠縺励↑縺�◆繧√√ョ繝輔か繝ォ繝医�邨�∩霎シ縺ソDB繧剃スソ縺」縺ヲ縺�∪縺� -knowledge.connection.msg.custom.transfer=繧ォ繧ケ繧ソ繝�DB縺ク繝��繧ソ縺ョ繧ウ繝斐�荳ュ縺ァ縺吶ょョ御コ�☆繧九∪縺ァ縺励�繧峨¥縺翫∪縺。縺上□縺輔>縲� -knowledge.connection.msg.custom.transfer.request=繧ォ繧ケ繧ソ繝�DB縺ク繝��繧ソ縺ョ繧ウ繝斐�縺ョ繝ェ繧ッ繧ィ繧ケ繝医r蜿励¢莉倥¢縺セ縺励◆ -knowledge.reindexing.title=讀懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ縺ョ蜀堺ス懈� -knowledge.reindexing.msg1=Knowledge縺ァ縺ッ縲√ョ繝シ繧ソ菫晏ュ倡畑縺ョDatabase縺ョ莉悶↓縲∵、懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ��Lucene�峨r謖√▲縺ヲ縺�∪縺吶� -knowledge.reindexing.msg2=譛ャ逕サ髱「縺ァ縺ッ縲√◎縺ョ讀懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ繧貞�菴懈�縺励∪縺吶� -knowledge.reindexing.msg3=繝舌�繧ク繝ァ繝ウ 0.5.1縺九i縲√さ繝。繝ウ繝医〒繧よ、懃エ「蜃コ譚・繧九h縺�↓讖溯�菫ョ豁」縺励∪縺励◆縺後∽サ翫∪縺ァ逋サ骭イ縺輔l縺滄℃蜴サ縺ョ繧ウ繝。繝ウ繝医ョ繝シ繧ソ縺後う繝ウ繝�ャ繧ッ繧ケ縺ォ蜈・縺」縺ヲ縺�↑縺�◆繧√∵、懃エ「邨先棡縺ォ蜈・繧翫∪縺帙s縲� -knowledge.reindexing.msg4=縺セ縺溘.B繧偵ム繝ウ繝励°繧牙セゥ蜈�@縺溘h縺�↑蝣エ蜷医b縲√う繝ウ繝�ャ繧ッ繧ケ縺セ縺ァ蠕ゥ蜈�☆繧九o縺代〒縺ッ縺ゅj縺セ縺帙s縲� -knowledge.reindexing.msg5=縺昴�繧医≧縺ェ蝣エ蜷医↓縲∵悽逕サ髱「縺ョ讖溯�繧剃スソ縺�う繝ウ繝�ャ繧ッ繧ケ繧貞�菴懈�縺励※縺上□縺輔>縲� -knowledge.reindexing.label.start=繧、繝ウ繝�ャ繧ッ繧ケ菴懈�縺吶k繝翫Ξ繝�ず縺ョ逡ェ蜿キ�磯幕蟋具シ� -knowledge.reindexing.label.end=繧、繝ウ繝�ャ繧ッ繧ケ菴懈�縺吶k繝翫Ξ繝�ず縺ョ逡ェ蜿キ�育オゆコ�シ� -knowledge.reindexing.msg.start=繧、繝ウ繝�ャ繧ッ繧ケ繧貞�菴懈�縺励※縺�∪縺吶ゑシ医%縺ョ繝。繝�そ繝シ繧ク縺後″縺医k縺セ縺ァ縲√♀蠕�■縺上□縺輔>�� -knowledge.reindexing.msg.end=繧、繝ウ繝�ャ繧ッ繧ケ蜀堺ス懈�縺悟ョ御コ�@縺セ縺励◆縲� +knowledge.connection.label.custom=Change Database +knowledge.connection.label.transfer=Data of default DB is copied to custom setting DB. +knowledge.connection.label.transfer.back=Data of custom setting DB is copied to default DB. +knowledge.connection.msg.custom.enable=Custom setting becomes effective at present. +knowledge.connection.msg.custom.disable=It's default because custom setting doesn't exist, it's included and DB is used. +knowledge.connection.msg.custom.transfer=Of data, it's being copied. Please wait a moment until it's completed. +knowledge.connection.msg.custom.transfer.request=A request of a copy of data was accepted. +knowledge.reindexing.title=Re-making of an index for searches +knowledge.reindexing.msg1=I have an index for searches (Lucene) in addition to Database for data storages in Knowledge. +knowledge.reindexing.msg2=An index for the searches is made on this screen. +knowledge.reindexing.msg3=A version Can search for a comment from 0.5.0, it functions, it was corrected, but I don't enter a search result because comment data in the registered past isn't included in an index so far. +knowledge.reindexing.msg4=When restoring DB, an index isn't even restored. +knowledge.reindexing.msg5=In such case, please make an index using the function of this screen. +knowledge.reindexing.label.start=The number of the knowledge I do index making of (starting) +knowledge.reindexing.label.end=The number of the knowledge I do index making of (end) +knowledge.reindexing.msg.start=An index is being made. (Please wait a moment until this message goes off.) +knowledge.reindexing.msg.end=Index re-making has been completed. knowledge.notify.title=Notify Config knowledge.notify.msg=Please set the notification of when the post state has changed @@ -378,6 +386,12 @@ knowledge.notify.msg.desktop.to.comment=Comment has been posted on knowledge {1} knowledge.notify.msg.desktop.stoke.update=Knowledge {1} that stock has been updated knowledge.notify.msg.desktop.stoke.comment=Comment has been posted on knowledge {1} that stock +knowledge.export.title=繝��繧ソ繧偵お繧ッ繧ケ繝昴�繝� +knowledge.export.msg1=繝��繧ソ繧偵お繧ッ繧ケ繝昴�繝医@縺セ縺吶�(zip蠖「蠑上〒繝繧ヲ繝ウ繝ュ繝シ繝�) +knowledge.export.msg2=繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ繧剃ス懈�縺吶k蜃ヲ逅��縲∫匳骭イ縺輔l縺ヲ縺�k繝��繧ソ縺ョ驥上↓繧医j縲∵凾髢薙′縺九°繧翫∪縺吶� +knowledge.export.msg3=縺薙�縺溘a縲√お繧ッ繧ケ繝昴�繝医r螳溯。後@縺溷セ後√ム繧ヲ繝ウ繝ュ繝シ繝峨∪縺ァ縺励�繧峨¥縺雁セ�■縺上□縺輔>縲� +knowledge.export.msg.start=繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ繧堤函謌舌@縺ヲ縺�∪縺吶� +knowledge.export.msg.end=繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ縺ョ逕滓�縺悟ョ御コ�@縺セ縺励◆縲� diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 43a6db00c..7edf3846a 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -53,7 +53,7 @@ message.allready.updated=縺吶〒縺ォ譖エ譁ー縺輔l縺ヲ縺�∪縺� message.allready.started=縺吶〒縺ォ髢句ァ区ク医〒縺� # Common Label -label.version=0.5.0 +label.version=0.5.1 pre1 label.login=繧オ繧、繝ウ繧、繝ウ label.previous = 蜑阪∈ label.next = 谺。縺ク @@ -123,9 +123,10 @@ knowledge.navbar.menu.knowledge.list=繝翫Ξ繝�ず荳隕ァ knowledge.navbar.menu.knowledge.add=繝翫Ξ繝�ず逋サ骭イ knowledge.navbar.tag=繧ソ繧ー knowledge.navbar.data=繝��繧ソ邂。逅� -knowledge.navbar.data.backup=繝��繧ソ縺ョ繝舌ャ繧ッ繧「繝��縺ィ蠕ゥ蜈� +knowledge.navbar.data.backup=邨�∩霎シ縺ソ繝��繧ソ繝吶�繧ケ縺ョ繝舌ャ繧ッ繧「繝��縺ィ蠕ゥ蜈� knowledge.navbar.data.connect=繝��繧ソ繝吶�繧ケ縺ョ謗・邯壼�螟画峩 knowledge.navbar.data.reindexing=讀懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ蜀肴ァ狗ッ� +knowledge.navbar.data.export=繧ィ繧ッ繧ケ繝昴�繝� knowledge.auth.description=繧オ繧、繝ウ繧、繝ウ縺悟ソ�ヲ√↑讖溯�縺ァ縺吶�<br/>(繝翫Ξ繝�ず縺ョ邱ィ髮�↑縺ゥ縺ッ繧オ繧、繝ウ繧、繝ウ縺悟ソ�ヲ√〒縺�) knowledge.auth.signin=繧オ繧、繝ウ繧、繝ウ螳溯。� @@ -200,6 +201,12 @@ knowledge.likes.title=蜿り�↓縺ェ縺」縺溘r謚シ縺励※縺上l縺溘Θ繝シ繧カ荳隕ァ knowledge.likes.list.label.empty=縺薙�繝壹�繧ク縺ァ縺ッ縲∝盾閠�↓縺ェ縺」縺滂シ√r謚シ縺励◆繝ヲ繝シ繧カ縺ッ縺�∪縺帙s縺ァ縺励◆ knowledge.likes.anonymous=Anonymous(譛ェ繝ュ繧ー繧、繝ウ繝ヲ繝シ繧カ) +knowledge.histories.title=譖エ譁ー螻・豁エ +knowledge.histories.list.label.empty=繝��繧ソ縺悟ュ伜惠縺励∪縺帙s縲� +knowledge.histories.label.diff=迴セ蝨ィ縺ィ縺ョ蟾ョ蛻� +knowledge.histories.label.history=驕主悉縺ョ繝翫Ξ繝�ず縺ョ蜀�ョケ +knowledge.histories.label.now=迴セ蝨ィ縺ョ繝翫Ξ繝�ず縺ョ蜀�ョケ + knowledge.signup.title=繝ヲ繝シ繧カ譁ー隕冗匳骭イ knowledge.signup.label.mail=繝。繝シ繝ォ繧「繝峨Ξ繧ケ(繝ュ繧ー繧、繝ウ譎ゅ�ID縺ォ縺ェ繧翫∪縺�/蜈ャ髢九&繧後k縺薙→縺ッ縺ゅj縺セ縺帙s) knowledge.signup.label.name=蜷榊燕(縺薙�繧オ繝シ繝薙せ縺ョ荳ュ縺ァ陦ィ遉コ縺輔l繧句錐遘ー縺ァ縺�) @@ -336,15 +343,16 @@ knowledge.connection.label.maxConn=max connection knowledge.connection.label.autocommit=auto commit knowledge.connection.label.custom=繝��繧ソ繝吶�繧ケ謗・邯壼�險ュ螳� knowledge.connection.label.transfer=邨�∩霎シ縺ソDB縺ァ菫晏ュ倥@縺ヲ縺�◆繝��繧ソ繧偵き繧ケ繧ソ繝�險ュ螳壹�DB縺ォ繧ウ繝斐� +knowledge.connection.label.transfer.back=繧ォ繧ケ繧ソ繝�險ュ螳壹�DB縺ョ繝��繧ソ繧堤オ�∩霎シ縺ソDB縺ク繧ウ繝斐� knowledge.connection.msg.custom.enable=迴セ蝨ィ縲√き繧ケ繧ソ繝�險ュ螳壹′譛牙柑縺ォ縺ェ縺」縺ヲ縺�∪縺� knowledge.connection.msg.custom.disable=繧ォ繧ケ繧ソ繝�險ュ螳壹�蟄伜惠縺励↑縺�◆繧√√ョ繝輔か繝ォ繝医�邨�∩霎シ縺ソDB繧剃スソ縺」縺ヲ縺�∪縺� -knowledge.connection.msg.custom.transfer=繧ォ繧ケ繧ソ繝�DB縺ク繝��繧ソ縺ョ繧ウ繝斐�荳ュ縺ァ縺吶ょョ御コ�☆繧九∪縺ァ縺励�繧峨¥縺翫∪縺。縺上□縺輔>縲ゑシ医%縺ョ繝。繝�そ繝シ繧ク縺後″縺医k縺セ縺ァ縲∵桃菴懊@縺ェ縺�〒縺上□縺輔>�� -knowledge.connection.msg.custom.transfer.request=繧ォ繧ケ繧ソ繝�DB縺ク繝��繧ソ縺ョ繧ウ繝斐�縺ョ繝ェ繧ッ繧ィ繧ケ繝医r蜿励¢莉倥¢縺セ縺励◆ +knowledge.connection.msg.custom.transfer=繝��繧ソ縺ョ繧ウ繝斐�荳ュ縺ァ縺吶ょョ御コ�☆繧九∪縺ァ縺励�繧峨¥縺翫∪縺。縺上□縺輔>縲ゑシ医%縺ョ繝。繝�そ繝シ繧ク縺後″縺医k縺セ縺ァ縲∵桃菴懊@縺ェ縺�〒縺上□縺輔>�� +knowledge.connection.msg.custom.transfer.request=繝��繧ソ縺ョ繧ウ繝斐�縺ョ繝ェ繧ッ繧ィ繧ケ繝医r蜿励¢莉倥¢縺セ縺励◆ knowledge.reindexing.title=讀懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ縺ョ蜀堺ス懈� knowledge.reindexing.msg1=Knowledge縺ァ縺ッ縲√ョ繝シ繧ソ菫晏ュ倡畑縺ョDatabase縺ョ莉悶↓縲∵、懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ��Lucene�峨r謖√▲縺ヲ縺�∪縺吶� knowledge.reindexing.msg2=譛ャ逕サ髱「縺ァ縺ッ縲√◎縺ョ讀懃エ「逕ィ縺ョ繧、繝ウ繝�ャ繧ッ繧ケ繧貞�菴懈�縺励∪縺吶� -knowledge.reindexing.msg3=繝舌�繧ク繝ァ繝ウ 0.5.1縺九i縲√さ繝。繝ウ繝医〒繧よ、懃エ「蜃コ譚・繧九h縺�↓讖溯�菫ョ豁」縺励∪縺励◆縺後∽サ翫∪縺ァ逋サ骭イ縺輔l縺滄℃蜴サ縺ョ繧ウ繝。繝ウ繝医ョ繝シ繧ソ縺後う繝ウ繝�ャ繧ッ繧ケ縺ォ蜈・縺」縺ヲ縺�↑縺�◆繧√∵、懃エ「邨先棡縺ォ蜈・繧翫∪縺帙s縲� -knowledge.reindexing.msg4=縺セ縺溘.B繧偵ム繝ウ繝励°繧牙セゥ蜈�@縺溘h縺�↑蝣エ蜷医b縲√う繝ウ繝�ャ繧ッ繧ケ縺セ縺ァ蠕ゥ蜈�☆繧九o縺代〒縺ッ縺ゅj縺セ縺帙s縲� +knowledge.reindexing.msg3=繝舌�繧ク繝ァ繝ウ 0.5.0縺九i縲√さ繝。繝ウ繝医〒繧よ、懃エ「蜃コ譚・繧九h縺�↓讖溯�菫ョ豁」縺励∪縺励◆縺後∽サ翫∪縺ァ逋サ骭イ縺輔l縺滄℃蜴サ縺ョ繧ウ繝。繝ウ繝医ョ繝シ繧ソ縺後う繝ウ繝�ャ繧ッ繧ケ縺ォ蜈・縺」縺ヲ縺�↑縺�◆繧√∵、懃エ「邨先棡縺ォ蜈・繧翫∪縺帙s縲� +knowledge.reindexing.msg4=縺セ縺溘.B繧貞セゥ蜈�@縺溘h縺�↑蝣エ蜷医b縲√う繝ウ繝�ャ繧ッ繧ケ縺セ縺ァ蠕ゥ蜈�☆繧九o縺代〒縺ッ縺ゅj縺セ縺帙s縲� knowledge.reindexing.msg5=縺昴�繧医≧縺ェ蝣エ蜷医↓縲∵悽逕サ髱「縺ョ讖溯�繧剃スソ縺�う繝ウ繝�ャ繧ッ繧ケ繧貞�菴懈�縺励※縺上□縺輔>縲� knowledge.reindexing.label.start=繧、繝ウ繝�ャ繧ッ繧ケ菴懈�縺吶k繝翫Ξ繝�ず縺ョ逡ェ蜿キ�磯幕蟋具シ� knowledge.reindexing.label.end=繧、繝ウ繝�ャ繧ッ繧ケ菴懈�縺吶k繝翫Ξ繝�ず縺ョ逡ェ蜿キ�育オゆコ�シ� @@ -378,7 +386,10 @@ knowledge.notify.msg.desktop.to.comment=繝翫Ξ繝�ず {1} 縺ォ繧ウ繝。繝ウ繝医′謚� knowledge.notify.msg.desktop.stoke.update=繧ケ繝医ャ繧ッ縺励※縺�k繝翫Ξ繝�ず {1} 縺梧峩譁ー縺輔l縺セ縺励◆ knowledge.notify.msg.desktop.stoke.comment=繧ケ繝医ャ繧ッ縺励※縺�k繝翫Ξ繝�ず {1} 縺ォ繧ウ繝。繝ウ繝医′謚慕ィソ縺輔l縺セ縺励◆ - - - +knowledge.export.title=繝��繧ソ繧偵お繧ッ繧ケ繝昴�繝� +knowledge.export.msg1=繝��繧ソ繧偵お繧ッ繧ケ繝昴�繝医@縺セ縺吶�(zip蠖「蠑上〒繝繧ヲ繝ウ繝ュ繝シ繝�) +knowledge.export.msg2=繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ繧剃ス懈�縺吶k蜃ヲ逅��縲∫匳骭イ縺輔l縺ヲ縺�k繝��繧ソ縺ョ驥上↓繧医j縲∵凾髢薙′縺九°繧翫∪縺吶� +knowledge.export.msg3=縺薙�縺溘a縲√お繧ッ繧ケ繝昴�繝医r螳溯。後@縺溷セ後√ム繧ヲ繝ウ繝ュ繝シ繝峨∪縺ァ縺励�繧峨¥縺雁セ�■縺上□縺輔>縲� +knowledge.export.msg.start=繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ繧堤函謌舌@縺ヲ縺�∪縺吶� +knowledge.export.msg.end=繧ィ繧ッ繧ケ繝昴�繝医ョ繝シ繧ソ縺ョ逕滓�縺悟ョ御コ�@縺セ縺励◆縲� diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_delete.sql new file mode 100644 index 000000000..fe05efdf7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_delete.sql @@ -0,0 +1,5 @@ +DELETE FROM KNOWLEDGE_HISTORIES +WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_insert.sql new file mode 100644 index 000000000..adfc87328 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_insert.sql @@ -0,0 +1,32 @@ +INSERT INTO KNOWLEDGE_HISTORIES +( +HISTORY_NO + , KNOWLEDGE_ID + , TITLE + , CONTENT + , PUBLIC_FLAG + , TAG_IDS + , TAG_NAMES + , LIKE_COUNT + , COMMENT_COUNT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql new file mode 100644 index 000000000..e31b7fba4 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_all.sql @@ -0,0 +1 @@ +SELECT * FROM KNOWLEDGE_HISTORIES; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_history_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_history_no.sql new file mode 100644 index 000000000..67e6b3181 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_history_no.sql @@ -0,0 +1,5 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? +; +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_key.sql new file mode 100644 index 000000000..8124dd0de --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_knowledge_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_knowledge_id.sql new file mode 100644 index 000000000..f40da0386 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_physical_select_on_knowledge_id.sql @@ -0,0 +1,5 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE +KNOWLEDGE_ID = ? +; +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_raw_insert.sql new file mode 100644 index 000000000..adfc87328 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_raw_insert.sql @@ -0,0 +1,32 @@ +INSERT INTO KNOWLEDGE_HISTORIES +( +HISTORY_NO + , KNOWLEDGE_ID + , TITLE + , CONTENT + , PUBLIC_FLAG + , TAG_IDS + , TAG_NAMES + , LIKE_COUNT + , COMMENT_COUNT + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_selectOnKnowledge.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_selectOnKnowledge.sql new file mode 100644 index 000000000..595a805a7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_selectOnKnowledge.sql @@ -0,0 +1,15 @@ +SELECT + KNOWLEDGE_HISTORIES.*, + USERS.USER_NAME + FROM + KNOWLEDGE_HISTORIES + LEFT OUTER JOIN USERS ON (KNOWLEDGE_HISTORIES.INSERT_USER = USERS.USER_ID) + WHERE + KNOWLEDGE_HISTORIES.KNOWLEDGE_ID = ? + AND KNOWLEDGE_HISTORIES.DELETE_FLAG = 0 + ORDER BY + KNOWLEDGE_HISTORIES.UPDATE_DATETIME DESC LIMIT ? OFFSET ?; + + + + diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql new file mode 100644 index 000000000..bc9469962 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_history_no.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_history_no.sql new file mode 100644 index 000000000..c9c0b17c4 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_history_no.sql @@ -0,0 +1,5 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? + AND DELETE_FLAG = 0; +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_key.sql new file mode 100644 index 000000000..d9bfe2fa8 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_key.sql @@ -0,0 +1,6 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? + AND DELETE_FLAG = 0; +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_knowledge_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_knowledge_id.sql new file mode 100644 index 000000000..7a80ca2a9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_select_on_knowledge_id.sql @@ -0,0 +1,5 @@ +SELECT * FROM KNOWLEDGE_HISTORIES + WHERE +KNOWLEDGE_ID = ? + AND DELETE_FLAG = 0; +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_update.sql new file mode 100644 index 000000000..787cfd3aa --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgeHistoriesDao/KnowledgeHistoriesDao_update.sql @@ -0,0 +1,18 @@ +UPDATE KNOWLEDGE_HISTORIES +SET + TITLE = ? + , CONTENT = ? + , PUBLIC_FLAG = ? + , TAG_IDS = ? + , TAG_NAMES = ? + , LIKE_COUNT = ? + , COMMENT_COUNT = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +HISTORY_NO = ? + AND KNOWLEDGE_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TargetsDao/selectOnKeyword.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TargetsDao/selectOnKeyword.sql index cc2c8c278..3d9765b92 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/TargetsDao/selectOnKeyword.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TargetsDao/selectOnKeyword.sql @@ -20,7 +20,7 @@ SELECT WHERE GROUPS.DELETE_FLAG != 1 AND GROUPS.GROUP_NAME LIKE '%' || ? || '%' - ) + ) AS TARGETS ORDER BY LABEL LIMIT ? OFFSET ? diff --git a/src/main/resources/org/support/project/knowledge/database/ddl.sql b/src/main/resources/org/support/project/knowledge/database/ddl.sql index 879b2b800..67990285c 100644 --- a/src/main/resources/org/support/project/knowledge/database/ddl.sql +++ b/src/main/resources/org/support/project/knowledge/database/ddl.sql @@ -1,3 +1,24 @@ +-- 繝翫Ξ繝�ず譖エ譁ー螻・豁エ +drop table if exists KNOWLEDGE_HISTORIES cascade; + +create table KNOWLEDGE_HISTORIES ( + KNOWLEDGE_ID bigint not null + , HISTORY_NO integer not null + , TITLE character varying(1024) not null + , CONTENT text + , PUBLIC_FLAG integer + , TAG_IDS character varying(1024) + , TAG_NAMES text + , LIKE_COUNT bigint + , COMMENT_COUNT integer + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint KNOWLEDGE_HISTORIES_PKC primary key (KNOWLEDGE_ID,HISTORY_NO) +) ; + -- 騾夂衍蠕�■繧ュ繝・繝シ drop table if exists NOTIFY_QUEUES cascade; @@ -242,6 +263,22 @@ create table KNOWLEDGES ( , constraint KNOWLEDGES_PKC primary key (KNOWLEDGE_ID) ) ; +comment on table KNOWLEDGE_HISTORIES is '繝翫Ξ繝�ず譖エ譁ー螻・豁エ'; +comment on column KNOWLEDGE_HISTORIES.KNOWLEDGE_ID is '繝翫Ξ繝�ずID'; +comment on column KNOWLEDGE_HISTORIES.HISTORY_NO is '螻・豁エ逡ェ蜿キ'; +comment on column KNOWLEDGE_HISTORIES.TITLE is '繧ソ繧、繝医Ν'; +comment on column KNOWLEDGE_HISTORIES.CONTENT is '蜀�ョケ'; +comment on column KNOWLEDGE_HISTORIES.PUBLIC_FLAG is '蜈ャ髢句玄蛻�'; +comment on column KNOWLEDGE_HISTORIES.TAG_IDS is '繧ソ繧ーID荳隕ァ'; +comment on column KNOWLEDGE_HISTORIES.TAG_NAMES is '繧ソ繧ー蜷咲ァー荳隕ァ'; +comment on column KNOWLEDGE_HISTORIES.LIKE_COUNT is '縺�>縺ュ莉カ謨ー'; +comment on column KNOWLEDGE_HISTORIES.COMMENT_COUNT is '繧ウ繝。繝ウ繝井サカ謨ー'; +comment on column KNOWLEDGE_HISTORIES.INSERT_USER is '逋サ骭イ繝ヲ繝シ繧カ'; +comment on column KNOWLEDGE_HISTORIES.INSERT_DATETIME is '逋サ骭イ譌・譎�'; +comment on column KNOWLEDGE_HISTORIES.UPDATE_USER is '譖エ譁ー繝ヲ繝シ繧カ'; +comment on column KNOWLEDGE_HISTORIES.UPDATE_DATETIME is '譖エ譁ー譌・譎�'; +comment on column KNOWLEDGE_HISTORIES.DELETE_FLAG is '蜑企勁繝輔Λ繧ー'; + comment on table NOTIFY_QUEUES is '騾夂衍蠕�■繧ュ繝・繝シ'; comment on column NOTIFY_QUEUES.HASH is 'HASH'; comment on column NOTIFY_QUEUES.TYPE is '遞ョ鬘�'; diff --git a/src/main/resources/org/support/project/knowledge/deploy/v0_5_1/migrate.sql b/src/main/resources/org/support/project/knowledge/deploy/v0_5_1/migrate.sql new file mode 100644 index 000000000..96ccdf3a3 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v0_5_1/migrate.sql @@ -0,0 +1,39 @@ +-- 繝翫Ξ繝�ず譖エ譁ー螻・豁エ +drop table if exists KNOWLEDGE_HISTORIES cascade; + +create table KNOWLEDGE_HISTORIES ( + KNOWLEDGE_ID bigint not null + , HISTORY_NO integer not null + , TITLE character varying(1024) not null + , CONTENT text + , PUBLIC_FLAG integer + , TAG_IDS character varying(1024) + , TAG_NAMES text + , LIKE_COUNT bigint + , COMMENT_COUNT integer + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint KNOWLEDGE_HISTORIES_PKC primary key (KNOWLEDGE_ID,HISTORY_NO) +) ; + + + +comment on table KNOWLEDGE_HISTORIES is '繝翫Ξ繝�ず譖エ譁ー螻・豁エ'; +comment on column KNOWLEDGE_HISTORIES.KNOWLEDGE_ID is '繝翫Ξ繝�ずID'; +comment on column KNOWLEDGE_HISTORIES.HISTORY_NO is '螻・豁エ逡ェ蜿キ'; +comment on column KNOWLEDGE_HISTORIES.TITLE is '繧ソ繧、繝医Ν'; +comment on column KNOWLEDGE_HISTORIES.CONTENT is '蜀�ョケ'; +comment on column KNOWLEDGE_HISTORIES.PUBLIC_FLAG is '蜈ャ髢句玄蛻�'; +comment on column KNOWLEDGE_HISTORIES.TAG_IDS is '繧ソ繧ーID荳隕ァ'; +comment on column KNOWLEDGE_HISTORIES.TAG_NAMES is '繧ソ繧ー蜷咲ァー荳隕ァ'; +comment on column KNOWLEDGE_HISTORIES.LIKE_COUNT is '縺�>縺ュ莉カ謨ー'; +comment on column KNOWLEDGE_HISTORIES.COMMENT_COUNT is '繧ウ繝。繝ウ繝井サカ謨ー'; +comment on column KNOWLEDGE_HISTORIES.INSERT_USER is '逋サ骭イ繝ヲ繝シ繧カ'; +comment on column KNOWLEDGE_HISTORIES.INSERT_DATETIME is '逋サ骭イ譌・譎�'; +comment on column KNOWLEDGE_HISTORIES.UPDATE_USER is '譖エ譁ー繝ヲ繝シ繧カ'; +comment on column KNOWLEDGE_HISTORIES.UPDATE_DATETIME is '譖エ譁ー譌・譎�'; +comment on column KNOWLEDGE_HISTORIES.DELETE_FLAG is '蜑企勁繝輔Λ繧ー'; + diff --git a/src/main/webapp/WEB-INF/views/admin/database/connection.jsp b/src/main/webapp/WEB-INF/views/admin/database/connection.jsp index 4a197cf78..9f3b6fc7c 100644 --- a/src/main/webapp/WEB-INF/views/admin/database/connection.jsp +++ b/src/main/webapp/WEB-INF/views/admin/database/connection.jsp @@ -35,7 +35,7 @@ window.onload = function() { $("#transfer_msg").alert('close'); } webSocket.onmessage = function(message) { - console.log('[RECEIVE] '); + //console.log('[RECEIVE] '); var result = JSON.parse(message.data); console.log(result); if (result.message.lastIndexOf('Data Transfer is ended', 0) === 0) { @@ -126,6 +126,10 @@ window.onload = function() { <a href="<%= request.getContextPath()%>/admin.database/data_transfer" class="btn btn-success"> <i class="fa fa-copy"></i> <%= jspUtil.label("knowledge.connection.label.transfer") %> </a> + + <a href="<%= request.getContextPath()%>/admin.database/data_transfer_back" class="btn btn-success"> + <i class="fa fa-copy"></i> <%= jspUtil.label("knowledge.connection.label.transfer.back") %> + </a> <% } %> </form> diff --git a/src/main/webapp/WEB-INF/views/admin/database/export.jsp b/src/main/webapp/WEB-INF/views/admin/database/export.jsp new file mode 100644 index 000000000..664d7a30c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/admin/database/export.jsp @@ -0,0 +1,103 @@ +<%@page import="org.support.project.knowledge.config.SystemConfig"%> +<%@page import="org.support.project.common.config.INT_FLAG"%> +<%@page import="org.support.project.knowledge.vo.Roles"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% JspUtil jspUtil = new JspUtil(request, pageContext); %> + +<c:import url="/WEB-INF/views/commons/layout/layoutMain.jsp"> + +<c:param name="PARAM_HEAD"> +<style> +.radio_block { + margin-bottom: 10px; +} +</style> +</c:param> + +<c:param name="PARAM_SCRIPTS"> +<% if (jspUtil.is(Boolean.TRUE, "start_export")) { %> +<script> +var webSocket; +window.onload = function() { + var forRtoA = document.createElement('a'); + forRtoA.href = '<%= request.getContextPath() %>/exporting'; + console.log(forRtoA.href.replace("http://", "ws://").replace("https://", "wss://")); + webSocket = new WebSocket(forRtoA.href.replace("http://", "ws://").replace("https://", "wss://")); + webSocket.onopen = function() { + } + webSocket.onclose = function() { + console.log('onclose'); + $('#msg').text('<%= jspUtil.label("knowledge.export.msg.end") %>'); + var psconsole = $('#log'); + psconsole.scrollTop( + psconsole[0].scrollHeight - psconsole.height() + ); + window.location.href = '<%= request.getContextPath() %>/admin.database/download'; + } + webSocket.onmessage = function(message) { + //console.log('[RECEIVE] '); + var result = JSON.parse(message.data); + console.log(result); + $('#log').val($('#log').val() + result.message + "\n"); + var psconsole = $('#log'); + psconsole.scrollTop( + psconsole[0].scrollHeight - psconsole.height() + ); + } + webSocket.onerror = function(message) { + console.log(message); + $('#log').val($('#log').val() + message + "\n"); + var psconsole = $('#log'); + psconsole.scrollTop( + psconsole[0].scrollHeight - psconsole.height() + ); + } +} +</script> +<% } %> +</c:param> + + + +<c:param name="PARAM_CONTENT"> +<h4 class="title"><%= jspUtil.label("knowledge.export.title") %></h4> + +<div class="alert alert-info alert-dismissible" role="alert"> + <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> + <strong>Information</strong><br/> + - <%= jspUtil.label("knowledge.export.msg1") %><br/> + - <%= jspUtil.label("knowledge.export.msg2") %><br/> + - <%= jspUtil.label("knowledge.export.msg3") %> +</div> + +<% if(jspUtil.is(Boolean.TRUE, "start_export")) { %> + <div class="alert alert-warning alert-dismissible" role="alert" id="indexing_msg"> + <strong>Information</strong> + <p id="msg"><%= jspUtil.label("knowledge.export.msg.start") %></p> + </div> +<% } %> + + +<form action="<%= request.getContextPath()%>/admin.database/export_data_create" method="get" role="form"> + <button type="submit" class="btn btn-primary"><i class="fa fa-file-archive-o"></i> <%= jspUtil.label("label.start") %></button> +</form> + +<br/> + +<% if(jspUtil.is(Boolean.TRUE, "start_export")) { %> + <div class="form-group"> + <label for="log">LOG</label> + <textarea class="form-control" id="log" readonly="readonly" rows="5"></textarea> + </div> +<% } %> + + +</c:param> + +</c:import> + diff --git a/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp b/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp index 2ca9cb252..817486f16 100644 --- a/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp +++ b/src/main/webapp/WEB-INF/views/admin/database/reindexing.jsp @@ -40,7 +40,7 @@ window.onload = function() { ); } webSocket.onmessage = function(message) { - console.log('[RECEIVE] '); + //console.log('[RECEIVE] '); var result = JSON.parse(message.data); console.log(result); $('#log').val($('#log').val() + result.message + "\n"); diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp index 3fe1a15ac..bfa97574a 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp @@ -145,6 +145,11 @@ <i class="fa fa-refresh"></i> <%= jspUtil.label("knowledge.navbar.data.reindexing") %> </a> </li> + <li > + <a href="<%= request.getContextPath() %>/admin.database/export" style="cursor: pointer;"> + <i class="fa fa-external-link"></i> <%= jspUtil.label("knowledge.navbar.data.export") %> + </a> + </li> </ul> @@ -178,7 +183,7 @@ <li class="divider"></li> <li id="tabLogout"> - <a href="<%= request.getContextPath() %>/signout" style="cursor: pointer;"> + <a id="menuSignout" href="<%= request.getContextPath() %>/signout" style="cursor: pointer;"> <i class="fa fa-sign-out"></i> <%= jspUtil.label("knowledge.navbar.signout") %> </a> </li> @@ -186,7 +191,7 @@ </li> <% } else { %> <li> - <a href="<%= request.getContextPath() %>/signin?page=<%= top %>" style="cursor: pointer;"> + <a id="menuSignin" href="<%= request.getContextPath() %>/signin?page=<%= top %>" style="cursor: pointer;"> <i class="fa fa-sign-in"></i> <%= jspUtil.label("knowledge.navbar.signin") %> </a> </li> diff --git a/src/main/webapp/WEB-INF/views/index/index.jsp b/src/main/webapp/WEB-INF/views/index/index.jsp index 2de6d9bae..6c306332b 100644 --- a/src/main/webapp/WEB-INF/views/index/index.jsp +++ b/src/main/webapp/WEB-INF/views/index/index.jsp @@ -148,7 +148,7 @@ <h1><i class="fa fa-book"></i> Knowledge</h1> <h2>Free Knowledge Base System</h2> <br/> - <a class="btn btn-info btn-lg" role="button" + <a id="showlist" class="btn btn-info btn-lg" role="button" href="<%=request.getContextPath()%>/open.knowledge/list"> <i class="fa fa-diamond"></i> <%=jspUtil.label("knowledge.top.use.button")%> </a> diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp new file mode 100644 index 000000000..0690ba6c8 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp @@ -0,0 +1,90 @@ +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" + errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% + JspUtil jspUtil = new JspUtil(request, pageContext); +%> + +<c:import url="/WEB-INF/views/commons/layout/layoutMain.jsp"> + + <c:param name="PARAM_HEAD"> + </c:param> + + <c:param name="PARAM_SCRIPTS"> + </c:param> + + <c:param name="PARAM_CONTENT"> + <h4 class="title"><%= jspUtil.label("knowledge.histories.title") %> + page[<%= jspUtil.getValue("page", Integer.class) + 1 %>] + </h4> + + <nav> + <ul class="pager"> + <li class="previous"> + <a href="<%= request.getContextPath() %>/open.knowledge/histories/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>&page=<%= jspUtil.out("previous") %>"> + <span aria-hidden="true">←</span><%= jspUtil.label("label.previous") %> + </a> + </li> + <li class="next"> + <a href="<%= request.getContextPath() %>/open.knowledge/histories/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>&page=<%= jspUtil.out("next") %>"> + <%= jspUtil.label("label.next") %> <span aria-hidden="true">→</span> + </a> + </li> + </ul> + </nav> + + +<div class="list-group"> +<c:if test="${empty histories}"> +<%= jspUtil.label("knowledge.histories.list.label.empty") %> +</c:if> + +<c:forEach var="history" items="${histories}" varStatus="status"> + <a class="list-group-item" href="<%= request.getContextPath() %>/open.knowledge/history/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>&page=<%= jspUtil.out("page") %>&history_no=<%= jspUtil.out("history.historyNo") %>" > + <h4 class="list-group-item-heading"> + <%= jspUtil.out("history.historyNo") %> + <%= jspUtil.out("history.title") %> + </h4> + + <p class="list-group-item-text"> + <i class="fa fa-calendar"></i> <%= jspUtil.date("history.updateDatetime")%> + <i class="fa fa-user"></i> + <%= jspUtil.out("history.userName") %> + </p> + + </a> +</c:forEach> +</div> + + + <nav> + <ul class="pager"> + <li class="previous"> + <a href="<%= request.getContextPath() %>/open.knowledge/histories/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>&page=<%= jspUtil.out("previous") %>"> + <span aria-hidden="true">←</span><%= jspUtil.label("label.previous") %> + </a> + </li> + <li class="next"> + <a href="<%= request.getContextPath() %>/open.knowledge/histories/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>&page=<%= jspUtil.out("next") %>"> + <%= jspUtil.label("label.next") %> <span aria-hidden="true">→</span> + </a> + </li> + </ul> + </nav> + + <a href="<%= request.getContextPath() %>/open.knowledge/view/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>" + class="btn btn-warning" role="button"><i class="fa fa-undo"></i> <%= jspUtil.label("label.back") %> + </a> + + <a href="<%= request.getContextPath() %>/open.knowledge/list/<%= jspUtil.out("offset") %><%= jspUtil.out("params") %>" + class="btn btn-success" role="button"><i class="fa fa-list-ul"></i> <%= jspUtil.label("knowledge.view.back.list") %></a> + + + </c:param> + +</c:import> + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp new file mode 100644 index 000000000..05fd2e771 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp @@ -0,0 +1,51 @@ +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" + errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% + JspUtil jspUtil = new JspUtil(request, pageContext); +%> + +<c:import url="/WEB-INF/views/commons/layout/layoutMain.jsp"> + + <c:param name="PARAM_HEAD"> + </c:param> + + <c:param name="PARAM_SCRIPTS"> + </c:param> + + <c:param name="PARAM_CONTENT"> +<h4 class="title"><%= jspUtil.label("knowledge.histories.title") %></h4> + +<h5 class="sub_title"><%= jspUtil.label("knowledge.histories.label.diff") %></h5> +<pre><c:if test="${empty changes}"><%= jspUtil.label("knowledge.histories.list.label.empty") %></c:if> +<c:forEach var="change" items="${changes}" varStatus="status"><%= jspUtil.out("change") %></c:forEach> +</pre> + +<br/> +<h5 class="sub_title"><%= jspUtil.label("knowledge.histories.label.history") %></h5> +<div class="form-group"> + <label for="input_content"><%= jspUtil.label("knowledge.add.label.content") %></label> + <textarea class="form-control" name="content" rows="5" placeholder="<%= jspUtil.label("knowledge.add.label.content") %>" id="content" readonly="readonly"><%= jspUtil.out("history.content") %></textarea> +</div> + +<br/> +<h5 class="sub_title"><%= jspUtil.label("knowledge.histories.label.now") %></h5> +<div class="form-group"> + <label for="input_content"><%= jspUtil.label("knowledge.add.label.content") %></label> + <textarea class="form-control" name="content" rows="5" placeholder="<%= jspUtil.label("knowledge.add.label.content") %>" id="content" readonly="readonly"><%= jspUtil.out("now.content") %></textarea> +</div> + + + +<a href="<%= request.getContextPath() %>/open.knowledge/histories/<%= jspUtil.out("knowledgeId") %><%= jspUtil.out("params") %>&page=<%= jspUtil.out("page") %>" + class="btn btn-warning" role="button"><i class="fa fa-undo"></i> <%= jspUtil.label("label.back") %> +</a> + + </c:param> + +</c:import> + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp index c61a2f591..9454ed42f 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp @@ -76,7 +76,7 @@ </ul> </nav> - <div class="row"> + <div class="row" id="knowledgeList"> <div class="col-sm-12 col-md-8"> <c:if test="${empty knowledges}"> <%= jspUtil.label("knowledge.list.empty") %> diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp index 2ae29839e..111ab50dc 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/view.jsp @@ -15,6 +15,7 @@ <link rel="stylesheet" href="<%= request.getContextPath() %>/bower/bootstrap-tagsinput/dist/bootstrap-tagsinput.css" /> <link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/knowledge-edit.css") %>" /> <link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/knowledge-view.css") %>" /> +<link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/markdown.css") %>" /> </c:param> <c:param name="PARAM_SCRIPTS"> @@ -70,8 +71,11 @@ var LABEL_LIKE = '<%= jspUtil.label("knowledge.view.like") %>'; data-echo="<%= request.getContextPath()%>/open.account/icon/<%= jspUtil.out("insertUser") %>" alt="icon" width="36" height="36" style="float:left" /> + <a href="<%= request.getContextPath() %>/open.knowledge/histories/<%= jspUtil.out("knowledgeId") %>"> <i class="fa fa-calendar" style="margin-left: 5px;"></i> <%= jspUtil.date("updateDatetime")%> + </a> + <%= jspUtil.is(String.valueOf(KnowledgeLogic.PUBLIC_FLAG_PUBLIC), "publicFlag", jspUtil.label("label.public.view")) %> <%= jspUtil.is(String.valueOf(KnowledgeLogic.PUBLIC_FLAG_PRIVATE), "publicFlag", @@ -99,7 +103,7 @@ var LABEL_LIKE = '<%= jspUtil.label("knowledge.view.like") %>'; </p> </c:forEach> - <p style="word-break:break-all" id="content"> + <p style="word-break:break-all" id="content" class="markdown"> </p> </div> diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp index 1b3c4d444..89a7ec16f 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/view_add.jsp @@ -14,6 +14,7 @@ <link rel="stylesheet" href="<%= request.getContextPath() %>/bower/jquery-file-upload/css/jquery.fileupload.css" /> <link rel="stylesheet" href="<%= request.getContextPath() %>/bower/jquery-file-upload/css/jquery.fileupload-ui.css" /> <link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/knowledge-edit.css") %>" /> +<link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/markdown.css") %>" /> </c:param> <c:param name="PARAM_SCRIPTS"> @@ -148,7 +149,7 @@ selectedGroups.push({label: '<%= jspUtil.out("group.label") %>', value: '<%= jsp -<p class="preview" id="preview"></p> +<p class="preview markdown" id="preview"></p> diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp index 6542b53a4..816d94881 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/view_edit.jsp @@ -14,6 +14,7 @@ <link rel="stylesheet" href="<%= request.getContextPath() %>/bower/jquery-file-upload/css/jquery.fileupload.css" /> <link rel="stylesheet" href="<%= request.getContextPath() %>/bower/jquery-file-upload/css/jquery.fileupload-ui.css" /> <link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/knowledge-edit.css") %>" /> +<link rel="stylesheet" href="<%= jspUtil.mustReloadFile("/css/markdown.css") %>" /> </c:param> <c:param name="PARAM_SCRIPTS"> @@ -156,7 +157,7 @@ selectedGroups.push({label: '<%= jspUtil.out("group.label") %>', value: '<%= jsp </form> -<p class="preview" id="preview"></p> +<p class="preview markdown" id="preview"></p> diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 40b216bbf..2f6b1bdcc 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -9,6 +9,9 @@ <display-name>knowledge</display-name> + <listener> + <listener-class>org.support.project.knowledge.listener.GlobalInitializationListener</listener-class> + </listener> <listener> <listener-class>org.support.project.web.listener.H2DBManagerListener</listener-class> </listener> diff --git a/src/main/webapp/css/knowledge-edit.css b/src/main/webapp/css/knowledge-edit.css index c96792306..75db9cc6c 100644 --- a/src/main/webapp/css/knowledge-edit.css +++ b/src/main/webapp/css/knowledge-edit.css @@ -26,3 +26,10 @@ -webkit-border-radius: 10px; /* Safari,Google Chrome用 */ -moz-border-radius: 10px; /* Firefox用 */ } + + +@media only screen and (max-width:767px){ + .radio-inline { + margin-left: 10px; + } +} diff --git a/src/main/webapp/css/markdown.css b/src/main/webapp/css/markdown.css new file mode 100644 index 000000000..d52ae5fd6 --- /dev/null +++ b/src/main/webapp/css/markdown.css @@ -0,0 +1,410 @@ +.markdown a { + color: #4183C4; +} + +.markdown a.absent { + color: #cc0000; +} + +.markdown a.anchor { + display: block; + padding-left: 30px; + margin-left: -30px; + cursor: pointer; + position: absolute; + top: 0; + left: 0; + bottom: 0; +} + +.markdown h1, +.markdown h2, +.markdown h3, +.markdown h4, +.markdown h5, +.markdown h6 { + margin: 20px 0 10px; + padding: 0; + font-weight: bold; + -webkit-font-smoothing: antialiased; + cursor: text; + position: relative; +} + +.markdown h1:hover a.anchor, +.markdown h2:hover a.anchor, +.markdown h3:hover a.anchor, +.markdown h4:hover a.anchor, +.markdown h5:hover a.anchor, +.markdown h6:hover a.anchor { + background: url("../../images/modules/styleguide/para.png") no-repeat + 10px center; + text-decoration: none; +} + +.markdown h1 tt, +.markdown h1 code { + font-size: inherit; +} + +.markdown h2 tt, +.markdown h2 code { + font-size: inherit; +} + +.markdown h3 tt, +.markdown h3 code { + font-size: inherit; +} + +.markdown h4 tt, +.markdown h4 code { + font-size: inherit; +} + +.markdown h5 tt, +.markdown h5 code { + font-size: inherit; +} + +.markdown h6 tt, +.markdown h6 code { + font-size: inherit; +} + +.markdown h1 { + font-size: 28px; + color: black; +} + +.markdown h2 { + font-size: 24px; + border-bottom: 1px solid #cccccc; + color: black; +} + +.markdown h3 { + font-size: 18px; +} + +.markdown h4 { + font-size: 16px; +} + +.markdown h5 { + font-size: 14px; +} + +.markdown h6 { + color: #777777; + font-size: 14px; +} + +.markdown p, +.markdown blockquote, +.markdown ul, +.markdown ol, +.markdown dl, +.markdown li, +.markdown table, +.markdown pre { + margin: 15px 0; +} + +.markdown hr { + background: transparent + url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0; + border: 0 none; + color: #cccccc; + height: 4px; + padding: 0; +} + +.markdown >h2:first-child { + margin-top: 0; + padding-top: 0; +} + +.markdown >h1:first-child { + margin-top: 0; + padding-top: 0; +} + +.markdown >h1:first-child+h2 { + margin-top: 0; + padding-top: 0; +} + +.markdown >h3:first-child, +.markdown >h4:first-child, +.markdown >h5:first-child, +.markdown >h6:first-child + { + margin-top: 0; + padding-top: 0; +} + +.markdown a:first-child h1, +.markdown a:first-child h2, +.markdown a:first-child h3, +.markdown a:first-child h4, +.markdown a:first-child h5, +.markdown a:first-child h6 { + margin-top: 0; + padding-top: 0; +} + +.markdown h1 p, +.markdown h2 p, +.markdown h3 p, +.markdown h4 p, +.markdown h5 p, +.markdown h6 p { + margin-top: 0; +} + +.markdown li p.first { + display: inline-block; +} + +.markdown ul, +.markdown ol { + padding-left: 30px; +} + +.markdown ul :first-child, +.markdown ol :first-child { + margin-top: 0; +} + +.markdown ul :last-child, +.markdown ol :last-child { + margin-bottom: 0; +} + +.markdown dl { + padding: 0; +} + +.markdown dl dt { + font-size: 14px; + font-weight: bold; + font-style: italic; + padding: 0; + margin: 15px 0 5px; +} + +.markdown dl dt:first-child { + padding: 0; +} + +.markdown dl dt>:first-child { + margin-top: 0; +} + +.markdown dl dt>:last-child { + margin-bottom: 0; +} + +.markdown dl dd { + margin: 0 0 15px; + padding: 0 15px; +} + +.markdown dl dd>:first-child { + margin-top: 0; +} + +.markdown dl dd>:last-child { + margin-bottom: 0; +} + +.markdown blockquote { + border-left: 4px solid #dddddd; + padding: 0 15px; + color: #777777; +} + +.markdown blockquote>:first-child { + margin-top: 0; +} + +.markdown blockquote>:last-child { + margin-bottom: 0; +} + +.markdown table { + padding: 0; +} + +.markdown table tr { + border-top: 1px solid #cccccc; + background-color: white; + margin: 0; + padding: 0; +} + +.markdown table tr:nth-child(2n) { + background-color: #f8f8f8; +} + +.markdown table tr th { + font-weight: bold; + border: 1px solid #cccccc; + text-align: left; + margin: 0; + padding: 6px 13px; +} + +.markdown table tr td { + border: 1px solid #cccccc; + text-align: left; + margin: 0; + padding: 6px 13px; +} + +.markdown table tr th :first-child, +.markdown table tr td :first-child { + margin-top: 0; +} + +.markdown table tr th :last-child, +.markdown table tr td :last-child { + margin-bottom: 0; +} + +.markdown img { + max-width: 100%; +} + +.markdown span.frame { + display: block; + overflow: hidden; +} + +.markdown span.frame>span { + border: 1px solid #dddddd; + display: block; + float: left; + overflow: hidden; + margin: 13px 0 0; + padding: 7px; + width: auto; +} + +.markdown span.frame span img { + display: block; + float: left; +} + +.markdown span.frame span span { + clear: both; + color: #333333; + display: block; + padding: 5px 0 0; +} + +.markdown span.align-center { + display: block; + overflow: hidden; + clear: both; +} + +.markdown span.align-center>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: center; +} + +.markdown span.align-center span img { + margin: 0 auto; + text-align: center; +} + +.markdown span.align-right { + display: block; + overflow: hidden; + clear: both; +} + +.markdown span.align-right>span { + display: block; + overflow: hidden; + margin: 13px 0 0; + text-align: right; +} + +.markdown span.align-right span img { + margin: 0; + text-align: right; +} + +.markdown span.float-left { + display: block; + margin-right: 13px; + overflow: hidden; + float: left; +} + +.markdown span.float-left span { + margin: 13px 0 0; +} + +.markdown span.float-right { + display: block; + margin-left: 13px; + overflow: hidden; + float: right; +} + +.markdown span.float-right>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: right; +} + +.markdown code, +.markdown tt { + margin: 0 2px; + padding: 0 5px; + white-space: nowrap; + border: 1px solid #eaeaea; + background-color: #f8f8f8; + border-radius: 3px; +} + +.markdown pre code { + margin: 0; + padding: 0; + white-space: pre; + border: none; + background: transparent; +} + +.markdown .highlight pre { + background-color: #f8f8f8; + border: 1px solid #cccccc; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} + +.markdown pre { + background-color: #f8f8f8; + border: 1px solid #cccccc; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} + +.markdown pre code, +.markdown pre tt { + background-color: transparent; + border: none; +} diff --git a/src/main/webapp/js/knowledge-edit.js b/src/main/webapp/js/knowledge-edit.js index d3ea4e32d..e9252b4c3 100644 --- a/src/main/webapp/js/knowledge-edit.js +++ b/src/main/webapp/js/knowledge-edit.js @@ -206,7 +206,7 @@ var removeAddedFile = function(fileNo) { var preview = function() { - $.get(_CONTEXT + '/open.knowledge/escape', { + $.post(_CONTEXT + '/open.knowledge/escape', { title : $('#input_title').val(), content : $('#content').val() }, function(data) { @@ -226,6 +226,9 @@ var preview = function() { html += '</div>'; $('#preview').html(html); + $('#preview').each(function(i, block) { + hljs.highlightBlock(block); + }); }); };