diff --git a/document/database/A5M2_knowledge.pdf b/document/database/A5M2_knowledge.pdf index a372e0d64..a6ef73af7 100755 Binary files a/document/database/A5M2_knowledge.pdf and b/document/database/A5M2_knowledge.pdf differ diff --git a/document/database/knowledge.a5er b/document/database/knowledge.a5er index 41442b6cf..34604e0ca 100755 --- a/document/database/knowledge.a5er +++ b/document/database/knowledge.a5er @@ -46,6 +46,61 @@ SqlSeparator=0 ShowTag=1 ShowCommonAttributes=0 +[Entity] +PName=TOKENS +LName=認証トークン +Comment= +TableOption= +Page=MAIN +Left=1600 +Top=50 +Field="TOKEN","TOKEN","@VARCHAR(128)","NOT NULL",0,"","",$FFFFFFFF,"" +Field="ユーザID","USER_ID","@INT","NOT NULL",,"","",$FFFFFFFF,"" +Field="有効期限","EXPIRES","@DATETIME","NOT NULL",,"","",$FFFFFFFF,"" +Index==1,USER_ID +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170620125822 +Position="MAIN",1600,50 + +[Relation] +Entity1=MAIL_HOOKS +Entity2=MAIL_PROPERTIES +RelationType1=1 +RelationType2=3 +Fields1=HOOK_ID +Fields2=HOOK_ID +Cardinarity1= +Cardinarity2= +Position="MAIN",0,1836,5081,4896,R,R +Dependence=1 +Caption= +PName= +LineMode=0 +Bar1=184 +Bar2=508 +Bar3=490 +TermPos1=R +TermPos2=R + +[Entity] +PName=MAIL_PROPERTIES +LName=メール受信設定 +Comment= +TableOption= +Page=MAIN +Left=2950 +Top=50 +Field="HOOK_ID","HOOK_ID","INTEGER","NOT NULL",0,"","",$FFFFFFFF,"" +Field="PROPERTY_KEY","PROPERTY_KEY","@VARCHAR(128)","NOT NULL",1,"","",$FFFFFFFF,"" +Field="PROPERTY_VALUE","PROPERTY_VALUE","@VARCHAR(256)",,,"","",$FFFFFFFF,"" +EffectMode=None +Color=$000000 +BkColor=$FFFFFF +ModifiedDateTime=20170616214751 +Position="MAIN",2950,50 + [Relation] Entity1=LOCALES Entity2=MAIL_LOCALE_TEMPLATES @@ -55,14 +110,14 @@ Fields1=KEY Fields2=KEY Cardinarity1= Cardinarity2= -Position="MAIN",0,5226,5024,4040,R,R +Position="MAIN",0,5226,5024,4720,R,R Dependence=1 Caption= PName= LineMode=0 Bar1=523 Bar2=502 -Bar3=404 +Bar3=472 TermPos1=R TermPos2=R @@ -92,8 +147,8 @@ LName=ロケール毎のメールテンプレート Comment= TableOption= Page=MAIN -Left=2950 -Top=250 +Left=3600 +Top=300 Field="テンプレートID","TEMPLATE_ID","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" Field="キー","KEY","@VARCHAR(12)","NOT NULL",1,"","",$FFFFFFFF,"" Field=" タイトル","TITLE","text","NOT NULL",,"","",$FFFFFFFF,"" @@ -102,7 +157,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170228163618 -Position="MAIN",2950,250 +Position="MAIN",3600,300 [Entity] PName=LOCALES @@ -110,7 +165,7 @@ LName=ロケール Comment= TableOption= Page=MAIN -Left=3550 +Left=3600 Top=50 Field="キー","KEY","@VARCHAR(12)","NOT NULL",0,"","",$FFFFFFFF,"" Field="言語","LANGUAGE","@VARCHAR(4)","NOT NULL",,"","",$FFFFFFFF,"" @@ -124,7 +179,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170228162957 -Position="MAIN",3550,50 +Position="MAIN",3600,50 [Entity] PName=MAIL_TEMPLATES @@ -133,7 +188,7 @@ Comment= TableOption= Page=MAIN Left=2950 -Top=50 +Top=200 Field="テンプレートID","TEMPLATE_ID","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,"" Field="テンプレートタイトル","TEMPLATE_TITLE","@VARCHAR(128)","NOT NULL",,"","",$FFFFFFFF,"" Field="説明文","DESCRIPTION","text",,,"","",$FFFFFFFF,"" @@ -141,7 +196,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170301131519 -Position="MAIN",2950,50 +Position="MAIN",2950,200 [Relation] Entity1=SURVEY_ANSWERS @@ -212,14 +267,14 @@ Fields1=KNOWLEDGE_ID Fields2=KNOWLEDGE_ID Cardinarity1= Cardinarity2= -Position="MAIN",0,4662,4335,5401,R,R +Position="MAIN",0,4662,4335,5351,R,R Dependence=0 Caption= PName= LineMode=0 Bar1=466 Bar2=434 -Bar3=540 +Bar3=535 TermPos1=R TermPos2=R @@ -229,7 +284,7 @@ LName=アンケートの回答 Comment= TableOption= Page=MAIN -Left=1900 +Left=1950 Top=1600 Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,"" Field="回答ID","ANSWER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,"" @@ -237,7 +292,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20170222215330 -Position="MAIN",1900,1600 +Position="MAIN",1950,1600 [Relation] Entity1=SURVEY_ITEMS @@ -248,7 +303,7 @@ Fields1=KNOWLEDGE_ID,ITEM_NO Fields2=KNOWLEDGE_ID,ITEM_NO Cardinarity1= Cardinarity2= -Position="MAIN",0,4139,4896,5178,R,R +Position="MAIN",0,4139,4896,5177,R,R Dependence=1 Caption= PName= @@ -672,8 +727,8 @@ LName=メールから投稿 Comment= TableOption= Page=MAIN -Left=1800 -Top=50 +Left=2950 +Top=350 Field="Message-ID","MESSAGE_ID","@VARCHAR(128)","NOT NULL",0,"","",$FFFFFFFF,"" Field="投稿区分","POST_KIND","@INT","NOT NULL",,"","1: Knowledge 2:Comment",$FFFFFFFF,"" Field="ID","ID","BIGINT","NOT NULL",,"","",$FFFFFFFF,"" @@ -682,7 +737,7 @@ EffectMode=None Color=$000000 BkColor=$FFFFFF ModifiedDateTime=20160611082117 -Position="MAIN",1800,50 +Position="MAIN",2950,350 [Relation] Entity1=MAIL_HOOKS diff --git a/gulpfile.js b/gulpfile.js index b403113fc..28e36ec58 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,6 +10,10 @@ gulp.task('min', function() { return gulp.src([ 'src/main/webapp/WEB-INF/views/**/*.jsp' ]) + .pipe(replace('href="<%= request.getContextPath() %>/bower', 'href="/bower')) + .pipe(replace('href="<%= request.getContextPath() %>/css', 'href="/css')) + .pipe(replace('src="<%= request.getContextPath() %>/bower', 'src="/bower')) + .pipe(replace('src="<%= request.getContextPath() %>/js', 'src="/js')) .pipe(usemin({ css: [rev], htmlmin: [ function () {return minifyHtml({ empty: true });} ], @@ -19,6 +23,14 @@ gulp.task('min', function() { outputRelativePath: '../../' })) .pipe(replace('var _LOGGING_NOTIFY_DESKTOP = true;', 'var _LOGGING_NOTIFY_DESKTOP = false;')) + .pipe(replace('href="/bower', 'href="<%= request.getContextPath() %>/bower')) + .pipe(replace('href="/css', 'href="<%= request.getContextPath() %>/css')) + .pipe(replace('src="/bower', 'src="<%= request.getContextPath() %>/bower')) + .pipe(replace('src="/js', 'src="<%= request.getContextPath() %>/js')) + .pipe(replace('href="bower', 'href="<%= request.getContextPath() %>/bower')) + .pipe(replace('href="css', 'href="<%= request.getContextPath() %>/css')) + .pipe(replace('src="bower', 'src="<%= request.getContextPath() %>/bower')) + .pipe(replace('src="js', 'src="<%= request.getContextPath() %>/js')) .pipe(gulp.dest('target/knowledge/WEB-INF/views/')); }); diff --git a/pom.xml b/pom.xml index 0bdd28d62..0b38d7c14 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.support-project knowledge - 1.9.0 + 1.10.0 war knowledge @@ -59,7 +59,7 @@ org.support-project web - 1.9.0 + 1.10.0 @@ -137,8 +137,13 @@ javax.mail - mail - 1.4.7 + javax.mail-api + 1.5.6 + + + com.sun.mail + javax.mail + 1.5.6 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 532fbd757..424f88786 100644 --- a/src/main/java/org/support/project/knowledge/bat/AbstractBat.java +++ b/src/main/java/org/support/project/knowledge/bat/AbstractBat.java @@ -8,7 +8,6 @@ import org.support.project.common.log.LogFactory; import org.support.project.common.util.PropertyUtil; import org.support.project.knowledge.config.AppConfig; -import org.support.project.knowledge.config.SystemConfig; import org.support.project.web.logic.DBConnenctionLogic; public abstract class AbstractBat { @@ -27,11 +26,11 @@ protected static void configInit(String batName) { TimeZone zone = TimeZone.getTimeZone("GMT"); TimeZone.setDefault(zone); - AppConfig.initEnvKey(SystemConfig.KNOWLEDGE_ENV_KEY); - String envValue = System.getenv(SystemConfig.KNOWLEDGE_ENV_KEY); + AppConfig.get(); + String envValue = System.getenv(AppConfig.getEnvKey()); LOG.info(batName + " is start."); if (LOG.isDebugEnabled()) { - LOG.debug("Env [" + SystemConfig.KNOWLEDGE_ENV_KEY + "] is [" + envValue + "]."); + LOG.debug("Env [" + AppConfig.getEnvKey() + "] 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 336c34a50..e6ec5209a 100644 --- a/src/main/java/org/support/project/knowledge/bat/FileParseBat.java +++ b/src/main/java/org/support/project/knowledge/bat/FileParseBat.java @@ -20,11 +20,13 @@ import org.support.project.common.util.StringUtils; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.config.IndexType; +import org.support.project.knowledge.dao.DraftKnowledgesDao; import org.support.project.knowledge.dao.KnowledgeFilesDao; import org.support.project.knowledge.dao.KnowledgeItemValuesDao; import org.support.project.knowledge.dao.KnowledgesDao; import org.support.project.knowledge.dao.TagsDao; import org.support.project.knowledge.dao.TemplateItemsDao; +import org.support.project.knowledge.entity.DraftKnowledgesEntity; import org.support.project.knowledge.entity.KnowledgeFilesEntity; import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; @@ -243,8 +245,16 @@ private void fileParse() throws FileNotFoundException, IOException, MimeTypeExce if (knowledgesEntity == null) { // 紐づくナレッジが存在していないのであれば解析はしない(例えば、一度添付ファイル付きのナレッジを登録後、ナレッジを削除した場合) // 理由:ナレッジに紐付いていないため、アクセス権が不定 - // ナレッジに紐づいていないファイルで、かつ更新日が24時間前のものは削除される - filesDao.changeStatus(knowledgeFilesEntity.getFileNo(), PARSE_STATUS_NO_TARGET, UPDATE_USER_ID); + // ナレッジに紐づいていないファイルで、かつ更新日が24時間前のものはステータスを更新する + if (knowledgeFilesEntity.getDraftId() == null) { + filesDao.changeStatus(knowledgeFilesEntity.getFileNo(), PARSE_STATUS_NO_TARGET, UPDATE_USER_ID); + } else { + DraftKnowledgesEntity draft = DraftKnowledgesDao.get().selectOnKey(knowledgeFilesEntity.getDraftId()); + if (draft == null) { + // 下書きが存在する場合は、削除対象にしないが、下書きも消えている場合はステータスを更新する + filesDao.changeStatus(knowledgeFilesEntity.getFileNo(), PARSE_STATUS_NO_TARGET, UPDATE_USER_ID); + } + } continue; } // タグを取得 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 9e51ff0aa..27e880533 100644 --- a/src/main/java/org/support/project/knowledge/config/SystemConfig.java +++ b/src/main/java/org/support/project/knowledge/config/SystemConfig.java @@ -15,7 +15,7 @@ public class SystemConfig { /** ログ */ private static final Log LOG = LogFactory.getLog(SystemConfig.class); - public static final String KNOWLEDGE_ENV_KEY = "KNOWLEDGE_HOME"; + //public static final String KNOWLEDGE_ENV_KEY = "KNOWLEDGE_HOME"; /** システム設定情報 */ private static ServiceConfigsEntity serviceConfigsEntity = null; 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 10650b84f..8b123d597 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 @@ -3,6 +3,7 @@ import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -13,8 +14,12 @@ import org.apache.directory.api.ldap.model.exception.LdapException; import org.support.project.common.bean.ValidateError; import org.support.project.common.config.INT_FLAG; +import org.support.project.common.log.Log; +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.common.validate.Validator; +import org.support.project.common.validate.ValidatorFactory; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.config.AppConfig; @@ -22,10 +27,14 @@ import org.support.project.web.annotation.Auth; import org.support.project.web.bean.LdapInfo; import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.config.WebConfig; import org.support.project.web.control.service.Get; import org.support.project.web.control.service.Post; import org.support.project.web.dao.LdapConfigsDao; +import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.entity.LdapConfigsEntity; +import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.exception.InvalidParamException; import org.support.project.web.logic.LdapLogic; @@ -33,33 +42,60 @@ @DI(instance = Instance.Prototype) public class LdapControl extends Control { + /** ログ */ + private static final Log LOG = LogFactory.getLog(LdapControl.class); private static final String CONFIG_TYPE2 = "config2"; private static final String CONFIG_TYPE1 = "config1"; private static final String NO_CHANGE_PASSWORD = "NO_CHANGE_PASSWORD-fXLSJ_V-ZJ2E-X6c2_iGCpkE"; // パスワードを更新しなかったことを表すパスワード - + + /** + * Ldap設定の一覧を表示 + * @return + */ + @Get(publishToken = "admin") + @Auth(roles = "admin") + public Boundary list() { + List configs = LdapConfigsDao.get().selectAll(); + setAttribute("configs", configs); + return forward("list.jsp"); + } + /** * 設定画面を表示 - * * @return */ @Get(publishToken = "admin") @Auth(roles = "admin") public Boundary config() { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + key = ""; + } + return config(key); + } + /** + * 設定画面を表示 + * @param key + * @return + */ + private Boundary config(String key) { + setAttribute("key", key); LdapConfigsDao dao = LdapConfigsDao.get(); - LdapConfigsEntity entity = dao.selectOnKey(AppConfig.get().getSystemName()); - String configType = CONFIG_TYPE1; + LdapConfigsEntity entity = dao.selectOnKey(key); + String configType = CONFIG_TYPE2; if (entity == null) { entity = new LdapConfigsEntity(); } else { entity.setBindPassword(NO_CHANGE_PASSWORD); entity.setSalt(""); - - if (entity.getAuthType().intValue() == LdapConfigsEntity.AUTH_TYPE_LDAP_2) { - configType = CONFIG_TYPE2; + if (entity.getAuthType().intValue() == LdapConfigsEntity.AUTH_TYPE_LDAP) { + configType = CONFIG_TYPE1; + } else if (entity.getAuthType().intValue() == LdapConfigsEntity.AUTH_TYPE_BOTH) { + configType = CONFIG_TYPE1; + } else if (entity.getAuthType().intValue() == LdapConfigsEntity.AUTH_TYPE_LDAP_2) { entity.setAuthType(LdapConfigsEntity.AUTH_TYPE_LDAP); } else if (entity.getAuthType().intValue() == LdapConfigsEntity.AUTH_TYPE_BOTH_2) { - configType = CONFIG_TYPE2; entity.setAuthType(LdapConfigsEntity.AUTH_TYPE_BOTH); } } @@ -80,7 +116,7 @@ public Boundary config() { return forward("config.jsp"); } - + /** * リクエストの情報からLdapの設定情報を抽出(共通処理) * @@ -95,10 +131,11 @@ public Boundary config() { * @throws IllegalBlockSizeException * @throws BadPaddingException */ - private LdapConfigsEntity loadLdapConfig() throws InstantiationException, IllegalAccessException, IOException, InvalidParamException, + private LdapConfigsEntity loadLdapConfig(String key) throws InstantiationException, IllegalAccessException, IOException, InvalidParamException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { LdapConfigsDao dao = LdapConfigsDao.get(); LdapConfigsEntity entity = super.getParamOnProperty(LdapConfigsEntity.class); + entity.setAuthType(LdapConfigsEntity.AUTH_TYPE_BOTH); String security = getParam("security"); if (!StringUtils.isEmpty(security)) { if (security.toLowerCase().equals("usessl")) { @@ -116,6 +153,7 @@ private LdapConfigsEntity loadLdapConfig() throws InstantiationException, Illega entity.setAuthType(LdapConfigsEntity.AUTH_TYPE_BOTH_2); } + entity.setDescription(getParam("description2")); entity.setHost(getParam("host2")); entity.setPort(getParam("port2", Integer.class)); security = getParam("security2"); @@ -139,7 +177,7 @@ private LdapConfigsEntity loadLdapConfig() throws InstantiationException, Illega String password = entity.getBindPassword(); if (password.equals(NO_CHANGE_PASSWORD)) { - LdapConfigsEntity saved = dao.selectOnKey(AppConfig.get().getSystemName()); + LdapConfigsEntity saved = dao.selectOnKey(key); if (saved != null) { String encPass = saved.getBindPassword(); String salt = saved.getSalt(); @@ -147,7 +185,6 @@ private LdapConfigsEntity loadLdapConfig() throws InstantiationException, Illega entity.setBindPassword(password); } } - return entity; } @@ -171,9 +208,14 @@ private LdapConfigsEntity loadLdapConfig() throws InstantiationException, Illega @Auth(roles = "admin") public Boundary check() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException, LdapException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + addMsgWarn("knowledge.ldap.msg.connect.error"); + return config(); + } LdapConfigsDao dao = LdapConfigsDao.get(); - LdapConfigsEntity entity = dao.selectOnKey(AppConfig.get().getSystemName()); - String configType = CONFIG_TYPE1; + LdapConfigsEntity entity = dao.selectOnKey(key); + String configType = CONFIG_TYPE2; if (entity == null) { addMsgWarn("knowledge.ldap.msg.connect.error"); return forward("config.jsp"); @@ -184,27 +226,31 @@ public Boundary check() throws InstantiationException, IllegalAccessException, J configType = CONFIG_TYPE2; } } - - LdapLogic ldapLogic = LdapLogic.get(); - if (CONFIG_TYPE2.equals(configType)) { - boolean check = ldapLogic.check(entity); - if (!check) { - addMsgWarn("knowledge.ldap.msg.connect.error"); - } else { - addMsgSuccess("knowledge.ldap.msg.connect.success2"); - } - } else { - String pass = entity.getBindPassword(); - if (StringUtils.isNotEmpty(entity.getSalt())) { - pass = PasswordUtil.decrypt(pass, entity.getSalt()); - } - LdapInfo result = ldapLogic.auth(entity, entity.getBindDn(), pass); - if (result == null) { - addMsgWarn("knowledge.ldap.msg.connect.error"); + try { + LdapLogic ldapLogic = LdapLogic.get(); + if (CONFIG_TYPE2.equals(configType)) { + boolean check = ldapLogic.check(entity); + if (!check) { + addMsgWarn("knowledge.ldap.msg.connect.error"); + } else { + addMsgSuccess("knowledge.ldap.msg.connect.success2"); + } } else { - addMsgSuccess("knowledge.ldap.msg.connect.success", result.getId(), result.getName(), result.getMail(), - String.valueOf(result.isAdmin())); + String pass = entity.getBindPassword(); + if (StringUtils.isNotEmpty(entity.getSalt())) { + pass = PasswordUtil.decrypt(pass, entity.getSalt()); + } + LdapInfo result = ldapLogic.auth(entity, entity.getBindDn(), pass); + if (result == null) { + addMsgWarn("knowledge.ldap.msg.connect.error"); + } else { + addMsgSuccess("knowledge.ldap.msg.connect.success", result.getId(), result.getName(), result.getMail(), + String.valueOf(result.isAdmin())); + } } + } catch (Exception e) { + LOG.warn(e); + addMsgWarn("knowledge.ldap.msg.connect.error"); } return config(); } @@ -229,18 +275,30 @@ public Boundary check() throws InstantiationException, IllegalAccessException, J @Auth(roles = "admin") public Boundary save() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException, LdapException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + String key = getParam("key"); Map params = getParams(); String configType = getParam("configType"); if (CONFIG_TYPE2.equals(configType)) { params.put("host", params.get("host2")); params.put("port", params.get("port2")); + params.put("description", params.get("description2")); } + params.put("authType", "" + LdapConfigsEntity.AUTH_TYPE_BOTH); List errors = LdapConfigsEntity.get().validate(params); + Validator validator = ValidatorFactory.getInstance(Validator.REQUIRED); + ValidateError error = validator.validate(params.get("description"), getResource("knowledge.ldap.label.description")); + if (error != null) { + if (errors == null) { + errors = new ArrayList<>(); + } + errors.add(error); + } if (errors != null && !errors.isEmpty()) { super.setResult("", errors); return forward("config.jsp"); } - LdapConfigsEntity entity = loadLdapConfig(); + LdapConfigsEntity entity = loadLdapConfig(key); + /* LdapLogic ldapLogic = LdapLogic.get(); boolean check = false; if (CONFIG_TYPE2.equals(configType)) { @@ -259,23 +317,33 @@ public Boundary save() throws InstantiationException, IllegalAccessException, JS check = true; } } + */ + boolean check = true; // 保存時の接続チェックをやめた(別途ボタンでチェック) if (!check) { addMsgWarn("knowledge.ldap.msg.save.error"); } else { // Ldap設定を保存 LdapConfigsDao dao = LdapConfigsDao.get(); - entity.setSystemName(AppConfig.get().getSystemName()); + + if (StringUtils.isEmpty(key)) { + int count = dao.selectCountAll(); + count++; + key = "Ldap" + "-" + count; + } + + entity.setSystemName(key); String salt = PasswordUtil.getSalt(); String passHash = PasswordUtil.encrypt(entity.getBindPassword(), salt); entity.setBindPassword(passHash); entity.setSalt(salt); dao.save(entity); - + entity.setBindPassword(NO_CHANGE_PASSWORD); setAttributeOnProperty(entity); addMsgSuccess("knowledge.ldap.msg.save.success"); + setAttribute("key", key); } - return config(); + return config(key); } /** @@ -286,18 +354,33 @@ public Boundary save() throws InstantiationException, IllegalAccessException, JS @Post(subscribeToken = "admin") @Auth(roles = "admin") public Boundary delete() { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } LdapConfigsDao dao = LdapConfigsDao.get(); - LdapConfigsEntity entity = dao.selectOnKey(AppConfig.get().getSystemName()); + LdapConfigsEntity entity = dao.selectOnKey(key); if (entity != null) { - dao.physicalDelete(AppConfig.get().getSystemName()); + dao.physicalDelete(key); } entity = new LdapConfigsEntity(); - entity.setSystemName(AppConfig.get().getSystemName()); + entity.setSystemName(key); setAttributeOnProperty(entity); - + + SystemConfigsEntity config = SystemConfigsDao.get().selectOnKey(WebConfig.KEY_LDAP_CONFIG, AppConfig.get().getSystemName()); + if (config != null) { + if (config.getConfigValue().indexOf(key) != -1) { + if (config.getConfigValue().indexOf(key) == 0) { + key = config.getConfigValue().substring(config.getConfigValue().indexOf(key)); + } else { + key = config.getConfigValue().substring(0, config.getConfigValue().indexOf(key) -1).concat(key.substring(config.getConfigValue().indexOf(key) + key.length())); + } + config.setConfigValue(key); + SystemConfigsDao.get().save(config); + } + } addMsgInfo("message.success.delete.target", getResource("knowledge.ldap.title")); - - return config(); + return list(); } } diff --git a/src/main/java/org/support/project/knowledge/control/admin/MailhookControl.java b/src/main/java/org/support/project/knowledge/control/admin/MailhookControl.java index a48319278..da8ef17a2 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/MailhookControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/MailhookControl.java @@ -22,8 +22,10 @@ import org.support.project.knowledge.control.Control; import org.support.project.knowledge.dao.MailHookConditionsDao; import org.support.project.knowledge.dao.MailHooksDao; +import org.support.project.knowledge.dao.MailPropertiesDao; import org.support.project.knowledge.entity.MailHookConditionsEntity; import org.support.project.knowledge.entity.MailHooksEntity; +import org.support.project.knowledge.entity.MailPropertiesEntity; import org.support.project.knowledge.logic.MailhookLogic; import org.support.project.knowledge.logic.TargetLogic; import org.support.project.web.annotation.Auth; @@ -44,8 +46,6 @@ public class MailhookControl extends Control { private static final String NO_CHANGE_PASSWORD = "NO_CHANGE_PASSWORD-GUHO-UIG-ZJ2E-HishaihTHY-YIOHA"; // パスワードを更新しなかったことを表すパスワード - private static final String[] MAIL_PROTOCOLS = {"imap"}; - /** * MailHookの設定画面を表示 * @@ -57,14 +57,24 @@ public Boundary index() { MailHooksEntity entity = MailHooksDao.get().selectOnKey(MailhookLogic.MAIL_HOOK_ID); if (entity == null) { entity = new MailHooksEntity(); - entity.setMailProtocol(MAIL_PROTOCOLS[0]); + + List properties = new ArrayList<>(); + MailPropertiesEntity property = new MailPropertiesEntity(MailhookLogic.MAIL_HOOK_ID, "mail.store.protocol"); + property.setPropertyValue("imaps"); + properties.add(property); + property = new MailPropertiesEntity(MailhookLogic.MAIL_HOOK_ID, "mail.imaps.ssl.trust"); + property.setPropertyValue("*"); + properties.add(property); + setAttribute("properties", properties); } else { if (StringUtils.isNotEmpty(entity.getMailPass())) { entity.setMailPass(NO_CHANGE_PASSWORD); } - List mailHooks = MailHookConditionsDao.get().selectOnHookId(MailhookLogic.MAIL_HOOK_ID); setAttribute("mailHooks", mailHooks); + + List properties = MailPropertiesDao.get().selectOnHookId(MailhookLogic.MAIL_HOOK_ID); + setAttribute("properties", properties); } setAttributeOnProperty(entity); return forward("config.jsp"); @@ -84,6 +94,25 @@ public Boundary index() { @Auth(roles = "admin") public Boundary save() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + // プロパティ取得 + String[] keys = getParam("propertyKey", String[].class); + String[] vals = getParam("propertyValue", String[].class); + List properties = new ArrayList<>(); + int count = 0; + if (keys != null) { + for (String key : keys) { + MailPropertiesEntity property = new MailPropertiesEntity(MailhookLogic.MAIL_HOOK_ID, key); + if (vals.length > count) { + property.setPropertyValue(vals[count]); + } else { + property.setPropertyValue(""); + } + properties.add(property); + count++; + } + } + setAttribute("properties", properties); + List errors = new ArrayList<>(); errors.addAll(MailHooksEntity.get().validate(getParams())); if (!errors.isEmpty()) { @@ -94,7 +123,7 @@ public Boundary save() throws InvalidKeyException, NoSuchAlgorithmException, NoS entity.setHookId(MailhookLogic.MAIL_HOOK_ID); if (NO_CHANGE_PASSWORD.equals(entity.getMailPass())) { MailHooksEntity db = MailHooksDao.get().selectOnKey(MailhookLogic.MAIL_HOOK_ID); - if (StringUtils.isNotEmpty(db.getMailPass())) { + if (db != null && StringUtils.isNotEmpty(db.getMailPass())) { entity.setMailPass(db.getMailPass()); entity.setMailPassSalt(db.getMailPassSalt()); } @@ -105,7 +134,8 @@ public Boundary save() throws InvalidKeyException, NoSuchAlgorithmException, NoS entity.setMailPassSalt(salt); } entity.setHookId(MailhookLogic.MAIL_HOOK_ID); - MailHooksDao.get().save(entity); + + MailhookLogic.get().saveMailConfig(entity, properties); setAttributeOnProperty(entity); String successMsg = "message.success.save"; 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 124343514..e636538c2 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 @@ -10,6 +10,8 @@ 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.MailLogic; import org.support.project.knowledge.logic.UserLogicEx; @@ -22,9 +24,11 @@ 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.SystemConfigsDao; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.ProvisionalRegistrationsEntity; import org.support.project.web.entity.RolesEntity; +import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UsersEntity; import org.support.project.web.exception.InvalidParamException; @@ -355,8 +359,14 @@ public Boundary accept() { addMsgSuccess("message.success.accept"); // 承認されたことを通知 + SystemConfigsEntity config = SystemConfigsDao.get().selectOnKey(SystemConfig.SYSTEM_URL, AppConfig.get().getSystemName()); + String url; + if (config == null) { + url = HttpUtil.getContextUrl(getRequest()); + } else { + url = config.getConfigValue(); + } MailLogic mailLogic = MailLogic.get(); - String url = HttpUtil.getContextUrl(getRequest()); mailLogic.sendAcceptedAddRequest(entity, url); } else { // 他の管理者がすでに承認していました diff --git a/src/main/java/org/support/project/knowledge/control/api/AttachControl.java b/src/main/java/org/support/project/knowledge/control/api/AttachControl.java new file mode 100644 index 000000000..4ac6ecaf8 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/api/AttachControl.java @@ -0,0 +1,45 @@ +package org.support.project.knowledge.control.api; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.knowledge.entity.KnowledgeFilesEntity; +import org.support.project.knowledge.logic.UploadedFileLogic; +import org.support.project.web.bean.ApiParams; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.ApiControl; +import org.support.project.web.control.service.Get; + +public class AttachControl extends ApiControl { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AttachControl.class); + + @Get(path="api/attachments") + public Boundary index() { + return get(); + } + + @Override + public Boundary getList(ApiParams params) { + return sendError(HttpStatus.SC_501_NOT_IMPLEMENTED); + } + + @Override + public Boundary getSingle(String id) { + try { + Long fileNo = Long.parseLong(id); + KnowledgeFilesEntity entity = UploadedFileLogic.get().getFile(fileNo, getLoginedUser()); + if (entity == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); + } + if (entity.getFileBinary() == null) { + LOG.debug("File binary is null. [fileNo] " + fileNo); + return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); + } + return download(entity.getFileName(), entity.getFileBinary(), entity.getFileSize().longValue()); + } catch (Exception e) { + return sendError(HttpStatus.SC_500_INTERNAL_SERVER_ERROR); + } + } + +} diff --git a/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java b/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java new file mode 100644 index 000000000..52e97db82 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/api/GroupsControl.java @@ -0,0 +1,116 @@ +package org.support.project.knowledge.control.api; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.ExGroupsDao; +import org.support.project.knowledge.logic.GroupLogic; +import org.support.project.knowledge.logic.KnowledgeDataSelectLogic; +import org.support.project.knowledge.vo.GroupUser; +import org.support.project.knowledge.vo.SearchKnowledgeParam; +import org.support.project.knowledge.vo.api.Group; +import org.support.project.knowledge.vo.api.GroupDetail; +import org.support.project.knowledge.vo.api.Knowledge; +import org.support.project.knowledge.vo.api.User; +import org.support.project.web.bean.ApiParams; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.ApiControl; +import org.support.project.web.control.service.Get; +import org.support.project.web.entity.GroupsEntity; +import org.support.project.web.entity.UsersEntity; + +@DI(instance = Instance.Prototype) +public class GroupsControl extends ApiControl { + /** + * List groups + */ + @Get(path="api/groups") + public Boundary index() { + return get(); + } + + @Override + public Boundary getList(ApiParams params) { + String keyword = getParam("keyword"); + List results = new ArrayList<>(); + List groups = GroupLogic.get().selectOnKeyword(keyword, super.getLoginedUser(), params.getOffset(), params.getLimit()); + for (GroupsEntity groupsEntity : groups) { + Group group = new Group(); + PropertyUtil.copyPropertyValue(groupsEntity, group); + results.add(group); + } + return send(results); + } + + @Override + public Boundary getSingle(String id) { + if (!StringUtils.isInteger(id)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST); + } + int groupId = Integer.parseInt(id); + // グループの情報にアクセスできるかのチェックを含めてグループ情報を取得 + GroupsEntity group = GroupLogic.get().getGroup(groupId, getLoginedUser()); + if (group == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND); + } + + // グループそのものの情報が取得したいのか、その下位の情報を取得したいかをチェック + String[] pathinfos = getPathInfos(); + if (pathinfos.length > 1) { + String submethod = pathinfos[1]; + if (StringUtils.isNotEmpty(submethod)) { + if (submethod.equals("knowledges")) { + return getKnowledgeList(group); + } else if (submethod.equals("users")) { + return getUserList(group); + } + } + } + + // グループの情報を取得 + GroupDetail result = new GroupDetail(); + PropertyUtil.copyPropertyValue(group, result); + + result.setGroupKnowledgeCount(ExGroupsDao.get().selectGroupKnowledgeCount(groupId)); + result.setUserCount(ExGroupsDao.get().selectGroupUserCount(groupId)); + + return send(result); + } + + private Boundary getUserList(GroupsEntity group) { + ApiParams params = getApiParams(); + List users = GroupLogic.get().getGroupUsers(group.getGroupId(), params.getOffset(), params.getLimit()); + List results = new ArrayList<>(); + for (GroupUser usersEntity : users) { + User user = new User(); + PropertyUtil.copyPropertyValue(usersEntity, user); + results.add(user); + } + return send(HttpStatus.SC_200_OK, results); + } + private Boundary getKnowledgeList(GroupsEntity group) { + List groups = new ArrayList<>(); + groups.add(group); + ApiParams params = getApiParams(); + SearchKnowledgeParam param = new SearchKnowledgeParam(); + param.setLimit(params.getLimit()); + param.setOffset(params.getOffset()); + param.setKeyword(""); + param.setTags(""); + param.setGroups(groups); + param.setTemplate(""); + param.setLoginedUser(getLoginedUser()); + try { + List results = KnowledgeDataSelectLogic.get().selectList(param); + return send(HttpStatus.SC_200_OK, results); + } catch (Exception e) { + return sendError(HttpStatus.SC_500_INTERNAL_SERVER_ERROR); + } + } + +} diff --git a/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java b/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java new file mode 100644 index 000000000..5ef8d6778 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/api/KnowledgesControl.java @@ -0,0 +1,135 @@ +package org.support.project.knowledge.control.api; + +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.logic.KnowledgeDataEditLogic; +import org.support.project.knowledge.logic.KnowledgeDataSelectLogic; +import org.support.project.knowledge.vo.SearchKnowledgeParam; +import org.support.project.knowledge.vo.api.Knowledge; +import org.support.project.knowledge.vo.api.KnowledgeDetail; +import org.support.project.web.bean.ApiParams; +import org.support.project.web.bean.Msg; +import org.support.project.web.bean.NameId; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.ApiControl; +import org.support.project.web.control.service.Delete; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; +import org.support.project.web.control.service.Put; +import org.support.project.web.exception.InvalidParamException; +import org.support.project.web.filter.ControlManagerFilter; + +import net.arnx.jsonic.JSONException; + +@DI(instance = Instance.Prototype) +public class KnowledgesControl extends ApiControl { + /** ログ */ + private static Log LOG = LogFactory.getLog(ControlManagerFilter.class); + + @Get(path="api/knowledges") + public Boundary index() { + return get(); + } + + @Override + public Boundary getList(ApiParams params) { + SearchKnowledgeParam param = new SearchKnowledgeParam(); + param.setLimit(params.getLimit()); + param.setOffset(params.getOffset()); + param.setKeyword(getParam("keyword")); + param.setTags(getParam("tags")); + param.setGroupsAndLoginUser(getParam("groups"), getLoginedUser()); + param.setTemplate(getParam("template")); + try { + List results = KnowledgeDataSelectLogic.get().selectList(param); + return send(HttpStatus.SC_200_OK, results); + } catch (Exception e) { + return sendError(HttpStatus.SC_500_INTERNAL_SERVER_ERROR); + } + } + + @Override + public Boundary getSingle(String id) { + // 1件取得 + if (!StringUtils.isLong(id)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST); + } + long knowledgeId = Long.parseLong(id); + Knowledge result = KnowledgeDataSelectLogic.get().select(knowledgeId, getLoginedUser()); + if (result == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND); + } + return send(HttpStatus.SC_200_OK, result); + } + + /** + * Post knowledges + */ + @Post(path="api/knowledges", checkReferer=false) + public Boundary post() { + try { + KnowledgeDetail data = getJsonObject(KnowledgeDetail.class); + long id = KnowledgeDataEditLogic.get().insert(data, getLoginedUser()); + return send(HttpStatus.SC_201_CREATED, new NameId(data.getTitle(), String.valueOf(id))); + } catch (JSONException e) { + LOG.debug("json parse error", e); + return sendError(HttpStatus.SC_400_BAD_REQUEST); + } catch (InvalidParamException e) { + return sendError(e); + } catch (Exception e) { + LOG.error("error", e); + return sendError(HttpStatus.SC_500_INTERNAL_SERVER_ERROR); + } + } + + /** + * Put knowledges + */ + @Put(path="api/knowledges", checkReferer=false) + public Boundary put() { + try { + Long id = getPathLong(); + KnowledgeDetail data = getJsonObject(KnowledgeDetail.class); + data.setKnowledgeId(id); + KnowledgeDataEditLogic.get().update(data, getLoginedUser()); + return send(HttpStatus.SC_200_OK, new Msg("updated")); + } catch (JSONException e) { + LOG.debug("json parse error", e); + return sendError(HttpStatus.SC_400_BAD_REQUEST); + } catch (InvalidParamException e) { + return sendError(e); + } catch (Exception e) { + LOG.error("error", e); + return sendError(HttpStatus.SC_500_INTERNAL_SERVER_ERROR); + } + } + + + /** + * Delete knowledges + */ + @Delete(path="api/knowledges", checkReferer=false) + public Boundary delete() { + try { + Long id = getPathLong(); + KnowledgeDataEditLogic.get().delete(id, getLoginedUser()); + return send(HttpStatus.SC_200_OK, new Msg("deleted")); + } catch (JSONException e) { + LOG.debug("json parse error", e); + return sendError(HttpStatus.SC_400_BAD_REQUEST); + } catch (InvalidParamException e) { + return sendError(e); + } catch (Exception e) { + LOG.error("error", e); + return sendError(HttpStatus.SC_500_INTERNAL_SERVER_ERROR); + } + } + + +} diff --git a/src/main/java/org/support/project/knowledge/control/api/SampleControl.java b/src/main/java/org/support/project/knowledge/control/api/SampleControl.java new file mode 100644 index 000000000..b73af7b5d --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/api/SampleControl.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.control.api; + +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.control.Control; +import org.support.project.web.bean.Msg; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; + +@DI(instance = Instance.Prototype) +public class SampleControl extends Control { + /** + * サンプル + */ + @Get(path="api/sample") + public Boundary index() { + Msg msg = new Msg("Hi, " + getLoginedUser().getLoginUser().getUserName() + ", this is api sample."); + return send(msg); + } + +} diff --git a/src/main/java/org/support/project/knowledge/control/api/UsersControl.java b/src/main/java/org/support/project/knowledge/control/api/UsersControl.java new file mode 100644 index 000000000..0013a42fc --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/api/UsersControl.java @@ -0,0 +1,59 @@ +package org.support.project.knowledge.control.api; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.ExUsersDao; +import org.support.project.knowledge.vo.AccountInfo; +import org.support.project.knowledge.vo.api.User; +import org.support.project.knowledge.vo.api.UserDetail; +import org.support.project.web.bean.ApiParams; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.control.ApiControl; +import org.support.project.web.control.service.Get; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.UsersEntity; + +@DI(instance = Instance.Prototype) +public class UsersControl extends ApiControl { + /** + * List users + */ + @Get(path="api/users") + public Boundary index() { + return get(); + } + + @Override + public Boundary getList(ApiParams params) { + List results = new ArrayList<>(); + List users = UsersDao.get().selectAllWidthPager(params.getLimit(), params.getOffset()); + for (UsersEntity usersEntity : users) { + User user = new User(); + PropertyUtil.copyPropertyValue(usersEntity, user); + results.add(user); + } + return send(HttpStatus.SC_200_OK, results); + } + + @Override + public Boundary getSingle(String id) { + if (!StringUtils.isInteger(id)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST); + } + int userId = Integer.parseInt(id); + AccountInfo entity = ExUsersDao.get().selectAccountInfoOnKey(userId); + if (entity == null) { + return sendError(HttpStatus.SC_404_NOT_FOUND); + } + UserDetail user = new UserDetail(); + PropertyUtil.copyPropertyValue(entity, user); + return send(HttpStatus.SC_200_OK, user); + } + +} 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 379919106..74c6991c5 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 @@ -37,6 +37,18 @@ public Boundary download() { LOG.debug("File binary is null. [fileNo] " + fileNo); return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND"); } + if (getParam("attachment").equals("")) { + // 画像(PNG, JPEG, GIF)を本文内に表示する場合は attachment パラメーターが付与されていない。 + if (entity.getFileName().toLowerCase().endsWith(".png")) { + return download(entity.getFileName(), entity.getFileBinary(), entity.getFileSize().longValue(), "image/png"); + } + if (entity.getFileName().toLowerCase().endsWith(".jpg") || entity.getFileName().toLowerCase().endsWith(".jpeg")) { + return download(entity.getFileName(), entity.getFileBinary(), entity.getFileSize().longValue(), "image/jpeg"); + } + if (entity.getFileName().toLowerCase().endsWith(".gif")) { + return download(entity.getFileName(), entity.getFileBinary(), entity.getFileSize().longValue(), "image/gif"); + } + } return download(entity.getFileName(), entity.getFileBinary(), entity.getFileSize().longValue()); } 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 5af0ff2ec..7fb8e8ddf 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 @@ -95,7 +95,13 @@ public Boundary save() { // 仮登録を行う ProvisionalRegistrationsEntity entity = addProvisionalRegistration(); // 招待のメールを送信 - String url = HttpUtil.getContextUrl(getRequest()); + SystemConfigsEntity config = SystemConfigsDao.get().selectOnKey(SystemConfig.SYSTEM_URL, AppConfig.get().getSystemName()); + String url; + if (config == null) { + url = HttpUtil.getContextUrl(getRequest()); + } else { + url = config.getConfigValue(); + } MailLogic mailLogic = MailLogic.get(); mailLogic.sendInvitation(entity, url, HttpUtil.getLocale(getRequest())); return forward("mail_sended.jsp"); diff --git a/src/main/java/org/support/project/knowledge/control/protect/ConfigControl.java b/src/main/java/org/support/project/knowledge/control/protect/ConfigControl.java index 5f540f10f..d4362923a 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/ConfigControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/ConfigControl.java @@ -1,16 +1,23 @@ package org.support.project.knowledge.control.protect; +import java.util.List; + import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.control.Control; import org.support.project.web.boundary.Boundary; import org.support.project.web.control.service.Get; +import org.support.project.web.dao.LdapConfigsDao; +import org.support.project.web.entity.LdapConfigsEntity; @DI(instance = Instance.Prototype) public class ConfigControl extends Control { @Get public Boundary index() { + List ldapConfigs = LdapConfigsDao.get().selectAll(); + Boolean ldapExists = ldapConfigs.size() > 0; + setAttribute("ldapExists", ldapExists); return forward("index.jsp"); } } diff --git a/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java b/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java new file mode 100644 index 000000000..b5c189bef --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/protect/ConnectControl.java @@ -0,0 +1,198 @@ +package org.support.project.knowledge.control.protect; + +import java.io.IOException; +import java.util.List; + +import org.apache.directory.api.ldap.model.exception.LdapException; +import org.support.project.common.config.INT_FLAG; +import org.support.project.common.util.StringUtils; +import org.support.project.knowledge.control.Control; +import org.support.project.web.bean.LdapInfo; +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.LdapConfigsDao; +import org.support.project.web.dao.UserAliasDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.LdapConfigsEntity; +import org.support.project.web.entity.UserAliasEntity; +import org.support.project.web.entity.UsersEntity; +import org.support.project.web.logic.LdapLogic; + +/** + * Ldapなどの外部サービスを使った認証の接続設定 + * @author koda + */ +public class ConnectControl extends Control { + @Get + public Boundary index() { + List ldapConfigs = LdapConfigsDao.get().selectAll(); + setAttribute("ldapConfigs", ldapConfigs); + + List alias = UserAliasDao.get().selectOnUserId(getLoginUserId()); + setAttribute("alias", alias); + + return forward("index.jsp"); + } + + /** + * 指定のユーザのLdap認証設定を設定する + * @return + */ + @Get + public Boundary config() { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + LdapConfigsEntity config = LdapConfigsDao.get().selectOnKey(key); + if (config == null) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + setAttribute("config", config); + + UserAliasEntity alias = UserAliasDao.get().selectOnKey(key, getLoginUserId()); + setAttribute("alias", alias); + + if (alias != null) { + List aliases = UserAliasDao.get().selectOnUserId(getLoginUserId()); + if (aliases.size() == 1) { + setAttribute("onlyone", Boolean.TRUE); + } else { + setAttribute("onlyone", Boolean.FALSE); + } + } + + return forward("config.jsp"); + } + + @Post + public Boundary connect() { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + LdapConfigsEntity config = LdapConfigsDao.get().selectOnKey(key); + if (config == null) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + String id = getParam("username"); + String password = getParam("password"); + if (StringUtils.isEmpty(id) || StringUtils.isEmpty(password)) { + super.addMsgWarn("message.login.error"); + return config(); + } + String userInfoUpdate = getParam("userInfoUpdate"); + if (StringUtils.isEmpty(userInfoUpdate)) { + userInfoUpdate = "0"; + } + try { + int update = Integer.parseInt(userInfoUpdate); + + UserAliasEntity exists = UserAliasDao.get().selectOnAliasKey(key, id); + if (exists != null) { + super.addMsgWarn("errors.exist", getResource("knowledge.connect.label.account")); + return config(); + } + + // LdapAuth + LdapLogic ldapLogic = LdapLogic.get(); + LdapInfo ldapInfo = ldapLogic.auth(config, id, password); + if (ldapInfo == null) { + super.addMsgWarn("message.login.error"); + return config(); + } + + UserAliasEntity alias = new UserAliasEntity(); + alias.setAuthKey(key); + alias.setUserId(getLoginUserId()); + alias.setAliasKey(id); + alias.setAliasName(ldapInfo.getName().toLowerCase()); + alias.setAliasMail(ldapInfo.getMail()); + alias.setUserInfoUpdate(update); + UserAliasDao.get().save(alias); + + if (update == 1) { + // ユーザの情報を更新する + UsersEntity user = UsersDao.get().selectOnKey(getLoginUserId()); + if (StringUtils.isNotEmpty(ldapInfo.getName())) { + user.setUserName(ldapInfo.getName()); + } + if (StringUtils.isNotEmpty(ldapInfo.getMail())) { + user.setMailAddress(ldapInfo.getMail()); + } + UsersDao.get().save(user); + } + return config(); + } catch (IOException | LdapException e) { + super.addMsgWarn("message.login.error"); + return config(); + } catch (NumberFormatException e) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + } + + @Post + public Boundary disconnect() { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + LdapConfigsEntity config = LdapConfigsDao.get().selectOnKey(key); + if (config == null) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + UserAliasEntity exists = UserAliasDao.get().selectOnKey(key, getLoginUserId()); + if (exists == null) { + super.addMsgWarn("errors.noexist", getResource("knowledge.connect.label.account")); + return index(); + } + UserAliasDao.get().physicalDelete(exists); + super.addMsgInfo("message.success.delete"); + return index(); + } + + @Post + public Boundary update() { + String key = getParam("key"); + if (StringUtils.isEmpty(key)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + LdapConfigsEntity config = LdapConfigsDao.get().selectOnKey(key); + if (config == null) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + String userInfoUpdate = getParam("userInfoUpdate"); + if (StringUtils.isEmpty(userInfoUpdate)) { + userInfoUpdate = "0"; + } + try { + int update = Integer.parseInt(userInfoUpdate); + + UserAliasEntity exists = UserAliasDao.get().selectOnKey(key, getLoginUserId()); + if (exists == null) { + super.addMsgWarn("errors.noexist", getResource("knowledge.connect.label.account")); + return index(); + } + exists.setUserInfoUpdate(update); + UserAliasDao.get().save(exists); + + if (update == INT_FLAG.ON.getValue()) { + UsersEntity user = UsersDao.get().selectOnKey(getLoginUserId()); + user.setUserName(exists.getAliasName()); + user.setMailAddress(exists.getAliasMail()); + UsersDao.get().save(user); + } + + super.addMsgInfo("message.success.update"); + return config(); + } catch (NumberFormatException e) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + } + + + + +} diff --git a/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java b/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java new file mode 100644 index 000000000..53a7734ea --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/protect/TokenControl.java @@ -0,0 +1,92 @@ +package org.support.project.knowledge.control.protect; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +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.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.dao.TokensDao; +import org.support.project.knowledge.entity.TokensEntity; +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; + +@DI(instance = Instance.Prototype) +public class TokenControl extends Control { + /** ログ */ + private static final Log LOG = LogFactory.getLog(TokenControl.class); + + private DateFormat gateDayFormat() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + + /** + * 現在のTokenの状態を見る + */ + @Get + public Boundary index() { + String expires = ""; + TokensEntity entity = TokensDao.get().selectOnUserId(getLoginUserId()); + if (entity == null) { + entity = new TokensEntity(); + entity.setToken(""); + } else { + expires = gateDayFormat().format(entity.getExpires()); + } + setAttribute("token", entity.getToken()); + setAttribute("expires", expires); + return forward("index.jsp"); + } + + + /** + * Tokenの発行/更新 + */ + @Post + public Boundary save() { + String expires = getParam("expires"); + if (StringUtils.isEmpty(expires)) { + expires = "9999-12-31"; + } + Date date; + try { + date = gateDayFormat().parse(expires); + } catch (ParseException e) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + + TokensEntity entity = TokensDao.get().selectOnUserId(getLoginUserId()); + if (entity == null) { + entity = new TokensEntity(); + entity.setToken(RandomUtil.randamGen(64)); + entity.setUserId(getLoginUserId()); + } + entity.setExpires(new Timestamp(date.getTime())); + TokensDao.get().save(entity); + addMsgSuccess("message.success.save"); + return index(); + } + + /** + * Tokenの削除 + */ + @Post + public Boundary delete() { + TokensEntity entity = TokensDao.get().selectOnUserId(getLoginUserId()); + if (entity != null) { + TokensDao.get().physicalDelete(entity); + } + addMsgSuccess("message.success.delete"); + return index(); + } +} diff --git a/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java b/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java index 7f48a0187..d8b8236cb 100644 --- a/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ExGroupsDao.java @@ -5,6 +5,7 @@ import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; +import org.support.project.knowledge.vo.api.GroupDetail; import org.support.project.ormapping.common.SQLManager; import org.support.project.web.bean.LoginedUser; import org.support.project.web.dao.GroupsDao; @@ -95,5 +96,24 @@ public List selectGroupsWithCount(int offset, int limit) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExGroupsDao/ExGroupsDao_selectGroupsWithCount.sql"); return executeQueryList(sql, GroupsEntity.class, limit, offset); } + + /** + * グループが宛先になっている投稿の件数を取得 + * @param groupId + * @return + */ + public Integer selectGroupKnowledgeCount(int groupId) { + String sql = "SELECT COUNT(*) FROM KNOWLEDGE_GROUPS WHERE GROUP_ID = ?"; + return executeQuerySingle(sql, Integer.class, groupId); + } + /** + * グループに所属するユーザの件数を取得 + * @param groupId + * @return + */ + public Integer selectGroupUserCount(int groupId) { + String sql = "SELECT COUNT(*) FROM USER_GROUPS WHERE GROUP_ID = ?"; + return executeQuerySingle(sql, Integer.class, groupId); + } } diff --git a/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java b/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java index 85155b165..1c7476e76 100644 --- a/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/ExUsersDao.java @@ -61,7 +61,9 @@ public List selectNotifyPublicUsers() { public AccountInfo selectAccountInfoOnKey(Integer userId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExUsersDao/selectAccountInfoOnKey.sql"); AccountInfo info = executeQuerySingle(sql, AccountInfo.class, userId); - + if (info == null) { + return null; + } sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/ExUsersDao/selectLikeCountOnAccount.sql"); Integer likeCount = executeQuerySingle(sql, Integer.class, userId); info.setLikeCount(likeCount); diff --git a/src/main/java/org/support/project/knowledge/dao/MailPropertiesDao.java b/src/main/java/org/support/project/knowledge/dao/MailPropertiesDao.java new file mode 100644 index 000000000..61ad050d8 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/MailPropertiesDao.java @@ -0,0 +1,27 @@ +package org.support.project.knowledge.dao; + +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.GenMailPropertiesDao; + +/** + * メール受信設定 + */ +@DI(instance = Instance.Singleton) +public class MailPropertiesDao extends GenMailPropertiesDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static MailPropertiesDao get() { + return Container.getComp(MailPropertiesDao.class); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java b/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java index ba6fc8b31..b417e7822 100644 --- a/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/TemplateMastersDao.java @@ -87,4 +87,14 @@ public void resetSequence() { .getSql("/org/support/project/knowledge/dao/sql/TemplateMastersDao/TemplateMastersDao_alter_sequence.sql"); executeUpdate(sql); } + + /** + * テンプレート名でテンプレートを取得 + * @param template + * @return + */ + public TemplateMastersEntity selectOnName(String template) { + String sql = "SELECT * FROM TEMPLATE_MASTERS WHERE TYPE_NAME = ? AND DELETE_FLAG = 0"; + return executeQuerySingle(sql, TemplateMastersEntity.class, template); + } } diff --git a/src/main/java/org/support/project/knowledge/dao/TokensDao.java b/src/main/java/org/support/project/knowledge/dao/TokensDao.java new file mode 100644 index 000000000..02fed72dc --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/TokensDao.java @@ -0,0 +1,39 @@ +package org.support.project.knowledge.dao; + +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.GenTokensDao; +import org.support.project.knowledge.entity.TokensEntity; +import org.support.project.ormapping.common.SQLManager; + +/** + * 認証トークン + */ +@DI(instance = Instance.Singleton) +public class TokensDao extends GenTokensDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + /** + * Get instance from DI container. + * @return instance + */ + public static TokensDao get() { + return Container.getComp(TokensDao.class); + } + /** + * ユーザのTokenを取得 + * @param userId + * @return + */ + public TokensEntity selectOnUserId(Integer userId) { + String sql = "SELECT * FROM TOKENS WHERE USER_ID = ? AND DELETE_FLAG = 0"; + return executeQuerySingle(sql, TokensEntity.class, userId); + + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java b/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java index fe252f78a..ec0d490f8 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/DatabaseControlDao.java @@ -20,48 +20,50 @@ public class DatabaseControlDao extends AbstractDao { /** Drop all tables */ public void dropAllTable() { - String[] sqls = new String[41]; + String[] sqls = new String[43]; sqls[0] = "DROP TABLE IF EXISTS KNOWLEDGES CASCADE;"; sqls[1] = "DROP TABLE IF EXISTS SERVICE_LOCALE_CONFIGS CASCADE;"; sqls[2] = "DROP TABLE IF EXISTS ACCOUNT_IMAGES CASCADE;"; sqls[3] = "DROP TABLE IF EXISTS EVENTS CASCADE;"; sqls[4] = "DROP TABLE IF EXISTS MAIL_POSTS CASCADE;"; - sqls[5] = "DROP TABLE IF EXISTS WEBHOOK_CONFIGS CASCADE;"; - sqls[6] = "DROP TABLE IF EXISTS MAIL_LOCALE_TEMPLATES CASCADE;"; - sqls[7] = "DROP TABLE IF EXISTS VOTES CASCADE;"; - sqls[8] = "DROP TABLE IF EXISTS COMMENTS CASCADE;"; - sqls[9] = "DROP TABLE IF EXISTS SURVEY_CHOICES CASCADE;"; - sqls[10] = "DROP TABLE IF EXISTS KNOWLEDGE_GROUPS CASCADE;"; - sqls[11] = "DROP TABLE IF EXISTS MAIL_HOOK_CONDITIONS CASCADE;"; - sqls[12] = "DROP TABLE IF EXISTS SURVEY_ITEM_ANSWERS CASCADE;"; - sqls[13] = "DROP TABLE IF EXISTS LIKES CASCADE;"; - sqls[14] = "DROP TABLE IF EXISTS DRAFT_ITEM_VALUES CASCADE;"; - sqls[15] = "DROP TABLE IF EXISTS VIEW_HISTORIES CASCADE;"; - sqls[16] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_GROUPS CASCADE;"; - sqls[17] = "DROP TABLE IF EXISTS WEBHOOKS CASCADE;"; - sqls[18] = "DROP TABLE IF EXISTS KNOWLEDGE_FILES CASCADE;"; - sqls[19] = "DROP TABLE IF EXISTS NOTIFY_QUEUES CASCADE;"; - sqls[20] = "DROP TABLE IF EXISTS TEMPLATE_MASTERS CASCADE;"; - sqls[21] = "DROP TABLE IF EXISTS SERVICE_CONFIGS CASCADE;"; - sqls[22] = "DROP TABLE IF EXISTS ITEM_CHOICES CASCADE;"; - sqls[23] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_USERS CASCADE;"; - sqls[24] = "DROP TABLE IF EXISTS PINS CASCADE;"; - sqls[25] = "DROP TABLE IF EXISTS KNOWLEDGE_HISTORIES CASCADE;"; - sqls[26] = "DROP TABLE IF EXISTS KNOWLEDGE_ITEM_VALUES CASCADE;"; - sqls[27] = "DROP TABLE IF EXISTS KNOWLEDGE_TAGS CASCADE;"; - sqls[28] = "DROP TABLE IF EXISTS SURVEY_ANSWERS CASCADE;"; - sqls[29] = "DROP TABLE IF EXISTS SURVEYS CASCADE;"; - sqls[30] = "DROP TABLE IF EXISTS MAIL_TEMPLATES CASCADE;"; - sqls[31] = "DROP TABLE IF EXISTS NOTIFY_CONFIGS CASCADE;"; - sqls[32] = "DROP TABLE IF EXISTS SURVEY_ITEMS CASCADE;"; - sqls[33] = "DROP TABLE IF EXISTS MAIL_HOOKS CASCADE;"; - sqls[34] = "DROP TABLE IF EXISTS DRAFT_KNOWLEDGES CASCADE;"; - sqls[35] = "DROP TABLE IF EXISTS STOCKS CASCADE;"; - sqls[36] = "DROP TABLE IF EXISTS STOCK_KNOWLEDGES CASCADE;"; - sqls[37] = "DROP TABLE IF EXISTS KNOWLEDGE_USERS CASCADE;"; - sqls[38] = "DROP TABLE IF EXISTS PARTICIPANTS CASCADE;"; - sqls[39] = "DROP TABLE IF EXISTS TAGS CASCADE;"; - sqls[40] = "DROP TABLE IF EXISTS TEMPLATE_ITEMS CASCADE;"; + sqls[5] = "DROP TABLE IF EXISTS MAIL_PROPERTIES CASCADE;"; + sqls[6] = "DROP TABLE IF EXISTS WEBHOOK_CONFIGS CASCADE;"; + sqls[7] = "DROP TABLE IF EXISTS MAIL_LOCALE_TEMPLATES CASCADE;"; + sqls[8] = "DROP TABLE IF EXISTS VOTES CASCADE;"; + sqls[9] = "DROP TABLE IF EXISTS COMMENTS CASCADE;"; + sqls[10] = "DROP TABLE IF EXISTS SURVEY_CHOICES CASCADE;"; + sqls[11] = "DROP TABLE IF EXISTS TOKENS CASCADE;"; + sqls[12] = "DROP TABLE IF EXISTS KNOWLEDGE_GROUPS CASCADE;"; + sqls[13] = "DROP TABLE IF EXISTS MAIL_HOOK_CONDITIONS CASCADE;"; + sqls[14] = "DROP TABLE IF EXISTS SURVEY_ITEM_ANSWERS CASCADE;"; + sqls[15] = "DROP TABLE IF EXISTS LIKES CASCADE;"; + sqls[16] = "DROP TABLE IF EXISTS DRAFT_ITEM_VALUES CASCADE;"; + sqls[17] = "DROP TABLE IF EXISTS VIEW_HISTORIES CASCADE;"; + sqls[18] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_GROUPS CASCADE;"; + sqls[19] = "DROP TABLE IF EXISTS WEBHOOKS CASCADE;"; + sqls[20] = "DROP TABLE IF EXISTS KNOWLEDGE_FILES CASCADE;"; + sqls[21] = "DROP TABLE IF EXISTS NOTIFY_QUEUES CASCADE;"; + sqls[22] = "DROP TABLE IF EXISTS TEMPLATE_MASTERS CASCADE;"; + sqls[23] = "DROP TABLE IF EXISTS SERVICE_CONFIGS CASCADE;"; + sqls[24] = "DROP TABLE IF EXISTS ITEM_CHOICES CASCADE;"; + sqls[25] = "DROP TABLE IF EXISTS KNOWLEDGE_EDIT_USERS CASCADE;"; + sqls[26] = "DROP TABLE IF EXISTS PINS CASCADE;"; + sqls[27] = "DROP TABLE IF EXISTS KNOWLEDGE_HISTORIES CASCADE;"; + sqls[28] = "DROP TABLE IF EXISTS KNOWLEDGE_ITEM_VALUES CASCADE;"; + sqls[29] = "DROP TABLE IF EXISTS KNOWLEDGE_TAGS CASCADE;"; + sqls[30] = "DROP TABLE IF EXISTS SURVEY_ANSWERS CASCADE;"; + sqls[31] = "DROP TABLE IF EXISTS SURVEYS CASCADE;"; + sqls[32] = "DROP TABLE IF EXISTS MAIL_TEMPLATES CASCADE;"; + sqls[33] = "DROP TABLE IF EXISTS NOTIFY_CONFIGS CASCADE;"; + sqls[34] = "DROP TABLE IF EXISTS SURVEY_ITEMS CASCADE;"; + sqls[35] = "DROP TABLE IF EXISTS MAIL_HOOKS CASCADE;"; + sqls[36] = "DROP TABLE IF EXISTS DRAFT_KNOWLEDGES CASCADE;"; + sqls[37] = "DROP TABLE IF EXISTS STOCKS CASCADE;"; + sqls[38] = "DROP TABLE IF EXISTS STOCK_KNOWLEDGES CASCADE;"; + sqls[39] = "DROP TABLE IF EXISTS KNOWLEDGE_USERS CASCADE;"; + sqls[40] = "DROP TABLE IF EXISTS PARTICIPANTS CASCADE;"; + sqls[41] = "DROP TABLE IF EXISTS TAGS CASCADE;"; + sqls[42] = "DROP TABLE IF EXISTS TEMPLATE_ITEMS CASCADE;"; for (String sql : sqls) { LOG.debug(sql); executeUpdate(sql); @@ -69,48 +71,50 @@ public void dropAllTable() { } /** Delete all table data */ public void dropAllData() { - String[] sqls = new String[41]; + String[] sqls = new String[43]; sqls[0] = "TRUNCATE TABLE KNOWLEDGES;"; sqls[1] = "TRUNCATE TABLE SERVICE_LOCALE_CONFIGS;"; sqls[2] = "TRUNCATE TABLE ACCOUNT_IMAGES;"; sqls[3] = "TRUNCATE TABLE EVENTS;"; sqls[4] = "TRUNCATE TABLE MAIL_POSTS;"; - sqls[5] = "TRUNCATE TABLE WEBHOOK_CONFIGS;"; - sqls[6] = "TRUNCATE TABLE MAIL_LOCALE_TEMPLATES;"; - sqls[7] = "TRUNCATE TABLE VOTES;"; - sqls[8] = "TRUNCATE TABLE COMMENTS;"; - sqls[9] = "TRUNCATE TABLE SURVEY_CHOICES;"; - sqls[10] = "TRUNCATE TABLE KNOWLEDGE_GROUPS;"; - sqls[11] = "TRUNCATE TABLE MAIL_HOOK_CONDITIONS;"; - sqls[12] = "TRUNCATE TABLE SURVEY_ITEM_ANSWERS;"; - sqls[13] = "TRUNCATE TABLE LIKES;"; - sqls[14] = "TRUNCATE TABLE DRAFT_ITEM_VALUES;"; - sqls[15] = "TRUNCATE TABLE VIEW_HISTORIES;"; - sqls[16] = "TRUNCATE TABLE KNOWLEDGE_EDIT_GROUPS;"; - sqls[17] = "TRUNCATE TABLE WEBHOOKS;"; - sqls[18] = "TRUNCATE TABLE KNOWLEDGE_FILES;"; - sqls[19] = "TRUNCATE TABLE NOTIFY_QUEUES;"; - sqls[20] = "TRUNCATE TABLE TEMPLATE_MASTERS;"; - sqls[21] = "TRUNCATE TABLE SERVICE_CONFIGS;"; - sqls[22] = "TRUNCATE TABLE ITEM_CHOICES;"; - sqls[23] = "TRUNCATE TABLE KNOWLEDGE_EDIT_USERS;"; - sqls[24] = "TRUNCATE TABLE PINS;"; - sqls[25] = "TRUNCATE TABLE KNOWLEDGE_HISTORIES;"; - sqls[26] = "TRUNCATE TABLE KNOWLEDGE_ITEM_VALUES;"; - sqls[27] = "TRUNCATE TABLE KNOWLEDGE_TAGS;"; - sqls[28] = "TRUNCATE TABLE SURVEY_ANSWERS;"; - sqls[29] = "TRUNCATE TABLE SURVEYS;"; - sqls[30] = "TRUNCATE TABLE MAIL_TEMPLATES;"; - sqls[31] = "TRUNCATE TABLE NOTIFY_CONFIGS;"; - sqls[32] = "TRUNCATE TABLE SURVEY_ITEMS;"; - sqls[33] = "TRUNCATE TABLE MAIL_HOOKS;"; - sqls[34] = "TRUNCATE TABLE DRAFT_KNOWLEDGES;"; - sqls[35] = "TRUNCATE TABLE STOCKS;"; - sqls[36] = "TRUNCATE TABLE STOCK_KNOWLEDGES;"; - sqls[37] = "TRUNCATE TABLE KNOWLEDGE_USERS;"; - sqls[38] = "TRUNCATE TABLE PARTICIPANTS;"; - sqls[39] = "TRUNCATE TABLE TAGS;"; - sqls[40] = "TRUNCATE TABLE TEMPLATE_ITEMS;"; + sqls[5] = "TRUNCATE TABLE MAIL_PROPERTIES;"; + sqls[6] = "TRUNCATE TABLE WEBHOOK_CONFIGS;"; + sqls[7] = "TRUNCATE TABLE MAIL_LOCALE_TEMPLATES;"; + sqls[8] = "TRUNCATE TABLE VOTES;"; + sqls[9] = "TRUNCATE TABLE COMMENTS;"; + sqls[10] = "TRUNCATE TABLE SURVEY_CHOICES;"; + sqls[11] = "TRUNCATE TABLE TOKENS;"; + sqls[12] = "TRUNCATE TABLE KNOWLEDGE_GROUPS;"; + sqls[13] = "TRUNCATE TABLE MAIL_HOOK_CONDITIONS;"; + sqls[14] = "TRUNCATE TABLE SURVEY_ITEM_ANSWERS;"; + sqls[15] = "TRUNCATE TABLE LIKES;"; + sqls[16] = "TRUNCATE TABLE DRAFT_ITEM_VALUES;"; + sqls[17] = "TRUNCATE TABLE VIEW_HISTORIES;"; + sqls[18] = "TRUNCATE TABLE KNOWLEDGE_EDIT_GROUPS;"; + sqls[19] = "TRUNCATE TABLE WEBHOOKS;"; + sqls[20] = "TRUNCATE TABLE KNOWLEDGE_FILES;"; + sqls[21] = "TRUNCATE TABLE NOTIFY_QUEUES;"; + sqls[22] = "TRUNCATE TABLE TEMPLATE_MASTERS;"; + sqls[23] = "TRUNCATE TABLE SERVICE_CONFIGS;"; + sqls[24] = "TRUNCATE TABLE ITEM_CHOICES;"; + sqls[25] = "TRUNCATE TABLE KNOWLEDGE_EDIT_USERS;"; + sqls[26] = "TRUNCATE TABLE PINS;"; + sqls[27] = "TRUNCATE TABLE KNOWLEDGE_HISTORIES;"; + sqls[28] = "TRUNCATE TABLE KNOWLEDGE_ITEM_VALUES;"; + sqls[29] = "TRUNCATE TABLE KNOWLEDGE_TAGS;"; + sqls[30] = "TRUNCATE TABLE SURVEY_ANSWERS;"; + sqls[31] = "TRUNCATE TABLE SURVEYS;"; + sqls[32] = "TRUNCATE TABLE MAIL_TEMPLATES;"; + sqls[33] = "TRUNCATE TABLE NOTIFY_CONFIGS;"; + sqls[34] = "TRUNCATE TABLE SURVEY_ITEMS;"; + sqls[35] = "TRUNCATE TABLE MAIL_HOOKS;"; + sqls[36] = "TRUNCATE TABLE DRAFT_KNOWLEDGES;"; + sqls[37] = "TRUNCATE TABLE STOCKS;"; + sqls[38] = "TRUNCATE TABLE STOCK_KNOWLEDGES;"; + sqls[39] = "TRUNCATE TABLE KNOWLEDGE_USERS;"; + sqls[40] = "TRUNCATE TABLE PARTICIPANTS;"; + sqls[41] = "TRUNCATE TABLE TAGS;"; + sqls[42] = "TRUNCATE TABLE TEMPLATE_ITEMS;"; for (String sql : sqls) { LOG.debug(sql); executeUpdate(sql); diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java new file mode 100644 index 000000000..6f4dd9ddf --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailPropertiesDao.java @@ -0,0 +1,419 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.MailPropertiesEntity; +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; + +/** + * メール受信設定 + * this class is auto generate and not edit. + * if modify dao method, you can edit MailPropertiesDao. + */ +@DI(instance = Instance.Singleton) +public class GenMailPropertiesDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenMailPropertiesDao get() { + return Container.getComp(GenMailPropertiesDao.class); + } + + /** + * Select all data. + * @return all data + */ + public List physicalSelectAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql"); + return executeQueryList(sql, MailPropertiesEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + public List physicalSelectAllWithPager(int limit, int offset) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql"); + return executeQueryList(sql, MailPropertiesEntity.class, limit, offset); + } + /** + * Select data on key. + * @param hookId hookId + * @param propertyKey propertyKey + * @return data + */ + public MailPropertiesEntity physicalSelectOnKey(Integer hookId, String propertyKey) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, MailPropertiesEntity.class, hookId, propertyKey); + } + /** + * Select all data that not deleted. + * @return all data + */ + public List selectAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql"); + return executeQueryList(sql, MailPropertiesEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + public List selectAllWidthPager(int limit, int offset) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql"); + return executeQueryList(sql, MailPropertiesEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param hookId hookId + * @param propertyKey propertyKey + * @return data + */ + public MailPropertiesEntity selectOnKey(Integer hookId, String propertyKey) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_key.sql"); + return executeQuerySingle(sql, MailPropertiesEntity.class, hookId, propertyKey); + } + /** + * Select data that not deleted on HOOK_ID column. + * @param hookId hookId + * @return list + */ + public List selectOnHookId(Integer hookId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_hook_id.sql"); + return executeQueryList(sql, MailPropertiesEntity.class, hookId); + } + /** + * Select data that not deleted on PROPERTY_KEY column. + * @param propertyKey propertyKey + * @return list + */ + public List selectOnPropertyKey(String propertyKey) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_property_key.sql"); + return executeQueryList(sql, MailPropertiesEntity.class, propertyKey); + } + /** + * Select data on HOOK_ID column. + * @param hookId hookId + * @return list + */ + public List physicalSelectOnHookId(Integer hookId) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_hook_id.sql"); + return executeQueryList(sql, MailPropertiesEntity.class, hookId); + } + /** + * Select data on PROPERTY_KEY column. + * @param propertyKey propertyKey + * @return list + */ + public List physicalSelectOnPropertyKey(String propertyKey) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_property_key.sql"); + return executeQueryList(sql, MailPropertiesEntity.class, propertyKey); + } + /** + * Count all data + * @return count + */ + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM MAIL_PROPERTIES"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity rawPhysicalInsert(MailPropertiesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_raw_insert.sql"); + executeUpdate(sql, + entity.getHookId(), + entity.getPropertyKey(), + entity.getPropertyValue(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity physicalInsert(MailPropertiesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_insert.sql"); + executeUpdate(sql, + entity.getHookId(), + entity.getPropertyKey(), + entity.getPropertyValue(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity insert(Integer user, MailPropertiesEntity 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); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity insert(MailPropertiesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity physicalUpdate(MailPropertiesEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_update.sql"); + executeUpdate(sql, + entity.getPropertyValue(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getHookId(), + entity.getPropertyKey()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity update(Integer user, MailPropertiesEntity entity) { + MailPropertiesEntity db = selectOnKey(entity.getHookId(), entity.getPropertyKey()); + 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); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity update(MailPropertiesEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity save(Integer user, MailPropertiesEntity entity) { + MailPropertiesEntity db = selectOnKey(entity.getHookId(), entity.getPropertyKey()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public MailPropertiesEntity save(MailPropertiesEntity entity) { + MailPropertiesEntity db = selectOnKey(entity.getHookId(), entity.getPropertyKey()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param hookId hookId + * @param propertyKey propertyKey + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(Integer hookId, String propertyKey) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_delete.sql"); + executeUpdate(sql, hookId, propertyKey); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(MailPropertiesEntity entity) { + physicalDelete(entity.getHookId(), entity.getPropertyKey()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param hookId hookId + * @param propertyKey propertyKey + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, Integer hookId, String propertyKey) { + MailPropertiesEntity db = selectOnKey(hookId, propertyKey); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param hookId hookId + * @param propertyKey propertyKey + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer hookId, String propertyKey) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, hookId, propertyKey); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, MailPropertiesEntity entity) { + delete(user, entity.getHookId(), entity.getPropertyKey()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(MailPropertiesEntity entity) { + delete(entity.getHookId(), entity.getPropertyKey()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param hookId hookId + * @param propertyKey propertyKey + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, Integer hookId, String propertyKey) { + MailPropertiesEntity db = physicalSelectOnKey(hookId, propertyKey); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param hookId hookId + * @param propertyKey propertyKey + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer hookId, String propertyKey) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, hookId, propertyKey); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, MailPropertiesEntity entity) { + activation(user, entity.getHookId(), entity.getPropertyKey()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(MailPropertiesEntity entity) { + activation(entity.getHookId(), entity.getPropertyKey()); + + } + +} diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java new file mode 100644 index 000000000..81d688106 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenTokensDao.java @@ -0,0 +1,376 @@ +package org.support.project.knowledge.dao.gen; + +import java.util.List; + +import java.sql.Timestamp; + + +import org.support.project.knowledge.entity.TokensEntity; +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; + +/** + * 認証トークン + * this class is auto generate and not edit. + * if modify dao method, you can edit TokensDao. + */ +@DI(instance = Instance.Singleton) +public class GenTokensDao extends AbstractDao { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenTokensDao get() { + return Container.getComp(GenTokensDao.class); + } + + /** + * Select all data. + * @return all data + */ + public List physicalSelectAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql"); + return executeQueryList(sql, TokensEntity.class); + } + /** + * Select all data with pager. + * @param limit limit + * @param offset offset + * @return all data on limit and offset + */ + public List physicalSelectAllWithPager(int limit, int offset) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql"); + return executeQueryList(sql, TokensEntity.class, limit, offset); + } + /** + * Select data on key. + * @param token token + * @return data + */ + public TokensEntity physicalSelectOnKey(String token) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_on_key.sql"); + return executeQuerySingle(sql, TokensEntity.class, token); + } + /** + * Select all data that not deleted. + * @return all data + */ + public List selectAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql"); + return executeQueryList(sql, TokensEntity.class); + } + /** + * Select all data that not deleted with pager. + * @param limit limit + * @param offset offset + * @return all data + */ + public List selectAllWidthPager(int limit, int offset) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql"); + return executeQueryList(sql, TokensEntity.class, limit, offset); + } + /** + * Select count that not deleted. + * @return count + */ + public Integer selectCountAll() { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_count_all.sql"); + return executeQuerySingle(sql, Integer.class); + } + /** + * Select data that not deleted on key. + * @param token token + * @return data + */ + public TokensEntity selectOnKey(String token) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_on_key.sql"); + return executeQuerySingle(sql, TokensEntity.class, token); + } + /** + * Count all data + * @return count + */ + public int physicalCountAll() { + String sql = "SELECT COUNT(*) FROM TOKENS"; + return executeQuerySingle(sql, Integer.class); + } + /** + * Physical Insert. + * it is not create key on database sequence. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity rawPhysicalInsert(TokensEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_raw_insert.sql"); + executeUpdate(sql, + entity.getToken(), + entity.getUserId(), + entity.getExpires(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Physical Insert. + * if key column have sequence, key value create by database. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity physicalInsert(TokensEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_insert.sql"); + executeUpdate(sql, + entity.getToken(), + entity.getUserId(), + entity.getExpires(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag()); + return entity; + } + /** + * Insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity insert(Integer user, TokensEntity 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); + } + /** + * Insert. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity insert(TokensEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return insert(userId, entity); + } + /** + * Physical Update. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity physicalUpdate(TokensEntity entity) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_update.sql"); + executeUpdate(sql, + entity.getUserId(), + entity.getExpires(), + entity.getInsertUser(), + entity.getInsertDatetime(), + entity.getUpdateUser(), + entity.getUpdateDatetime(), + entity.getDeleteFlag(), + entity.getToken()); + return entity; + } + /** + * Update. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity update(Integer user, TokensEntity entity) { + TokensEntity db = selectOnKey(entity.getToken()); + 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); + } + /** + * Update. + * saved user id is auto set. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity update(TokensEntity entity) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer userId = (Integer) pool.getUser(); + return update(userId, entity); + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * set saved user id. + * @param user saved userid + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity save(Integer user, TokensEntity entity) { + TokensEntity db = selectOnKey(entity.getToken()); + if (db == null) { + return insert(user, entity); + } else { + return update(user, entity); + } + } + /** + * Save. + * if same key data is exists, the data is update. otherwise the data is insert. + * @param entity entity + * @return saved entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public TokensEntity save(TokensEntity entity) { + TokensEntity db = selectOnKey(entity.getToken()); + if (db == null) { + return insert(entity); + } else { + return update(entity); + } + } + /** + * Physical Delete. + * @param token token + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(String token) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_delete.sql"); + executeUpdate(sql, token); + } + /** + * Physical Delete. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void physicalDelete(TokensEntity entity) { + physicalDelete(entity.getToken()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param token token + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, String token) { + TokensEntity db = selectOnKey(token); + db.setDeleteFlag(1); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + physicalUpdate(db); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * @param token token + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(String token) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + delete(user, token); + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(Integer user, TokensEntity entity) { + delete(user, entity.getToken()); + + } + /** + * Delete. + * if delete flag is exists, the data is logical delete. + * set saved user id. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void delete(TokensEntity entity) { + delete(entity.getToken()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param token token + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, String token) { + TokensEntity db = physicalSelectOnKey(token); + db.setDeleteFlag(0); + db.setUpdateUser(user); + db.setUpdateDatetime(new Timestamp(new java.util.Date().getTime())); + physicalUpdate(db); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param token token + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(String token) { + DBUserPool pool = Container.getComp(DBUserPool.class); + Integer user = (Integer) pool.getUser(); + activation(user, token); + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * set saved user id. + * @param user saved userid + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(Integer user, TokensEntity entity) { + activation(user, entity.getToken()); + + } + /** + * Ativation. + * if delete flag is exists and delete flag is true, delete flug is false to activate. + * @param entity entity + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void activation(TokensEntity entity) { + activation(entity.getToken()); + + } + +} 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 f41e58b8d..f71d5c0d4 100644 --- a/src/main/java/org/support/project/knowledge/deploy/InitDB.java +++ b/src/main/java/org/support/project/knowledge/deploy/InitDB.java @@ -17,6 +17,9 @@ import org.support.project.knowledge.deploy.v0_6_0pre2.Migrate_0_6_0pre2; import org.support.project.knowledge.deploy.v0_6_0pre4.Migrate_0_6_0pre4; import org.support.project.knowledge.deploy.v0_8_0pre1.Migrate_0_8_0pre1; +import org.support.project.knowledge.deploy.v1_10_0.Migrate_1_10_0; +import org.support.project.knowledge.deploy.v1_10_0.Migrate_1_10_1; +import org.support.project.knowledge.deploy.v1_10_0.Migrate_1_10_2; import org.support.project.knowledge.deploy.v1_1_0pre1.Migrate_1_1_0pre1; import org.support.project.knowledge.deploy.v1_4_0.Migrate_1_4_0; import org.support.project.knowledge.deploy.v1_5_0.Migrate_1_5_0; @@ -41,7 +44,7 @@ public class InitDB { private static final Map MAP = new LinkedHashMap<>(); private static final Migrate INIT = InitializeSystem.get(); - public static final String CURRENT = "1.8.5"; + public static final String CURRENT = "1.10.2"; public InitDB() { super(); @@ -68,6 +71,9 @@ public InitDB() { MAP.put("1.8.3", Migrate_1_8_3.get()); MAP.put("1.8.4", Migrate_1_8_4.get()); MAP.put("1.8.5", Migrate_1_8_5.get()); + MAP.put("1.10.0", Migrate_1_10_0.get()); + MAP.put("1.10.1", Migrate_1_10_1.get()); + MAP.put("1.10.2", Migrate_1_10_2.get()); } public static void main(String[] args) throws Exception { diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_0.java b/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_0.java new file mode 100644 index 000000000..f3dce3ded --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_0.java @@ -0,0 +1,52 @@ +package org.support.project.knowledge.deploy.v1_10_0; + +import java.util.List; + +import org.support.project.common.config.INT_FLAG; +import org.support.project.common.util.Compare; +import org.support.project.knowledge.config.AppConfig; +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.ormapping.tool.dao.InitializeDao; +import org.support.project.web.dao.LdapConfigsDao; +import org.support.project.web.dao.UserAliasDao; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.LdapConfigsEntity; +import org.support.project.web.entity.UserAliasEntity; +import org.support.project.web.entity.UsersEntity; + +public class Migrate_1_10_0 implements Migrate { + + public static Migrate_1_10_0 get() { + return org.support.project.di.Container.getComp(Migrate_1_10_0.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_10_0/migrate.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + + // 既にLdapを使っている人の情報をAliasに入れる + LdapConfigsEntity entity = LdapConfigsDao.get().selectOnKey(AppConfig.get().getSystemName()); + if (entity != null) { + // Descriptionに初期値をセット + entity.setDescription("LDAP"); + LdapConfigsDao.get().save(entity); + // あまりに多くのユーザだと問題だけど、ユーザなのでたぶん1000件以下なので一気にロード + List users = UsersDao.get().selectAll(); + for (UsersEntity user : users) { + if (Compare.equal(user.getAuthLdap(), INT_FLAG.ON.getValue())) { + UserAliasEntity alias = new UserAliasEntity(AppConfig.get().getSystemName(), user.getUserId()); + alias.setAliasKey(user.getUserKey()); + alias.setAliasMail(user.getMailAddress()); + alias.setAliasName(user.getUserName()); + alias.setUserInfoUpdate(INT_FLAG.ON.getValue()); + UserAliasDao.get().save(alias); + } + } + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_1.java b/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_1.java new file mode 100644 index 000000000..16ff95319 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_1.java @@ -0,0 +1,39 @@ +package org.support.project.knowledge.deploy.v1_10_0; + +import org.support.project.knowledge.dao.MailHooksDao; +import org.support.project.knowledge.dao.MailPropertiesDao; +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.knowledge.entity.MailHooksEntity; +import org.support.project.knowledge.entity.MailPropertiesEntity; +import org.support.project.knowledge.logic.MailhookLogic; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_10_1 implements Migrate { + + public static Migrate_1_10_1 get() { + return org.support.project.di.Container.getComp(Migrate_1_10_1.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_10_0/migrate2.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + + // メール設定が既に存在している場合は、それと同等のプロパティ情報を生成する + MailHooksEntity mailHook = MailHooksDao.get().selectOnKey(MailhookLogic.MAIL_HOOK_ID); + if (mailHook != null) { + MailPropertiesEntity property = new MailPropertiesEntity(MailhookLogic.MAIL_HOOK_ID, "mail.store.protocol"); + property.setPropertyValue("imaps"); + MailPropertiesDao.get().save(property); + + property.setPropertyKey("mail.imaps.ssl.trust"); + property.setPropertyValue("*"); + MailPropertiesDao.get().save(property); + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_2.java b/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_2.java new file mode 100644 index 000000000..dac3ea6d0 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/deploy/v1_10_0/Migrate_1_10_2.java @@ -0,0 +1,21 @@ +package org.support.project.knowledge.deploy.v1_10_0; + +import org.support.project.knowledge.deploy.Migrate; +import org.support.project.ormapping.tool.dao.InitializeDao; + +public class Migrate_1_10_2 implements Migrate { + + public static Migrate_1_10_2 get() { + return org.support.project.di.Container.getComp(Migrate_1_10_2.class); + } + + @Override + public boolean doMigrate() throws Exception { + InitializeDao initializeDao = InitializeDao.get(); + String[] sqlpaths = { + "/org/support/project/knowledge/deploy/v1_10_0/migrate3.sql", + }; + initializeDao.initializeDatabase(sqlpaths); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/support/project/knowledge/entity/MailPropertiesEntity.java b/src/main/java/org/support/project/knowledge/entity/MailPropertiesEntity.java new file mode 100644 index 000000000..2ee3d9c40 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/MailPropertiesEntity.java @@ -0,0 +1,50 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenMailPropertiesEntity; + +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 MailPropertiesEntity extends GenMailPropertiesEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static MailPropertiesEntity get() { + return Container.getComp(MailPropertiesEntity.class); + } + + /** + * Constructor. + */ + public MailPropertiesEntity() { + super(); + } + + /** + * Constructor + * @param hookId HOOK_ID + * @param propertyKey PROPERTY_KEY + */ + + public MailPropertiesEntity(Integer hookId, String propertyKey) { + super( hookId, propertyKey); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/TokensEntity.java b/src/main/java/org/support/project/knowledge/entity/TokensEntity.java new file mode 100644 index 000000000..a3348804b --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/TokensEntity.java @@ -0,0 +1,49 @@ +package org.support.project.knowledge.entity; + +import org.support.project.knowledge.entity.gen.GenTokensEntity; + +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 TokensEntity extends GenTokensEntity { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static TokensEntity get() { + return Container.getComp(TokensEntity.class); + } + + /** + * Constructor. + */ + public TokensEntity() { + super(); + } + + /** + * Constructor + * @param token TOKEN + */ + + public TokensEntity(String token) { + super( token); + } + +} diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java index 97929bd13..2280f2463 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenEventsEntity.java @@ -51,7 +51,7 @@ public GenEventsEntity(Long knowledgeId) { } /** ナレッジID */ private Long knowledgeId; - /** 開催日 UTC */ + /** 開催日 UTC */ private Timestamp startDateTime; /** タイムゾーン */ private String timeZone; @@ -85,15 +85,15 @@ public GenEventsEntity setKnowledgeId(Long knowledgeId) { } /** - * Get 開催日 UTC. - * @return 開催日 UTC + * Get 開催日 UTC. + * @return 開催日 UTC */ public Timestamp getStartDateTime() { return this.startDateTime; } /** - * Set 開催日 UTC. - * @param startDateTime 開催日 UTC + * Set 開催日 UTC. + * @param startDateTime 開催日 UTC * @return this object */ public GenEventsEntity setStartDateTime(Timestamp startDateTime) { this.startDateTime = startDateTime; diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java index 58cc721aa..5b35fb4ac 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenMailHookConditionsEntity.java @@ -55,13 +55,13 @@ public GenMailHookConditionsEntity(Integer conditionNo, Integer hookId) { private Integer hookId; /** CONDITION_NO */ private Integer conditionNo; - /** 条件の種類 1:宛先が「条件文字」であった場合 */ + /** 条件の種類 1:宛先が「条件文字」であった場合 */ private Integer conditionKind; /** 条件の文字 */ private String condition; /** 投稿者 */ private Integer processUser; - /** 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 */ + /** 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 */ private Integer processUserKind; /** 公開区分 */ private Integer publicFlag; @@ -119,15 +119,15 @@ public GenMailHookConditionsEntity setConditionNo(Integer conditionNo) { } /** - * Get 条件の種類 1:宛先が「条件文字」であった場合. - * @return 条件の種類 1:宛先が「条件文字」であった場合 + * Get 条件の種類 1:宛先が「条件文字」であった場合. + * @return 条件の種類 1:宛先が「条件文字」であった場合 */ public Integer getConditionKind() { return this.conditionKind; } /** - * Set 条件の種類 1:宛先が「条件文字」であった場合. - * @param conditionKind 条件の種類 1:宛先が「条件文字」であった場合 + * Set 条件の種類 1:宛先が「条件文字」であった場合. + * @param conditionKind 条件の種類 1:宛先が「条件文字」であった場合 * @return this object */ public GenMailHookConditionsEntity setConditionKind(Integer conditionKind) { this.conditionKind = conditionKind; @@ -167,15 +167,15 @@ public GenMailHookConditionsEntity setProcessUser(Integer processUser) { } /** - * Get 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. - * @return 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 + * Get 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. + * @return 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 */ public Integer getProcessUserKind() { return this.processUserKind; } /** - * Set 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. - * @param processUserKind 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 + * Set 投稿者の指定 1:送信者のメールアドレスから、2:常に固定. + * @param processUserKind 投稿者の指定 1:送信者のメールアドレスから、2:常に固定 * @return this object */ public GenMailHookConditionsEntity setProcessUserKind(Integer processUserKind) { this.processUserKind = processUserKind; diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java index 8f54e0736..4ea8071cc 100644 --- a/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenMailPostsEntity.java @@ -51,7 +51,7 @@ public GenMailPostsEntity(String messageId) { } /** Message-ID */ private String messageId; - /** 投稿区分 1: Knowledge 2:Comment */ + /** 投稿区分 1: Knowledge 2:Comment */ private Integer postKind; /** ID */ private Long id; @@ -85,15 +85,15 @@ public GenMailPostsEntity setMessageId(String messageId) { } /** - * Get 投稿区分 1: Knowledge 2:Comment. - * @return 投稿区分 1: Knowledge 2:Comment + * Get 投稿区分 1: Knowledge 2:Comment. + * @return 投稿区分 1: Knowledge 2:Comment */ public Integer getPostKind() { return this.postKind; } /** - * Set 投稿区分 1: Knowledge 2:Comment. - * @param postKind 投稿区分 1: Knowledge 2:Comment + * Set 投稿区分 1: Knowledge 2:Comment. + * @param postKind 投稿区分 1: Knowledge 2:Comment * @return this object */ public GenMailPostsEntity setPostKind(Integer postKind) { this.postKind = postKind; diff --git a/src/main/java/org/support/project/knowledge/entity/gen/GenMailPropertiesEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenMailPropertiesEntity.java new file mode 100644 index 000000000..94fa391a9 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenMailPropertiesEntity.java @@ -0,0 +1,370 @@ +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 GenMailPropertiesEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenMailPropertiesEntity get() { + return Container.getComp(GenMailPropertiesEntity.class); + } + + /** + * Constructor. + */ + public GenMailPropertiesEntity() { + super(); + } + + /** + * Constructor + * @param hookId HOOK_ID + * @param propertyKey PROPERTY_KEY + */ + + public GenMailPropertiesEntity(Integer hookId, String propertyKey) { + super(); + this.hookId = hookId; + this.propertyKey = propertyKey; + } + /** HOOK_ID */ + private Integer hookId; + /** PROPERTY_KEY */ + private String propertyKey; + /** PROPERTY_VALUE */ + private String propertyValue; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get HOOK_ID. + * @return HOOK_ID + */ + public Integer getHookId() { + return this.hookId; + } + /** + * Set HOOK_ID. + * @param hookId HOOK_ID + * @return this object */ + public GenMailPropertiesEntity setHookId(Integer hookId) { + this.hookId = hookId; + return this; + } + + /** + * Get PROPERTY_KEY. + * @return PROPERTY_KEY + */ + public String getPropertyKey() { + return this.propertyKey; + } + /** + * Set PROPERTY_KEY. + * @param propertyKey PROPERTY_KEY + * @return this object */ + public GenMailPropertiesEntity setPropertyKey(String propertyKey) { + this.propertyKey = propertyKey; + return this; + } + + /** + * Get PROPERTY_VALUE. + * @return PROPERTY_VALUE + */ + public String getPropertyValue() { + return this.propertyValue; + } + /** + * Set PROPERTY_VALUE. + * @param propertyValue PROPERTY_VALUE + * @return this object */ + public GenMailPropertiesEntity setPropertyValue(String propertyValue) { + this.propertyValue = propertyValue; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenMailPropertiesEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenMailPropertiesEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenMailPropertiesEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenMailPropertiesEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenMailPropertiesEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[2]; + keyValues[0] = this.hookId; + keyValues[1] = this.propertyKey; + return keyValues; + } + /** + * Set key values + * @param hookId HOOK_ID + * @param propertyKey PROPERTY_KEY + */ + public void setKeyValues(Integer hookId, String propertyKey) { + this.hookId = hookId; + this.propertyKey = propertyKey; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenMailPropertiesEntity 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 + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("hookId = ").append(hookId).append("\n"); + builder.append("propertyKey = ").append(propertyKey).append("\n"); + builder.append("propertyValue = ").append(propertyValue).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(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.hookId, convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.hookId, convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.propertyKey, convLabelName("Property Key")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.propertyKey, convLabelName("Property Key"), 128); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.propertyValue, convLabelName("Property Value"), 256); + 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 + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("hookId"), convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("hookId"), convLabelName("Hook Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("propertyKey"), convLabelName("Property Key")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("propertyKey"), convLabelName("Property Key"), 128); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("propertyValue"), convLabelName("Property Value"), 256); + 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/entity/gen/GenTokensEntity.java b/src/main/java/org/support/project/knowledge/entity/gen/GenTokensEntity.java new file mode 100644 index 000000000..af065ea3c --- /dev/null +++ b/src/main/java/org/support/project/knowledge/entity/gen/GenTokensEntity.java @@ -0,0 +1,365 @@ +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 GenTokensEntity implements Serializable { + + /** SerialVersion */ + private static final long serialVersionUID = 1L; + + /** + * Get instance from DI container. + * @return instance + */ + public static GenTokensEntity get() { + return Container.getComp(GenTokensEntity.class); + } + + /** + * Constructor. + */ + public GenTokensEntity() { + super(); + } + + /** + * Constructor + * @param token TOKEN + */ + + public GenTokensEntity(String token) { + super(); + this.token = token; + } + /** TOKEN */ + private String token; + /** ユーザID */ + private Integer userId; + /** 有効期限 */ + private Timestamp expires; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** 削除フラグ */ + private Integer deleteFlag; + + /** + * Get TOKEN. + * @return TOKEN + */ + public String getToken() { + return this.token; + } + /** + * Set TOKEN. + * @param token TOKEN + * @return this object */ + public GenTokensEntity setToken(String token) { + this.token = token; + return this; + } + + /** + * Get ユーザID. + * @return ユーザID + */ + public Integer getUserId() { + return this.userId; + } + /** + * Set ユーザID. + * @param userId ユーザID + * @return this object */ + public GenTokensEntity setUserId(Integer userId) { + this.userId = userId; + return this; + } + + /** + * Get 有効期限. + * @return 有効期限 + */ + public Timestamp getExpires() { + return this.expires; + } + /** + * Set 有効期限. + * @param expires 有効期限 + * @return this object */ + public GenTokensEntity setExpires(Timestamp expires) { + this.expires = expires; + return this; + } + + /** + * Get 登録ユーザ. + * @return 登録ユーザ + */ + public Integer getInsertUser() { + return this.insertUser; + } + /** + * Set 登録ユーザ. + * @param insertUser 登録ユーザ + * @return this object */ + public GenTokensEntity setInsertUser(Integer insertUser) { + this.insertUser = insertUser; + return this; + } + + /** + * Get 登録日時. + * @return 登録日時 + */ + public Timestamp getInsertDatetime() { + return this.insertDatetime; + } + /** + * Set 登録日時. + * @param insertDatetime 登録日時 + * @return this object */ + public GenTokensEntity setInsertDatetime(Timestamp insertDatetime) { + this.insertDatetime = insertDatetime; + return this; + } + + /** + * Get 更新ユーザ. + * @return 更新ユーザ + */ + public Integer getUpdateUser() { + return this.updateUser; + } + /** + * Set 更新ユーザ. + * @param updateUser 更新ユーザ + * @return this object */ + public GenTokensEntity setUpdateUser(Integer updateUser) { + this.updateUser = updateUser; + return this; + } + + /** + * Get 更新日時. + * @return 更新日時 + */ + public Timestamp getUpdateDatetime() { + return this.updateDatetime; + } + /** + * Set 更新日時. + * @param updateDatetime 更新日時 + * @return this object */ + public GenTokensEntity setUpdateDatetime(Timestamp updateDatetime) { + this.updateDatetime = updateDatetime; + return this; + } + + /** + * Get 削除フラグ. + * @return 削除フラグ + */ + public Integer getDeleteFlag() { + return this.deleteFlag; + } + /** + * Set 削除フラグ. + * @param deleteFlag 削除フラグ + * @return this object */ + public GenTokensEntity setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + return this; + } + + /** + * Get key values + * @return values + */ + public Object[] getKeyValues() { + Object[] keyValues = new Object[1]; + keyValues[0] = this.token; + return keyValues; + } + /** + * Set key values + * @param token TOKEN + */ + public void setKeyValues(String token) { + this.token = token; + } + /** + * compare on key + * @param entity entity + * @return result + */ + public boolean equalsOnKey(GenTokensEntity 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 + * @return string + */ + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("token = ").append(token).append("\n"); + builder.append("userId = ").append(userId).append("\n"); + builder.append("expires = ").append(expires).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(); + } + /** + * Convert label to display + * @param label label + * @return convert label + */ + protected String convLabelName(String label) { + return label; + } + /** + * validate + * @return validate error list + */ + public List validate() { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.token, convLabelName("Token")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(this.token, convLabelName("Token"), 128); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(this.userId, convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(this.expires, convLabelName("Expires")); + 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 + * @param values value map + * @return validate error list + */ + public List validate(Map values) { + List errors = new ArrayList<>(); + Validator validator; + ValidateError error; + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("token"), convLabelName("Token")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.MAX_LENGTH); + error = validator.validate(values.get("token"), convLabelName("Token"), 128); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.INTEGER); + error = validator.validate(values.get("userId"), convLabelName("User Id")); + if (error != null) { + errors.add(error); + } + validator = ValidatorFactory.getInstance(Validator.REQUIRED); + error = validator.validate(values.get("expires"), convLabelName("Expires")); + 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/filter/ApiFilter.java b/src/main/java/org/support/project/knowledge/filter/ApiFilter.java new file mode 100644 index 000000000..542886f6f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/filter/ApiFilter.java @@ -0,0 +1,117 @@ +package org.support.project.knowledge.filter; + +import java.io.IOException; +import java.util.Date; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.Filter; +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.di.Container; +import org.support.project.knowledge.dao.TokensDao; +import org.support.project.knowledge.entity.TokensEntity; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.UsersEntity; +import org.support.project.web.logic.AuthenticationLogic; +import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl; +import org.support.project.web.wrapper.HttpServletRequestWrapper; + +public class ApiFilter implements Filter { + private String targetRegex = "(^/api)(.)*"; + private Pattern pattern; + private boolean enableAuthParameter = true; // TODO 後でfalseへ + + @Override + public void init(final FilterConfig filterconfig) throws ServletException { + String targetRegex = filterconfig.getInitParameter("target-regex"); + if (StringUtils.isNotEmpty(targetRegex)) { + this.targetRegex = targetRegex; + } + this.pattern = Pattern.compile(this.targetRegex); + + String authParam = filterconfig.getInitParameter("enable-auth-parameter"); + if (StringUtils.isNotEmpty(authParam)) { + if (authParam.toLowerCase().equals("true")) { + enableAuthParameter = true; + } + } + } + @Override + public void destroy() { + this.targetRegex = null; + } + + @Override + public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) + throws IOException, ServletException { + AuthenticationLogic authenticationLogic = (AuthenticationLogic) Container.getComp(DefaultAuthenticationLogicImpl.class); + HttpServletRequest req_origin = (HttpServletRequest) servletrequest; + HttpServletRequestWrapper req = new HttpServletRequestWrapper((HttpServletRequest) req_origin, authenticationLogic); + HttpServletResponse res = (HttpServletResponse) servletresponse; + + 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()) { + // 対象外 + filterchain.doFilter(req, res); + return; + } + // 認証 + // Httpヘッダー「PRIVATE-TOKEN」か、リクエストパラメータ「private_token」の値で認証することを検討(GitLab準拠) + // → クエリパラメータ指定だとアクセスログにtoken情報が表示されてしまい良くない気がするので、デフォルトはHttpヘッダー指定のみにする(設定で有効にもできる) + String token = req.getHeader("PRIVATE-TOKEN"); + if (enableAuthParameter) { + if (StringUtils.isEmpty(token)) { + token = req.getParameter("private_token"); + } + } + if (StringUtils.isEmpty(token)) { + // Tokenが指定されていない + res.sendError(HttpStatus.SC_403_FORBIDDEN); + return; + } + TokensEntity tokensEntity = TokensDao.get().selectOnKey(token); + if (tokensEntity == null) { + res.sendError(HttpStatus.SC_403_FORBIDDEN); + return; + } + Date now = new Date(); + if (now.getTime() > tokensEntity.getExpires().getTime()) { + res.sendError(HttpStatus.SC_403_FORBIDDEN); + return; + } + // APIを使う場合、Tokensテーブルの「更新日付」現在の日付でアップデートする(最終利用日時) + TokensDao.get().update(tokensEntity); + // セッション生成 + UsersEntity user = UsersDao.get().selectOnKey(tokensEntity.getUserId()); + if (user == null) { + res.sendError(HttpStatus.SC_403_FORBIDDEN); + return; + } + // 毎回セッションを生成して登録する(毎回なので少し重いかも) + authenticationLogic.setSession(user.getUserKey(), req); + + // APIの実際の処理を実施 + filterchain.doFilter(req, res); + + // リクエスト毎にセッションはクリアする + authenticationLogic.clearSession(req); + } + + +} 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 4ad7cc514..4ff9f14f5 100644 --- a/src/main/java/org/support/project/knowledge/listener/CronListener.java +++ b/src/main/java/org/support/project/knowledge/listener/CronListener.java @@ -20,7 +20,6 @@ import org.support.project.knowledge.bat.NotifyMailBat; import org.support.project.knowledge.bat.WebhookBat; import org.support.project.knowledge.config.AppConfig; -import org.support.project.knowledge.config.SystemConfig; public class CronListener implements ServletContextListener { @@ -39,7 +38,8 @@ public class CronListener implements ServletContextListener { public void contextInitialized(final ServletContextEvent sce) { String logsPath = AppConfig.get().getLogsPath(); File logDir = new File(logsPath); - String envValue = System.getenv(SystemConfig.KNOWLEDGE_ENV_KEY); + AppConfig.get(); + String envValue = System.getenv(AppConfig.getEnvKey()); service = new ScheduledThreadPoolExecutor(1); fileClearfuture = service.scheduleAtFixedRate(new Runnable() { @@ -54,7 +54,7 @@ public void run() { job.setMainClass(KnowledgeFileClearBat.class.getName()); job.setXmx(256); if (StringUtils.isNotEmpty(envValue)) { - job.addEnvironment(SystemConfig.KNOWLEDGE_ENV_KEY, envValue); + job.addEnvironment(AppConfig.getEnvKey(), envValue); } try { JobResult result = job.execute(); @@ -82,7 +82,7 @@ public void run() { job.setMainClass(FileParseBat.class.getName()); job.setXmx(1024); if (StringUtils.isNotEmpty(envValue)) { - job.addEnvironment(SystemConfig.KNOWLEDGE_ENV_KEY, envValue); + job.addEnvironment(AppConfig.getEnvKey(), envValue); } try { JobResult result = job.execute(); @@ -110,7 +110,7 @@ public void run() { job.setMainClass(MailSendBat.class.getName()); job.setXmx(256); if (StringUtils.isNotEmpty(envValue)) { - job.addEnvironment(SystemConfig.KNOWLEDGE_ENV_KEY, envValue); + job.addEnvironment(AppConfig.getEnvKey(), envValue); } try { JobResult result = job.execute(); @@ -138,7 +138,7 @@ public void run() { job.setMainClass(WebhookBat.class.getName()); job.setXmx(256); if (StringUtils.isNotEmpty(envValue)) { - job.addEnvironment(SystemConfig.KNOWLEDGE_ENV_KEY, envValue); + job.addEnvironment(AppConfig.getEnvKey(), envValue); } try { JobResult result = job.execute(); @@ -166,7 +166,7 @@ public void run() { job.setMainClass(MailReadBat.class.getName()); job.setXmx(256); if (StringUtils.isNotEmpty(envValue)) { - job.addEnvironment(SystemConfig.KNOWLEDGE_ENV_KEY, envValue); + job.addEnvironment(AppConfig.getEnvKey(), envValue); } try { JobResult result = job.execute(); @@ -193,7 +193,7 @@ public void run() { job.addClassPathDir(new File(sce.getServletContext().getRealPath("/WEB-INF/classes"))); job.setMainClass(NotifyMailBat.class.getName()); if (StringUtils.isNotEmpty(envValue)) { - job.addEnvironment(SystemConfig.KNOWLEDGE_ENV_KEY, envValue); + job.addEnvironment(AppConfig.getEnvKey(), envValue); } try { JobResult result = job.execute(); diff --git a/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java b/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java index 5235fa4b0..e22962035 100644 --- a/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java +++ b/src/main/java/org/support/project/knowledge/listener/GlobalInitializationListener.java @@ -18,10 +18,10 @@ public class GlobalInitializationListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent config) { - AppConfig.initEnvKey(SystemConfig.KNOWLEDGE_ENV_KEY); - String envValue = System.getenv(SystemConfig.KNOWLEDGE_ENV_KEY); + AppConfig.get(); + String envValue = System.getenv(AppConfig.getEnvKey()); if (StringUtils.isNotEmpty(envValue)) { - LOG.info("Env [" + SystemConfig.KNOWLEDGE_ENV_KEY + "] is [" + envValue + "]."); + LOG.info("Env [" + AppConfig.getEnvKey() + "] is [" + envValue + "]."); } String rootPath = AppConfig.get().getBasePath(); System.setProperty("user.dir", rootPath); diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java new file mode 100644 index 000000000..36564bb1d --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeDataEditLogic.java @@ -0,0 +1,191 @@ +package org.support.project.knowledge.logic; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import org.support.project.common.bean.ValidateError; +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.PropertyUtil; +import org.support.project.common.util.StringJoinBuilder; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.KnowledgesDao; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.TemplateItemsEntity; +import org.support.project.knowledge.entity.TemplateMastersEntity; +import org.support.project.knowledge.vo.KnowledgeData; +import org.support.project.knowledge.vo.api.KnowledgeDetail; +import org.support.project.knowledge.vo.api.Target; +import org.support.project.web.bean.LabelValue; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.MessageResult; +import org.support.project.web.bean.NameId; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.config.MessageStatus; +import org.support.project.web.exception.InvalidParamException; + +@DI(instance = Instance.Singleton) +public class KnowledgeDataEditLogic { + /** LOG */ + private static final Log LOG = LogFactory.getLog(KnowledgeDataEditLogic.class); + /** Get instance */ + public static KnowledgeDataEditLogic get() { + return Container.getComp(KnowledgeDataEditLogic.class); + } + + /** + * WebAPIで受信したデータを画面で登録した形式に合わせてデータ変換 + * @param data + * @return + * @throws InvalidParamException + */ + private KnowledgeData conv(KnowledgeDetail data) throws InvalidParamException { + KnowledgeData knowledge = new KnowledgeData(); + + // KnowledgesEntity knowledge + KnowledgesEntity entity = new KnowledgesEntity(); + PropertyUtil.copyPropertyValue(data, entity); + + List errors = entity.validate(); + if (errors != null && !errors.isEmpty()) { + StringJoinBuilder builder = new StringJoinBuilder<>(); + for (ValidateError validateError : errors) { + builder.append(validateError.getMsg(Locale.ENGLISH)); + } + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_400_BAD_REQUEST, builder.join(","), "")); + } + knowledge.setKnowledge(entity); + + // List tags + StringJoinBuilder tags = new StringJoinBuilder<>(data.getTags()); + knowledge.setTagsStr(tags.join(",")); + + // List viewers, editors + knowledge.setViewers(convTargets(data.getViewers())); + knowledge.setEditors(convTargets(data.getEditors())); + + // List fileNos (現在未対応) + knowledge.setFileNos(new ArrayList<>()); + + // TemplateMastersEntity template + TemplateMastersEntity template = TemplateLogic.get().selectOnName(data.getTemplate()); + if (template == null) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_400_BAD_REQUEST, "bad template name", "")); + } + List items = template.getItems(); + for (TemplateItemsEntity item : items) { + List vals = data.getTemplateItems(); + for (LabelValue labelValue : vals) { + if (item.getItemName().equals(labelValue.getLabel())) { + item.setItemValue(labelValue.getValue()); + } + } + } + knowledge.setTemplate(template); + entity.setTypeId(template.getTypeId()); + + // Long draftId + knowledge.setDraftId(null); + + // boolean updateContent + knowledge.setUpdateContent(true); + + return knowledge; + } + + private String convTargets(Target viewers) { + StringJoinBuilder builder = new StringJoinBuilder<>(); + List groups = viewers.getGroups(); + if (groups != null) { + for (NameId nameId : groups) { + builder.append(TargetLogic.ID_PREFIX_GROUP.concat(nameId.getId())); + } + } + List users = viewers.getUsers(); + if (users != null) { + for (NameId nameId : users) { + builder.append(TargetLogic.ID_PREFIX_USER.concat(nameId.getId())); + } + } + return builder.join(","); + } + + /** + * WebAPIからの Knowledge登録 + * @param data + * @param loginedUser + * @return + * @throws Exception + */ + public long insert(KnowledgeDetail data, LoginedUser loginedUser) throws Exception { + LOG.trace("insert"); + // 画面での登録と形をあわせる + KnowledgeData knowledge = conv(data); + knowledge.getKnowledge().setKnowledgeId(null); + KnowledgesEntity insertedEntity = KnowledgeLogic.get().insert(knowledge, loginedUser); + return insertedEntity.getKnowledgeId(); + } + /** + * WebAPIからの Knowledge更新 + * @param data + * @param loginedUser + * @return + * @throws Exception + */ + public void update(KnowledgeDetail data, LoginedUser loginedUser) throws Exception { + LOG.trace("update"); + KnowledgesEntity check = KnowledgesDao.get().selectOnKey(data.getKnowledgeId()); + if (check == null) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_404_NOT_FOUND, "NOT_FOUND", "")); + } + // 編集権限チェック + Resources resources = Resources.getInstance(Locale.ENGLISH); + List editors = TargetLogic.get().selectEditorsOnKnowledgeId(data.getKnowledgeId()); + if (!KnowledgeLogic.get().isEditor(loginedUser, check, editors)) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_403_FORBIDDEN, resources.getResource("knowledge.edit.noaccess"), "")); + } + // 画面での登録と形をあわせる + KnowledgeData knowledge = conv(data); + KnowledgeLogic.get().update(knowledge, loginedUser); + } + + /** + * WebAPIからの Knowledge削除 + * @param data + * @param loginedUser + * @return + * @throws Exception + */ + public void delete(Long id, LoginedUser loginedUser) throws Exception { + LOG.trace("delete"); + KnowledgesEntity check = KnowledgesDao.get().selectOnKey(id); + if (check == null) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_404_NOT_FOUND, "NOT_FOUND", "")); + } + // 編集権限チェック + Resources resources = Resources.getInstance(Locale.ENGLISH); + List editors = TargetLogic.get().selectEditorsOnKnowledgeId(id); + if (!KnowledgeLogic.get().isEditor(loginedUser, check, editors)) { + throw new InvalidParamException(new MessageResult( + MessageStatus.Warning, HttpStatus.SC_403_FORBIDDEN, resources.getResource("knowledge.edit.noaccess"), "")); + } + KnowledgeLogic.get().delete(id); + + } + + + + + + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeDataSelectLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeDataSelectLogic.java new file mode 100644 index 000000000..b0cf8ded1 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeDataSelectLogic.java @@ -0,0 +1,273 @@ +package org.support.project.knowledge.logic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections4.map.HashedMap; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +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.knowledge.dao.CommentsDao; +import org.support.project.knowledge.dao.KnowledgeFilesDao; +import org.support.project.knowledge.dao.KnowledgeItemValuesDao; +import org.support.project.knowledge.dao.TargetsDao; +import org.support.project.knowledge.dao.TemplateMastersDao; +import org.support.project.knowledge.entity.CommentsEntity; +import org.support.project.knowledge.entity.KnowledgeFilesEntity; +import org.support.project.knowledge.entity.KnowledgeItemValuesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.TemplateItemsEntity; +import org.support.project.knowledge.entity.TemplateMastersEntity; +import org.support.project.knowledge.vo.SearchKnowledgeParam; +import org.support.project.knowledge.vo.api.AttachedFile; +import org.support.project.knowledge.vo.api.Comment; +import org.support.project.knowledge.vo.api.Knowledge; +import org.support.project.knowledge.vo.api.KnowledgeDetail; +import org.support.project.knowledge.vo.api.Target; +import org.support.project.web.bean.LabelValue; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.bean.NameId; +import org.support.project.web.entity.GroupsEntity; +import org.support.project.web.entity.UsersEntity; + +@DI(instance = Instance.Singleton) +public class KnowledgeDataSelectLogic { + /** LOG */ + private static final Log LOG = LogFactory.getLog(KnowledgeDataSelectLogic.class); + /** Get instance */ + public static KnowledgeDataSelectLogic get() { + return Container.getComp(KnowledgeDataSelectLogic.class); + } + + private static final int SINGLE = 0; + private static final int LIST = 1; + + + /** + * KnowledgesEntity を WebAPIで送る情報に変換する + * @param entity + * @return + */ + private Knowledge conv(KnowledgesEntity entity, int type) { + if (entity == null) { + return null; + } + Knowledge result = new Knowledge(); + PropertyUtil.copyPropertyValue(entity, result); + + // テンプレートの情報を追加 + TemplateMastersEntity template = getTemplate(entity); + result.setTemplate(template.getTypeName()); + + // タグ + String[] tags = entity.getTagNames().split(","); + result.setTags(Arrays.asList(tags)); + + // 公開範囲 + Target viewers = getViewers(entity); + result.setViewers(viewers); + + // 1件取得の場合は詳細な情報を取得する + if (SINGLE == type) { + KnowledgeDetail detail = new KnowledgeDetail(); + PropertyUtil.copyPropertyValue(result, detail); + + // テンプレートで拡張した項目の値を取得 + List templateItems = getTemplateItems(entity, template); + detail.setTemplateItems(templateItems); + + // コメント + List comments = getComments(entity); + detail.setComments(comments); + + // 添付ファイル + List attachedFiles = getAttachedFiles(entity); + detail.setAttachments(attachedFiles); + + // 共同編集者 + Target editors = getEditors(entity); + detail.setEditors(editors); + + + return detail; + } + return result; + } + /** + * 添付ファイルを取得 + * @param entity + * @return + */ + private List getAttachedFiles(KnowledgesEntity entity) { + List attachedFiles = new ArrayList<>(); + List filesEntities = KnowledgeFilesDao.get().selectOnKnowledgeId(entity.getKnowledgeId()); + for (KnowledgeFilesEntity knowledgeFilesEntity : filesEntities) { + AttachedFile file = new AttachedFile(); + PropertyUtil.copyPropertyValue(knowledgeFilesEntity, file); + attachedFiles.add(file); + } + return attachedFiles; + } + /** + * コメント取得 + * @param entity + * @return + */ + private List getComments(KnowledgesEntity entity) { + List comments = new ArrayList<>(); + List commentsEntities = CommentsDao.get().selectOnKnowledgeId(entity.getKnowledgeId()); + for (CommentsEntity commentsEntity : commentsEntities) { + Comment comment = new Comment(); + PropertyUtil.copyPropertyValue(commentsEntity, comment); + comments.add(comment); + } + return comments; + } + /** + * テンプレートの項目とその値を取得 + * @param entity + * @param template + * @return + */ + private List getTemplateItems(KnowledgesEntity entity, TemplateMastersEntity template) { + List values = KnowledgeItemValuesDao.get().selectOnKnowledgeId(entity.getKnowledgeId()); + List items = template.getItems(); + List templateItems = new ArrayList<>(); + for (KnowledgeItemValuesEntity val : values) { + for (TemplateItemsEntity item : items) { + if (val.getItemNo().equals(item.getItemNo())) { + item.setItemValue(val.getItemValue()); + templateItems.add(new LabelValue( + item.getItemName(), + val.getItemValue())); + break; + } + } + } + return templateItems; + } + /** + * 共同編集者を取得 + * @param entity + * @return + */ + private Target getEditors(KnowledgesEntity entity) { + Target editors = new Target(); + List listGroups = new ArrayList<>(); + List listUsers = new ArrayList<>(); + editors.setGroups(listGroups); + editors.setUsers(listUsers); + TargetsDao targetsDao = TargetsDao.get(); + List groups = targetsDao.selectEditorGroupsOnKnowledgeId(entity.getKnowledgeId()); + for (GroupsEntity groupsEntity : groups) { + NameId group = new NameId(groupsEntity.getGroupName(), String.valueOf(groupsEntity.getGroupId())); + listGroups.add(group); + } + List users = targetsDao.selectEditorUsersOnKnowledgeId(entity.getKnowledgeId()); + for (UsersEntity usersEntity : users) { + NameId user = new NameId(usersEntity.getUserName(), String.valueOf(usersEntity.getUserId())); + listUsers.add(user); + } + return editors; + } + /** + * 公開対象を取得 + * @param entity + * @return + */ + private Target getViewers(KnowledgesEntity entity) { + Target viewers = new Target(); + if (entity.getPublicFlag().intValue() == KnowledgeLogic.PUBLIC_FLAG_PROTECT) { + List groupViewers = new ArrayList<>(); + List userViewers = new ArrayList<>(); + viewers.setGroups(groupViewers); + viewers.setUsers(userViewers); + TargetsDao targetsDao = TargetsDao.get(); + List groups = targetsDao.selectGroupsOnKnowledgeId(entity.getKnowledgeId()); + for (GroupsEntity groupsEntity : groups) { + NameId group = new NameId(groupsEntity.getGroupName(), String.valueOf(groupsEntity.getGroupId())); + groupViewers.add(group); + } + List users = targetsDao.selectUsersOnKnowledgeId(entity.getKnowledgeId()); + for (UsersEntity usersEntity : users) { + NameId user = new NameId(usersEntity.getUserName(), String.valueOf(usersEntity.getUserId())); + userViewers.add(user); + } + } + return viewers; + } + /** + * テンプレートの情報を取得 + * @param entity + * @return + */ + private TemplateMastersEntity getTemplate(KnowledgesEntity entity) { + int typeId = entity.getTypeId(); + TemplateMastersEntity template = TemplateMastersDao.get().selectWithItems(typeId); + if (template == null) { + // そのテンプレートは既に削除済みの場合、通常のナレッジのテンプレートで表示する + typeId = TemplateLogic.TYPE_ID_KNOWLEDGE; + template = TemplateMastersDao.get().selectWithItems(typeId); + } + return template; + } + + /** + * Knowledgeのデータを1件取得(WebAPIで返す形で) + * @param knowledgeId + * @param loginedUser + * @return + */ + public Knowledge select(long knowledgeId, LoginedUser loginedUser) { + KnowledgesEntity entity = KnowledgeLogic.get().selectWithTags(knowledgeId, loginedUser); + if (entity == null) { + return null; + } + Knowledge result = conv(entity, SINGLE); + return result; + } + /** + * Knowledgeのデータを取得(WebAPIで返す形で) + * @param param + * @return + * @throws Exception + */ + public List selectList(SearchKnowledgeParam param) throws Exception { + if (LOG.isDebugEnabled()) { + LOG.debug("get knowledge list. [params] " + PropertyUtil.reflectionToString(param)); + } + List results = new ArrayList<>(); + List entities = KnowledgeLogic.get().searchKnowledge( + param.getKeyword(), + param.getTags(), + param.getGroups(), + param.getTemplate(), + param.getLoginedUser(), + param.getOffset(), + param.getLimit()); + List ids = new ArrayList<>(); + for (KnowledgesEntity entity : entities) { + Knowledge result = conv(entity, LIST); + results.add(result); + ids.add(String.valueOf(result.getKnowledgeId())); + } + List dbs = KnowledgeLogic.get().getKnowledges(ids, param.getLoginedUser()); + Map idMap = new HashedMap<>(); + for (KnowledgesEntity knowledgesEntity : dbs) { + idMap.put(knowledgesEntity.getKnowledgeId(), knowledgesEntity); + } + for (Knowledge knowledge : results) { + if (idMap.containsKey(knowledge.getKnowledgeId())) { + // Titleのハイライトを消す + knowledge.setTitle(idMap.get(knowledge.getKnowledgeId()).getTitle()); + } + } + return results; + } + +} diff --git a/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java b/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java index 477076daa..d7c596ccf 100644 --- a/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MailhookLogic.java @@ -44,6 +44,7 @@ import org.support.project.knowledge.dao.MailHookConditionsDao; import org.support.project.knowledge.dao.MailHooksDao; import org.support.project.knowledge.dao.MailPostsDao; +import org.support.project.knowledge.dao.MailPropertiesDao; import org.support.project.knowledge.dao.TagsDao; import org.support.project.knowledge.entity.CommentsEntity; import org.support.project.knowledge.entity.KnowledgeFilesEntity; @@ -51,6 +52,7 @@ import org.support.project.knowledge.entity.MailHookConditionsEntity; import org.support.project.knowledge.entity.MailHooksEntity; import org.support.project.knowledge.entity.MailPostsEntity; +import org.support.project.knowledge.entity.MailPropertiesEntity; import org.support.project.knowledge.entity.TagsEntity; import org.support.project.knowledge.vo.KnowledgeData; import org.support.project.ormapping.common.DBUserPool; @@ -65,7 +67,8 @@ public class MailhookLogic { private static final Log LOG = LogFactory.getLog(MailhookLogic.class); /** - * MAIL HOOK のID DBとしては、MailHookは複数のメールアドレスで実行できる構成をとったが、 システムが受信するメールアドレスは1つと考えたほうが無難なのでIDを決め打ちする + * MAIL HOOK のID DBとしては、MailHookは複数のメールアドレスで実行できる構成をとったが、 + * システムが受信するメールアドレスは1つと考えたほうが無難なのでIDを決め打ちする */ public static final Integer MAIL_HOOK_ID = 1; @@ -74,7 +77,66 @@ public class MailhookLogic { public static MailhookLogic get() { return Container.getComp(MailhookLogic.class); } - + + /** + * メールセッションのデバッグ出力を行うか + */ + private static final boolean MAIL_SESSION_DEBUG = false; + /** + * メールを受信後、削除するか + */ + private static final boolean DELETE_READED_MAIL = true; + + + /** + * メールサーバーと接続 + * @param entity + * @return + * @throws MessagingException + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws IllegalBlockSizeException + * @throws BadPaddingException + */ + private Store getStore(MailHooksEntity entity) throws MessagingException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + // TODO MailHooksEntity の protocol は必要無かった(プロパティで設定する)ため、いずれ削除する + Properties props = new Properties(); + + List properties = MailPropertiesDao.get().selectOnHookId(MAIL_HOOK_ID); + if (properties == null) { + // v1.10.0以前のデフォルト値 + props.setProperty("mail.store.protocol", "imaps"); + props.put("mail.imaps.ssl.trust", "*"); + + /* IMAPS無しのサンプル + props.setProperty("mail.store.protocol", "imap"); + String protocol = "mail.imap"; + props.setProperty(protocol + ".starttls.enable", "false"); + props.setProperty(protocol + ".ssl.enable", "false"); + props.setProperty("mail.imap.auth.ntlm.disable", "true"); + props.setProperty("mail.imap.auth.plain.disable", "true"); + props.setProperty("mail.imap.auth.gssapi.disable", "true"); + */ + } else { + for (MailPropertiesEntity property : properties) { + props.setProperty(property.getPropertyKey(), property.getPropertyValue()); + } + } + String host = entity.getMailHost(); + int port = entity.getMailPort(); + String user = entity.getMailUser(); + String pass = PasswordUtil.decrypt(entity.getMailPass(), entity.getMailPassSalt()); + Session session = Session.getInstance(props, null); + session.setDebug(MAIL_SESSION_DEBUG); + Store store = session.getStore(); + store.connect(host, port, user, pass); + + return store; + } + + + /** * メール受信サーバーに接続できるかチェック * @@ -82,17 +144,8 @@ public static MailhookLogic get() { * @return */ public boolean connect(MailHooksEntity entity) { - Properties props = new Properties(); - props.setProperty("mail.store.protocol", "imaps"); - props.put("mail.imaps.ssl.trust", "*"); try { - String host = entity.getMailHost(); - int port = entity.getMailPort(); - String user = entity.getMailUser(); - String pass = PasswordUtil.decrypt(entity.getMailPass(), entity.getMailPassSalt()); - Session session = Session.getInstance(props, null); - Store store = session.getStore(); - store.connect(host, port, user, pass); + Store store = getStore(entity); Folder inbox = store.getFolder(MAIL_FOLDER); inbox.open(Folder.READ_ONLY); LOG.info("[Mail Count] " + inbox.getMessageCount()); @@ -122,17 +175,8 @@ public void postFromMail() { return; } - Properties props = new Properties(); - props.setProperty("mail.store.protocol", "imaps"); - props.put("mail.imaps.ssl.trust", "*"); try { - String host = entity.getMailHost(); - int port = entity.getMailPort(); - String user = entity.getMailUser(); - String pass = PasswordUtil.decrypt(entity.getMailPass(), entity.getMailPassSalt()); - Session session = Session.getInstance(props, null); - Store store = session.getStore(); - store.connect(host, port, user, pass); + Store store = getStore(entity); Folder inbox = store.getFolder(MAIL_FOLDER); inbox.open(Folder.READ_WRITE); @@ -144,8 +188,11 @@ public void postFromMail() { for (Message msg : messages) { checkConditionsAndPost(msg, conditions); } - Flags deleted = new Flags(Flags.Flag.DELETED); - inbox.setFlags(messages, deleted, true); + if (DELETE_READED_MAIL) { + LOG.info("Remove all readed mails."); + Flags deleted = new Flags(Flags.Flag.DELETED); + inbox.setFlags(messages, deleted, true); + } } inbox.close(true); } catch (Exception e) { @@ -615,7 +662,11 @@ private void checkConditionsAndPost(Message msg, List for (MailHookConditionsEntity condition : conditions) { if (checkCondition(msg, condition)) { + LOG.info("Post Knowledge from a mail. " + msg.getSubject()); addData(msg, condition); + } else { + LOG.warn("Receive mail is not target condition. " + msg.getSubject()); + LOG.warn(getContent(msg)); } } } @@ -745,7 +796,28 @@ public void removeHook(Integer mailHookId) { for (MailHookConditionsEntity mailHookConditionsEntity : conditions) { MailHookConditionsDao.get().physicalDelete(mailHookConditionsEntity); } + List now = MailPropertiesDao.get().selectOnHookId(MAIL_HOOK_ID); + for (MailPropertiesEntity mailPropertiesEntity : now) { + MailPropertiesDao.get().physicalDelete(mailPropertiesEntity); + } MailHooksDao.get().physicalDelete(mailHookId); } + /** + * メール受信の設定を保存 + * @param entity + * @param properties + */ + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void saveMailConfig(MailHooksEntity entity, List properties) { + MailHooksDao.get().save(entity); + List now = MailPropertiesDao.get().selectOnHookId(MAIL_HOOK_ID); + for (MailPropertiesEntity mailPropertiesEntity : now) { + MailPropertiesDao.get().physicalDelete(mailPropertiesEntity); + } + for (MailPropertiesEntity mailPropertiesEntity : properties) { + MailPropertiesDao.get().save(mailPropertiesEntity); + } + } + } diff --git a/src/main/java/org/support/project/knowledge/logic/SlideLogic.java b/src/main/java/org/support/project/knowledge/logic/SlideLogic.java index a5f99e5cc..86d7124c1 100644 --- a/src/main/java/org/support/project/knowledge/logic/SlideLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/SlideLogic.java @@ -236,7 +236,7 @@ public DownloadInfo getSlideImage(String fileNo, String slideImage, LoginedUser return null; } DownloadInfo down = new DownloadInfo(); - down.setContentType("application/octet-stream"); + down.setContentType("image/png"); down.setFileName(slideImage); down.setSize(file.length()); down.setInputStream(new FileInputStream(file)); diff --git a/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java b/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java index d7eb1fc1b..e8fb80b72 100644 --- a/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/TemplateLogic.java @@ -339,4 +339,12 @@ public int compare(TemplateMastersEntity o1, TemplateMastersEntity o2) { return templates; } + public TemplateMastersEntity selectOnName(String template) { + TemplateMastersEntity entity = TemplateMastersDao.get().selectOnName(template); + if (entity == null) { + return null; + } + return loadTemplate(entity.getTypeId()); + } + } diff --git a/src/main/java/org/support/project/knowledge/parser/impl/PptxSlideShowParser.java b/src/main/java/org/support/project/knowledge/parser/impl/PptxSlideShowParser.java index f1afdfe6b..a02839075 100644 --- a/src/main/java/org/support/project/knowledge/parser/impl/PptxSlideShowParser.java +++ b/src/main/java/org/support/project/knowledge/parser/impl/PptxSlideShowParser.java @@ -1,6 +1,8 @@ package org.support.project.knowledge.parser.impl; import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -21,8 +23,7 @@ public class PptxSlideShowParser extends AbstractSlideShowParser implements Slid @Override public void parse(File inputFile, File outputDir) throws ParseException { - try { - SlideShow, ?> ss = SlideShowFactory.create(inputFile, null, true); + try (SlideShow, ?> ss = SlideShowFactory.create(inputFile, null, true)) { List extends Slide, ?>> slides = ss.getSlides(); Dimension pgsize = ss.getPageSize(); @@ -35,8 +36,16 @@ public void parse(File inputFile, File outputDir) throws ParseException { System.out.println("Rendering slide " + slideNo + (title == null ? "" : ": " + title)); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics = img.createGraphics(); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); + graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); + slide.draw(graphics); + img.flush(); //ImageIOUtil.writeImage(img, outputDir.getAbsolutePath() + "/" + (slideNo) + ".png", 300); super.writeImage(img, outputDir.getAbsolutePath() + "/" + (slideNo) + ".png"); + graphics.dispose(); slideNo++; } } catch (EncryptedDocumentException | IOException e) { diff --git a/src/main/java/org/support/project/knowledge/vo/SearchKnowledgeParam.java b/src/main/java/org/support/project/knowledge/vo/SearchKnowledgeParam.java new file mode 100644 index 000000000..dae335531 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/SearchKnowledgeParam.java @@ -0,0 +1,146 @@ +package org.support.project.knowledge.vo; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.knowledge.dao.TagsDao; +import org.support.project.knowledge.entity.TagsEntity; +import org.support.project.knowledge.logic.KeywordLogic; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.GroupsDao; +import org.support.project.web.entity.GroupsEntity; + +public class SearchKnowledgeParam { + + private String keyword; + private List tags; + private List groups; + private String template; + private LoginedUser loginedUser; + private int offset; + private int limit; + + public void setTags(String tagNames) { + String[] taglist = tagNames.split(","); + List tags = new ArrayList(); + for (String string : taglist) { + String tagname = string.trim(); + if (tagname.startsWith(" ") && tagname.length() > " ".length()) { + tagname = tagname.substring(" ".length()); + } + TagsEntity tagsEntity = TagsDao.get().selectOnTagName(tagname); + if (tagsEntity != null) { + tags.add(tagsEntity); + } + } + setTags(tags); + } + public void setGroupsAndLoginUser(String groupNames, LoginedUser loginedUser) { + this.loginedUser = loginedUser; + List groups = new ArrayList(); + if (loginedUser != null) { + String[] grouplist = groupNames.split(","); + for (String string : grouplist) { + String groupname = string.trim(); + if (groupname.startsWith(" ") && groupname.length() > " ".length()) { + groupname = groupname.substring(" ".length()); + } + GroupsEntity groupsEntity = GroupsDao.get().selectOnGroupName(groupname); + if (groupsEntity != null) { + groups.add(groupsEntity); + } + } + } + setGroups(groups); + } + + + + + + /** + * @return the keyword + */ + public String getKeyword() { + return keyword; + } + /** + * @param keyword the keyword to set + */ + public void setKeyword(String keyword) { + this.keyword = keyword; + } + /** + * @return the tags + */ + public List getTags() { + return tags; + } + /** + * @param tags the tags to set + */ + public void setTags(List tags) { + this.tags = tags; + } + /** + * @return the groups + */ + public List getGroups() { + return groups; + } + /** + * @param groups the groups to set + */ + public void setGroups(List groups) { + this.groups = groups; + } + /** + * @return the template + */ + public String getTemplate() { + return template; + } + /** + * @param template the template to set + */ + public void setTemplate(String template) { + this.template = template; + } + /** + * @return the loginedUser + */ + public LoginedUser getLoginedUser() { + return loginedUser; + } + /** + * @param loginedUser the loginedUser to set + */ + public void setLoginedUser(LoginedUser loginedUser) { + this.loginedUser = loginedUser; + } + /** + * @return the offset + */ + public int getOffset() { + return offset; + } + /** + * @param offset the offset to set + */ + public void setOffset(int offset) { + this.offset = offset; + } + /** + * @return the limit + */ + public int getLimit() { + return limit; + } + /** + * @param limit the limit to set + */ + public void setLimit(int limit) { + this.limit = limit; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/AttachedFile.java b/src/main/java/org/support/project/knowledge/vo/api/AttachedFile.java new file mode 100644 index 000000000..34af59ac2 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/AttachedFile.java @@ -0,0 +1,137 @@ +package org.support.project.knowledge.vo.api; + +import java.sql.Timestamp; + +public class AttachedFile { + + /** 添付ファイル番号 */ + private Long fileNo; + /** ナレッジID */ + private Long knowledgeId; + /** コメント番号 */ + private Long commentNo; + /** ファイル名 */ + private String fileName; + /** ファイルサイズ */ + private Double fileSize; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** + * @return the fileNo + */ + public Long getFileNo() { + return fileNo; + } + /** + * @param fileNo the fileNo to set + */ + public void setFileNo(Long fileNo) { + this.fileNo = fileNo; + } + /** + * @return the knowledgeId + */ + public Long getKnowledgeId() { + return knowledgeId; + } + /** + * @param knowledgeId the knowledgeId to set + */ + public void setKnowledgeId(Long knowledgeId) { + this.knowledgeId = knowledgeId; + } + /** + * @return the commentNo + */ + public Long getCommentNo() { + return commentNo; + } + /** + * @param commentNo the commentNo to set + */ + public void setCommentNo(Long commentNo) { + this.commentNo = commentNo; + } + /** + * @return the fileName + */ + public String getFileName() { + return fileName; + } + /** + * @param fileName the fileName to set + */ + public void setFileName(String fileName) { + this.fileName = fileName; + } + /** + * @return the fileSize + */ + public Double getFileSize() { + return fileSize; + } + /** + * @param fileSize the fileSize to set + */ + public void setFileSize(Double fileSize) { + this.fileSize = fileSize; + } + /** + * @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; + } + + + + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/Comment.java b/src/main/java/org/support/project/knowledge/vo/api/Comment.java new file mode 100644 index 000000000..eca943177 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/Comment.java @@ -0,0 +1,120 @@ +package org.support.project.knowledge.vo.api; + +import java.sql.Timestamp; + +public class Comment { + /** コメント番号 */ + private Long commentNo; + /** ナレッジID */ + private Long knowledgeId; + /** コメント */ + private String comment; + /** ステータス */ + private Integer commentStatus; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** + * @return the commentNo + */ + public Long getCommentNo() { + return commentNo; + } + /** + * @param commentNo the commentNo to set + */ + public void setCommentNo(Long commentNo) { + this.commentNo = commentNo; + } + /** + * @return the knowledgeId + */ + public Long getKnowledgeId() { + return knowledgeId; + } + /** + * @param knowledgeId the knowledgeId to set + */ + public void setKnowledgeId(Long knowledgeId) { + this.knowledgeId = knowledgeId; + } + /** + * @return the comment + */ + public String getComment() { + return comment; + } + /** + * @param comment the comment to set + */ + public void setComment(String comment) { + this.comment = comment; + } + /** + * @return the commentStatus + */ + public Integer getCommentStatus() { + return commentStatus; + } + /** + * @param commentStatus the commentStatus to set + */ + public void setCommentStatus(Integer commentStatus) { + this.commentStatus = commentStatus; + } + /** + * @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; + } + + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/Group.java b/src/main/java/org/support/project/knowledge/vo/api/Group.java new file mode 100644 index 000000000..4ecf8ade4 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/Group.java @@ -0,0 +1,136 @@ +package org.support.project.knowledge.vo.api; + +import java.sql.Timestamp; + +public class Group { + /** グループID */ + private Integer groupId; + /** グループ名称 */ + private String groupName; + /** 説明 */ + private String description; + /** グループの区分 */ + private Integer groupClass; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + + /** グループのナレッジ数 */ + private int groupKnowledgeCount = 0; + + + /** + * @return the groupId + */ + public Integer getGroupId() { + return groupId; + } + /** + * @param groupId the groupId to set + */ + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + /** + * @return the groupName + */ + public String getGroupName() { + return groupName; + } + /** + * @param groupName the groupName to set + */ + public void setGroupName(String groupName) { + this.groupName = groupName; + } + /** + * @return the description + */ + public String getDescription() { + return description; + } + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + /** + * @return the groupClass + */ + public Integer getGroupClass() { + return groupClass; + } + /** + * @param groupClass the groupClass to set + */ + public void setGroupClass(Integer groupClass) { + this.groupClass = groupClass; + } + /** + * @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 groupKnowledgeCount + */ + public int getGroupKnowledgeCount() { + return groupKnowledgeCount; + } + /** + * @param groupKnowledgeCount the groupKnowledgeCount to set + */ + public void setGroupKnowledgeCount(int groupKnowledgeCount) { + this.groupKnowledgeCount = groupKnowledgeCount; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/GroupDetail.java b/src/main/java/org/support/project/knowledge/vo/api/GroupDetail.java new file mode 100644 index 000000000..2129d0a52 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/GroupDetail.java @@ -0,0 +1,24 @@ +package org.support.project.knowledge.vo.api; + +public class GroupDetail extends Group { + /** 所属ユーザ数 */ + private int userCount = 0; + + /** + * @return the userCount + */ + public int getUserCount() { + return userCount; + } + + /** + * @param userCount the userCount to set + */ + public void setUserCount(int userCount) { + this.userCount = userCount; + } + + + + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java b/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java new file mode 100644 index 000000000..d69c7238d --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/Knowledge.java @@ -0,0 +1,227 @@ +package org.support.project.knowledge.vo.api; + +import java.sql.Timestamp; +import java.util.List; + +public class Knowledge { + /** ナレッジID */ + private Long knowledgeId; + /** タイトル */ + private String title; + /** 内容 */ + private String content; + /** 公開区分 */ + private Integer publicFlag; + /** いいね件数 */ + private Long likeCount; + /** コメント件数 */ + private Integer commentCount; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + + /** タグ */ + private List tags; + + /** テンプレート名 */ + private String template; + + /** 閲覧可能な対象(publicflag=2(保護)の場合に指定) */ + private Target viewers; + + + /** + * @return the knowledgeId + */ + public Long getKnowledgeId() { + return knowledgeId; + } + + /** + * @param knowledgeId the knowledgeId to set + */ + public void setKnowledgeId(Long knowledgeId) { + this.knowledgeId = knowledgeId; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the content + */ + public String getContent() { + return content; + } + + /** + * @param content the content to set + */ + public void setContent(String content) { + this.content = content; + } + + /** + * @return the publicFlag + */ + public Integer getPublicFlag() { + return publicFlag; + } + + /** + * @param publicFlag the publicFlag to set + */ + public void setPublicFlag(Integer publicFlag) { + this.publicFlag = publicFlag; + } + + /** + * @return the likeCount + */ + public Long getLikeCount() { + return likeCount; + } + + /** + * @param likeCount the likeCount to set + */ + public void setLikeCount(Long likeCount) { + this.likeCount = likeCount; + } + + /** + * @return the commentCount + */ + public Integer getCommentCount() { + return commentCount; + } + + /** + * @param commentCount the commentCount to set + */ + public void setCommentCount(Integer commentCount) { + this.commentCount = commentCount; + } + + /** + * @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 tags + */ + public List getTags() { + return tags; + } + + /** + * @param tags the tags to set + */ + public void setTags(List tags) { + this.tags = tags; + } + + /** + * @return the template + */ + public String getTemplate() { + return template; + } + + /** + * @param template the template to set + */ + public void setTemplate(String template) { + this.template = template; + } + + /** + * @return the viewers + */ + public Target getViewers() { + return viewers; + } + + /** + * @param viewers the viewers to set + */ + public void setViewers(Target viewers) { + this.viewers = viewers; + } + + + + + + + + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/KnowledgeDetail.java b/src/main/java/org/support/project/knowledge/vo/api/KnowledgeDetail.java new file mode 100644 index 000000000..038c13cbe --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/KnowledgeDetail.java @@ -0,0 +1,66 @@ +package org.support.project.knowledge.vo.api; + +import java.util.List; + +import org.support.project.web.bean.LabelValue; + +public class KnowledgeDetail extends Knowledge { + /** テンプレートの項目値 */ + private List templateItems; + /** コメント */ + private List comments; + /** 添付ファイル */ + private List attachments; + + /** 編集可能な対象(共同編集者) */ + private Target editors; + + /** + * @return the templateItems + */ + public List getTemplateItems() { + return templateItems; + } + /** + * @param templateItems the templateItems to set + */ + public void setTemplateItems(List templateItems) { + this.templateItems = templateItems; + } + /** + * @return the comments + */ + public List getComments() { + return comments; + } + /** + * @param comments the comments to set + */ + public void setComments(List comments) { + this.comments = comments; + } + /** + * @return the editors + */ + public Target getEditors() { + return editors; + } + /** + * @param editors the editors to set + */ + public void setEditors(Target editors) { + this.editors = editors; + } + /** + * @return the attachments + */ + public List getAttachments() { + return attachments; + } + /** + * @param attachments the attachments to set + */ + public void setAttachments(List attachments) { + this.attachments = attachments; + } +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/Target.java b/src/main/java/org/support/project/knowledge/vo/api/Target.java new file mode 100644 index 000000000..6ff2e70b8 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/Target.java @@ -0,0 +1,41 @@ +package org.support.project.knowledge.vo.api; + +import java.util.ArrayList; +import java.util.List; + +import org.support.project.web.bean.NameId; + +/** + * 閲覧可能/編集可能に指定されているターゲット情報 + * @author koda + */ +public class Target { + + private List groups = new ArrayList<>(); + private List users = new ArrayList<>(); + /** + * @return the groups + */ + public List getGroups() { + return groups; + } + /** + * @param groups the groups to set + */ + public void setGroups(List groups) { + this.groups = groups; + } + /** + * @return the users + */ + public List getUsers() { + return users; + } + /** + * @param users the users to set + */ + public void setUsers(List users) { + this.users = users; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/User.java b/src/main/java/org/support/project/knowledge/vo/api/User.java new file mode 100644 index 000000000..b163a7219 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/User.java @@ -0,0 +1,95 @@ +package org.support.project.knowledge.vo.api; + +import java.sql.Timestamp; + +/** + * APIで返すユーザ情報 + * @author koda + */ +public class User { + /** ユーザID */ + private Integer userId; + /** ユーザ名 */ + private String userName; + /** 登録ユーザ */ + private Integer insertUser; + /** 登録日時 */ + private Timestamp insertDatetime; + /** 更新ユーザ */ + private Integer updateUser; + /** 更新日時 */ + private Timestamp updateDatetime; + /** + * @return the userId + */ + public Integer getUserId() { + return userId; + } + /** + * @param userId the userId to set + */ + public void setUserId(Integer userId) { + this.userId = userId; + } + /** + * @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; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/api/UserDetail.java b/src/main/java/org/support/project/knowledge/vo/api/UserDetail.java new file mode 100644 index 000000000..e6b69b70f --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/api/UserDetail.java @@ -0,0 +1,47 @@ +package org.support.project.knowledge.vo.api; + +public class UserDetail extends User { + /** ナレッジの件数 */ + private int knowledgeCount; + /** イイネの件数 */ + private int likeCount; + /** ストックの件数 */ + private int stockCount; + /** + * @return the knowledgeCount + */ + public int getKnowledgeCount() { + return knowledgeCount; + } + /** + * @param knowledgeCount the knowledgeCount to set + */ + public void setKnowledgeCount(int knowledgeCount) { + this.knowledgeCount = knowledgeCount; + } + /** + * @return the likeCount + */ + public int getLikeCount() { + return likeCount; + } + /** + * @param likeCount the likeCount to set + */ + public void setLikeCount(int likeCount) { + this.likeCount = likeCount; + } + /** + * @return the stockCount + */ + public int getStockCount() { + return stockCount; + } + /** + * @param stockCount the stockCount to set + */ + public void setStockCount(int stockCount) { + this.stockCount = stockCount; + } + +} diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index ba74d7ee1..fc33c7adf 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -59,7 +59,7 @@ message.allready.started=Already started. message.confirm.delete=Are you sure you want to delete? # Common Label -label.version=v1.9.0 +label.version=v1.10.0 label.login=Sign in label.previous = Previous label.next=Next @@ -601,6 +601,7 @@ knowledge.sample.markdown.502=- [GitHub Flavored Markdown](https://help.github.c knowledge.sample.markdown.preview=Preview this sample knowledge.ldap.title=Ldap config +knowledge.ldap.label.description=Name knowledge.ldap.label.host=Host knowledge.ldap.label.port=Port knowledge.ldap.label.security=Security @@ -765,6 +766,7 @@ knowledge.admin.mailhook.condition.limit.param=Domain (If domain limit selected) knowledge.admin.mailhook.info.1=Post from e-mail is a automation function for add knowledge. It is receive mail by regularly, and add knowledge if satisfy the conditions. knowledge.admin.mailhook.info.2=After the reception, all mails will delete in this mailbox. knowledge.admin.mailhook.info.3=For this reason, please prepare the e-mail address of this function only. +knowledge.admin.mailhook.title.properties=Properties of mail. (Advanced option) knowledge.draft.list.title=Draft List knowledge.draft.list.empty=Empty List @@ -805,4 +807,24 @@ knowledge.survey.msg.survey.notfound=survey data is not found knowledge.survey.msg.copy.select=Please select a survey for copy. knowledge.survey.msg.copy.confirm=Do you want to copy the survey? This contents are overwritten with the contents to be copied. +knowledge.connect.title=Link to other accounts (ex Ldap account) +knowledge.connect.msg=You will be able to SignIn with a linked account. +knowledge.connect.linked=Linked +knowledge.connect.unlinked=Unlinked +knowledge.connect.link=Link +knowledge.connect.unlink=Unlink +knowledge.connect.info.link=If you want to connect to {1}, enter ID / password and execute "{2}" +knowledge.connect.update.me=Update your account information with linked information +knowledge.connect.disable.unlink=Your account use Ldap sign in, and this is the only linked ldap.You can not be unlink, because you can not sign in if you unlink this ldap. +knowledge.connect.label.account=This account + +knowledge.token.title=Access token +knowledge.token.label.token=Token +knowledge.token.msg.token=(Token is generated by the system) +knowledge.token.label.expires=expiration date +knowledge.token.msg.expires=(If not specified, it will be indefinite [9999-12-31]) +knowledge.token.label.create=Generate a Token +knowledge.token.label.update=Update expiration date +knowledge.token.label.delete=Delete Token +knowledge.token.msg.copy=Copied diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 866503a8f..fbf528dd2 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -59,7 +59,7 @@ message.allready.started=すでに開始済です message.confirm.delete=本当に削除しますか? # Common Label -label.version=v1.9.0 +label.version=v1.10.0 label.login=サインイン label.previous = 前へ label.next = 次へ @@ -492,7 +492,7 @@ knowledge.data.label.active.status.active=稼働中 knowledge.data.label.active.status.stop=停止中 knowledge.data.label.active.status.to.active=起動する knowledge.data.label.active.status.to.stop=停止する -knowledge.data.label.msg.restore=復元しました。少し立ってからデータベースを起動してください。 +knowledge.data.label.msg.restore=復元しました。少し経ってからデータベースを起動してください。 knowledge.data.label.msg.empty=復元するファイルが指定されていません knowledge.data.label.msg.invalid.file=復元するファイルがバックアップしたファイルであることを認識できませんでした。別のファイルを指定していませんか? knowledge.data.label.msg.fail=復元に失敗しました。再度お試しください。 @@ -601,6 +601,7 @@ knowledge.sample.markdown.502=- [GitHub Flavored Markdown](https://help.github.c knowledge.sample.markdown.preview=Sampleで確認 knowledge.ldap.title=Ldap 設定 +knowledge.ldap.label.description=設定名 knowledge.ldap.label.host=Host knowledge.ldap.label.port=Port knowledge.ldap.label.security=Security @@ -765,6 +766,7 @@ knowledge.admin.mailhook.condition.limit.param=ドメイン(特定ドメイン knowledge.admin.mailhook.info.1=メールから投稿は以下に設定したメールボックスで受信したメールを定期的に受信し、条件にあったメールをKnowledgeに投稿する機能です。 knowledge.admin.mailhook.info.2=定期的に受信するメールボックスに届いたメールは、受信後に削除します。 knowledge.admin.mailhook.info.3=このため、メール投稿専用のメールアドレスを用意してください。 +knowledge.admin.mailhook.title.properties=メール設定のプロパティ(高度なオプション) knowledge.draft.list.title=下書き一覧 knowledge.draft.list.empty=このページに該当するデータは存在しませんでした。 @@ -805,3 +807,23 @@ knowledge.survey.msg.survey.notfound=取得できるアンケートが存在し knowledge.survey.msg.copy.select=コピーするアンケートを選択してください knowledge.survey.msg.copy.confirm=アンケートをコピーしますか?編集中の内容はコピーされる内容で上書きされます。 +knowledge.connect.title=他アカウントの連携(Ldapのアカウントとの連携) +knowledge.connect.msg=連携したアカウントでログインできるようになります。 +knowledge.connect.linked=連携済 +knowledge.connect.unlinked=未連携 +knowledge.connect.link=連携する +knowledge.connect.unlink=連携を解除する +knowledge.connect.info.link={1}に接続したい場合、ID/パスワードを入力し、「{2}」を実行してください +knowledge.connect.update.me=連携した情報でアカウントの情報を更新する +knowledge.connect.disable.unlink=Ldapログイン利用アカウントで、連携しているアカウントはこれだけです。連携解除するとログインできなくなるため、解除できません。 +knowledge.connect.label.account=指定のアカウント + +knowledge.token.title=Access token +knowledge.token.label.token=Token +knowledge.token.msg.token=(Tokenはシステムが生成します) +knowledge.token.label.expires=有効期限 +knowledge.token.msg.expires=(無指定の場合、無期限[9999-12-31]になります) +knowledge.token.label.create=Tokenを生成する +knowledge.token.label.update=有効期限を更新する +knowledge.token.label.delete=Tokenを削除する +knowledge.token.msg.copy=コピーしました diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_delete.sql new file mode 100644 index 000000000..9ef3b2c6e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_delete.sql @@ -0,0 +1,5 @@ +DELETE FROM MAIL_PROPERTIES +WHERE +HOOK_ID = ? + AND PROPERTY_KEY = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_insert.sql new file mode 100644 index 000000000..de3e5ad1e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO MAIL_PROPERTIES +( +HOOK_ID + , PROPERTY_KEY + , PROPERTY_VALUE + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql new file mode 100644 index 000000000..ebdc6ad4b --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM MAIL_PROPERTIES +ORDER BY INSERT_DATETIME DESC; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..a7c99c6a9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM MAIL_PROPERTIES +ORDER BY INSERT_DATETIME DESC +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_hook_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_hook_id.sql new file mode 100644 index 000000000..168216a42 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_hook_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_PROPERTIES + WHERE +HOOK_ID = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_key.sql new file mode 100644 index 000000000..3d27f77e6 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM MAIL_PROPERTIES + WHERE +HOOK_ID = ? + AND PROPERTY_KEY = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_property_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_property_key.sql new file mode 100644 index 000000000..1567a3284 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_physical_select_on_property_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_PROPERTIES + WHERE +PROPERTY_KEY = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_raw_insert.sql new file mode 100644 index 000000000..de3e5ad1e --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO MAIL_PROPERTIES +( +HOOK_ID + , PROPERTY_KEY + , PROPERTY_VALUE + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql new file mode 100644 index 000000000..91b5059e6 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM MAIL_PROPERTIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME DESC; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql new file mode 100644 index 000000000..20be0fa61 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_PROPERTIES +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME DESC +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_count_all.sql new file mode 100644 index 000000000..60d5e1849 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM MAIL_PROPERTIES +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_hook_id.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_hook_id.sql new file mode 100644 index 000000000..37a1b3879 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_hook_id.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_PROPERTIES + WHERE +HOOK_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_key.sql new file mode 100644 index 000000000..458683d30 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_key.sql @@ -0,0 +1,5 @@ +SELECT * FROM MAIL_PROPERTIES + WHERE +HOOK_ID = ? + AND PROPERTY_KEY = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_property_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_property_key.sql new file mode 100644 index 000000000..387d16410 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_select_on_property_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_PROPERTIES + WHERE +PROPERTY_KEY = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_update.sql new file mode 100644 index 000000000..d741ddad9 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailPropertiesDao/MailPropertiesDao_update.sql @@ -0,0 +1,12 @@ +UPDATE MAIL_PROPERTIES +SET + PROPERTY_VALUE = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +HOOK_ID = ? + AND PROPERTY_KEY = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_delete.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_delete.sql new file mode 100644 index 000000000..7484c7889 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_delete.sql @@ -0,0 +1,4 @@ +DELETE FROM TOKENS +WHERE +TOKEN = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_insert.sql new file mode 100644 index 000000000..e3f012b5d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO TOKENS +( +TOKEN + , USER_ID + , EXPIRES + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql new file mode 100644 index 000000000..7fa82fc05 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all.sql @@ -0,0 +1,2 @@ +SELECT * FROM TOKENS +ORDER BY INSERT_DATETIME DESC; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql new file mode 100644 index 000000000..b704def52 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_all_with_pager.sql @@ -0,0 +1,3 @@ +SELECT * FROM TOKENS +ORDER BY INSERT_DATETIME DESC +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_on_key.sql new file mode 100644 index 000000000..8929f6cc5 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_physical_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM TOKENS + WHERE +TOKEN = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_raw_insert.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_raw_insert.sql new file mode 100644 index 000000000..e3f012b5d --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_raw_insert.sql @@ -0,0 +1,20 @@ +INSERT INTO TOKENS +( +TOKEN + , USER_ID + , EXPIRES + , INSERT_USER + , INSERT_DATETIME + , UPDATE_USER + , UPDATE_DATETIME + , DELETE_FLAG +) VALUES ( +? + , ? + , ? + , ? + , ? + , ? + , ? + , ? +); diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql new file mode 100644 index 000000000..d3cb05f49 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all.sql @@ -0,0 +1,3 @@ +SELECT * FROM TOKENS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME DESC; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql new file mode 100644 index 000000000..1787498bd --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_all_with_pager.sql @@ -0,0 +1,4 @@ +SELECT * FROM TOKENS +WHERE DELETE_FLAG = 0 +ORDER BY INSERT_DATETIME DESC +LIMIT ? OFFSET ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_count_all.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_count_all.sql new file mode 100644 index 000000000..f9295c283 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_count_all.sql @@ -0,0 +1,2 @@ +SELECT COUNT(*) FROM TOKENS +WHERE DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_on_key.sql new file mode 100644 index 000000000..13b3edff1 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_select_on_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM TOKENS + WHERE +TOKEN = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_update.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_update.sql new file mode 100644 index 000000000..d03549e9c --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/TokensDao/TokensDao_update.sql @@ -0,0 +1,12 @@ +UPDATE TOKENS +SET + USER_ID = ? + , EXPIRES = ? + , INSERT_USER = ? + , INSERT_DATETIME = ? + , UPDATE_USER = ? + , UPDATE_DATETIME = ? + , DELETE_FLAG = ? +WHERE +TOKEN = ? +; 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 d73ab27ca..aa7ff4623 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,36 @@ +-- 認証トークン +drop table if exists TOKENS cascade; + +create table TOKENS ( + TOKEN character varying(128) not null + , USER_ID integer not null + , EXPIRES timestamp not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint TOKENS_PKC primary key (TOKEN) +) ; + +create unique index TOKENS_IX1 + on TOKENS(USER_ID); + +-- メール受信設定 +drop table if exists MAIL_PROPERTIES cascade; + +create table MAIL_PROPERTIES ( + HOOK_ID INTEGER not null + , PROPERTY_KEY character varying(128) not null + , PROPERTY_VALUE character varying(256) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint MAIL_PROPERTIES_PKC primary key (HOOK_ID,PROPERTY_KEY) +) ; + -- ロケール毎のメールテンプレート drop table if exists MAIL_LOCALE_TEMPLATES cascade; @@ -700,6 +733,26 @@ create table KNOWLEDGES ( , constraint KNOWLEDGES_PKC primary key (KNOWLEDGE_ID) ) ; +comment on table TOKENS is '認証トークン'; +comment on column TOKENS.TOKEN is 'TOKEN'; +comment on column TOKENS.USER_ID is 'ユーザID'; +comment on column TOKENS.EXPIRES is '有効期限'; +comment on column TOKENS.INSERT_USER is '登録ユーザ'; +comment on column TOKENS.INSERT_DATETIME is '登録日時'; +comment on column TOKENS.UPDATE_USER is '更新ユーザ'; +comment on column TOKENS.UPDATE_DATETIME is '更新日時'; +comment on column TOKENS.DELETE_FLAG is '削除フラグ'; + +comment on table MAIL_PROPERTIES is 'メール受信設定'; +comment on column MAIL_PROPERTIES.HOOK_ID is 'HOOK_ID'; +comment on column MAIL_PROPERTIES.PROPERTY_KEY is 'PROPERTY_KEY'; +comment on column MAIL_PROPERTIES.PROPERTY_VALUE is 'PROPERTY_VALUE'; +comment on column MAIL_PROPERTIES.INSERT_USER is '登録ユーザ'; +comment on column MAIL_PROPERTIES.INSERT_DATETIME is '登録日時'; +comment on column MAIL_PROPERTIES.UPDATE_USER is '更新ユーザ'; +comment on column MAIL_PROPERTIES.UPDATE_DATETIME is '更新日時'; +comment on column MAIL_PROPERTIES.DELETE_FLAG is '削除フラグ'; + comment on table MAIL_LOCALE_TEMPLATES is 'ロケール毎のメールテンプレート'; comment on column MAIL_LOCALE_TEMPLATES.TEMPLATE_ID is 'テンプレートID'; comment on column MAIL_LOCALE_TEMPLATES.KEY is 'キー'; @@ -777,7 +830,7 @@ comment on column SURVEYS.DELETE_FLAG is '削除フラグ'; comment on table EVENTS is 'イベント'; comment on column EVENTS.KNOWLEDGE_ID is 'ナレッジID'; -comment on column EVENTS.START_DATE_TIME is '開催日 UTC'; +comment on column EVENTS.START_DATE_TIME is '開催日 UTC'; comment on column EVENTS.TIME_ZONE is 'タイムゾーン'; comment on column EVENTS.NOTIFY_STATUS is '通知ステータス'; comment on column EVENTS.INSERT_USER is '登録ユーザ'; @@ -878,7 +931,7 @@ comment on column DRAFT_KNOWLEDGES.DELETE_FLAG is '削除フラグ'; comment on table MAIL_POSTS is 'メールから投稿'; comment on column MAIL_POSTS.MESSAGE_ID is 'Message-ID'; -comment on column MAIL_POSTS.POST_KIND is '投稿区分 1: Knowledge 2:Comment'; +comment on column MAIL_POSTS.POST_KIND is '投稿区分 1: Knowledge 2:Comment'; comment on column MAIL_POSTS.ID is 'ID'; comment on column MAIL_POSTS.SENDER is 'SENDER'; comment on column MAIL_POSTS.INSERT_USER is '登録ユーザ'; @@ -890,10 +943,10 @@ comment on column MAIL_POSTS.DELETE_FLAG is '削除フラグ'; comment on table MAIL_HOOK_CONDITIONS is 'メールから投稿する条件'; comment on column MAIL_HOOK_CONDITIONS.HOOK_ID is 'HOOK_ID'; comment on column MAIL_HOOK_CONDITIONS.CONDITION_NO is 'CONDITION_NO'; -comment on column MAIL_HOOK_CONDITIONS.CONDITION_KIND is '条件の種類 1:宛先が「条件文字」であった場合'; +comment on column MAIL_HOOK_CONDITIONS.CONDITION_KIND is '条件の種類 1:宛先が「条件文字」であった場合'; comment on column MAIL_HOOK_CONDITIONS.CONDITION is '条件の文字'; comment on column MAIL_HOOK_CONDITIONS.PROCESS_USER is '投稿者'; -comment on column MAIL_HOOK_CONDITIONS.PROCESS_USER_KIND is '投稿者の指定 1:送信者のメールアドレスから、2:常に固定'; +comment on column MAIL_HOOK_CONDITIONS.PROCESS_USER_KIND is '投稿者の指定 1:送信者のメールアドレスから、2:常に固定'; comment on column MAIL_HOOK_CONDITIONS.PUBLIC_FLAG is '公開区分'; comment on column MAIL_HOOK_CONDITIONS.TAGS is 'タグ'; comment on column MAIL_HOOK_CONDITIONS.VIEWERS is '公開先'; diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate.sql new file mode 100644 index 000000000..3395fea29 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate.sql @@ -0,0 +1,45 @@ +-- ユーザのエイリアス +drop table if exists USER_ALIAS cascade; + +create table USER_ALIAS ( + USER_ID INTEGER not null + , AUTH_KEY character varying(64) not null + , ALIAS_KEY character varying(256) not null + , ALIAS_NAME character varying(256) not null + , ALIAS_MAIL character varying(256) + , USER_INFO_UPDATE integer + , ROW_ID character varying(64) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint USER_ALIAS_PKC primary key (USER_ID,AUTH_KEY) +) ; + +create unique index USER_ALIAS_IX1 + on USER_ALIAS(AUTH_KEY,ALIAS_KEY); + +comment on table USER_ALIAS is 'ユーザのエイリアス'; +comment on column USER_ALIAS.USER_ID is 'ユーザID'; +comment on column USER_ALIAS.AUTH_KEY is '認証設定キー'; +comment on column USER_ALIAS.ALIAS_KEY is 'エイリアスのキー'; +comment on column USER_ALIAS.ALIAS_NAME is 'エイリアスの表示名'; +comment on column USER_ALIAS.ALIAS_MAIL is 'メールアドレス'; +comment on column USER_ALIAS.USER_INFO_UPDATE is 'アカウント情報更新フラグ'; +comment on column USER_ALIAS.ROW_ID is '行ID'; +comment on column USER_ALIAS.INSERT_USER is '登録ユーザ'; +comment on column USER_ALIAS.INSERT_DATETIME is '登録日時'; +comment on column USER_ALIAS.UPDATE_USER is '更新ユーザ'; +comment on column USER_ALIAS.UPDATE_DATETIME is '更新日時'; +comment on column USER_ALIAS.DELETE_FLAG is '削除フラグ'; + +-- LDAP_CONFIGS へ DESCRIPTION を追加 +ALTER TABLE LDAP_CONFIGS DROP COLUMN IF EXISTS DESCRIPTION; +ALTER TABLE LDAP_CONFIGS ADD COLUMN DESCRIPTION character varying(64); +comment on column LDAP_CONFIGS.SYSTEM_NAME is '設定名'; +comment on column LDAP_CONFIGS.DESCRIPTION is 'DESCRIPTION'; + + + + diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate2.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate2.sql new file mode 100644 index 000000000..f37d95d9c --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate2.sql @@ -0,0 +1,25 @@ +-- メール受信設定 +drop table if exists MAIL_PROPERTIES cascade; + +create table MAIL_PROPERTIES ( + HOOK_ID INTEGER not null + , PROPERTY_KEY character varying(128) not null + , PROPERTY_VALUE character varying(256) + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint MAIL_PROPERTIES_PKC primary key (HOOK_ID,PROPERTY_KEY) +) ; + +comment on table MAIL_PROPERTIES is 'メール受信設定'; +comment on column MAIL_PROPERTIES.HOOK_ID is 'HOOK_ID'; +comment on column MAIL_PROPERTIES.PROPERTY_KEY is 'PROPERTY_KEY'; +comment on column MAIL_PROPERTIES.PROPERTY_VALUE is 'PROPERTY_VALUE'; +comment on column MAIL_PROPERTIES.INSERT_USER is '登録ユーザ'; +comment on column MAIL_PROPERTIES.INSERT_DATETIME is '登録日時'; +comment on column MAIL_PROPERTIES.UPDATE_USER is '更新ユーザ'; +comment on column MAIL_PROPERTIES.UPDATE_DATETIME is '更新日時'; +comment on column MAIL_PROPERTIES.DELETE_FLAG is '削除フラグ'; + diff --git a/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate3.sql b/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate3.sql new file mode 100644 index 000000000..c3f515b55 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/deploy/v1_10_0/migrate3.sql @@ -0,0 +1,28 @@ +-- 認証トークン +drop table if exists TOKENS cascade; + +create table TOKENS ( + TOKEN character varying(128) not null + , USER_ID integer not null + , EXPIRES timestamp not null + , INSERT_USER integer + , INSERT_DATETIME timestamp + , UPDATE_USER integer + , UPDATE_DATETIME timestamp + , DELETE_FLAG integer + , constraint TOKENS_PKC primary key (TOKEN) +) ; + +create unique index TOKENS_IX1 + on TOKENS(USER_ID); + +comment on table TOKENS is '認証トークン'; +comment on column TOKENS.TOKEN is 'TOKEN'; +comment on column TOKENS.USER_ID is 'ユーザID'; +comment on column TOKENS.EXPIRES is '有効期限'; +comment on column TOKENS.INSERT_USER is '登録ユーザ'; +comment on column TOKENS.INSERT_DATETIME is '登録日時'; +comment on column TOKENS.UPDATE_USER is '更新ユーザ'; +comment on column TOKENS.UPDATE_DATETIME is '更新日時'; +comment on column TOKENS.DELETE_FLAG is '削除フラグ'; + diff --git a/src/main/webapp/WEB-INF/views/admin/customservice/config.jsp b/src/main/webapp/WEB-INF/views/admin/customservice/config.jsp index ca91dd213..6febf5211 100644 --- a/src/main/webapp/WEB-INF/views/admin/customservice/config.jsp +++ b/src/main/webapp/WEB-INF/views/admin/customservice/config.jsp @@ -27,7 +27,7 @@ - + diff --git a/src/main/webapp/WEB-INF/views/admin/database/index.jsp b/src/main/webapp/WEB-INF/views/admin/database/index.jsp index a00a379d4..ecf25c00e 100644 --- a/src/main/webapp/WEB-INF/views/admin/database/index.jsp +++ b/src/main/webapp/WEB-INF/views/admin/database/index.jsp @@ -18,13 +18,13 @@ } - + - + @@ -51,206 +51,199 @@ $('#myTabs #myTabLdapConfig2').click(function (e) { <%= jspUtil.label("knowledge.ldap.title") %> - × - Information - - <%= jspUtil.label("knowledge.ldap.msg.ldap") %> - - <%= jspUtil.label("knowledge.ldap.msg.adminid1") %> - - <%= jspUtil.label("knowledge.ldap.msg.adminid2") %> - - <%= jspUtil.label("knowledge.ldap.msg.adminid3") %> - - <%= jspUtil.label("knowledge.ldap.msg.adminid4") %> + × + Information + - <%= jspUtil.label("knowledge.ldap.msg.ldap") %> + - <%= jspUtil.label("knowledge.ldap.msg.adminid1") %> + - <%= jspUtil.label("knowledge.ldap.msg.adminid2") %> + - <%= jspUtil.label("knowledge.ldap.msg.adminid3") %> + - <%= jspUtil.label("knowledge.ldap.msg.adminid4") %> - - - <%= jspUtil.label("knowledge.ldap.label.authtype") %> - - /> - <%= jspUtil.label("knowledge.ldap.label.authtype.db") %> - - - /> - <%= jspUtil.label("knowledge.ldap.label.authtype.ldap") %> - - - /> - <%= jspUtil.label("knowledge.ldap.label.authtype.both") %> - - - - - - - Ldap Config1 - - - Ldap Config2 - - - - + " /> + + + Ldap Config1 + + + Ldap Config2 + + + + - - - - × - Ldap Config1 - <%= jspUtil.label("knowledge.ldap.msg.config1") %> - - - - <%= jspUtil.label("knowledge.ldap.label.host") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.port") %><%= jspUtil.label("label.required") %> - " /> - - - - <%= jspUtil.label("knowledge.ldap.label.security") %> - - /> - <%= jspUtil.label("knowledge.ldap.label.plain") %> - - - /> - <%= jspUtil.label("knowledge.ldap.label.usessl") %> - - - /> - <%= jspUtil.label("knowledge.ldap.label.usetls") %> - - - - - <%= jspUtil.label("knowledge.ldap.label.basedn") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.idattr") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.nameattr") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.mailattr") %> - " /> - - - - - <%= jspUtil.label("knowledge.ldap.label.testid") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.testpass") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.adminid") %><%= jspUtil.label("label.required") %> - " value="<%= jspUtil.out("adminCheckFilter") %>" /> - - + + + × + Ldap Config1 + <%= jspUtil.label("knowledge.ldap.msg.config1") %> + + + + <%= jspUtil.label("knowledge.ldap.label.description") %><%= jspUtil.label("label.required") %> + " value="<%= jspUtil.out("description") %>" /> + + + <%= jspUtil.label("knowledge.ldap.label.host") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.port") %><%= jspUtil.label("label.required") %> + " /> + + + + <%= jspUtil.label("knowledge.ldap.label.security") %> + + /> + <%= jspUtil.label("knowledge.ldap.label.plain") %> + + + /> + <%= jspUtil.label("knowledge.ldap.label.usessl") %> + + + /> + <%= jspUtil.label("knowledge.ldap.label.usetls") %> + + + + + <%= jspUtil.label("knowledge.ldap.label.basedn") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.idattr") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.nameattr") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.mailattr") %> + " /> + + + + + <%= jspUtil.label("knowledge.ldap.label.testid") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.testpass") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.adminid") %> + " value="<%= jspUtil.out("adminCheckFilter") %>" /> + + - - - × - Ldap Config2 - <%= jspUtil.label("knowledge.ldap.msg.config2") %> - - - - <%= jspUtil.label("knowledge.ldap.label.host") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.port") %><%= jspUtil.label("label.required") %> - " /> - - - - <%= jspUtil.label("knowledge.ldap.label.security") %> - - /> - <%= jspUtil.label("knowledge.ldap.label.plain") %> - - - /> - <%= jspUtil.label("knowledge.ldap.label.usessl") %> - - - /> - <%= jspUtil.label("knowledge.ldap.label.usetls") %> - - - - <%= jspUtil.label("knowledge.ldap.label.config2.binddn") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.config2.password") %><%= jspUtil.label("label.required") %> - " /> - - - - <%= jspUtil.label("knowledge.ldap.label.config2.basedn") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.config2.filter") %><%= jspUtil.label("label.required") %> - <%= jspUtil.label("knowledge.ldap.info.filter") %> - - " /> - - - - <%= jspUtil.label("knowledge.ldap.label.idattr") %><%= jspUtil.label("label.required") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.nameattr") %> - " /> - - - <%= jspUtil.label("knowledge.ldap.label.mailattr") %> - " /> - - - - <%= jspUtil.label("knowledge.ldap.label.adminid") %><%= jspUtil.label("label.required") %> - " value="<%= jspUtil.out("adminCheckFilter") %>" /> - - - - - - - " /> - - " /> - - - <%= jspUtil.label("knowledge.ldap.label.dotest") %> - - - <%= jspUtil.label("label.save") %> - - <%= jspUtil.label("label.delete") %> + + + × + Ldap Config2 + <%= jspUtil.label("knowledge.ldap.msg.config2") %> + + + + <%= jspUtil.label("knowledge.ldap.label.description") %><%= jspUtil.label("label.required") %> + " value="<%= jspUtil.out("description") %>" /> + + + <%= jspUtil.label("knowledge.ldap.label.host") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.port") %><%= jspUtil.label("label.required") %> + " /> + + + + <%= jspUtil.label("knowledge.ldap.label.security") %> + + /> + <%= jspUtil.label("knowledge.ldap.label.plain") %> + + + /> + <%= jspUtil.label("knowledge.ldap.label.usessl") %> + + + /> + <%= jspUtil.label("knowledge.ldap.label.usetls") %> + + + + <%= jspUtil.label("knowledge.ldap.label.config2.binddn") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.config2.password") %><%= jspUtil.label("label.required") %> + " /> + + + + <%= jspUtil.label("knowledge.ldap.label.config2.basedn") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.config2.filter") %><%= jspUtil.label("label.required") %> + <%= jspUtil.label("knowledge.ldap.info.filter") %> + + " /> + + + + <%= jspUtil.label("knowledge.ldap.label.idattr") %><%= jspUtil.label("label.required") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.nameattr") %> + " /> + + + <%= jspUtil.label("knowledge.ldap.label.mailattr") %> + " /> + + + + <%= jspUtil.label("knowledge.ldap.label.adminid") %> + " value="<%= jspUtil.out("adminCheckFilter") %>" /> + + + + + + + " /> + + " /> + + + <%= jspUtil.label("knowledge.ldap.label.dotest") %> + + + <%= jspUtil.label("label.save") %> + + <%= jspUtil.label("label.delete") %> + <%= jspUtil.label("label.backlist") %> + + diff --git a/src/main/webapp/WEB-INF/views/admin/ldap/list.jsp b/src/main/webapp/WEB-INF/views/admin/ldap/list.jsp new file mode 100644 index 000000000..f395af43c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/admin/ldap/list.jsp @@ -0,0 +1,41 @@ +<%@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"%> + +<%@page import="java.util.List"%> +<%@page import="org.support.project.common.util.HtmlUtils"%> +<%@page import="org.support.project.common.config.INT_FLAG"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page import="org.support.project.web.entity.LdapConfigsEntity"%> + +<% JspUtil jspUtil = new JspUtil(request, pageContext); %> + + + + + + + + + + + +<%= jspUtil.label("knowledge.ldap.title") %> + + + <%= jspUtil.label("label.add") %> + + + +<% List configs = (List) request.getAttribute("configs"); %> +<% for (LdapConfigsEntity ldapConfig : configs) { %> + + <%= ldapConfig.getDescription() %> + +<% } %> + + + + + diff --git a/src/main/webapp/WEB-INF/views/admin/mailhook/config.jsp b/src/main/webapp/WEB-INF/views/admin/mailhook/config.jsp index da85038a0..a0b1078d7 100644 --- a/src/main/webapp/WEB-INF/views/admin/mailhook/config.jsp +++ b/src/main/webapp/WEB-INF/views/admin/mailhook/config.jsp @@ -3,9 +3,11 @@ <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@page import="java.util.List"%> <%@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 import="org.support.project.knowledge.vo.Roles"%> +<%@page import="org.support.project.knowledge.entity.MailPropertiesEntity"%> <% JspUtil jspUtil = new JspUtil(request, pageContext); %> @@ -15,6 +17,10 @@ + + + + @@ -42,7 +58,6 @@ function deleteMail() { - <%= jspUtil.label("knowledge.mail.subtitle.param") %> @@ -55,15 +70,6 @@ function deleteMail() { " value="<%= jspUtil.out("mailPort") %>" /> - - <%= jspUtil.label("knowledge.admin.mailhook.protocol") %> - - /> - - <%= jspUtil.label("knowledge.admin.mailhook.protocol.imap") %> - - <%= jspUtil.label("knowledge.admin.mailhook.user") %> + + + + + <%=jspUtil.label("knowledge.admin.mailhook.title.properties") %> + + + + + + Add + Remove + + + + + + <%= jspUtil.label("label.save") %> <% if (jspUtil.is(1, "hookId")) { %> diff --git a/src/main/webapp/WEB-INF/views/admin/mailhook/hook.jsp b/src/main/webapp/WEB-INF/views/admin/mailhook/hook.jsp index ac46bb979..199d9de56 100644 --- a/src/main/webapp/WEB-INF/views/admin/mailhook/hook.jsp +++ b/src/main/webapp/WEB-INF/views/admin/mailhook/hook.jsp @@ -14,15 +14,15 @@ - + - - - + + + + diff --git a/src/main/webapp/WEB-INF/views/admin/notice/list.jsp b/src/main/webapp/WEB-INF/views/admin/notice/list.jsp index 73e6d3c3d..fe7dcfe26 100644 --- a/src/main/webapp/WEB-INF/views/admin/notice/list.jsp +++ b/src/main/webapp/WEB-INF/views/admin/notice/list.jsp @@ -15,21 +15,21 @@ - - + + - - - - - - + + + + + + - + diff --git a/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp b/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp index 2f0b81ef0..b42b95965 100644 --- a/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp +++ b/src/main/webapp/WEB-INF/views/admin/systemconfig/index.jsp @@ -70,7 +70,7 @@ <%=jspUtil.label("knowledge.navbar.config.system.mail")%> - + <%=jspUtil.label("knowledge.ldap.title")%> diff --git a/src/main/webapp/WEB-INF/views/admin/template/edit.jsp b/src/main/webapp/WEB-INF/views/admin/template/edit.jsp index d220b6f53..b4b6bc6c4 100644 --- a/src/main/webapp/WEB-INF/views/admin/template/edit.jsp +++ b/src/main/webapp/WEB-INF/views/admin/template/edit.jsp @@ -11,14 +11,14 @@ - + - - + + diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp index 16290c9c8..c216f94a9 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp @@ -33,33 +33,31 @@ - - - + <% if (StringUtils.isNotEmpty(jspUtil.out("thema"))) { %> -/bootstrap.min.css" /> +/bootstrap.min.css" /> <% } else { %> -/bootstrap.min.css" /> +/bootstrap.min.css" /> <% } %> <% if (StringUtils.isNotEmpty(jspUtil.out("highlight"))) { %> -.css" /> +.css" /> <% } else { %> -.css" /> +.css" /> <% } %> - - + + - - + + 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 8a45e493c..4895daee3 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp @@ -65,77 +65,112 @@ - " style="cursor: pointer;" - id="navAddButtonLink"> - <%= jspUtil.label("knowledge.navbar.add.knowledge") %> - + + " class="btn btn-info" id="navAddButtonLink"> + + <%= jspUtil.label("knowledge.navbar.add.knowledge") %> + + + + + + + "> + <%= jspUtil.label("knowledge.navbar.add.knowledge") %> + + + + + <%=jspUtil.label("knowledge.draft.list.title")%> + + + + - - <%= jspUtil.label("knowledge.navbar.list.knowledge") %> - + + + + <%=jspUtil.label("knowledge.navbar.account.mystock")%> + + <% if (!jspUtil.logined()) { %> - - - - - - - - - <%= jspUtil.label("knowledge.navbar.search") %> - - - - - - <%= jspUtil.label("knowledge.navbar.signin") %> - - - + + + + + + + + + + + + <%= jspUtil.label("knowledge.navbar.list.knowledge") %> + + + + + + <%= jspUtil.label("knowledge.navbar.search") %> + + + + + + <%= jspUtil.label("knowledge.navbar.signin") %> + + + + <% } else { %> - - - - - - - - - <%= jspUtil.label("knowledge.navbar.search") %> - - - <% if (request.isUserInRole("admin")) { %> - - - - <%= jspUtil.label("knowledge.navbar.config.system") %> - - - <% } %> - <% if (jspUtil.logined()) { %> - - - - <%= jspUtil.label("knowledge.navbar.config") %> - - - <% } %> - - - - <%= jspUtil.label("knowledge.navbar.signout") %> - - - + + + + + + + + + + + + <%= jspUtil.label("knowledge.navbar.list.knowledge") %> + + + + + + <%= jspUtil.label("knowledge.navbar.search") %> + + + <% if (request.isUserInRole("admin")) { %> + + + + <%= jspUtil.label("knowledge.navbar.config.system") %> + + + <% } %> + <% if (jspUtil.logined()) { %> + + + + <%= jspUtil.label("knowledge.navbar.config") %> + + + <% } %> + + + + <%= jspUtil.label("knowledge.navbar.signout") %> + + + + <% } %> diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp index 50c36ea01..8f807966c 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp @@ -10,26 +10,26 @@ <% JspUtil jspUtil = new JspUtil(request, pageContext); %> - - + + - + - - - + + + - - + + - + - - + + - + - + diff --git a/src/main/webapp/WEB-INF/views/index/index.jsp b/src/main/webapp/WEB-INF/views/index/index.jsp index f8895a198..890d5b253 100644 --- a/src/main/webapp/WEB-INF/views/index/index.jsp +++ b/src/main/webapp/WEB-INF/views/index/index.jsp @@ -18,7 +18,7 @@ - + diff --git a/src/main/webapp/WEB-INF/views/open/account/account.jsp b/src/main/webapp/WEB-INF/views/open/account/account.jsp index 74d1a3742..2c07fb4ad 100644 --- a/src/main/webapp/WEB-INF/views/open/account/account.jsp +++ b/src/main/webapp/WEB-INF/views/open/account/account.jsp @@ -14,14 +14,14 @@ - + - - + + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp index dd2baee17..adfc3176e 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/histories.jsp @@ -16,7 +16,7 @@ - + - - - + + + + - - - - - - + + + + + + + - - - - - + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-styles.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-styles.jsp index 62aadaad7..a880fc45a 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-styles.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-styles.jsp @@ -7,16 +7,16 @@ <% JspUtil jspUtil = new JspUtil(request, pageContext); %> - - - - - - + + + + + + - - - - + + + + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/search.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/search.jsp index 45e70b5e1..5576b1ade 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/search.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/search.jsp @@ -16,18 +16,18 @@ - - + + - - - - - + + + + + - - + + - + - - - + + + diff --git a/src/main/webapp/WEB-INF/views/protect/account/index.jsp b/src/main/webapp/WEB-INF/views/protect/account/index.jsp index 28e1f7805..ec178ab85 100644 --- a/src/main/webapp/WEB-INF/views/protect/account/index.jsp +++ b/src/main/webapp/WEB-INF/views/protect/account/index.jsp @@ -13,19 +13,19 @@ - - - + + + - - - - - + + + + + diff --git a/src/main/webapp/WEB-INF/views/protect/account/targets.jsp b/src/main/webapp/WEB-INF/views/protect/account/targets.jsp index ff691d353..5d0ae568f 100644 --- a/src/main/webapp/WEB-INF/views/protect/account/targets.jsp +++ b/src/main/webapp/WEB-INF/views/protect/account/targets.jsp @@ -17,7 +17,7 @@ - + + + + + + <%=jspUtil.label("knowledge.connect.title")%> + + + <%=jspUtil.out("config.description")%> + + [<%=jspUtil.label("knowledge.connect.linked")%>] + + + [<%=jspUtil.label("knowledge.connect.unlinked")%>] + + + + + " /> + + + × + Information + <%=jspUtil.label("knowledge.connect.info.link", jspUtil.out("config.description"), jspUtil.label("knowledge.connect.link"))%> + + <%= jspUtil.label("") %> + + <%= jspUtil.label("knowledge.auth.label.id") %> + " + placeholder="<%= jspUtil.label("knowledge.auth.label.id") %>" autofocus> + + + <%= jspUtil.label("knowledge.auth.label.password") %> + " + placeholder="<%= jspUtil.label("knowledge.auth.label.password") %>"> + + + + <%= jspUtil.label("knowledge.connect.update.me") %> + + + + + <%= jspUtil.label("knowledge.connect.link") %> + + + + + <% if (jspUtil.is(Boolean.TRUE, "onlyone")) { %> + + × + Information + <%=jspUtil.label("knowledge.connect.disable.unlink")%> + + <% } %> + + Key + <%= jspUtil.out("alias.aliasKey") %> + + + Name + <%= jspUtil.out("alias.aliasName") %> + + + Mail + <%= jspUtil.out("alias.aliasMail") %> + + + + <%= jspUtil.label("knowledge.connect.update.me") %> + + + + + <%= jspUtil.label("label.update") %> + + + disabled="disabled" <% } %>> + <%= jspUtil.label("knowledge.connect.unlink") %> + + + + + <%= jspUtil.label("label.backlist") %> + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/views/protect/connect/index.jsp b/src/main/webapp/WEB-INF/views/protect/connect/index.jsp new file mode 100644 index 000000000..5c8ec2c22 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/protect/connect/index.jsp @@ -0,0 +1,56 @@ +<%@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"%> + +<%@page import="java.util.List"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page import="org.support.project.web.entity.UserAliasEntity"%> +<%@page import="org.support.project.web.entity.LdapConfigsEntity"%> +<% JspUtil jspUtil = new JspUtil(request, pageContext); %> + + + + + + + + + + + + <%=jspUtil.label("knowledge.connect.title")%> + + + × + Information + <%=jspUtil.label("knowledge.connect.msg")%> + + + + <% List ldapConfigs = (List) request.getAttribute("ldapConfigs"); %> + <% List alias = (List) request.getAttribute("alias"); %> + <% for (LdapConfigsEntity ldapConfig : ldapConfigs) { %> + + <%= ldapConfig.getDescription() %> + <% + UserAliasEntity info = null; + for (UserAliasEntity a : alias) { + if (a.getAuthKey().equals(ldapConfig.getSystemName())) { + info = a; + break; + } + } + if (info != null) { + %> + [ <%=jspUtil.label("knowledge.connect.linked")%>] (<%= info.getAliasKey() %>) + <% } else { %> + [ <%=jspUtil.label("knowledge.connect.unlinked")%>] + <% } %> + + <% } %> + + + + + 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 3ab96573a..d7931d708 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 @@ -19,7 +19,7 @@ - + - - + + - - - + + + - - + + - - - + + + - - + + @@ -109,7 +109,7 @@ var _SET_IMAGE_LABEL= '<%= jspUtil.label("knowledge.edit.set.image.path") %>'; "> " /> - "><%= jspUtil.out("file.name") %> + &attachment=true"><%= jspUtil.out("file.name") %> " /> diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-attach.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-attach.jsp index 7405085fb..460e1d0ea 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-attach.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-attach.jsp @@ -40,7 +40,7 @@ "> " width="20"/> - "><%= jspUtil.out("file.name", jspUtil.ESCAPE_HTML, 20) %> + &attachment=true"><%= jspUtil.out("file.name", jspUtil.ESCAPE_HTML, 20) %> " /> <% if (jspUtil.is("image", "file.type")) { %> diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-scripts.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-scripts.jsp index e890cd8f6..9e4e4bcb3 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-scripts.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-scripts.jsp @@ -15,39 +15,39 @@ MathJax.Hub.Config({ }); - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + diff --git a/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-styles.jsp b/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-styles.jsp index cca8c4ee4..a04523aa1 100644 --- a/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-styles.jsp +++ b/src/main/webapp/WEB-INF/views/protect/knowledge/partials/partials-edit-styles.jsp @@ -9,18 +9,18 @@ <% JspUtil jspUtil = new JspUtil(request, pageContext); %> - - - - - - - + + + + + + + - - - - + + + +