From 59fb9c4c80b5576c63023b642ffbaa189efff30e Mon Sep 17 00:00:00 2001 From: Koda Date: Mon, 27 Jul 2015 06:34:18 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E3=81=8C=E5=B1=8A=E3=81=8B=E3=81=AA=E3=81=84=20#64=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=83=A1=E3=83=BC=E3=83=AB=E3=81=AF=E3=81=BE=E3=81=A8?= =?UTF-8?q?=E3=82=81=E3=81=A6=E5=87=BA=E3=81=99=20#75=20=E3=82=B0=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=97=E3=81=AE=E3=83=A1=E3=83=B3=E3=83=90=E3=83=BC?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=8C10=E4=BB=B6=E3=81=97=E3=81=8B?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E5=87=BA=E6=9D=A5=E3=81=AA=E3=81=84=20#70?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/knowledge/bat/AbstractBat.java | 6 +- .../project/knowledge/bat/FileParseBat.java | 65 ++++++------ .../knowledge/bat/KnowledgeFileClearBat.java | 26 +++++ .../project/knowledge/bat/MailSendBat.java | 2 + .../project/knowledge/bat/NotifyMailBat.java | 43 +++++++- .../knowledge/config/SystemConfig.java | 8 ++ .../control/admin/ConfigControl.java | 23 +++++ .../control/admin/DatabaseControl.java | 3 + .../knowledge/control/admin/LdapControl.java | 3 + .../knowledge/control/admin/MailControl.java | 3 + .../control/protect/AccountControl.java | 5 + .../control/protect/GroupControl.java | 11 +++ .../control/protect/TargetControl.java | 5 +- .../knowledge/dao/NotifyQueuesDao.java | 13 ++- .../project/knowledge/deploy/InitDB.java | 6 +- .../deploy/v0_5_3pre2/Migrate_0_5_3pre2.java | 4 - .../deploy/v0_5_3pre3/Migrate_0_5_3pre3.java | 30 ++++++ .../CloseAbleAuthenticationFilter.java | 98 +++++++++++++++++++ .../knowledge/listener/CronListener.java | 6 +- .../project/knowledge/logic/AccountLogic.java | 4 + .../knowledge/logic/CompressLogic.java | 3 + .../knowledge/logic/DataTransferLogic.java | 3 + .../knowledge/logic/DatabaseLogic.java | 3 + .../project/knowledge/logic/DiffLogic.java | 3 + .../project/knowledge/logic/GroupLogic.java | 3 + .../project/knowledge/logic/IndexLogic.java | 3 + .../knowledge/logic/KnowledgeLogic.java | 13 ++- .../project/knowledge/logic/MailLogic.java | 3 + .../project/knowledge/logic/NotifyLogic.java | 25 ++++- .../logic/PasswordInitializationLogic.java | 16 +-- .../knowledge/logic/SystemConfigLogic.java | 21 +++- .../project/knowledge/logic/TagLogic.java | 3 + .../project/knowledge/logic/TargetLogic.java | 3 + .../knowledge/logic/UploadedFileLogic.java | 3 + .../project/knowledge/logic/UserLogic.java | 3 + src/main/resources/appresource.properties | 10 +- src/main/resources/appresource_ja.properties | 10 +- src/main/resources/log4j.xml | 2 +- .../dao/sql/ExUsersDao/selectGroupUser.sql | 12 +-- .../ExUsersDao/selectNotifyPublicUsers.sql | 2 +- .../WEB-INF/views/admin/config/system.jsp | 20 ++++ .../WEB-INF/views/admin/users/view_add.jsp | 7 ++ .../WEB-INF/views/admin/users/view_edit.jsp | 10 +- .../views/protect/group/view_group.jsp | 39 +++++++- src/main/webapp/WEB-INF/web.xml | 6 +- 45 files changed, 507 insertions(+), 83 deletions(-) create mode 100644 src/main/java/org/support/project/knowledge/deploy/v0_5_3pre3/Migrate_0_5_3pre3.java create mode 100644 src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java 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 948560bc8..02c3f3b08 100644 --- a/src/main/java/org/support/project/knowledge/bat/AbstractBat.java +++ b/src/main/java/org/support/project/knowledge/bat/AbstractBat.java @@ -24,8 +24,10 @@ protected static void configInit(String batName) { AppConfig.initEnvKey(SystemConfig.KNOWLEDGE_ENV_KEY); String envValue = System.getenv(SystemConfig.KNOWLEDGE_ENV_KEY); LOG.info(batName + " is start."); - LOG.info("Env [" + SystemConfig.KNOWLEDGE_ENV_KEY + "] is [" + envValue + "]."); - LOG.info("Config :" + PropertyUtil.reflectionToString(AppConfig.get())); + if (LOG.isDebugEnabled()) { + LOG.debug("Env [" + SystemConfig.KNOWLEDGE_ENV_KEY + "] is [" + envValue + "]."); + LOG.debug("Config :" + PropertyUtil.reflectionToString(AppConfig.get())); + } } /** 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 7e9f2d9dc..8a8061edb 100644 --- a/src/main/java/org/support/project/knowledge/bat/FileParseBat.java +++ b/src/main/java/org/support/project/knowledge/bat/FileParseBat.java @@ -36,6 +36,7 @@ public class FileParseBat extends AbstractBat { public static final int PARSE_STATUS_WAIT = 0; public static final int PARSE_STATUS_PARSING = 1; + public static final int PARSE_STATUS_ERROR_FINISHED = -100; public static final int PARSE_STATUS_PARSED = 100; public static final int PARSE_STATUS_NO_TARGET = -1; @@ -52,10 +53,10 @@ public static void main(String[] args) throws Exception { FileParseBat bat = new FileParseBat(); bat.dbInit(); bat.start(); + LOG.info("finished"); } private void start() throws Exception { - LOG.info("start"); KnowledgeFilesDao filesDao = KnowledgeFilesDao.get(); IndexLogic indexLogic = IndexLogic.get(); KnowledgesDao knowledgesDao = KnowledgesDao.get(); @@ -70,7 +71,8 @@ private void start() throws Exception { // ナレッジを取得 KnowledgesEntity knowledgesEntity = knowledgesDao.selectOnKey(knowledgeFilesEntity.getKnowledgeId()); if (knowledgesEntity == null) { - // 紐づくナレッジが存在していないのであれば解析はしない + // 紐づくナレッジが存在していないのであれば解析はしない(例えば、一度添付ファイル付きのナレッジを登録後、ナレッジを削除した場合) + // ナレッジに紐づいていないファイルで、かつ更新日が24時間前のものは削除される filesDao.changeStatus(knowledgeFilesEntity.getFileNo(), PARSE_STATUS_NO_TARGET, UPDATE_USER_ID); continue; } @@ -110,33 +112,40 @@ private void start() throws Exception { // パースステータスをパース中(1)に変更(もしパースでエラーが発生しても、次回から対象外になる) filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_PARSING, UPDATE_USER_ID); - // パースを実行 - Parser parser = ParserFactory.getParser(tmp.getAbsolutePath()); - ParseResult result = parser.parse(tmp); - LOG.info("content text(length): " + result.getText().length()); - - // 全文検索エンジンへ登録 - IndexingValue value = new IndexingValue(); - value.setType(TYPE_FILE); - value.setId(ID_PREFIX + entity.getFileNo()); - value.setTitle(entity.getFileName()); - value.setContents(result.getText()); - value.addUser(entity.getInsertUser()); - if (knowledgesEntity.getPublicFlag() == null - || KnowledgeLogic.PUBLIC_FLAG_PUBLIC == knowledgesEntity.getPublicFlag()) { - value.addUser(KnowledgeLogic.ALL_USER); - } - for (TagsEntity tagsEntity : tagsEntities) { - value.addTag(tagsEntity.getTagId()); + try { + // パースを実行 + Parser parser = ParserFactory.getParser(tmp.getAbsolutePath()); + ParseResult result = parser.parse(tmp); + LOG.info("content text(length): " + result.getText().length()); + + // 全文検索エンジンへ登録 + IndexingValue value = new IndexingValue(); + value.setType(TYPE_FILE); + value.setId(ID_PREFIX + entity.getFileNo()); + value.setTitle(entity.getFileName()); + value.setContents(result.getText()); + value.addUser(entity.getInsertUser()); + if (knowledgesEntity.getPublicFlag() == null + || KnowledgeLogic.PUBLIC_FLAG_PUBLIC == knowledgesEntity.getPublicFlag()) { + value.addUser(KnowledgeLogic.ALL_USER); + } + for (TagsEntity tagsEntity : tagsEntities) { + value.addTag(tagsEntity.getTagId()); + } + value.setCreator(entity.getInsertUser()); + value.setTime(entity.getUpdateDatetime().getTime()); // 更新日時をセットするので、更新日時でソート + indexLogic.save(value); + + // パースステータスをパース完了に変更(もしパースでエラーが発生しても、次回から対象外になる) + filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_PARSED, UPDATE_USER_ID); + + } catch (Exception e) { + // パースの解析でなんらかのエラー + filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_ERROR_FINISHED, UPDATE_USER_ID); + LOG.error("File parse error.", e); + throw e; } - value.setCreator(entity.getInsertUser()); - value.setTime(entity.getUpdateDatetime().getTime()); // 更新日時をセットするので、更新日時でソート - indexLogic.save(value); - - // パースステータスをパース完了に変更(もしパースでエラーが発生しても、次回から対象外になる) - filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_PARSED, UPDATE_USER_ID); - - // 正常に終了すれば、テンポラリを削除 + // 終了すれば、テンポラリを削除 tmp.delete(); LOG.info("deleteed: " + tmp.getAbsolutePath()); } 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 df9824a7d..ac7576fea 100644 --- a/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java +++ b/src/main/java/org/support/project/knowledge/bat/KnowledgeFileClearBat.java @@ -1,9 +1,17 @@ package org.support.project.knowledge.bat; +import java.util.List; + import org.apache.commons.lang.ClassUtils; +import org.support.project.common.config.Flag; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.NumberUtils; import org.support.project.knowledge.dao.KnowledgeFilesDao; +import org.support.project.knowledge.dao.NotifyQueuesDao; +import org.support.project.knowledge.entity.NotifyQueuesEntity; +import org.support.project.web.dao.MailsDao; +import org.support.project.web.entity.MailsEntity; public class KnowledgeFileClearBat extends AbstractBat { @@ -17,6 +25,7 @@ public static void main(String[] args) { KnowledgeFileClearBat bat = new KnowledgeFileClearBat(); bat.dbInit(); bat.start(); + LOG.info("finished"); } private void start() { @@ -25,6 +34,23 @@ private void start() { if (count > 0) { LOG.debug("Knowledge Files deleted. Count: " + count + ""); } + + // メール送信とNotifyのゴミ情報をクリア + List notifyQueuesEntities = NotifyQueuesDao.get().physicalSelectAll(); + for (NotifyQueuesEntity notifyQueuesEntity : notifyQueuesEntities) { + if (Flag.is(notifyQueuesEntity.getDeleteFlag())) { + // 削除フラグはONになっているのに、物理削除していないものは物理削除する(とっておいてもしかたない) + NotifyQueuesDao.get().physicalDelete(notifyQueuesEntity); + } + } + + List mailsEntities = MailsDao.get().physicalSelectAll(); + for (MailsEntity mailsEntity : mailsEntities) { + if (NumberUtils.is(mailsEntity.getStatus(), MailSendBat.MAIL_STATUS_SENDED)) { + // 送信済みになっているものは、削除 + MailsDao.get().physicalDelete(mailsEntity); + } + } } } 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 5816969f2..0f4f70acf 100644 --- a/src/main/java/org/support/project/knowledge/bat/MailSendBat.java +++ b/src/main/java/org/support/project/knowledge/bat/MailSendBat.java @@ -89,6 +89,8 @@ public void start() throws UnsupportedEncodingException, MessagingException, Inv for (MailsEntity mailsEntity : entities) { if (mailsEntity.getToAddress().matches(MAIL_FORMAT)) { mailSend(mailConfigsEntity, mailsEntity); + // 正常に送信できたら、物理削除 + dao.physicalDelete(mailsEntity); } else { mailsEntity.setStatus(MAIL_STATUS_FORMAT_ERROR); dao.save(mailsEntity); 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 31825455c..291516ac4 100644 --- a/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java +++ b/src/main/java/org/support/project/knowledge/bat/NotifyMailBat.java @@ -45,11 +45,14 @@ public class NotifyMailBat extends AbstractBat { /** ログ */ - private static Log LOG = LogFactory.getLog(MailSendBat.class); + private static Log LOG = LogFactory.getLog(NotifyMailBat.class); private static final String MAIL_CONFIG_DIR = "/org/support/project/knowledge/mail/"; private static final DateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); - + + private List sendedCommentKnowledgeIds = new ArrayList<>(); + private List sendedLikeKnowledgeIds = new ArrayList<>(); + public static void main(String[] args) throws Exception { initLogName("NotifyMailBat.log"); configInit(ClassUtils.getShortClassName(NotifyMailBat.class)); @@ -57,6 +60,7 @@ public static void main(String[] args) throws Exception { NotifyMailBat bat = new NotifyMailBat(); bat.dbInit(); bat.start(); + LOG.info("finished"); } /** @@ -75,8 +79,8 @@ private void start() { notifyLikeInsert(notifyQueuesEntity); } // 通知のキューから削除 - notifyQueuesDao.delete(notifyQueuesEntity); - //notifyQueuesDao.physicalDelete(notifyQueuesEntity); + //notifyQueuesDao.delete(notifyQueuesEntity); + notifyQueuesDao.physicalDelete(notifyQueuesEntity); // とっておいてもしょうがないので物理削除 } LOG.info("Notify process finished. count: " + notifyQueuesEntities.size()); } @@ -114,6 +118,15 @@ private void notifyLikeInsert(NotifyQueuesEntity notifyQueuesEntity) { KnowledgesDao knowledgesDao = KnowledgesDao.get(); KnowledgesEntity knowledge = knowledgesDao.selectOnKey(like.getKnowledgeId()); + if (sendedLikeKnowledgeIds.contains(knowledge.getKnowledgeId())) { + if (LOG.isDebugEnabled()) { + LOG.debug("Knowledge [" + knowledge.getKnowledgeId() + "] "); + } + return; + } else { + sendedLikeKnowledgeIds.add(knowledge.getKnowledgeId()); + } + UsersDao usersDao = UsersDao.get(); UsersEntity likeUser = usersDao.selectOnKey(like.getInsertUser()); @@ -168,6 +181,10 @@ private void sendLikeMail(LikesEntity like, KnowledgesEntity knowledge, UsersEnt contents = contents.replace("{URL}", makeURL(knowledge)); mailsEntity.setContent(contents); + if (LOG.isDebugEnabled()) { + LOG.debug("News email has been registered. [type] Like added. [knowledge]" + knowledge.getKnowledgeId().toString() + + " [target] " + user.getMailAddress()); + } MailsDao.get().insert(mailsEntity); } @@ -181,6 +198,15 @@ private void notifyCommentInsert(NotifyQueuesEntity notifyQueuesEntity) { KnowledgesDao knowledgesDao = KnowledgesDao.get(); KnowledgesEntity knowledge = knowledgesDao.selectOnKey(comment.getKnowledgeId()); + if (sendedCommentKnowledgeIds.contains(knowledge.getKnowledgeId())) { + if (LOG.isDebugEnabled()) { + LOG.debug("Knowledge [" + knowledge.getKnowledgeId() + "] "); + } + return; + } else { + sendedCommentKnowledgeIds.add(knowledge.getKnowledgeId()); + } + UsersDao usersDao = UsersDao.get(); UsersEntity commentUser = usersDao.selectOnKey(comment.getInsertUser()); @@ -284,6 +310,10 @@ private void sendCommentMail(CommentsEntity comment, KnowledgesEntity knowledge, contents = contents.replace("{URL}", makeURL(knowledge)); mailsEntity.setContent(contents); + if (LOG.isDebugEnabled()) { + LOG.debug("News email has been registered. [type] comment added. [knowledge]" + knowledge.getKnowledgeId().toString() + + " [target] " + user.getMailAddress()); + } MailsDao.get().insert(mailsEntity); } @@ -441,6 +471,11 @@ private void insertNotifyKnowledgeUpdateMailQue(KnowledgesEntity knowledge, User contents = contents.replace("{URL}", makeURL(knowledge)); mailsEntity.setContent(contents); + + if (LOG.isDebugEnabled()) { + LOG.debug("News email has been registered. [type] knowledge update. [knowledge]" + knowledge.getKnowledgeId().toString() + + " [target] " + usersEntity.getMailAddress()); + } MailsDao.get().insert(mailsEntity); } 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 05519b667..5e9177e21 100644 --- a/src/main/java/org/support/project/knowledge/config/SystemConfig.java +++ b/src/main/java/org/support/project/knowledge/config/SystemConfig.java @@ -29,4 +29,12 @@ public class SystemConfig { /** エクスポートのための設定値 */ public static final String DATA_EXPORT = "DATA_EXPORT"; + /** 「公開」の情報であれば、ログインしなくても参照出来る */ + public static final String SYSTEM_EXPOSE_TYPE = "SYSTEM_EXPOSE_TYPE"; + /** 「公開」の情報であれば、ログインしなくても参照出来る */ + public static final String SYSTEM_EXPOSE_TYPE_OPEN = "OPEN"; + /** 全ての機能は、ログインしないとアクセス出来ない */ + public static final String SYSTEM_EXPOSE_TYPE_CLOSE = "CLOSE"; + + } 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 00aaddb24..256e1423a 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 @@ -5,9 +5,12 @@ import org.support.project.common.bean.ValidateError; import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; import org.support.project.knowledge.control.Control; +import org.support.project.knowledge.logic.SystemConfigLogic; import org.support.project.web.annotation.Auth; import org.support.project.web.boundary.Boundary; import org.support.project.web.common.HttpUtil; @@ -20,6 +23,7 @@ import org.support.project.web.entity.MailConfigsEntity; import org.support.project.web.entity.SystemConfigsEntity; +@DI(instance=Instance.Prototype) public class ConfigControl extends Control { /** @@ -115,6 +119,12 @@ public Boundary system() { dao.save(config); } setAttribute("systemurl", config.getConfigValue()); + + config = dao.selectOnKey(SystemConfig.SYSTEM_EXPOSE_TYPE, AppConfig.get().getSystemName()); + if (config != null) { + setAttribute("system_open_type", config.getConfigValue()); + } + return forward("system.jsp"); } @@ -143,6 +153,19 @@ public Boundary save_params() { config.setConfigValue(systemurl); dao.save(config); + String system_open_type = getParam("system_open_type"); + if (StringUtils.isNotEmpty(system_open_type)) { + config = new SystemConfigsEntity(SystemConfig.SYSTEM_EXPOSE_TYPE, AppConfig.get().getSystemName()); + config.setConfigValue(system_open_type); + dao.save(config); + + if (SystemConfig.SYSTEM_EXPOSE_TYPE_CLOSE.equals(system_open_type)) { + SystemConfigLogic.get().setClose(true); + } else { + SystemConfigLogic.get().setClose(false); + } + } + String successMsg = "message.success.save"; setResult(successMsg, errors); 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 f0fca035d..183713583 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 @@ -18,6 +18,8 @@ import org.support.project.common.serialize.SerializeUtils; import org.support.project.common.wrapper.FileInputStreamWithDeleteWrapper; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.bat.CreateExportDataBat; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; @@ -40,6 +42,7 @@ import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.logic.DBConnenctionLogic; +@DI(instance=Instance.Prototype) public class DatabaseControl extends Control { /* (non-Javadoc) diff --git a/src/main/java/org/support/project/knowledge/control/admin/LdapControl.java b/src/main/java/org/support/project/knowledge/control/admin/LdapControl.java index 2019e92c3..e776a7096 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/LdapControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/LdapControl.java @@ -16,6 +16,8 @@ import org.support.project.common.config.INT_FLAG; import org.support.project.common.util.PasswordUtil; import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.control.Control; import org.support.project.web.annotation.Auth; @@ -28,6 +30,7 @@ import org.support.project.web.exception.InvalidParamException; import org.support.project.web.logic.LdapLogic; +@DI(instance=Instance.Prototype) public class LdapControl extends Control { private static final String NO_CHANGE_PASSWORD = "NO_CHANGE_PASSWORD-fXLSJ_V-ZJ2E-X6c2_iGCpkE"; //パスワードを更新しなかったことを表すパスワード 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 55e31e32b..a04224512 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 @@ -13,6 +13,8 @@ import org.support.project.common.config.INT_FLAG; import org.support.project.common.util.PasswordUtil; import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.control.Control; import org.support.project.web.annotation.Auth; @@ -22,6 +24,7 @@ import org.support.project.web.dao.MailConfigsDao; import org.support.project.web.entity.MailConfigsEntity; +@DI(instance=Instance.Prototype) public class MailControl extends Control { /** 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 b224d7734..1168d709a 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 @@ -135,6 +135,11 @@ public Boundary update() throws ParseException { user.setPassword(getParam("password")); user.setEncrypted(false); } + if (StringUtils.isEmpty(user.getMailAddress())) { + if (StringUtils.isEmailAddress(user.getUserKey())) { + user.setMailAddress(user.getUserKey()); + } + } dao.update(user); } String successMsg = "message.success.update"; 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 87b3cd417..8d9196d04 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 @@ -10,6 +10,8 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.util.RandomUtil; import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.control.Control; import org.support.project.knowledge.logic.GroupLogic; import org.support.project.knowledge.vo.GroupUser; @@ -27,6 +29,7 @@ import org.support.project.web.entity.UserGroupsEntity; import org.support.project.web.exception.InvalidParamException; +@DI(instance=Instance.Prototype) public class GroupControl extends Control { /** ログ */ private static Log LOG = LogFactory.getLog(GroupControl.class); @@ -159,6 +162,14 @@ public Boundary view() throws InvalidParamException { } } + int previous = offset -1; + if (previous < 0) { + previous = 0; + } + setAttribute("offset", offset); + setAttribute("previous", previous); + setAttribute("next", offset + 1); + setAttribute("users", users); setAttribute("belong", belong); 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 8a6577ae2..ead6721f5 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 @@ -1,19 +1,20 @@ package org.support.project.knowledge.control.protect; -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.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.control.Control; import org.support.project.knowledge.logic.TargetLogic; import org.support.project.web.bean.LabelValue; import org.support.project.web.boundary.Boundary; import org.support.project.web.control.service.Get; import org.support.project.web.exception.InvalidParamException; -import org.support.project.web.logic.UserLogic; +@DI(instance=Instance.Prototype) public class TargetControl extends Control { /** ログ */ private static Log LOG = LogFactory.getLog(GroupControl.class); diff --git a/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java b/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java index 240ceef37..cf2cc84ba 100644 --- a/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/NotifyQueuesDao.java @@ -3,8 +3,8 @@ 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.GenNotifyQueuesDao; +import org.support.project.knowledge.entity.NotifyQueuesEntity; /** * 通知待ちキュー @@ -22,6 +22,17 @@ public class NotifyQueuesDao extends GenNotifyQueuesDao { public static NotifyQueuesDao get() { return Container.getComp(NotifyQueuesDao.class); } + + /** + * 通知キューに、同一の通知種類/IDの情報が無いか検索する + * @param type + * @param id + * @return + */ + public NotifyQueuesEntity selectOnTypeAndId(Integer type, Long id) { + String sql = "SELECT * FROM NOTIFY_QUEUES WHERE TYPE = ? AND ID = ? AND DELETE_FLAG = 0"; + return super.executeQuerySingle(sql, NotifyQueuesEntity.class, type, id); + } 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 cbbeb0419..9a1ace59e 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitDB.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitDB.java @@ -13,6 +13,7 @@ import org.support.project.knowledge.deploy.v0_5_1.Migrate_0_5_1; import org.support.project.knowledge.deploy.v0_5_2pre2.Migrate_0_5_2pre2; import org.support.project.knowledge.deploy.v0_5_3pre2.Migrate_0_5_3pre2; +import org.support.project.knowledge.deploy.v0_5_3pre3.Migrate_0_5_3pre3; import org.support.project.web.dao.SystemsDao; import org.support.project.web.entity.SystemsEntity; @@ -25,7 +26,7 @@ public class InitDB { private static final Map MAP = new LinkedHashMap<>(); private static final Migrate INIT = InitializeSystem.get(); - public static final String CURRENT = "0.5.3.pre2"; + public static final String CURRENT = "0.5.3.pre3"; public InitDB() { super(); @@ -34,7 +35,8 @@ public InitDB() { MAP.put("0.5.0", Migrate_0_5_0.get()); // 通知設定 MAP.put("0.5.1", Migrate_0_5_1.get()); // ナレッジの更新履歴 MAP.put("0.5.2.pre2", Migrate_0_5_2pre2.get()); // 共同編集 - MAP.put(CURRENT, Migrate_0_5_3pre2.get()); // ALLグループ + MAP.put("0.5.3.pre2", Migrate_0_5_3pre2.get()); // ALLグループ + MAP.put(CURRENT, Migrate_0_5_3pre3.get()); // メールアドレス } public static void main(String[] args) throws Exception { diff --git a/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre2/Migrate_0_5_3pre2.java b/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre2/Migrate_0_5_3pre2.java index bc26ec506..abf23aee5 100644 --- a/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre2/Migrate_0_5_3pre2.java +++ b/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre2/Migrate_0_5_3pre2.java @@ -33,10 +33,6 @@ public boolean doMigrate() throws Exception { userGroupsEntity.setGroupId(0); //ALL userGroupsEntity.setGroupRole(CommonWebParameter.GROUP_ROLE_MEMBER); userGroupsDao.save(userGroupsEntity); - - if (StringUtils.isEmailAddress(usersEntity.getUserKey())) { - usersEntity.setMailAddress(usersEntity.getUserKey()); - } } return true; } diff --git a/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre3/Migrate_0_5_3pre3.java b/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre3/Migrate_0_5_3pre3.java new file mode 100644 index 000000000..bac0e7de5 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v0_5_3pre3/Migrate_0_5_3pre3.java @@ -0,0 +1,30 @@ +package org.support.project.knowledge.deploy.v0_5_3pre3; + +import java.util.List; + +import org.support.project.common.util.StringUtils; +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.UsersEntity; + +public class Migrate_0_5_3pre3 implements Migrate { + + public static Migrate_0_5_3pre3 get() { + return org.support.project.di.Container.getComp(Migrate_0_5_3pre3.class); + } + + @Override + public boolean doMigrate() throws Exception { + List users = UsersDao.get().selectAll(); + for (UsersEntity usersEntity : users) { + if (StringUtils.isEmailAddress(usersEntity.getUserKey())) { + usersEntity.setMailAddress(usersEntity.getUserKey()); + usersEntity.setEncrypted(true); + UsersDao.get().save(usersEntity); + } + } + return true; + } + + +} diff --git a/src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java b/src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java new file mode 100644 index 000000000..589acfdbd --- /dev/null +++ b/src/main/java/org/support/project/knowledge/listener/CloseAbleAuthenticationFilter.java @@ -0,0 +1,98 @@ +package org.support.project.knowledge.listener; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +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.logic.SystemConfigLogic; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.common.HttpUtil; +import org.support.project.web.dao.SystemConfigsDao; +import org.support.project.web.entity.SystemConfigsEntity; +import org.support.project.web.filter.AuthenticationFilter; + +public class CloseAbleAuthenticationFilter extends AuthenticationFilter { + + private Pattern pattern = null; + + /* (non-Javadoc) + * @see org.support.project.web.filter.AuthenticationFilter#init(javax.servlet.FilterConfig) + */ + @Override + public void init(FilterConfig filterconfig) throws ServletException { + SystemConfigsDao dao = SystemConfigsDao.get(); + SystemConfigsEntity config = dao.selectOnKey(SystemConfig.SYSTEM_EXPOSE_TYPE, AppConfig.get().getSystemName()); + if (config != null) { + if (SystemConfig.SYSTEM_EXPOSE_TYPE_CLOSE.equals(config.getConfigValue())) { + SystemConfigLogic.get().setClose(true); + } + } + String ignoreRegularExpression = filterconfig.getInitParameter("close-ignore-regular-expression"); + if (StringUtils.isNotEmpty(ignoreRegularExpression)) { + this.pattern = Pattern.compile(ignoreRegularExpression); + } + super.init(filterconfig); + } + + + + /* (non-Javadoc) + * @see org.support.project.web.filter.AuthenticationFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) + */ + @Override + public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) throws IOException, + ServletException { + if (SystemConfigLogic.get().isClose()) { + HttpServletRequest req = (HttpServletRequest) servletrequest; + HttpServletResponse res = (HttpServletResponse) servletresponse; + try { + if (!isLogin(req)) { + cookieLogin(req, res); + } + + if (!isLogin(req)) { + // ログインしていない + if (pattern != null) { + StringBuilder pathBuilder = new StringBuilder(); + pathBuilder.append(req.getServletPath()); + if (req.getPathInfo() != null && req.getPathInfo().length() > 0) { + pathBuilder.append(req.getPathInfo()); + } + String path = pathBuilder.toString(); + Matcher matcher = pattern.matcher(path); + if (!matcher.find() && !path.equals(getLoginProcess())) { + // 対象外でないし、ログインページへの遷移でない + String page = req.getParameter("page"); + req.setAttribute("page", page); + + res.setStatus(HttpStatus.SC_401_UNAUTHORIZED); + StringBuilder builder = new StringBuilder(); + builder.append(getLoginPage()); + HttpUtil.forward(res, req, builder.toString()); + return; + } + } + } + } catch (Exception e) { + throw new ServletException(e); + } + } + super.doFilter(servletrequest, servletresponse, filterchain); + } + + + + + +} diff --git a/src/main/java/org/support/project/knowledge/listener/CronListener.java b/src/main/java/org/support/project/knowledge/listener/CronListener.java index 886fdbd79..303e6ab53 100644 --- a/src/main/java/org/support/project/knowledge/listener/CronListener.java +++ b/src/main/java/org/support/project/knowledge/listener/CronListener.java @@ -92,7 +92,7 @@ public void run() { LOG.error("Faild parse.", e); } } - }, 70, 30, TimeUnit.SECONDS); // 30秒毎に実行 + }, 70, 60, TimeUnit.SECONDS); // 60秒毎に実行 mailfuture = service.scheduleAtFixedRate(new Runnable() { @Override @@ -119,7 +119,7 @@ public void run() { LOG.error("Failed send mail.", e); } } - }, 50, 10, TimeUnit.SECONDS); // 10秒毎に実行 + }, 50, 60, TimeUnit.SECONDS); // 60秒毎に実行 notifyfuture = service.scheduleAtFixedRate(new Runnable() { @Override @@ -146,7 +146,7 @@ public void run() { LOG.error("Failed to Notify", e); } } - }, 45, 10, TimeUnit.SECONDS); // 10秒毎に実行 + }, 40, 60, TimeUnit.SECONDS); // 60秒毎に実行 } @Override diff --git a/src/main/java/org/support/project/knowledge/logic/AccountLogic.java b/src/main/java/org/support/project/knowledge/logic/AccountLogic.java index e7cd45dde..1c7bbd51d 100644 --- a/src/main/java/org/support/project/knowledge/logic/AccountLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/AccountLogic.java @@ -17,6 +17,8 @@ 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; import org.support.project.knowledge.dao.AccountImagesDao; import org.support.project.knowledge.entity.AccountImagesEntity; import org.support.project.knowledge.vo.UploadFile; @@ -26,6 +28,7 @@ import org.support.project.web.entity.ConfirmMailChangesEntity; import org.support.project.web.entity.UsersEntity; +@DI(instance=Instance.Singleton) public class AccountLogic { /** ログ */ private static Log LOG = LogFactory.getLog(AccountLogic.class); @@ -195,6 +198,7 @@ public List completeChangeEmailRequest(String id, LoginedUser log errors.add(error); } else { usersEntity.setUserKey(mailChangesEntity.getMailAddress()); + usersEntity.setMailAddress(mailChangesEntity.getMailAddress()); usersDao.update(usersEntity); } // メール変更を無効化 diff --git a/src/main/java/org/support/project/knowledge/logic/CompressLogic.java b/src/main/java/org/support/project/knowledge/logic/CompressLogic.java index 4afc18619..d218d9353 100644 --- a/src/main/java/org/support/project/knowledge/logic/CompressLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/CompressLogic.java @@ -17,7 +17,10 @@ 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; +@DI(instance=Instance.Singleton) public class CompressLogic { /** ログ */ private static Log LOG = LogFactory.getLog(CompressLogic.class); 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 b376b9358..37a14952e 100644 --- a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java @@ -21,6 +21,8 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.util.DateUtils; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.deploy.InitDB; import org.support.project.ormapping.config.ConnectionConfig; @@ -31,6 +33,7 @@ import org.support.project.web.dao.SystemsDao; import org.support.project.web.entity.SystemsEntity; +@DI(instance=Instance.Singleton) public class DataTransferLogic { private static final String TRANSFER_REQEST = "TRANSFER_REQEST"; private static final String TRANSFER_REQEST_BACK = "TRANSFER_REQEST_BACK"; 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 5de20569a..702a137e8 100644 --- a/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DatabaseLogic.java @@ -22,8 +22,11 @@ import org.support.project.common.util.FileUtil; import org.support.project.common.wrapper.FileInputStreamWithDeleteWrapper; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; +@DI(instance=Instance.Singleton) public class DatabaseLogic { /** ログ */ private static Log LOG = LogFactory.getLog(DatabaseLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/DiffLogic.java b/src/main/java/org/support/project/knowledge/logic/DiffLogic.java index 87ce1ccca..275bc9666 100644 --- a/src/main/java/org/support/project/knowledge/logic/DiffLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DiffLogic.java @@ -6,11 +6,14 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import difflib.Delta; import difflib.DiffUtils; import difflib.Patch; +@DI(instance=Instance.Singleton) public class DiffLogic { /** ログ */ private static Log LOG = LogFactory.getLog(DiffLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/GroupLogic.java b/src/main/java/org/support/project/knowledge/logic/GroupLogic.java index 3e5927432..a7ca19747 100644 --- a/src/main/java/org/support/project/knowledge/logic/GroupLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/GroupLogic.java @@ -9,6 +9,8 @@ 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.dao.ExUsersDao; import org.support.project.knowledge.dao.KnowledgeGroupsDao; import org.support.project.knowledge.dao.TargetsDao; @@ -24,6 +26,7 @@ import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.UserGroupsEntity; +@DI(instance=Instance.Singleton) public class GroupLogic { /** ログ */ private static Log LOG = LogFactory.getLog(GroupLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/IndexLogic.java b/src/main/java/org/support/project/knowledge/logic/IndexLogic.java index d9c80a7fa..418b66e70 100644 --- a/src/main/java/org/support/project/knowledge/logic/IndexLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/IndexLogic.java @@ -5,6 +5,8 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.indexer.Indexer; import org.support.project.knowledge.indexer.IndexingValue; import org.support.project.knowledge.searcher.SearchResultValue; @@ -18,6 +20,7 @@ * @author Koda * */ +@DI(instance=Instance.Singleton) public class IndexLogic { /** ログ */ private static Log LOG = LogFactory.getLog(IndexLogic.class); 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 8a56ded7c..dd18f7ee2 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -2,7 +2,6 @@ import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -15,6 +14,8 @@ import org.support.project.common.util.StringJoinBuilder; 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.bat.FileParseBat; import org.support.project.knowledge.config.IndexType; import org.support.project.knowledge.dao.CommentsDao; @@ -48,6 +49,7 @@ import org.support.project.web.bean.LoginedUser; import org.support.project.web.entity.GroupsEntity; +@DI(instance=Instance.Singleton) public class KnowledgeLogic { /** ログ */ private static Log LOG = LogFactory.getLog(KnowledgeLogic.class); @@ -95,6 +97,15 @@ public List manegeTags(String tags) { } for (String tag : splits) { + tag = tag.trim(); + if (tag.startsWith(" ")) { + tag = tag.substring(" ".length()); + } + if (tag.startsWith(" ")) { + tag = tag.substring(" ".length()); + } + + TagsEntity tagsEntity = tagsDao.selectOnTagName(tag); if (tagsEntity == null) { tagsEntity = new TagsEntity(); diff --git a/src/main/java/org/support/project/knowledge/logic/MailLogic.java b/src/main/java/org/support/project/knowledge/logic/MailLogic.java index e81d26302..cfac5a69d 100644 --- a/src/main/java/org/support/project/knowledge/logic/MailLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MailLogic.java @@ -12,6 +12,8 @@ import org.support.project.common.util.DateUtils; 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.bat.MailSendBat; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.MailConfig; @@ -30,6 +32,7 @@ import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UsersEntity; +@DI(instance=Instance.Singleton) public class MailLogic { /** ログ */ private static Log LOG = LogFactory.getLog(MailLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java b/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java index 37e934e86..4760e78c6 100644 --- a/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/NotifyLogic.java @@ -7,7 +7,10 @@ import org.support.project.common.config.Resources; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; +import org.support.project.common.util.NumberUtils; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.dao.KnowledgeGroupsDao; import org.support.project.knowledge.dao.KnowledgeUsersDao; import org.support.project.knowledge.dao.KnowledgesDao; @@ -26,6 +29,7 @@ import org.support.project.web.bean.MessageResult; import org.support.project.web.entity.GroupsEntity; +@DI(instance=Instance.Singleton) public class NotifyLogic { /** ログ */ private static Log LOG = LogFactory.getLog(NotifyLogic.class); @@ -42,7 +46,26 @@ private void notify(Notify notify) { // Mail通知 NotifyQueuesDao notifyQueuesDao = NotifyQueuesDao.get(); NotifyQueuesEntity notifyQueuesEntity = notify.getQueue(); - notifyQueuesDao.insert(notifyQueuesEntity); + // 重複チェックし + if (NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_INSERT)) { + // ナレッジの新規登録は必ず通知のキューに入れる + notifyQueuesDao.insert(notifyQueuesEntity); + } else if (NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_UPDATE)) { + // ナレッジが更新された場合、キューに「登録通知」もしくは「更新通知」が存在しているのであれば登録しない + NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(notifyQueuesEntity.getType(), notifyQueuesEntity.getId()); + if (exist == null) { + exist = notifyQueuesDao.selectOnTypeAndId(Notify.TYPE_KNOWLEDGE_INSERT, notifyQueuesEntity.getId()); + if (exist == null) { + notifyQueuesDao.insert(notifyQueuesEntity); + } + } + } else if (NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_LIKE) + || NumberUtils.is(notifyQueuesEntity.getType(), Notify.TYPE_KNOWLEDGE_COMMENT)) { + NotifyQueuesEntity exist = notifyQueuesDao.selectOnTypeAndId(notifyQueuesEntity.getType(), notifyQueuesEntity.getId()); + if (exist == null) { + notifyQueuesDao.insert(notifyQueuesEntity); + } + } // Desktop通知 NotifyAction notifyAction = Container.getComp(NotifyAction.class); diff --git a/src/main/java/org/support/project/knowledge/logic/PasswordInitializationLogic.java b/src/main/java/org/support/project/knowledge/logic/PasswordInitializationLogic.java index 31b4d444a..5dfd61c1f 100644 --- a/src/main/java/org/support/project/knowledge/logic/PasswordInitializationLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/PasswordInitializationLogic.java @@ -1,31 +1,21 @@ package org.support.project.knowledge.logic; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.Locale; -import java.util.UUID; import org.support.project.aop.Aspect; import org.support.project.common.bean.ValidateError; -import org.support.project.common.config.LocaleConfigLoader; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.common.util.RandomUtil; import org.support.project.di.Container; -import org.support.project.knowledge.bat.MailSendBat; -import org.support.project.knowledge.config.AppConfig; -import org.support.project.knowledge.config.MailConfig; -import org.support.project.knowledge.config.SystemConfig; -import org.support.project.web.dao.MailsDao; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.web.dao.PasswordResetsDao; -import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.dao.UsersDao; -import org.support.project.web.entity.MailsEntity; import org.support.project.web.entity.PasswordResetsEntity; -import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UsersEntity; +@DI(instance=Instance.Singleton) public class PasswordInitializationLogic { /** ログ */ private static Log LOG = LogFactory.getLog(PasswordInitializationLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/SystemConfigLogic.java b/src/main/java/org/support/project/knowledge/logic/SystemConfigLogic.java index 215f91d0e..49e8ad3b4 100644 --- a/src/main/java/org/support/project/knowledge/logic/SystemConfigLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/SystemConfigLogic.java @@ -3,6 +3,8 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.SystemConfig; import org.support.project.web.dao.LdapConfigsDao; @@ -10,10 +12,13 @@ import org.support.project.web.entity.LdapConfigsEntity; import org.support.project.web.entity.SystemConfigsEntity; +@DI(instance=Instance.Singleton) public class SystemConfigLogic { /** ログ */ private static Log LOG = LogFactory.getLog(SystemConfigLogic.class); - + + private boolean close = false; + public static SystemConfigLogic get() { return Container.getComp(SystemConfigLogic.class); } @@ -39,6 +44,20 @@ public boolean isUserAddAble() { } return true; } + + /** + * @return the close + */ + public boolean isClose() { + return close; + } + + /** + * @param close the close to set + */ + public void setClose(boolean close) { + this.close = close; + } diff --git a/src/main/java/org/support/project/knowledge/logic/TagLogic.java b/src/main/java/org/support/project/knowledge/logic/TagLogic.java index 63be4cf86..756055a2c 100644 --- a/src/main/java/org/support/project/knowledge/logic/TagLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/TagLogic.java @@ -6,11 +6,14 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.dao.TagsDao; import org.support.project.knowledge.entity.TagsEntity; import org.support.project.web.bean.LoginedUser; import org.support.project.web.entity.GroupsEntity; +@DI(instance=Instance.Singleton) public class TagLogic { /** ログ */ private static Log LOG = LogFactory.getLog(TagLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/TargetLogic.java b/src/main/java/org/support/project/knowledge/logic/TargetLogic.java index 6add3589d..7719dea96 100644 --- a/src/main/java/org/support/project/knowledge/logic/TargetLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/TargetLogic.java @@ -7,6 +7,8 @@ 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.dao.TargetsDao; import org.support.project.web.bean.LabelValue; import org.support.project.web.bean.LoginedUser; @@ -15,6 +17,7 @@ import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.UsersEntity; +@DI(instance=Instance.Singleton) public class TargetLogic { /** ログ */ private static Log LOG = LogFactory.getLog(TargetLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java b/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java index ea893f409..a2a18f52b 100644 --- a/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/UploadedFileLogic.java @@ -12,12 +12,15 @@ import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; import org.support.project.knowledge.dao.KnowledgeFilesDao; import org.support.project.knowledge.entity.KnowledgeFilesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.vo.UploadFile; import org.support.project.web.bean.LoginedUser; +@DI(instance=Instance.Singleton) public class UploadedFileLogic { /** ログ */ private static Log LOG = LogFactory.getLog(UploadedFileLogic.class); diff --git a/src/main/java/org/support/project/knowledge/logic/UserLogic.java b/src/main/java/org/support/project/knowledge/logic/UserLogic.java index 8a50c693c..af8257d04 100644 --- a/src/main/java/org/support/project/knowledge/logic/UserLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/UserLogic.java @@ -3,7 +3,10 @@ import java.util.Locale; import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +@DI(instance=Instance.Singleton) public class UserLogic extends org.support.project.web.logic.UserLogic { public static UserLogic get() { diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index be14b8644..3e0742808 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -53,7 +53,7 @@ message.allready.updated=Allready updated. message.allready.started=Allready started. # Common Label -label.version=0.5.3 pre2 +label.version=0.5.3 pre3 label.login=Sign in label.previous = Previous label.next=Next @@ -251,6 +251,10 @@ knowledge.account.changekey.title=Change E-mail 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.account.id=ログイン用のID(ログイン時のIDになります/公開されることはありません) +knowledge.account.id.info1=管理者による登録の場合、IDは自由に設定できます。 +knowledge.account.id.info2=ただし、メールアドレス形式で無いIDの場合、メール通知ができません。 +knowledge.account.mail=メールアドレス(DB Userの場合、基本的にはユーザのログインIDと同じになります) knowledge.withdrawal.title=Withdrawal knowledge.withdrawal.msg=You unsubscribe from Knowledge of service.
How do you the knowledge that you have registered up to now?
knowledge.withdrawal.label.remove=Remove @@ -289,6 +293,9 @@ knowledge.config.mail.smtppass.require=If you want to authentication, SMTP passw knowledge.config.mail=Mail transmission settings knowledge.config.system.title=System Config knowledge.config.system.label.url=Service URL +knowledge.config.system.open.title=システムの公開設定 +knowledge.config.system.open=公開情報などには、ログインしなくてもアクセス可能 +knowledge.config.system.close=全ての機能には、ログインしないとアクセス不可 knowledge.accept.title=List of users awaiting approval knowledge.accept.label.list.empty=There is no user waiting for approval @@ -329,6 +336,7 @@ knowledge.group.mylist.label.member= - You are group member - knowledge.group.mylist.label.wait= - It is in affiliation request (it does not yet belong) - knowledge.group.list.title=Group list knowledge.group.list.label.mylist=MyGroups +knowledge.group.list.empty=データが存在しません。ページを切り替えてください。 knowledge.group.add.title=Add Group knowledge.group.edit.title=Edit Group knowledge.group.edit.label.public=[Public] (Anyone can join free.) diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 73fb866fd..d570e1e83 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -53,7 +53,7 @@ message.allready.updated=すでに更新されています message.allready.started=すでに開始済です # Common Label -label.version=0.5.3 pre2 +label.version=0.5.3 pre3 label.login=サインイン label.previous = 前へ label.next = 次へ @@ -251,6 +251,10 @@ knowledge.account.changekey.title=メールアドレス変更 knowledge.account.label.email=変更したいメールアドレス(指定のアドレスに変更確認のためのメールを送ります) knowledge.account.changekey.request=メールアドレス変更のリクエストを受け付けました。新しいメールアドレスに確認用のメールを送りましたので、メールを受信して、メールアドレス変更処理を完了してください。 knowledge.account.changekey.complete=メールアドレス変更が完了しました。 +knowledge.account.id=ログイン用のID(ログイン時のIDになります/公開されることはありません) +knowledge.account.id.info1=管理者による登録の場合、IDは自由に設定できます。 +knowledge.account.id.info2=ただし、メールアドレス形式で無いIDの場合、メール通知ができません。 +knowledge.account.mail=メールアドレス(DB Userの場合、基本的にはユーザのログインIDと同じになります) knowledge.withdrawal.title=退会 knowledge.withdrawal.msg=Knowledgeのサービスから退会します。
今まで登録したナレッジをどうしますか?
knowledge.withdrawal.label.remove=削除する @@ -289,6 +293,9 @@ knowledge.config.mail.smtppass.require=認証する場合、SMTP パスワード knowledge.config.mail=メール送信設定 knowledge.config.system.title=システム設定 knowledge.config.system.label.url=サービスのURL +knowledge.config.system.open.title=システムの公開設定 +knowledge.config.system.open=公開情報などには、ログインしなくてもアクセス可能 +knowledge.config.system.close=全ての機能には、ログインしないとアクセス不可 knowledge.accept.title=承認待ちのユーザの一覧 knowledge.accept.label.list.empty=承認待ちのユーザはいません @@ -329,6 +336,7 @@ knowledge.group.mylist.label.member= - あなたは[グループのメンバー] knowledge.group.mylist.label.wait= - 所属のリクエスト中です(まだ所属していません) - knowledge.group.list.title=グループの一覧 knowledge.group.list.label.mylist=自分が所属しているグループを表示する +knowledge.group.list.empty=データが存在しません。ページを切り替えてください。 knowledge.group.add.title=新たにグループを作成 knowledge.group.edit.title=グループを更新する knowledge.group.edit.label.public=[公開](誰でも自由に参加できます。) diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index f7fc043fa..5de90db80 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -43,7 +43,7 @@ - + diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectGroupUser.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectGroupUser.sql index 14b0798d9..e838439eb 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectGroupUser.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectGroupUser.sql @@ -1,15 +1,5 @@ SELECT - USERS.USER_ID - ,USERS.USER_KEY - ,USERS.USER_NAME - ,USERS.PASSWORD - ,USERS.SALT - ,USERS.ROW_ID - ,USERS.INSERT_USER - ,USERS.INSERT_DATETIME - ,USERS.UPDATE_USER - ,USERS.UPDATE_DATETIME - ,USERS.DELETE_FLAG + USERS.* ,USER_GROUPS.GROUP_ROLE FROM USERS INNER JOIN USER_GROUPS diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql b/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql index d742ff30e..2ae9270f6 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/ExUsersDao/selectNotifyPublicUsers.sql @@ -1,4 +1,4 @@ -SELECT USERS.USER_ID, USERS.USER_KEY, USERS.USER_NAME +SELECT USERS.* FROM USERS INNER JOIN NOTIFY_CONFIGS ON (USERS.USER_ID = NOTIFY_CONFIGS.USER_ID) WHERE NOTIFY_CONFIGS.NOTIFY_MAIL = 1 diff --git a/src/main/webapp/WEB-INF/views/admin/config/system.jsp b/src/main/webapp/WEB-INF/views/admin/config/system.jsp index 9b1aabc21..cd104d2d9 100644 --- a/src/main/webapp/WEB-INF/views/admin/config/system.jsp +++ b/src/main/webapp/WEB-INF/views/admin/config/system.jsp @@ -12,6 +12,11 @@ + @@ -29,6 +34,21 @@ +
+
+ +
+ +
+ diff --git a/src/main/webapp/WEB-INF/views/admin/users/view_add.jsp b/src/main/webapp/WEB-INF/views/admin/users/view_add.jsp index 6e34d71ea..8df8ff255 100644 --- a/src/main/webapp/WEB-INF/views/admin/users/view_add.jsp +++ b/src/main/webapp/WEB-INF/views/admin/users/view_add.jsp @@ -22,6 +22,13 @@

<%= jspUtil.label("knowledge.user.add.title") %>

+ +
diff --git a/src/main/webapp/WEB-INF/views/admin/users/view_edit.jsp b/src/main/webapp/WEB-INF/views/admin/users/view_edit.jsp index 0f0a43f3f..40fd787a9 100644 --- a/src/main/webapp/WEB-INF/views/admin/users/view_edit.jsp +++ b/src/main/webapp/WEB-INF/views/admin/users/view_edit.jsp @@ -41,11 +41,11 @@ function deleteUser() { <% if(jspUtil.is(1, "authLdap")) { %>
- + " readonly="readonly" />
- + " readonly="readonly" />
@@ -55,9 +55,13 @@ function deleteUser() { <% } else { %>
- + " />
+
+ + " readonly="readonly" /> +
" /> diff --git a/src/main/webapp/WEB-INF/views/protect/group/view_group.jsp b/src/main/webapp/WEB-INF/views/protect/group/view_group.jsp index 60c165d3a..70fb46762 100644 --- a/src/main/webapp/WEB-INF/views/protect/group/view_group.jsp +++ b/src/main/webapp/WEB-INF/views/protect/group/view_group.jsp @@ -59,7 +59,10 @@ var _CONFIRM_DELETE = '<%= jspUtil.label("knowledge.group.view.label.confirm.del "> -

<%= jspUtil.label("knowledge.group.view.label.member") %>

+

+ <%= jspUtil.label("knowledge.group.view.label.member") %> + page[<%= jspUtil.getValue("offset", Integer.class) + 1 %>] +

<% if(jspUtil.is(CommonWebParameter.GROUP_CLASS_PROTECT, "groupClass")) { %> @@ -99,9 +102,25 @@ var _CONFIRM_DELETE = '<%= jspUtil.label("knowledge.group.view.label.confirm.del <% } %>

+

+ + -<%= jspUtil.label("knowledge.accept.label.list.empty") %> +<%= jspUtil.label("knowledge.group.list.empty") %> @@ -143,6 +162,22 @@ var _CONFIRM_DELETE = '<%= jspUtil.label("knowledge.group.view.label.confirm.del
+ + +
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 48d65c4f9..30672ff44 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -44,11 +44,15 @@ AuthenticationFilter - org.support.project.web.filter.AuthenticationFilter + org.support.project.knowledge.listener.CloseAbleAuthenticationFilter ignore-regular-expression ^/index|^/open|^/template|^/bower|^/images|^/css|^/js|^/favicon.ico|^/lang|css$|js$|jpg$|jpeg$|gif$|png$|ico$|html$ + + close-ignore-regular-expression + ^/index|^/template|^/bower|^/images|^/css|^/js|^/favicon.ico|^/lang|css$|js$|jpg$|jpeg$|gif$|png$|ico$|html$|^/open.signup|^/open.PasswordInitialization + login-page /WEB-INF/views/auth/form.jsp