LICENSE.txt100644 0 0 26450 10710047156 10060 0ustar 0 0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. src/ 40755 0 0 0 10710110421 6662 5ustar 0 0 src/com/ 40755 0 0 0 10535006555 7461 5ustar 0 0 src/com/kickmogu/ 40755 0 0 0 10710110430 11251 5ustar 0 0 src/com/kickmogu/core/ 40755 0 0 0 10560603050 12211 5ustar 0 0 src/com/kickmogu/rhythm/ 40755 0 0 0 10710110430 12564 5ustar 0 0 src/com/kickmogu/rhythm/addressbook/ 40755 0 0 0 10537242540 15103 5ustar 0 0 src/com/kickmogu/rhythm/addressbook/dao/ 40755 0 0 0 10537242540 15646 5ustar 0 0 src/com/kickmogu/rhythm/addressbook/schema/ 40755 0 0 0 10536007376 16350 5ustar 0 0 src/com/kickmogu/rhythm/addressbook/test/ 40755 0 0 0 10536007376 16067 5ustar 0 0 src/com/kickmogu/rhythm/addressbook/ws/ 40755 0 0 0 10536007376 15541 5ustar 0 0 src/com/kickmogu/rhythm/board/ 40755 0 0 0 10551403454 13671 5ustar 0 0 src/com/kickmogu/rhythm/board/dao/ 40755 0 0 0 10551416074 14436 5ustar 0 0 src/com/kickmogu/rhythm/board/test/ 40755 0 0 0 10560063101 14637 5ustar 0 0 src/com/kickmogu/rhythm/board/ws/ 40755 0 0 0 10541732060 14317 5ustar 0 0 src/com/kickmogu/rhythm/core/ 40755 0 0 0 10710345414 13530 5ustar 0 0 src/com/kickmogu/rhythm/core/dao/ 40755 0 0 0 10700171663 14275 5ustar 0 0 src/com/kickmogu/rhythm/core/schema/ 40755 0 0 0 10700171663 14772 5ustar 0 0 src/com/kickmogu/rhythm/core/test/ 40755 0 0 0 10613126543 14511 5ustar 0 0 src/com/kickmogu/rhythm/core/ws/ 40755 0 0 0 10547442714 14172 5ustar 0 0 src/com/kickmogu/rhythm/core/ws/serializer/ 40755 0 0 0 10547442714 16343 5ustar 0 0 src/com/kickmogu/rhythm/mail/ 40755 0 0 0 10551403455 13525 5ustar 0 0 src/com/kickmogu/rhythm/mail/test/ 40755 0 0 0 10535006554 14505 5ustar 0 0 src/com/kickmogu/rhythm/mail/ws/ 40755 0 0 0 10560063110 14144 5ustar 0 0 src/com/kickmogu/rhythm/timecard/ 40755 0 0 0 10560063110 14361 5ustar 0 0 src/com/kickmogu/rhythm/timecard/dao/ 40755 0 0 0 10535006555 15140 5ustar 0 0 src/com/kickmogu/rhythm/timecard/schema/ 40755 0 0 0 10535006554 15634 5ustar 0 0 src/com/kickmogu/rhythm/timecard/ws/ 40755 0 0 0 10535006554 15025 5ustar 0 0 src/com/kickmogu/rhythm/todo/ 40755 0 0 0 10560063235 13546 5ustar 0 0 src/com/kickmogu/rhythm/todo/dao/ 40755 0 0 0 10560063321 14305 5ustar 0 0 src/com/kickmogu/rhythm/todo/test/ 40755 0 0 0 10560063110 14515 5ustar 0 0 src/com/kickmogu/rhythm/todo/ws/ 40755 0 0 0 10613132425 14174 5ustar 0 0 src/com/kickmogu/rhythm/util/ 40755 0 0 0 10560063110 13546 5ustar 0 0 src/com/kickmogu/rhythm/util/dao/ 40755 0 0 0 10560063110 14311 5ustar 0 0 src/com/kickmogu/rhythm/util/ws/ 40755 0 0 0 10560063110 14177 5ustar 0 0 src/com/kickmogu/s2/ 40755 0 0 0 10535006554 11615 5ustar 0 0 src/com/kickmogu/s2/dao/ 40755 0 0 0 10535006555 12361 5ustar 0 0 src/com/kickmogu/s2/test/ 40755 0 0 0 10535006555 12575 5ustar 0 0 src/sql/ 40755 0 0 0 10710345607 7501 5ustar 0 0 .classpath100644 0 0 4657 10710326501 10177 0ustar 0 0 .project100644 0 0 574 10526527701 7647 0ustar 0 0 flex org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature WEB-INF/server-config.wsdd100644 0 0 21373 10710333777 12726 0ustar 0 0 http://xml.apache.org/axis/wsdd/ WEB-INF/web.xml100644 0 0 12423 10710124333 10547 0ustar 0 0 Welcome to Tomcat Welcome to Tomcat org.apache.jsp.index_jsp org.apache.jsp.index_jsp org.apache.jsp.index_jsp /index.jsp HttpCmdDispatcher com.kickmogu.rhythm.core.HttpCmdDispatcher HttpCmdDispatcher /servlet/HttpCmdDispatcher RhythmMailFileDownloader com.kickmogu.rhythm.mail.FileDownloader RhythmMailFileDownloader /servlet/RhythmMailFileDownloader RhythmMailFileUploader com.kickmogu.rhythm.mail.FileUploader RhythmMailFileUploader /servlet/RhythmMailFileUploader AxisServlet Apache-Axis Servlet org.apache.axis.transport.http.AxisServlet use-servlet-security false 100 AdminServlet Axis Admin Servlet org.apache.axis.transport.http.AdminServlet use-servlet-security false 100 SOAPMonitorService SOAPMonitorService org.apache.axis.monitor.SOAPMonitorService SOAPMonitorPort 5001 100 AxisServlet /servlet/AxisServlet AxisServlet *.jws AxisServlet /services/* SOAPMonitorService /SOAPMonitor AdminServlet /servlet/AdminServlet s2servlet Seasar2 Servlet org.seasar.framework.container.servlet.S2ContainerServlet 1 s2servlet /s2servlet s2filter org.seasar.framework.container.filter.S2ContainerFilter build.xml100644 0 0 3022 10710517142 10021 0ustar 0 0 doc/INSTALL.txt100644 0 0 15610 10710363265 10647 0ustar 0 0 1.必要なもの  サーバ側 ・PostgreSQL8.1以上 ・Tomcat5.5系 ・Rhythmバイナリ版ファイル rhythm_bin_xxxxx.tar.gz ・Rhythm JARパック rhythm_jar_xxxxx.tar.gz (Jakarta CommonやSeasar2など、Rhythmで利用しているJARファイルをまとめたもの)  クライアント側 ・Flash Ver9以上が動作するWEBブラウザ 1.1.動作確認された環境(キックモグの開発環境) Debian GNU/Linux 3.1 i386 kernel 2.6.18 Jakarta Tomcat 5.5.25 PostgreSQL 8.1.9 JDK 1.5.12 2.インストール手順 実行例についてはLinuxでの操作例となっています。Windowsの場合は、適宜読み替えてください。 2.1.Tomcat5.5のインストール http://tomcat.apache.org/download-55.cgi からCoreのものでいいのでダウンロードしてください。 ダウンロードしたファイルをTomcat5.5を動作させたいディレクトリに解凍します。 ディレクトリは任意の名称でかまいません。以下の例では、/installto/にインストールを行います。 実行例) user@host:$ mkdir /installto/ user@host:$ cd /installto/ user@host:$ tar zxvf ダウンロードしたディレクトリ/apache-tomcat-5.5.xx.tar.gz 2.2.Rhythmファイルの展開 Tomcat5.5を展開したディレクトリに移動して、Rhythmバイナリ版ファイルとRhythm JARパックを展開します。 なお、Rhythmはwebapps/rhythm/とdata/というディレクトリを作成しますので、これらのディレクトリが別の目的で利用している場合は、事前にそれらのディレクトリ名を変更してください。 (ファイル名まで、Rhythmのシステムと重複している場合、ファイルが上書きされてしまいます。もちろん、Rhythmの新しいバージョンを展開する場合は、同じディレクトリがあっても構いません。) 実行例) user@host:$ cd /installto/apache-tomcat-5.5.xx user@host:$ tar zxvf rhythm_bin_xxxxx.tar.gz user@host:$ tar zxvf rhythm_jar_xxxxx.tar.gz Tomcatは、インストール直後はポート8080で動作します。8080が利用済みであったり、他のポートを使いたい場合は、/installto/apache-tomcat-5.5.xx/conf/server.xmlを変更してください。 2.3.追加で必要なJARのダウンロード ライセンスの都合により、JavaMailで必要なJARファイルは含めていません。 http://java.sun.com/products/javamail/downloads/index.html http://java.sun.com/products/javabeans/jaf/downloads/index.html 上記のURLより、JavaMailとJAFをダウンロードし、それぞれを適当なディレクトリに解凍し、中に含まれているmail.jarとactivation.jarを/installto/apache-tomcat-5.5.xx/webapps/rhythm/WEB-INF/lib/にコピーしてください。 2.4.データベースのインストール 文字コードEUC-JPにてPostgreSQLのデータベースを新規作成します。 以下のコマンドは、PostgreSQLへ特権モードでアクセスできるユーザで実行してください。 ほとんどの場合、ユーザ名は postgres などとなっているでしょう。 実行例) postgres@host:~$ createdb -E EUC_JP rhythmdb また、Rhythmシステムでアクセスするために専用のアカウントを作成することをお勧めします。 実行例) postgres@host:~$ psql Welcome to psql 8.x.x, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=# create user rhythmuser; postgres=# alter user rhythmuser password 'rhythmpswd'; postgres=# grant all on database rhythmdb to rhythmuser; postgres=# (CTRL+D) 最後にRhythmのスキーマと初期データを作成します。 実行例) postgres@host:~$ psql -U rhythmuser -f /installto/apache-tomcat-5.5.xx/data/rhythm_init.sql rhythmdb 2.5.各種設定ファイルの編集 (1)Flashのアクセス制限ファイルを編集 /installto/apache-tomcat-5.5.xx/webapps/rhythm/crossdomain.xmlにTomcatをインストールしたサーバのFQDN、もしくはIPアドレスを記述してください。 の "*"を変更します。 編集後、crossdomain.xmlを/installto/apache-tomcat-5.5.xx/webapps/ROOTに移動してください。 変更例) (2)Tomcat実行時のJAVAオプション設定 /installto/apache-tomcat-5.5.xx/bin/catalina.shに以下の一行を追加します。 JAVA_OPTS=" -Dkickmogu.property=flex.properties -Dsun.nio.cs.map=x-windows-iso2022jp/ISO-2022-JP" 追加する場所は、最初のコメント部分が終わった直後(56行目付近)でかまいません。 変更例) # # CATALINA_PID (Optional) Path of the file which should contains the pid # of catalina startup java process, when start (fork) is used # # $Id: INSTALL.txt,v 1.7 2007-10-26 13:08:05 mogu Exp $ # ----------------------------------------------------------------------------- JAVA_OPTS=" -Dkickmogu.property=flex.properties -Dsun.nio.cs.map=x-windows-iso2022jp/ISO-2022-JP" (3)WebServiceが動作しているURLを設定 Flash側のRhythmクライアントがどのRhythmサーバにアクセスするかを設定します。 /installto/apache-tomcat-5.5.xx/webapps/rhythm/index.htmlの74行目付近に "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '&soapRootUrl=http://192.168.1.1:8080/rhythm/services/&servletRootUrl=http://192.168.1.1:8080/rhythm/servlet/', となっている箇所を修正します。修正箇所は soapRootUrl=http://192.168.1.1:8080/ と servletRootUrl=http://192.168.1.1:8080/ の2点です。 それぞれ、TomcatサーバをインストールしたIPアドレス(もしくはFQDN)とポート番号に変更します。 ここから下のファイルは全て/installto/apache-tomcat-5.5.xx/webapps/rhythm/WEB-INF/classes/の中にあります。 (4)Rhythmの設定ファイル(flex.properties)を編集 path.sysrootをTomcatをインストールしたディレクトリに変更します。 変更例) path.sysroot=/installto/apache-tomcat-5.5.xx その他、mail.upload.tmpdirやmail.attach.dirは、適当なテンポラリディレクトリを指定します。多くのUnix系OSでは、変更しなくても動作します。 また、kickmogu.Config.portについては、利用されていないポート番号を指定してください。 (5)データベースアクセスの設定ファイル(j2ee.dicon)を編集 ファイルの78行目からPostgreSQLの設定情報を記入します。 変更する箇所は以下の部分です。 "jdbc:postgresql://PostgreSQLをインストールしたサーバの名前/データベース名" "DBにアクセスする時のユーザ名" "上記ユーザのパスワード" 上記のケースで、PostgreSQLとTomcatを同じサーバにインストールした場合は以下のようになります。 変更例) "jdbc:postgresql://localhost/rhythmdb" "rhythmuser" "rhythmpswd" なお、PostgreSQLが別のサーバにある場合は、PostgreSQL側のアクセス許可設定も必要になるかもしれません。 その際には、PostgreSQLのpg_hba.confを変更してください。 3.起動 お疲れ様でした。設定はこれで終了です。 後は、Tomcatを起動して、ブラウザでRhythmのTopページをブラウザで開いてください。 Tomcat実行例) cd /installto/apache-tomcat-5.5.xx/ bin/startup.sh RhythmのTopページは http://あなたのTomcatサーバIPアドレス:Tomcatのポート番号/rhythm/ となります。 ログインID,パスワードともに"root","root"でログインできるようになっていますが、ログイン後、パスワードはすぐに変更したほうが良いでしょう。 パスワードの変更は、左のメニューバーから管理ペインを選択し、個人設定メニューを選ぶことにより可能です。 src/com/kickmogu/Config.java100644 0 0 5656 10707773644 13466 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ package com.kickmogu; import java.util.*; import java.io.*; import java.net.*; public class Config extends Thread { static String prop_file = null; static Properties props = null; static private Config instance; static { prop_file = System.getProperty("kickmogu.property"); if (prop_file == null) prop_file = "kickmogu.properties"; instance = new Config(); instance.readProperty(); } public void run() { try { ServerSocket ss = new ServerSocket(Integer.parseInt(Config.getProperty("kickmogu.Config.port"))); Socket reread = ss.accept(); reread.close(); ss.close(); readProperty(); } catch (Exception ex) { System.out.println("Kickmogu.Config need property 'kickmogu.Config.port' .\n " + ex); } } private synchronized void readProperty() { try { if (props == null) props = new Properties(); String[] prop = prop_file.split(","); if (prop_file.indexOf(File.separator) == -1) props.load(this.getClass().getClassLoader().getResourceAsStream(prop[0])); else props.load(new FileInputStream(prop[0])); for (int i = 1; i < prop.length; i++) { Properties opt_prop = new Properties(); if (prop_file.indexOf(File.pathSeparator) == -1) opt_prop.load(this.getClass().getClassLoader().getResourceAsStream(prop[i])); else opt_prop.load(new FileInputStream(prop[i])); props.putAll(opt_prop); } Config cnf = new Config(); cnf.setPriority(Thread.MIN_PRIORITY); cnf.setDaemon(true); cnf.start(); } catch (Exception ex) { ex.printStackTrace(); System.out.println("property file not found=" + prop_file + "\n " + ex); } } static public int getInt(String key) { return Integer.parseInt(getProperty(key)); } static public String getProperty(String key) { int f = -1, t = -1; String val = props.getProperty(key); if (val == null) return null; while ((f = val.indexOf("${")) > -1) { if ((t = val.indexOf("}")) == -1) break; String dest = props.getProperty(val.substring(f + 2, t)); if (dest == null) break; val = val.replace(val.substring(f, t + 1), props.getProperty(val.substring(f + 2, t))); } return val; } public static void main(String[] arg) { System.out.println(getProperty(arg[0])); } } src/com/kickmogu/StopWatch.java100644 0 0 1631 10707773644 14162 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/04/24 * */ package com.kickmogu; import java.util.Date; public class StopWatch { private Date startTime = new Date(); public long getPastTime() { Date currentTime = new Date(); return currentTime.getTime() - startTime.getTime(); } } src/com/kickmogu/Util.java100644 0 0 24633 10707773644 13212 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ package com.kickmogu; import java.text.*; import java.util.*; import java.util.zip.*; import java.io.*; import java.security.*; import java.sql.Timestamp; import org.apache.commons.betwixt.io.BeanWriter; public class Util { static public void zipFile(File zipfile, File[] targets) throws IOException { ZipOutputStream zipout = new ZipOutputStream(new FileOutputStream(zipfile)); try { for (int i = 0; i < targets.length; i++) { ZipEntry ze = new ZipEntry(targets[i].getName()); zipout.putNextEntry(ze); BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(targets[i])); byte[] byteBuf=new byte[8192]; for (;;) { int iReadLen= inStream.read(byteBuf); if(iReadLen==(-1)){ break; } zipout.write(byteBuf,0,iReadLen); } inStream.close(); } } finally { zipout.close(); } } static public void unzipFile(File baseFile, File zipfile) throws IOException { ZipInputStream zipin = new ZipInputStream(new FileInputStream(zipfile)); ZipEntry zentry = null; try { while ((zentry = zipin.getNextEntry()) != null) { if (zentry.isDirectory()) { File dir = new File(baseFile, zentry.getName()); if (!dir.exists()) dir.mkdirs(); } else { File extractFile = new File(baseFile, zentry.getName()); if (!extractFile.getParentFile().exists()) extractFile.getParentFile().mkdirs(); BufferedOutputStream outStream=new BufferedOutputStream(new FileOutputStream(extractFile)); byte[] byteBuf=new byte[8192]; for(;;){ int iReadLen= zipin.read(byteBuf); if(iReadLen==(-1)){ break; } outStream.write(byteBuf,0,iReadLen); } outStream.close(); } } } finally { zipin.close(); } } public static String dumpBean(Object bean) { CharArrayWriter charout = new CharArrayWriter(); BeanWriter out = new BeanWriter(charout); out.enablePrettyPrint(); try { out.write(bean); out.close(); } catch (Exception ex) { return bean.toString(); } return charout.toString(); } static public String left(String src, int len) { if (src.length() <= len) return src; return src.substring(0, len); } static public String right(String src, int len) { if (src.length() <= len) return src; return src.substring(src.length() - len, src.length()); } final static String PASSWD_CHAR = "0123456789abcdefghijklmnopqrstuvwxvzABCDEFGHIJKLMNOPQRSTUVWXYZ"; static public String createPassword(int pswdLen) { StringBuffer passwd = new StringBuffer(); Random rnd = new Random(); for (int i = 0; i < pswdLen; i++) passwd.append(PASSWD_CHAR.charAt(rnd.nextInt(PASSWD_CHAR.length()))); return passwd.toString(); } static public String createPassword() { return createPassword(10); } static public String correctUnicodeMapping(String src) { return src.replace('−', '\u2015').replace('\uff5e', '\u301c'); } public static String makePassword(String eh_id, String pm_id) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA"); } catch (Exception ex) { } Random rand = new Random(); md.update((eh_id + "\t"+ pm_id + "\t"+ System.currentTimeMillis() + "\t" + rand.nextLong() + "\t" + Runtime.getRuntime().freeMemory()).getBytes()); byte[] dig = md.digest(); StringBuffer passwd = new StringBuffer(); for (int i = 0; i < dig.length; i++) passwd.append(Integer.toHexString(dig[i] < 0 ? dig[i] + 256 : dig[i])); return passwd.toString(); } static public byte[] stream2byte(InputStream bin) throws IOException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); byte[] buf = new byte[4096]; int len; while ((len = bin.read(buf)) != -1) byteOut.write(buf, 0, len); byteOut.close(); return byteOut.toByteArray(); } static public byte[] gzip2byte(byte[] gzipBody) throws IOException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); byte[] buf = new byte[4096]; int len; ByteArrayInputStream byteIn = new ByteArrayInputStream(gzipBody); GZIPInputStream gzipIn = new GZIPInputStream(byteIn); byteOut = new ByteArrayOutputStream(); while ((len = gzipIn.read(buf)) != -1) byteOut.write(buf, 0, len); byteOut.close(); return byteOut.toByteArray(); } static public byte[] byte2gzip(byte[] src) throws IOException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); GZIPOutputStream gzipOut = new GZIPOutputStream(byteOut); gzipOut.write(src, 0, src.length); gzipOut.flush(); gzipOut.close(); byteOut.close(); byte[] gzipBody = byteOut.toByteArray(); return gzipBody; } static public String reader2String(Reader in) throws IOException { BufferedReader bin = new BufferedReader(in); String ln = ""; StringBuffer out = new StringBuffer(); while ((ln = bin.readLine()) != null) out.append(ln); return out.toString(); } static public String getStackTrace(Exception ex) { StringWriter sout = new StringWriter(); PrintWriter out = new PrintWriter(sout); ex.printStackTrace(out); return sout.toString(); } static public boolean isDate(String fmt, String date) { SimpleDateFormat sfmt = new SimpleDateFormat(fmt); sfmt.setLenient(false); ParsePosition pp = new ParsePosition(0); java.util.Date dt = sfmt.parse(date, pp); return dt != null && pp.getIndex() == date.length() ? true : false; } static public String toStr(Object val) { return toStr((String) val); } static public String toStr(String val) { return val == null || val.equals("") ? "" : val; } final static String[][] UNPRINT_HTML_CHAR = { {"&", "&"}, {"<", "<"}, {">", ">"}, {"\"", """}, }; static public String convHtmlChar(String src) { for (int i = 0; i < UNPRINT_HTML_CHAR.length; i++) { int pos = 0; while ((pos = src.indexOf(UNPRINT_HTML_CHAR[i][0].charAt(0), pos)) != -1) { src = src.substring(0, pos) + UNPRINT_HTML_CHAR[i][1] + src.substring(pos + 1); pos += UNPRINT_HTML_CHAR[i][1].length() - 1; } } return src; } final static String[][] CONV_HTML_CHAR = { {"&", "&"}, {"<", "<"}, {">", ">"}, {""", "\""}, {"/", "/"}, }; static public String convCharRef2Str(String src) { for (int i = 0; i < CONV_HTML_CHAR.length; i++) { src = src.replace(CONV_HTML_CHAR[i][0], CONV_HTML_CHAR[i][1]); } return src; } static public String decodeHex(String src) { StringBuffer dest = new StringBuffer(); for (int i = 0; i < src.length() / 4; i++) { String hex = src.substring(i * 4, i * 4 + 4); dest.append((char) Integer.parseInt(hex, 16)); } return dest.toString(); } static public String encodeHex(String src) { StringBuffer dest = new StringBuffer(); for (int i = 0; i < src.length(); i++) { String hex = "000" + Integer.toHexString((int) src.charAt(i)); dest.append(hex.substring(hex.length() - 4)); } return dest.toString(); } static BitSet dontNeedEncoding; static final int caseDiff = ('a' - 'A'); /* The list of characters that are not encoded have been determined by referencing O'Reilly's "HTML: The Definitive Guide" (page 164). */ static { dontNeedEncoding = new BitSet(256); int i; for (i = 'a'; i <= 'z'; i++) { dontNeedEncoding.set(i); } for (i = 'A'; i <= 'Z'; i++) { dontNeedEncoding.set(i); } for (i = '0'; i <= '9'; i++) { dontNeedEncoding.set(i); } dontNeedEncoding.set(' '); /* encoding a space to a + is done in the encode() method */ dontNeedEncoding.set('-'); dontNeedEncoding.set('_'); dontNeedEncoding.set('.'); dontNeedEncoding.set('*'); } /** * Translates a string into x-www-form-urlencoded format. * * @param s String to be translated. * @return the translated String. */ public static String urlencode(String s, String enc) throws UnsupportedEncodingException { int maxBytesPerChar = 10; StringBuffer out = new StringBuffer(s.length()); ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar); OutputStreamWriter writer = new OutputStreamWriter(buf, enc); for (int i = 0; i < s.length(); i++) { int c = (int)s.charAt(i); if (dontNeedEncoding.get(c)) { if (c == ' ') { c = '+'; } out.append((char)c); } else { // convert to external encoding before hex conversion try { writer.write(c); writer.flush(); } catch(IOException e) { buf.reset(); continue; } byte[] ba = buf.toByteArray(); for (int j = 0; j < ba.length; j++) { out.append('%'); char ch = Character.forDigit((ba[j] >> 4) & 0xF, 16); // converting to use uppercase letter as part of // the hex value if ch is a letter. if (Character.isLetter(ch)) { ch -= caseDiff; } out.append(ch); ch = Character.forDigit(ba[j] & 0xF, 16); if (Character.isLetter(ch)) { ch -= caseDiff; } out.append(ch); } buf.reset(); } } return out.toString(); } public static Timestamp yyyymmdd2Timestamp(String ymd) { ymd = ymd.replace('/', '-'); return java.sql.Timestamp.valueOf(ymd + " 00:00:00.0"); } } src/com/kickmogu/core/Utils.java100644 0 0 2161 10710110422 14242 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/07 * */ package com.kickmogu.core; import java.io.CharArrayWriter; import org.apache.commons.betwixt.io.BeanWriter; public class Utils { public static String dumpBean(Object bean) throws Exception { if (bean == null) { return "bean is null."; } CharArrayWriter charout = new CharArrayWriter(); BeanWriter out = new BeanWriter(charout); out.enablePrettyPrint(); out.write(bean); out.close(); return charout.toString(); } } src/com/kickmogu/core/XmlUtils.java100644 0 0 3562 10710110422 14731 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/31 * */ package com.kickmogu.core; import org.apache.commons.beanutils.BeanUtils; import java.lang.reflect.InvocationTargetException; import java.util.*; public class XmlUtils { static public String bean2attributes(Object bean) { return bean2attributes(bean, null); } static public String bean2attributes(Object bean, String[] excludeProperties) { StringBuffer out = new StringBuffer(); Map properties; try { List excludeList = Arrays.asList(excludeProperties == null ? new String[]{} : excludeProperties); properties = BeanUtils.describe(bean); Iterator ite = properties.keySet().iterator(); while (ite.hasNext()) { String propName = (String) ite.next(); if (excludeList.indexOf(propName) > -1) { continue; } String val = BeanUtils.getProperty(bean, propName); if (val != null) { val = val.replaceAll("\"", "\\\""); out.append(propName + "=\"" + BeanUtils.getProperty(bean, propName) + "\" "); } } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } return out.toString(); } } src/com/kickmogu/rhythm/addressbook/AddressBook.java100644 0 0 7603 10710110422 20233 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/06 * */ package com.kickmogu.rhythm.addressbook; import com.kickmogu.rhythm.core.*; public class AddressBook { public final static String UNIQ_KEYNAME = "rhtym addressbook id"; private int id; private int categoryId; private int registrant; private String firstName; private String lastName; private String firstSpell; private String lastSpell; private String displayName; private String email; private EmailAddress[] emails; private Telephone[] tels; private Address[] addresses; /** * @return displayName を戻します。 */ public String getDisplayName() { return displayName; } /** * @param displayName displayName を設定。 */ public void setDisplayName(String displayName) { this.displayName = displayName; } /** * @return emails を戻します。 */ public EmailAddress[] getEmails() { return emails; } /** * @param emails emails を設定。 */ public void setEmails(EmailAddress[] emails) { this.emails = emails; } /** * @return firstName を戻します。 */ public String getFirstName() { return firstName; } /** * @param firstName firstName を設定。 */ public void setFirstName(String firstName) { this.firstName = firstName; } /** * @return firstSpell を戻します。 */ public String getFirstSpell() { return firstSpell; } /** * @param firstSpell firstSpell を設定。 */ public void setFirstSpell(String firstSpell) { this.firstSpell = firstSpell; } /** * @return lastName を戻します。 */ public String getLastName() { return lastName; } /** * @param lastName lastName を設定。 */ public void setLastName(String lastName) { this.lastName = lastName; } /** * @return lastSpell を戻します。 */ public String getLastSpell() { return lastSpell; } /** * @param lastSpell lastSpell を設定。 */ public void setLastSpell(String lastSpell) { this.lastSpell = lastSpell; } /** * @return tels を戻します。 */ public Telephone[] getTels() { return tels; } /** * @param tels tels を設定。 */ public void setTels(Telephone[] tels) { this.tels = tels; } /** * @return addresses を戻します。 */ public Address[] getAddresses() { return addresses; } /** * @param addresses addresses を設定。 */ public void setAddresses(Address[] addresses) { this.addresses = addresses; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return registrant を戻します。 */ public int getRegistrant() { return registrant; } /** * @param registrant registrant を設定。 */ public void setRegistrant(int registrant) { this.registrant = registrant; } /** * @return categoryId を戻します。 */ public int getCategoryId() { return categoryId; } /** * @param categoryId categoryId を設定。 */ public void setCategoryId(int categoryId) { this.categoryId = categoryId; } /** * @return email を戻します。 */ public String getEmail() { return email; } /** * @param email email を設定。 */ public void setEmail(String email) { this.email = email; } } src/com/kickmogu/rhythm/addressbook/AddressBookAddress.java100644 0 0 3066 10710110422 21540 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/06 * */ package com.kickmogu.rhythm.addressbook; public class AddressBookAddress { public final static String UNIQ_KEYNAME = "rhtym addressbookaddress id"; private int id; private int addressBookId; private int addressId; /** * @return addressBookId を戻します。 */ public int getAddressBookId() { return addressBookId; } /** * @param addressBookId addressBookId を設定。 */ public void setAddressBookId(int addressBookId) { this.addressBookId = addressBookId; } /** * @return addressId を戻します。 */ public int getAddressId() { return addressId; } /** * @param addressId addressId を設定。 */ public void setAddressId(int addressId) { this.addressId = addressId; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } } src/com/kickmogu/rhythm/addressbook/AddressBookEmailAddress.java100644 0 0 3162 10710110423 22506 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/06 * */ package com.kickmogu.rhythm.addressbook; public class AddressBookEmailAddress { public final static String UNIQ_KEYNAME = "rhtym addressbookemailaddress id"; private int id; private int addressBookId; private int emailAddressId; /** * @return addressBookId を戻します。 */ public int getAddressBookId() { return addressBookId; } /** * @param addressBookId addressBookId を設定。 */ public void setAddressBookId(int addressBookId) { this.addressBookId = addressBookId; } /** * @return emailAddressId を戻します。 */ public int getEmailAddressId() { return emailAddressId; } /** * @param emailAddressId emailAddressId を設定。 */ public void setEmailAddressId(int emailAddressId) { this.emailAddressId = emailAddressId; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } } src/com/kickmogu/rhythm/addressbook/AddressBookTelephone.java100644 0 0 3116 10710110423 22073 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/06 * */ package com.kickmogu.rhythm.addressbook; public class AddressBookTelephone { public final static String UNIQ_KEYNAME = "rhtym addressbooktelephone id"; private int id; private int addressBookId; private int telephoneId; /** * @return addressBookId を戻します。 */ public int getAddressBookId() { return addressBookId; } /** * @param addressBookId addressBookId を設定。 */ public void setAddressBookId(int addressBookId) { this.addressBookId = addressBookId; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return telephoneId を戻します。 */ public int getTelephoneId() { return telephoneId; } /** * @param telephoneId telephoneId を設定。 */ public void setTelephoneId(int telephoneId) { this.telephoneId = telephoneId; } } src/com/kickmogu/rhythm/addressbook/AddressCategory.java100644 0 0 2764 10710110423 21122 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/11 * */ package com.kickmogu.rhythm.addressbook; public class AddressCategory { public final static String UNIQ_KEYNAME = "rhtym addresscategory id"; private int id; private int registrant; private String name; /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return name を戻します。 */ public String getName() { return name; } /** * @param name name を設定。 */ public void setName(String name) { this.name = name; } /** * @return registrant を戻します。 */ public int getRegistrant() { return registrant; } /** * @param registrant registrant を設定。 */ public void setRegistrant(int registrant) { this.registrant = registrant; } } src/com/kickmogu/rhythm/addressbook/dao/AddressBookAddressDao.java100644 0 0 3164 10710110423 22727 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.addressbook.*; /** * @author mogu * */ public interface AddressBookAddressDao { public Class BEAN = AddressBookAddress.class; public static final String getAddressBook_Address_QUERY = "addressBookId = ? and addressId = ?"; public static final String list_SQL = "select AddressBookAddress.* from AddressBookAddress, AddressBook " + " where registrant = ? and AddressBook.id = AddressBookAddress.addressBookId"; public int update(AddressBookAddress tel); public int insert(AddressBookAddress tel); public int delete(AddressBookAddress tel); public AddressBookAddress getAddressBook_Address(int addressBookId, int addressId); public AddressBookAddress[] list(int registrant); } src/com/kickmogu/rhythm/addressbook/dao/AddressBookDao.java100644 0 0 2673 10710110423 21425 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.addressbook.*; /** * @author mogu * */ public interface AddressBookDao { public Class BEAN = AddressBook.class; public static final String getAddressBook_QUERY = "registrant = ? and id = ?"; public static final String list_QUERY = "registrant = ? and categoryId = ?"; public int update(AddressBook addrbook); public int insert(AddressBook addrbook); public int delete(AddressBook addrbook); public AddressBook getAddressBook(int memid, int id); public AddressBook[] list(int memid, int catid); } src/com/kickmogu/rhythm/addressbook/dao/AddressBookEmailAddressDao.java100644 0 0 3271 10710110423 23676 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.addressbook.*; /** * @author mogu * */ public interface AddressBookEmailAddressDao { public Class BEAN = AddressBookEmailAddress.class; public static final String getAddressBookEmailAddress_QUERY = "addressBookId = ? and emailAddressId = ?"; public static final String list_SQL = "select AddressBookEmailAddress.* from AddressBookEmailAddress, AddressBook " + " where registrant = ? and AddressBook.id = AddressBookEmailAddress.addressBookId"; public int update(AddressBookEmailAddress tel); public int insert(AddressBookEmailAddress tel); public int delete(AddressBookEmailAddress tel); public AddressBookEmailAddress getAddressBook_EmailAddress(int addressBookId, int emailAddressId); public AddressBookEmailAddress[] list(int registrant); } src/com/kickmogu/rhythm/addressbook/dao/AddressBookTelephoneDao.java100644 0 0 3220 10710110423 23256 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.addressbook.*; /** * @author mogu * */ public interface AddressBookTelephoneDao { public Class BEAN = AddressBookTelephone.class; public static final String getAddressBookTelephone_QUERY = "addressBookId = ? and telephoneId = ?"; public static final String list_SQL = "select AddressBookTelephone.* from AddressBookTelephone, AddressBook " + " where registrant = ? and AddressBook.id = AddressBookTelephone.addressBookId "; public int update(AddressBookTelephone tel); public int insert(AddressBookTelephone tel); public int delete(AddressBookTelephone tel); public AddressBookTelephone getAddressBook_Telephone(int addressBookId, int telephoneId); public AddressBookTelephone[] list(int registrant); } src/com/kickmogu/rhythm/addressbook/dao/AddressCategoryDao.java100644 0 0 2676 10710110423 22313 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.addressbook.*; /** * @author mogu * */ public interface AddressCategoryDao { public Class BEAN = AddressCategory.class; public static final String getAddressCategory_QUERY = "registrant = ? and id = ?"; public static final String list_QUERY = "registrant = ?"; public int update(AddressCategory addrcat); public int insert(AddressCategory addrcat); public int delete(AddressCategory addrcat); public AddressCategory getAddressCategory(int memid, int id); public AddressCategory[] list(int memid); } src/com/kickmogu/rhythm/addressbook/dao/AddressDao.java100644 0 0 3000 10710110423 20573 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.core.*; /** * @author mogu * */ public interface AddressDao { public Class BEAN = Address.class; public static final String getAddress_QUERY = "id = ?"; public static final String list_SQL = "select Address.* from Address, AddressBookAddress, AddressBook " + " where registrant = ? and AddressBook.id = AddressBookAddress.addressBookId and Address.id = AddressBookAddress.addressId"; public int update(Address addr); public int insert(Address addr); public int delete(Address addr); public Address getAddress(int id); public Address[] list(int registrant); } src/com/kickmogu/rhythm/addressbook/dao/EmailAddressDao.java100644 0 0 3123 10710110423 21551 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.core.*; /** * @author mogu * */ public interface EmailAddressDao { public Class BEAN = EmailAddress.class; public static final String getEmailAddress_QUERY = "id = ?"; public static final String list_SQL = "select EmailAddress.* from EmailAddress, AddressBookEmailAddress, AddressBook " + " where registrant = ? and AddressBook.id = AddressBookEmailAddress.addressBookId and EmailAddress.id = AddressBookEmailAddress.emailAddressId"; public int update(EmailAddress eaddr); public int insert(EmailAddress eaddr); public int delete(EmailAddress eaddr); public EmailAddress getEmailAddress(int id); public EmailAddress[] list(int registrant); } src/com/kickmogu/rhythm/addressbook/dao/TelephoneDao.java100644 0 0 3035 10710110423 21141 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.addressbook.dao; import com.kickmogu.rhythm.core.*; /** * @author mogu * */ public interface TelephoneDao { public Class BEAN = Telephone.class; public static final String getTelephone_QUERY = "id = ?"; public static final String list_SQL = "select Telephone.* from Telephone, AddressBookTelephone, AddressBook " + " where registrant = ? and AddressBook.id = AddressBookTelephone.addressBookId and Telephone.id = AddressBookTelephone.telephoneId"; public int update(Telephone tel); public int insert(Telephone tel); public int delete(Telephone tel); public Telephone getTelephone(int id); public Telephone[] list(int registrant); } src/com/kickmogu/rhythm/addressbook/schema/schema.sql100644 0 0 1437 10537242540 20426 0ustar 0 0 create table AddressBook ( id int not null, categoryId int not null, registrant int not null, firstName varchar(50), lastName varchar(50), firstSpell varchar(50), lastSpell varchar(50), displayName varchar(100), primary key(id)); create table AddressBook_Address ( id int not null, addressBookId int not null, addressId int not null, primary key(id)); create table AddressBook_EmailAddress ( id int not null, addressBookId int not null, emailAddressId int not null, primary key(id)); create table AddressBook_Telephone ( id int not null, addressBookId int not null, telephoneId int not null, primary key(id)); create table AddressCategory ( id int not null, registrant int not null, name varchar(100), primary key(id)); src/com/kickmogu/rhythm/addressbook/test/AddressBookTest.java100644 0 0 2302 10710110423 22042 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/07 * */ package com.kickmogu.rhythm.addressbook.test; import com.kickmogu.core.*; import com.kickmogu.rhythm.addressbook.dao.*; import com.kickmogu.rhythm.addressbook.*; import com.kickmogu.s2.S2Util; public class AddressBookTest { /** * @param args */ public static void main(String[] args) throws Exception { AddressBookDao addrDao = (AddressBookDao) S2Util.getS2Container().getComponent(AddressBookDao.class); AddressBook abook = addrDao.getAddressBook(0, 0); System.out.println(Utils.dumpBean(abook)); } } src/com/kickmogu/rhythm/addressbook/ws/AddressBookWs.java100644 0 0 17454 10710110423 21224 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/07 * */ package com.kickmogu.rhythm.addressbook.ws; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.addressbook.*; import com.kickmogu.rhythm.addressbook.dao.*; import com.kickmogu.s2.DAOSequence; import com.kickmogu.s2.S2Util; public class AddressBookWs { AddressBookDao abdao = (AddressBookDao) S2Util.getS2Container().getComponent(AddressBookDao.class); AddressCategoryDao abcatdao = (AddressCategoryDao) S2Util.getS2Container().getComponent(AddressCategoryDao.class); AddressDao addrdao = (AddressDao) S2Util.getS2Container().getComponent(AddressDao.class); TelephoneDao teldao = (TelephoneDao) S2Util.getS2Container().getComponent(TelephoneDao.class); EmailAddressDao emaildao = (EmailAddressDao) S2Util.getS2Container().getComponent(EmailAddressDao.class); AddressBookAddressDao abaddrdao = (AddressBookAddressDao) S2Util.getS2Container().getComponent(AddressBookAddressDao.class); AddressBookTelephoneDao abteldao = (AddressBookTelephoneDao) S2Util.getS2Container().getComponent(AddressBookTelephoneDao.class); AddressBookEmailAddressDao abemaildao = (AddressBookEmailAddressDao) S2Util.getS2Container().getComponent(AddressBookEmailAddressDao.class); private void registTelephone(AddressBook abook) { AddressBookTelephone[] abtels = abteldao.list(abook.getRegistrant()); for (int i = 0; i < abtels.length; i++) { abteldao.delete(abtels[i]); } Telephone[] tels = teldao.list(abook.getRegistrant()); for (int i = 0; i < abtels.length; i++) { teldao.delete(tels[i]); } for (int i = 0; abook.getTels() != null && i < abook.getTels().length; i++) { Telephone tel = abook.getTels()[i]; if (tel.getId() == -1) { tel.setId(DAOSequence.getNextId(Telephone.UNIQ_KEYNAME)); } teldao.insert(tel); AddressBookTelephone abtel = new AddressBookTelephone(); abtel.setId(DAOSequence.getNextId(AddressBookTelephone.UNIQ_KEYNAME)); abtel.setAddressBookId(abook.getId()); abtel.setTelephoneId(tel.getId()); abteldao.insert(abtel); } } private void registAddress(AddressBook abook) { AddressBookAddress[] abaddrs = abaddrdao.list(abook.getRegistrant()); for (int i = 0; i < abaddrs.length; i++) { abaddrdao.delete(abaddrs[i]); } Address[] addrs = addrdao.list(abook.getRegistrant()); for (int i = 0; i < addrs.length; i++) { addrdao.delete(addrs[i]); } for (int i = 0; abook.getAddresses() != null && i < abook.getAddresses().length; i++) { Address addr = abook.getAddresses()[i]; if (addr.getId() == -1) { addr.setId(DAOSequence.getNextId(Telephone.UNIQ_KEYNAME)); } addrdao.insert(addr); AddressBookAddress abaddr = new AddressBookAddress(); abaddr.setId(DAOSequence.getNextId(AddressBookAddress.UNIQ_KEYNAME)); abaddr.setAddressBookId(abook.getId()); abaddr.setAddressId(addr.getId()); abaddrdao.insert(abaddr); } } private void registEmailAddress(AddressBook abook) { AddressBookEmailAddress[] abeaddrs = abemaildao.list(abook.getRegistrant()); for (int i = 0; i < abeaddrs.length; i++) { abemaildao.delete(abeaddrs[i]); } EmailAddress[] eaddrs = emaildao.list(abook.getRegistrant()); for (int i = 0; i < eaddrs.length; i++) { emaildao.delete(eaddrs[i]); } for (int i = 0; abook.getEmails() != null && i < abook.getEmails().length; i++) { EmailAddress eaddr = abook.getEmails()[i]; if (eaddr.getId() == -1) { eaddr.setId(DAOSequence.getNextId(EmailAddress.UNIQ_KEYNAME)); } emaildao.insert(eaddr); AddressBookEmailAddress eabaddr = new AddressBookEmailAddress(); eabaddr.setId(DAOSequence.getNextId(AddressBookAddress.UNIQ_KEYNAME)); eabaddr.setAddressBookId(abook.getId()); eabaddr.setEmailAddressId(eaddr.getId()); abemaildao.insert(eabaddr); } } public BaseResult add(Member loginMember, AddressBook abook) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } abook.setId(DAOSequence.getNextId(AddressBook.UNIQ_KEYNAME)); abook.setRegistrant(loginMember.getId()); abdao.insert(abook); registTelephone(abook); registAddress(abook); registEmailAddress(abook); return result; } public BaseResult update(Member loginMember, AddressBook abook) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } abdao.update(abook); registTelephone(abook); registAddress(abook); registEmailAddress(abook); return result; } public BaseResult delete(Member loginMember, AddressBook abook) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } abdao.delete(abook); return result; } public BaseResult addCategory(Member loginMember, String catname) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } AddressCategory cat = new AddressCategory(); cat.setId(DAOSequence.getNextId(AddressCategory.UNIQ_KEYNAME)); cat.setRegistrant(loginMember.getId()); cat.setName(catname); abcatdao.insert(cat); return result; } public BaseResult updateCategory(Member loginMember, AddressCategory cat) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } abcatdao.update(cat); return result; } public BaseResult deleteCategory(Member loginMember, AddressCategory cat) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } abcatdao.delete(cat); AddressBook[] delAb = (AddressBook[]) list(loginMember, cat.getId()).getResult(); for (int i = 0; i < delAb.length; i++) { delete(loginMember, delAb[i]); } return result; } public BaseResult listCategory(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(abcatdao.list(loginMember.getId())); return result; } public BaseResult getById(Member loginMember, int id) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(abdao.getAddressBook(loginMember.getId(), id)); return result; } public BaseResult list(Member loginMember, int catid) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(abdao.list(loginMember.getId(), catid)); return result; } public BaseResult listTelephone(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(teldao.list(loginMember.getId())); return result; } public BaseResult listAddress(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(addrdao.list(loginMember.getId())); return result; } public BaseResult listEmailAddress(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(emaildao.list(loginMember.getId())); return result; } } src/com/kickmogu/rhythm/board/Board.java100644 0 0 7426 10710110423 15655 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/18 * */ package com.kickmogu.rhythm.board; import java.util.*; public class Board { public static final String insert_NO_PERSISTENT_PROPS = "registrantName"; public final static String PERM_ALL = "BOARD_ALL"; public final static String PERM_VIEW = "BOARD_VIEW"; public final static String PERM_WRITE = "BOARD_WRITE"; public final static String PERM_MANAGE = "BOARD_MANAGE"; public final static String UNIQ_KEYNAME = "rhtym board id"; private int id; private int registrant; private Date registDate; private int seq; private int depth; private int rootId; private int rootSeq; private String subject; private String body; // 発言しているカテゴリのID private int boardTreeId; private String registrantName; /** * @return body を戻します。 */ public String getBody() { return body; } /** * @param body body を設定。 */ public void setBody(String body) { this.body = body; } /** * @return depth を戻します。 */ public int getDepth() { return depth; } /** * @param depth depth を設定。 */ public void setDepth(int depth) { this.depth = depth; } /** * @return registDate を戻します。 */ public Date getRegistDate() { return registDate; } /** * @param registDate registDate を設定。 */ public void setRegistDate(Date registDate) { this.registDate = registDate; } /** * @return registrant を戻します。 */ public int getRegistrant() { return registrant; } /** * @param registrant registrant を設定。 */ public void setRegistrant(int registrant) { this.registrant = registrant; } /** * @return rootId を戻します。 */ public int getRootId() { return rootId; } /** * @param rootId rootId を設定。 */ public void setRootId(int rootId) { this.rootId = rootId; } /** * @return rootSeq を戻します。 */ public int getRootSeq() { return rootSeq; } /** * @param rootSeq rootSeq を設定。 */ public void setRootSeq(int rootSeq) { this.rootSeq = rootSeq; } /** * @return seq を戻します。 */ public int getSeq() { return seq; } /** * @param seq seq を設定。 */ public void setSeq(int seq) { this.seq = seq; } /** * @return subject を戻します。 */ public String getSubject() { return subject; } /** * @param subject subject を設定。 */ public void setSubject(String subject) { this.subject = subject; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return boardTreeId を戻します。 */ public int getBoardTreeId() { return boardTreeId; } /** * @param boardTreeId boardTreeId を設定。 */ public void setBoardTreeId(int boardTreeId) { this.boardTreeId = boardTreeId; } /** * @return registrantName を戻します。 */ public String getRegistrantName() { return registrantName; } /** * @param registrantName registrantName を設定。 */ public void setRegistrantName(String registrantName) { this.registrantName = registrantName; } } src/com/kickmogu/rhythm/board/BoardTree.java100644 0 0 1575 10710110423 16474 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/05 * */ package com.kickmogu.rhythm.board; import com.kickmogu.rhythm.core.PermissionTarget; public class BoardTree extends PermissionTarget { public final static String UNIQ_KEYNAME = "rhtym boardtree id"; } src/com/kickmogu/rhythm/board/dao/BoardDao.java100644 0 0 3436 10710110423 17041 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.board.dao; import com.kickmogu.rhythm.board.*; /** * @author mogu */ public interface BoardDao { public Class BEAN = Board.class; public static final String BasicSql = "select Board.*, Member.name as registrantName from Board, Member where "; public static final String JoinSql = " and Board.registrant = Member.id"; public static final String listRootBoards_SQL = BasicSql + " depth = 0 and boardTreeId = ? " + JoinSql + " order by rootId desc, seq"; public static final String listBoardThreads_SQL = BasicSql + " rootId = ? " + JoinSql + " order by seq"; public static final String getBoard_SQL = BasicSql + "Board.id = ?" + JoinSql; public int update(Board board); public int insert(Board board); public int delete(Board board); public Board getBoard(int id); public Board[] listRootBoards(int categoryId); public Board[] listBoardThreads(int rootId); } src/com/kickmogu/rhythm/board/test/BoardTest.java100644 0 0 3235 10710110423 17466 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/11 * */ package com.kickmogu.rhythm.board.test; import com.kickmogu.rhythm.board.ws.BoardWs; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.core.ws.MemberWs; import jp.co.dgic.testing.framework.DJUnitTestCase; public class BoardTest extends DJUnitTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void test001() throws Exception { BoardWs boardWs = new BoardWs(); MemberWs memWs = new MemberWs(); Member member = (Member) memWs.authorize("mogu", "hfc01415").getResult(); BaseResult result = boardWs.listBoardThreads(member, 1); System.out.println("result:" + result.getResult()); } public void test002() throws Exception { BoardWs boardWs = new BoardWs(); MemberWs memWs = new MemberWs(); Member member = (Member) memWs.authorize("mogu", "hfc01415").getResult(); boardWs.reply(member, 1, "test reply", "reply body"); } } src/com/kickmogu/rhythm/board/ws/BoardWs.java100644 0 0 15461 10710110423 16636 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/18 * */ package com.kickmogu.rhythm.board.ws; import java.util.Date; import java.sql.*; import org.apache.log4j.Category; import com.kickmogu.rhythm.board.*; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.board.dao.BoardDao; import com.kickmogu.s2.DAOSequence; import com.kickmogu.s2.S2Util; public class BoardWs { BoardDao boarddao = (BoardDao) S2Util.getS2Container().getComponent(BoardDao.class); static Category log = Category.getInstance(BoardWs.class.getName()); public BaseResult addNode(Member loginMember, String name, int parentId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } BoardTree boardtree = new BoardTree(); boardtree.setId(DAOSequence.getNextId(BoardTree.UNIQ_KEYNAME)); boardtree.setName(name); BoardTree parent = (BoardTree) RhythmTreeManager.getRoot(BoardTree.class).search(parentId); if (parent == null) { result.setStatusCode(100); return result; } boardtree.addToParent(parent); RhythmTreeManager.write(BoardTree.class); result.setResult(boardtree.getId()); return result; } public BaseResult removeNode(Member loginMember, int targetId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } BoardTree boardTree = (BoardTree) RhythmTreeManager.getRoot(BoardTree.class).search(targetId); boardTree.remove(); RhythmTreeManager.write(BoardTree.class); result.setResult(boardTree.getId()); return result; } public BaseResult updateNode(Member loginMember, int targetId, String newName) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } BoardTree boardTree = (BoardTree) RhythmTreeManager.getRoot(BoardTree.class).search(targetId); boardTree.setName(newName); RhythmTreeManager.write(BoardTree.class); result.setResult(boardTree.getId()); return result; } public BaseResult post(Member loginMember, int categoryId, String subject, String body) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Board board = new Board(); board.setId(DAOSequence.getNextId(Board.UNIQ_KEYNAME)); board.setRegistrant(loginMember.getId()); board.setRootId(board.getId()); board.setSubject(subject); board.setBody(body); board.setBoardTreeId(categoryId); board.setRegistDate(new Date()); boarddao.insert(board); result.setResult(board); return result; } public BaseResult reply(Member loginMember, int parentId, String subject, String body) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Board parentBoard = boarddao.getBoard(parentId); int newSeq = getChildMaxSeq(parentBoard.getRootId(), parentBoard.getSeq(), parentBoard.getDepth()) + 1; updateThreadSeq(parentBoard.getRootId(), newSeq); Board board = new Board(); board.setId(DAOSequence.getNextId(Board.UNIQ_KEYNAME)); board.setRegistrant(loginMember.getId()); board.setRootId(parentBoard.getRootId()); board.setSubject(subject); board.setBody(body); board.setSeq(newSeq); board.setDepth(parentBoard.getDepth() + 1); board.setBoardTreeId(parentBoard.getBoardTreeId()); board.setRegistDate(new Date()); boarddao.insert(board); result.setResult(board); return result; } public BaseResult listRootBoards(Member loginMember, int categoryId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(boarddao.listRootBoards(categoryId)); return result; } public BaseResult getBoard(Member loginMember, int boardId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(boarddao.getBoard(boardId)); return result; } private int getChildMaxSeq(int rootId, int seq, int depth) throws Exception { int maxSeq = seq; Connection conn = S2Util.getConnection(); PreparedStatement ps = conn.prepareStatement("select seq, depth from board where rootId = ? and seq > ? order by seq"); try { ps.setInt(1, rootId); ps.setInt(2, seq); ResultSet rs = ps.executeQuery(); while (rs.next()) { if (depth >= rs.getInt("depth")) { break; } maxSeq = rs.getInt("seq"); } } finally { ps.close(); conn.close(); } return maxSeq; } private void updateThreadSeq(int rootId, int seq) throws Exception { Connection conn = S2Util.getConnection(); PreparedStatement ps = conn.prepareStatement("update board set seq = seq + 1 where rootId = ? and seq >= ?"); try { ps.setInt(1, rootId); ps.setInt(2, seq); ps.execute(); } finally { ps.close(); conn.close(); } } private String toBoardXmlTag(Board board) { return ""; } /** * 特定のThreadの親子関係を含めたXML形式文字列を返す * @param loginMember * @param rootId * @return */ public BaseResult listBoardThreads(Member loginMember, int rootId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Board[] threads = boarddao.listBoardThreads(rootId); StringBuffer out = new StringBuffer(); int beforeDepth = -1; for (int i = 0; i < threads.length; i++) { if (beforeDepth < threads[i].getDepth()) { for (int j = 0; j < threads[i].getDepth() - beforeDepth; j++) { out.append(toBoardXmlTag(threads[i]) + "\n"); } } else { for (int j = 0; j < beforeDepth - threads[i].getDepth() + 1; j++) { out.append("\n"); } out.append(toBoardXmlTag(threads[i]) + "\n"); } beforeDepth = threads[i].getDepth(); } for (int j = 0; j < beforeDepth + 1; j++) { out.append("\n"); } result.setResult(out.toString()); return result; } public void wsdldummy(Board board) { } } src/com/kickmogu/rhythm/core/Address.java100644 0 0 4674 10710110423 16056 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/05 * */ package com.kickmogu.rhythm.core; public class Address { public final static String UNIQ_KEYNAME = "rhtym address id"; public final static int KIND_HOME = 1; public final static int KIND_OFFICE = 2; private int id; private int kind; private String zip; private int prefecture; private String city; private String address; private String comment; /** * @return address を戻します。 */ public String getAddress() { return address; } /** * @param address address を設定。 */ public void setAddress(String address) { this.address = address; } /** * @return city を戻します。 */ public String getCity() { return city; } /** * @param city city を設定。 */ public void setCity(String city) { this.city = city; } /** * @return comment を戻します。 */ public String getComment() { return comment; } /** * @param comment comment を設定。 */ public void setComment(String comment) { this.comment = comment; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return kind を戻します。 */ public int getKind() { return kind; } /** * @param kind kind を設定。 */ public void setKind(int kind) { this.kind = kind; } /** * @return prefecture を戻します。 */ public int getPrefecture() { return prefecture; } /** * @param prefecture prefecture を設定。 */ public void setPrefecture(int prefecture) { this.prefecture = prefecture; } /** * @return zip を戻します。 */ public String getZip() { return zip; } /** * @param zip zip を設定。 */ public void setZip(String zip) { this.zip = zip; } } src/com/kickmogu/rhythm/core/AssignPermission.java100644 0 0 4072 10710110423 17756 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core; public class AssignPermission { public final static String UNIQ_KEYNAME = "rhtym AssignPermission id"; private int id; private int permissionId; private int targetId; public boolean equals(Object ap) { if (! (ap instanceof AssignPermission)) { return false; } return id == ((AssignPermission) ap).id; } /** * @return permission を戻します。 */ public Permission getPermission() { return (Permission) RhythmTreeManager.getRoot(Permission.class).search(permissionId); } /** * @return target を戻します。 */ public PermissionTarget getTarget() { Class targetClass = null; try { targetClass = Class.forName(getPermission().getClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } return (PermissionTarget) RhythmTreeManager.getRoot(targetClass).search(targetId); } public AssignPermission(int id) { this.id = id; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } public int getPermissionId() { return permissionId; } public void setPermissionId(int permissionId) { this.permissionId = permissionId; } public int getTargetId() { return targetId; } public void setTargetId(int targetId) { this.targetId = targetId; } } src/com/kickmogu/rhythm/core/BaseBean.java100644 0 0 5146 10710110423 16124 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/23 * */ package com.kickmogu.rhythm.core; import java.util.Date; public class BaseBean { public static final String insert_NO_PERSISTENT_PROPS = "registrantName"; private int id; private int deleted; private Date registDate; private Date updateDate; private int registrant; private String registrantName; /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } public boolean equals(Object tree) { if (! (tree instanceof BaseBean)) { return false; } return id == ((BaseBean) tree).id; } public BaseBean() { } public BaseBean(int id) { this.id = id; } /** * @return deleted を戻します。 */ public int getDeleted() { return deleted; } /** * @param deleted deleted を設定。 */ public void setDeleted(int deleted) { this.deleted = deleted; } /** * @return registDate を戻します。 */ public Date getRegistDate() { return registDate; } /** * @param registDate registDate を設定。 */ public void setRegistDate(Date registDate) { this.registDate = registDate; } /** * @return registrant を戻します。 */ public int getRegistrant() { return registrant; } /** * @param registrant registrant を設定。 */ public void setRegistrant(int registrant) { this.registrant = registrant; } /** * @return registrantName を戻します。 */ public String getRegistrantName() { return registrantName; } /** * @param registrantName registrantName を設定。 */ public void setRegistrantName(String registrantName) { this.registrantName = registrantName; } /** * @return updateDate を戻します。 */ public Date getUpdateDate() { return updateDate; } /** * @param updateDate updateDate を設定。 */ public void setUpdateDate(Date updateDate) { this.updateDate = updateDate; } } src/com/kickmogu/rhythm/core/BaseResult.java100644 0 0 3111 10710110424 16524 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/13 * */ package com.kickmogu.rhythm.core; public class BaseResult { private int statusCode = 0; private String statusMessage = ""; // 呼び出し側に戻す何らかの値 private Object result; /** * @return result を戻します。 */ public Object getResult() { return result; } /** * @param result result を設定。 */ public void setResult(Object result) { this.result = result; } /** * @return statusCode を戻します。 */ public int getStatusCode() { return statusCode; } /** * @param statusCode statusCode を設定。 */ public void setStatusCode(int statusCode) { this.statusCode = statusCode; } /** * @return statusMessage を戻します。 */ public String getStatusMessage() { return statusMessage; } /** * @param statusMessage statusMessage を設定。 */ public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } } src/com/kickmogu/rhythm/core/EmailAddress.java100644 0 0 3002 10710110424 17007 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/05 * */ package com.kickmogu.rhythm.core; public class EmailAddress { public final static String UNIQ_KEYNAME = "rhtym emailaddress id"; public final static int KIND_NORMAL = 1; public final static int KIND_MOBILE = 2; private int id; private int kind; private String email; /** * @return email を戻します。 */ public String getEmail() { return email; } /** * @param email email を設定。 */ public void setEmail(String email) { this.email = email; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return kind を戻します。 */ public int getKind() { return kind; } /** * @param kind kind を設定。 */ public void setKind(int kind) { this.kind = kind; } } src/com/kickmogu/rhythm/core/HttpCmdAction.java100644 0 0 1531 10710110424 17160 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/15 * */ package com.kickmogu.rhythm.core; import java.util.Map; public interface HttpCmdAction { public BaseResult doAction(Map params) throws Exception ; } src/com/kickmogu/rhythm/core/HttpCmdDispatcher.java100644 0 0 5433 10710110424 20036 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/15 * */ package com.kickmogu.rhythm.core; import java.lang.reflect.Constructor; import com.kickmogu.StopWatch; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.*; import java.io.*; import org.apache.log4j.Category; public class HttpCmdDispatcher extends HttpServlet { static Category log = Category.getInstance(HttpCmdDispatcher.class.getName()); private BaseResult doService(HttpServletRequest req, HttpServletResponse resp) throws Exception { BaseResult result = new BaseResult(); if (!SessionManager.isValidSession(req.getParameter("sessionId"), Integer.parseInt(req.getParameter("memberId")))) { result.setStatusCode(10); return result; } Class actionClass = Class.forName(req.getParameter("className")); Constructor actionConst = actionClass.getConstructor(new Class[] {}); Map params = req.getParameterMap(); HttpCmdAction action = (HttpCmdAction) actionConst.newInstance(new Object[] {}); StopWatch stpWtch = new StopWatch(); result = action.doAction(params); log.info(req.getParameter("className") + " call time:" + stpWtch.getPastTime()); if (result.getStatusCode() != 0) { return result; } PrintWriter out = new PrintWriter(new OutputStreamWriter(resp.getOutputStream(), "UTF8")); out.println("0"); out.print(result.getResult().toString()); out.close(); return result; } protected void service(HttpServletRequest req, HttpServletResponse resp) { try { resp.setHeader("Cache-Control", "max-age=0, must-revalidate"); req.setCharacterEncoding("UTF8"); BaseResult result = doService(req, resp); if (result.getStatusCode() != 0) { PrintWriter out = new PrintWriter(new OutputStreamWriter(resp.getOutputStream(), "UTF8")); out.print(result.getStatusCode() + "\t" + result.getStatusMessage()); out.close(); } } catch (Exception ex) { log.error(ex); resp.setStatus(503); try { ex.printStackTrace(new PrintWriter(resp.getWriter())); } catch (IOException iex) { log.error(iex); } } } } src/com/kickmogu/rhythm/core/LoginSession.java100644 0 0 2330 10710110424 17071 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/13 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core; import java.util.*; public class LoginSession { private int memberId; private Date registDate; public int getMemberId() { return memberId; } public void setMemberId(int memberId) { this.memberId = memberId; } public Date getRegistDate() { return registDate; } public void setRegistDate(Date registDate) { this.registDate = registDate; } } src/com/kickmogu/rhythm/core/MailSetting.java100644 0 0 11116 10710110424 16717 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/28 * */ package com.kickmogu.rhythm.core; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Category; import com.kickmogu.Config; public class MailSetting { static Category log = Category.getInstance(MailSetting.class.getName()); public final static String UNIQ_KEYNAME = "rhythm " + MailSetting.class.getName() + " id"; private int id; private int memberId; private String name; // 設定名称 private String senderName; private String imapLoginid; private String imapHost; private String imapPassword; private String smtpHost; private String email; private String mailSendedFolder = "Sent"; private String mailFooter; /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return imapHost を戻します。 */ public String getImapHost() { if (!StringUtils.isEmpty(Config.getProperty("demo.mailsetting.imap_host"))) { return Config.getProperty("demo.mailsetting.imap_host"); } return imapHost; } /** * @param imapHost imapHost を設定。 */ public void setImapHost(String imapHost) { this.imapHost = imapHost; } /** * @return imapLoginid を戻します。 */ public String getImapLoginid() { if (!StringUtils.isEmpty(Config.getProperty("demo.mailsetting.imap_user"))) { return Config.getProperty("demo.mailsetting.imap_user"); } return imapLoginid; } /** * @param imapLoginid imapLoginid を設定。 */ public void setImapLoginid(String imapLoginid) { this.imapLoginid = imapLoginid; } /** * @return impaPassword を戻します。 */ public String getImapPassword() { if (!StringUtils.isEmpty(Config.getProperty("demo.mailsetting.imap_password"))) { return Config.getProperty("demo.mailsetting.imap_password"); } return imapPassword; } /** * @param impaPassword impaPassword を設定。 */ public void setImapPassword(String impaPassword) { this.imapPassword = impaPassword; } /** * @return smtpHost を戻します。 */ public String getSmtpHost() { if (!StringUtils.isEmpty(Config.getProperty("demo.mailsetting.smtp_host"))) { return Config.getProperty("demo.mailsetting.smtp_host"); } return smtpHost; } /** * @param smtpHost smtpHost を設定。 */ public void setSmtpHost(String smtpHost) { this.smtpHost = smtpHost; } /** * @return email を戻します。 */ public String getEmail() { if (!StringUtils.isEmpty(Config.getProperty("demo.mailsetting.email"))) { return Config.getProperty("demo.mailsetting.email"); } return email; } /** * @param email email を設定。 */ public void setEmail(String email) { this.email = email; } /** * @return mailSendedFolder を戻します。 */ public String getMailSendedFolder() { return mailSendedFolder; } /** * @param mailSendedFolder mailSendedFolder を設定。 */ public void setMailSendedFolder(String mailSendedFolder) { this.mailSendedFolder = mailSendedFolder; } /** * @return mailFooter を戻します。 */ public String getMailFooter() { return mailFooter; } /** * @param mailFooter mailFooter を設定。 */ public void setMailFooter(String mailFooter) { this.mailFooter = mailFooter; } /** * @return member_id を戻します。 */ public int getMemberId() { return memberId; } /** * @param member_id member_id を設定。 */ public void setMemberId(int member_id) { this.memberId = member_id; } /** * @return sendname を戻します。 */ public String getSenderName() { return senderName; } /** * @param sendname sendname を設定。 */ public void setSenderName(String sendname) { this.senderName = sendname; } /** * @return name を戻します。 */ public String getName() { return name; } /** * @param name name を設定。 */ public void setName(String name) { this.name = name; } } src/com/kickmogu/rhythm/core/Member.java100644 0 0 12132 10710110424 15705 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/28 * */ package com.kickmogu.rhythm.core; import java.util.*; import com.kickmogu.Config; import com.kickmogu.rhythm.core.dao.*; import com.kickmogu.s2.S2Util; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Category; public class Member { static Category log = Category.getInstance(Member.class.getName()); public final static String UNIQ_KEYNAME = "rhtym member id"; private int id; private String loginid; private String name; private String passwd; private String sessionId; private int payHour; // 交通費 private int trafficExpenses; /* 交通費種別 * 0 ・・・ 日割 * 1 ・・・ 月額固定 */ private int trafficExpensesKind; private int restMinutes; public boolean isLogined(BaseResult result) { if (!SessionManager.isValidSession(getSessionId(), getId())) { result.setStatusCode(10); return false; } return true; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return logindid を戻します。 */ public String getLoginid() { return loginid; } /** * @param logindid logindid を設定。 */ public void setLoginid(String logindid) { this.loginid = logindid; } /** * @return name を戻します。 */ public String getName() { return name; } /** * @param name name を設定。 */ public void setName(String name) { this.name = name; } /** * @return password を戻します。 */ public String getPasswd() { if (!StringUtils.isEmpty(Config.getProperty("demo.member.password"))) { return Config.getProperty("demo.member.password"); } return passwd; } /** * @param password password を設定。 */ public void setPasswd(String password) { this.passwd = password; } /** * @return payHour を戻します。 */ public int getPayHour() { return payHour; } /** * @param payHour payHour を設定。 */ public void setPayHour(int payHour) { this.payHour = payHour; } /** * @return restMinutes を戻します。 */ public int getRestMinutes() { return restMinutes; } /** * @param restMinutes restMinutes を設定。 */ public void setRestMinutes(int restMinutes) { this.restMinutes = restMinutes; } /** * @return trafficExpenses を戻します。 */ public int getTrafficExpenses() { return trafficExpenses; } /** * @param trafficExpenses trafficExpenses を設定。 */ public void setTrafficExpenses(int trafficExpenses) { this.trafficExpenses = trafficExpenses; } /** * 指定されて権限があるかチェックする * @param permCode 権限名 * @return 権限があればTrue * @throws Exception */ public boolean hasPermission(String permCode) throws Exception { return true; } /** * 自分が持っている権限の中で指定されてPermissionCode持つPermissionTargetを返す * @param permCode * @return * @throws Exception */ public List getAssignTarget(String permCode) throws Exception { List roles = getBelongRoles(); List results = new ArrayList(); for (int i = 0; i < roles.size(); i++) { results.addAll(roles.get(i).getAssignTarget(permCode)); } return results; } /** * 自分が所属しているRoleのIDを返す * @return */ public List getBelongRoles() { RoleMemberDao roleMemberDao = (RoleMemberDao) S2Util.getS2Container().getComponent(RoleMemberDao.class); List roleMembers = roleMemberDao.getByMemberId(getId()); List results = new ArrayList(); for (int i = 0; i < roleMembers.size(); i++) { RhythmTree role = (Role) RhythmTreeManager.getRoot(Role.class).search(roleMembers.get(i).getRoleId()); // Roleが削除されていなければ取得 if (role != null) { results.addAll(role.getAll()); } } return (List) results; } /** * @return trafficExpensesKind を戻します。 */ public int getTrafficExpensesKind() { return trafficExpensesKind; } /** * @param trafficExpensesKind trafficExpensesKind を設定。 */ public void setTrafficExpensesKind(int trafficExpensesKind) { this.trafficExpensesKind = trafficExpensesKind; } /** * @return sessionId を戻します。 */ public String getSessionId() { return sessionId; } /** * @param sessionId sessionId を設定。 */ public void setSessionId(String sessionId) { this.sessionId = sessionId; } } src/com/kickmogu/rhythm/core/Permission.java100644 0 0 10072 10710110424 16627 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/11/24 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core; import org.apache.log4j.Category; public class Permission extends RhythmTree { static Category log = Category.getInstance(Permission.class.getName()); public final static String ROLE_ALL = "ROLE_ALL"; public final static String USER_MANAGE = "USER_MANAGE"; public final static String ROLE_MANAGE = "ROLE_MANAGE"; public final static String USER_VIEW = "USER_VIEW"; public final static String PERMISSION_ALL = "PERMISSION_ALL"; String code; String className; public String getCode() { return code; } public void setCode(String code) { this.code = code; } protected String getXmlOpenTag() { return "<" + this.getClass().getName().replace(".", "_") + " id=\"" + getId() + "\"" + " code=\"" + getCode() + "\"" + " className=\"" + getClassName() + "\"" + " name=\"" + getName() + "\">\n"; } /** * Tree全体から条件のIDを持つインスタンスを探す * @param condId * @return */ public static Permission searchByCode(String condCode) { return ((Permission) RhythmTreeManager.getRoot(Permission.class)).searchByCodeImpl(condCode); } /** * 指定されたPermissionCodeがThisインスタンスの枝も含めたツリーに属しているかチェックする * @param permCode * @return true ・・・ 指定されたPermissionCodeが含まれている */ public boolean isIncludePermission(String permCode) { Permission perm = searchByCode(permCode); if (perm == null) { log.error("permission code not found:" + permCode); return false; } return search(perm.getId()) != null; } public Permission searchByCodeImpl(String condCode) { if (getCode().equals(condCode)) { return this; } for (int i = 0; i < getChildren().size(); i++) { Permission result = ((Permission) getChildren().get(i)).searchByCodeImpl(condCode); if (result != null) { return result; } } return null; } /** * @return className を戻します。 */ public String getClassName() { return className; } /** * @param className className を設定。 */ public void setClassName(String className) { this.className = className; } /** * 初期データ作成 */ public static void main(String[] arg) throws Exception { Permission rootPerm = new Permission(); rootPerm.setName("全ての権限"); rootPerm.setCode(PERMISSION_ALL); Permission rolePerm = new Permission(); rolePerm.setName("ユーザグルール管理"); rolePerm.setCode(ROLE_ALL); rootPerm.addToChild(rolePerm); rolePerm.setClassName(Role.class.getName()); Permission roleChildPerm = new Permission(); roleChildPerm.setName("ユーザ参照"); roleChildPerm.setCode(USER_VIEW); roleChildPerm.setClassName(Role.class.getName()); rolePerm.addToChild(roleChildPerm); roleChildPerm = new Permission(); roleChildPerm.setName("ユーザグループ管理"); roleChildPerm.setCode(ROLE_MANAGE); roleChildPerm.setClassName(Role.class.getName()); rolePerm.addToChild(roleChildPerm); roleChildPerm = new Permission(); roleChildPerm.setName("ユーザ管理"); roleChildPerm.setCode(USER_MANAGE); roleChildPerm.setClassName(Role.class.getName()); rolePerm.addToChild(roleChildPerm); RhythmTreeManager.setRoot(rootPerm); RhythmTreeManager.write(Permission.class); } } src/com/kickmogu/rhythm/core/PermissionTarget.java100644 0 0 2021 10710110424 17751 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/18 * */ package com.kickmogu.rhythm.core; public class PermissionTarget extends RhythmTree { private String treeKind; /** * @return treeKind を戻します。 */ public String getTreeKind() { return treeKind; } /** * @param treeKind treeKind を設定。 */ public void setTreeKind(String treeKind) { this.treeKind = treeKind; } } src/com/kickmogu/rhythm/core/RhythmTree.java100644 0 0 11667 10710110424 16605 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/11/24 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core; import java.util.*; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Category; import com.kickmogu.s2.DAOSequence; public class RhythmTree { public final static String UNIQ_KEYNAME = "rhtym RhythmTree id"; static Category log = Category.getInstance(RhythmTree.class.getName()); private int id = -1; private String name; private RhythmTree parent = null; private List children = new ArrayList(); /** * Treeから条件のIDを持つインスタンスを探す * @param condId * @return */ public RhythmTree search(int condId) { if (getId() == condId) { return this; } for (int i = 0; i < children.size(); i++) { RhythmTree result = children.get(i).search(condId); if (result != null) { return result; } } return null; } public boolean equals(Object tree) { if (! (tree instanceof RhythmTree)) { return false; } return id == ((RhythmTree) tree).id; } public void addToParent(RhythmTree parent) { setId(DAOSequence.getNextId(RhythmTree.UNIQ_KEYNAME)); this.parent = parent; this.parent.children.add(this); } public void addToChild(RhythmTree child) { child.setId(DAOSequence.getNextId(RhythmTree.UNIQ_KEYNAME)); child.setParent(this); children.add(child); } public void remove() { if (parent == null) { return; } parent.children.remove(this); } public void removeChild(RhythmTree child) { children.remove(child); } public void changeParent(RhythmTree newRoot) { if (parent != null) { parent.removeChild(this); } addToParent(newRoot); } /** * 兄弟間の順序を変更する * @param newSeq */ public void moveSeq(int newSeq) { if (parent == null) { return; } remove(); parent.children.add(newSeq, this); } protected String getXmlOpenTag() { return "<" + this.getClass().getName().replace(".", "_") + " id=\"" + getId() + "\"" + " name=\"" + getName() + "\">\n"; } protected String getXmlCloseTag() { return "\n"; } /** * @return XML表記の返却 */ public String toXmlAll() { StringBuffer out = new StringBuffer(); int level = getLevel(); out.append(StringUtils.repeat(" ", level - 1)); out.append(getXmlOpenTag()); for (int i = 0; i < children.size(); i++) { out.append(children.get(i).toXmlAll()); } out.append(StringUtils.repeat(" ", level - 1) + getXmlCloseTag()); return out.toString(); } /** * @return ツリー構造のデバッグ表示 */ public String toString() { StringBuffer out = new StringBuffer(); int level = getLevel(); out.append(StringUtils.repeat("\t", level - 1)); out.append(getName() + "\n"); for (int i = 0; i < children.size(); i++) { out.append(children.get(i).toString()); } return out.toString(); } public List getAll() { List results = new ArrayList(); results.add(this); for (int i = 0; i < children.size(); i++) { results.addAll(children.get(i).getAll()); } return results; } /* * レベルを返す(最上位の親がレベル1、以下子供になるごとにレベルが * 1下がる) */ public int getLevel() { return parent == null ? 1 : parent.getLevel() + 1; } /** * @return children を戻します。 */ public List getChildren() { return children; } /** * @param children children を設定。 */ public void setChildren(List children) { this.children = children; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return name を戻します。 */ public String getName() { return name; } /** * @param name name を設定。 */ public void setName(String name) { this.name = name; } /** * @return parent を戻します。 */ public RhythmTree getParent() { return parent; } /** * @param parent parent を設定。 */ public void setParent(RhythmTree parent) { this.parent = parent; } } src/com/kickmogu/rhythm/core/RhythmTreeManager.java100644 0 0 4212 10710110424 20044 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/20 * */ package com.kickmogu.rhythm.core; import java.io.*; import java.util.*; import org.apache.log4j.Category; import com.kickmogu.Config; import com.thoughtworks.xstream.XStream; public class RhythmTreeManager { static Category log = Category.getInstance(RhythmTreeManager.class.getName()); private static Map roots = new HashMap(); static private String getXmlFilename(String prefix) { return Config.getProperty(prefix + ".path.xml"); } public static void refresh(Class targetClass) throws FileNotFoundException { Reader reader = new FileReader(getXmlFilename(targetClass.getCanonicalName())); XStream xstream = new XStream(); RhythmTree root = (RhythmTree) xstream.fromXML(reader); setRoot(root); } public static RhythmTree getRoot(Class targetClass) { System.out.println("getRoot class" + targetClass.getName()); if (roots.get(targetClass) == null) { try { refresh(targetClass); } catch (FileNotFoundException e) { log.error(e); } } return (RhythmTree) roots.get(targetClass); } public static void setRoot(RhythmTree r) { System.out.println("setRoot class" + r.getClass().getName()); roots.put(r.getClass(), r); } public static void write(Class targetClass) throws IOException { Writer writer = new FileWriter(getXmlFilename(targetClass.getCanonicalName())); XStream xstream = new XStream(); xstream.toXML(getRoot(targetClass), writer); } } src/com/kickmogu/rhythm/core/Role.java100644 0 0 13562 10710110424 15407 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core; import com.kickmogu.s2.DAOSequence; import java.util.*; import org.apache.commons.lang.StringUtils; public class Role extends PermissionTarget { private List assisnPermissions = new ArrayList(); /** * 権限の追加 * @param permCode * @param targetId */ public AssignPermission assignPermission(String permCode, int targetId) throws ClassNotFoundException { Permission perm = Permission.searchByCode(permCode); Class rTreeClass = Class.forName(perm.getClassName()); PermissionTarget target = (PermissionTarget) RhythmTreeManager.getRoot(rTreeClass).search(targetId); AssignPermission ap = new AssignPermission(DAOSequence.getNextId(AssignPermission.UNIQ_KEYNAME)); ap.setPermissionId(perm.getId()); ap.setTargetId(target.getId()); assisnPermissions.add(ap); return ap; } private boolean isIncludePermissionTarget(PermissionTarget newTarget, List results) { for (int i = 0; i < results.size(); i++) { if (results.get(i).search(newTarget.getId()) != null) { return true; } } return false; } /** * このRole配下で指定されたPermissionCodeをもつPermissionTargetを返す。 * @param permCode * @return * @throws Exception */ public List getAssignTarget(String permCode) throws Exception { List results = new ArrayList(); for (int i = 0; i < assisnPermissions.size(); i++) { if (assisnPermissions.get(i).getPermission().isIncludePermission(permCode)) { PermissionTarget src = assisnPermissions.get(i).getTarget(); PermissionTarget target = (PermissionTarget) RhythmTreeManager.getRoot(src.getClass()).search(src.getId()); results.add(target); } } for (int i = 0; i < getChildren().size(); i++) { List childResults = ((Role) getChildren().get(i)).getAssignTarget(permCode); for (int j = 0; j < childResults.size(); j++) { if (!isIncludePermissionTarget(childResults.get(i), results)) { PermissionTarget target = (PermissionTarget) RhythmTreeManager.getRoot(childResults.get(i).getClass()).search(childResults.get(i).getId()); results.add(target); } } } return results; } public void removePermission(int id) { assisnPermissions.remove(new AssignPermission(id)); } public void updatePermission(int id, String permCode, int targetId) throws ClassNotFoundException { AssignPermission newAp = new AssignPermission(id); int idx = assisnPermissions.indexOf(newAp); if (idx == -1) { log.error("update AssignPermission not found:" + id + "," + permCode + "," + targetId); return; } Permission perm = Permission.searchByCode(permCode); Class rTreeClass = Class.forName(perm.getClassName()); PermissionTarget target = (PermissionTarget) RhythmTreeManager.getRoot(rTreeClass).search(targetId); newAp.setPermissionId(perm.getId()); newAp.setTargetId(target.getId()); assisnPermissions.set(idx, newAp); } /** * @return XML表記の返却 */ public String toXmlAllWithPermission() { StringBuffer out = new StringBuffer(); int level = getLevel(); out.append(StringUtils.repeat(" ", level - 1)); out.append(getXmlOpenTagWithPermission()); for (int i = 0; i < getChildren().size(); i++) { out.append(((Role) getChildren().get(i)).toXmlAllWithPermission()); } out.append(StringUtils.repeat(" ", level - 1) + getXmlCloseTag()); return out.toString(); } protected String getXmlOpenTagWithPermission() { StringBuffer out = new StringBuffer(); out.append(getXmlOpenTag()); for (int i = 0; i < assisnPermissions.size(); i++) { out.append(StringUtils.repeat(" ", getLevel() - 2) + " "); out.append(""); out.append("\n"); } return out.toString(); } public String toString() { StringBuffer out = new StringBuffer(); out.append(super.toString()); for (int i = 0; i < assisnPermissions.size(); i++) { out.append(StringUtils.repeat("\t", getLevel() - 1)); out.append(i < assisnPermissions.size() - 1 ? "├" : "└"); out.append(assisnPermissions.get(i).getPermission().getCode() + "->" + assisnPermissions.get(i).getTarget().getName()); out.append("\n"); } return out.toString(); } public static void main(String[] arg) throws Exception { Role rootRole = new Role(); rootRole.setName("全てのユーザ"); RhythmTreeManager.setRoot(rootRole); RhythmTreeManager.write(Role.class); } public List getAssisnPermissions() { return assisnPermissions; } public void setAssisnPermissions(List assisnPermissions) { this.assisnPermissions = assisnPermissions; } } src/com/kickmogu/rhythm/core/RoleMember.java100644 0 0 2656 10710110424 16521 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ package com.kickmogu.rhythm.core; /** * @version 1.0 * @created 23-8-2005 15:42:52 */ public class RoleMember { private int roleId; private int memberId; public RoleMember() { } public RoleMember(int roleId, int memberId) { this.roleId = roleId; this.memberId = memberId; } public void create(){ } public void delete(){ } /** * @return memberId を戻します。 */ public int getMemberId() { return memberId; } /** * @param memberId memberId を設定。 */ public void setMemberId(int memberId) { this.memberId = memberId; } /** * @return roleId を戻します。 */ public int getRoleId() { return roleId; } /** * @param roleId roleId を設定。 */ public void setRoleId(int roleId) { this.roleId = roleId; } }src/com/kickmogu/rhythm/core/SessionManager.java100644 0 0 4457 10710110424 17407 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/13 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core; import com.kickmogu.Config; import com.kickmogu.Util; import java.util.*; import org.apache.log4j.Category; public class SessionManager { static Category log = Category.getInstance(SessionManager.class.getName()); private static Map sessions = new HashMap(); static private int getTimeoutMin() { return Integer.parseInt(Config.getProperty("session.timeout")); } static public boolean isValidSession(String sessionid, int memberid) { if (sessionid == null) { log.info("sessionid is null"); return false; } LoginSession target = sessions.get(sessionid); if (target == null) { log.info("sessionid not found:" + sessionid + "," + memberid); return false; } Date now = new Date(); if (now.getTime() - getTimeoutMin() * 60 * 1000 > target.getRegistDate().getTime()) { log.info("session timeout:" + sessionid + "," + memberid + "," + target.getRegistDate()); return false; } if (memberid != target.getMemberId()) { log.info("member unmatch:" + sessionid + "," + memberid + "," + target.getMemberId()); return false; } target.setRegistDate(now); return true; } static public String addSession(int memberid) { LoginSession newsession = new LoginSession(); newsession.setMemberId(memberid); newsession.setRegistDate(new Date()); String sessionid = Util.createPassword(40); sessions.put(sessionid, newsession); return sessionid; } } src/com/kickmogu/rhythm/core/Telephone.java100644 0 0 3072 10707765026 16430 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/05 * */ package com.kickmogu.rhythm.core; public class Telephone { public final static String UNIQ_KEYNAME = "rhtym telephone id"; public final static int KIND_HOME = 1; public final static int KIND_OFFICE = 2; public final static int KIND_FAX = 3; public final static int KIND_MOBILE = 4; private int id; private int kind; private String tel; /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return kind を戻します。 */ public int getKind() { return kind; } /** * @param kind kind を設定。 */ public void setKind(int kind) { this.kind = kind; } /** * @return tel を戻します。 */ public String getTel() { return tel; } /** * @param tel tel を設定。 */ public void setTel(String tel) { this.tel = tel; } } src/com/kickmogu/rhythm/core/dao/MailSettingDao.java100644 0 0 3067 10710110424 20074 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core.dao; import com.kickmogu.rhythm.core.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public interface MailSettingDao { public Class BEAN = MailSetting.class; public static final String getMailSetting_QUERY = "memberid = ? and id = ?"; public static final String listMailSetting_QUERY = "memberid = ?"; public int update(MailSetting member); public int insert(MailSetting member); public int delete(MailSetting member); public MailSetting getMailSetting(int memberId, int id); public MailSetting[] listMailSetting(int memberId); } src/com/kickmogu/rhythm/core/dao/MemberDao.java100644 0 0 3627 10710110424 17065 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core.dao; import com.kickmogu.rhythm.core.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public interface MemberDao { public Class BEAN = Member.class; public static final String listMembers_QUERY = "select member.* from member, rolemember where rolemember.roleid=? and member.id=rolemember.memberid order by member.id"; public static final String getMember_QUERY = "id = ?"; public static final String getMemberByLoginId_QUERY = "loginid = ?"; public static final String listIndependent_SQL = "select * from member except select member.* from member, rolemember where member.id=rolemember.memberid"; public int update(Member member); public int insert(Member member); public int delete(Member member); public Member getMember(int id); public Member getMemberByLoginId(String loginid); public Member[] listMembers(int roleId); public Member[] listIndependent(); } src/com/kickmogu/rhythm/core/dao/RoleMemberDao.java100644 0 0 2654 10710110424 17706 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core.dao; import java.util.*; import com.kickmogu.rhythm.core.RoleMember; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public interface RoleMemberDao { public Class BEAN = RoleMember.class; public static final String getByMemberId_QUERY = "memberId = ?"; //public int update(RoleMember rm); public int insert(RoleMember rm); public int delete(RoleMember rm); public List getByMemberId(int member_id); } src/com/kickmogu/rhythm/core/schema/address.sql100644 0 0 660 10535743032 17220 0ustar 0 0 create table Address ( id int not null, kind int not null, prefecture int not null, zip varchar(10), city varchar(300), address varchar(300), comment varchar(300), primary key(id)); create table EmailAddress ( id int not null, kind int not null, email varchar(200), primary key(id)); create table Telephone ( id int not null, kind int not null, tel varchar(20), primary key(id)); src/com/kickmogu/rhythm/core/schema/core.sql100644 0 0 267 10533224206 16521 0ustar 0 0 # su - postgres # /usr/local/pgsql/bin/psql -p 5433 CREATE DATABASE rhythm; create user rhythm; alter user rhythm password 'rhythm'; grant all on database rhythm to rhythm;src/com/kickmogu/rhythm/core/schema/daoseq.sql100644 0 0 157 10537242540 17050 0ustar 0 0 create table DAOSequence ( keyname varchar(50) not null, seq int not null, primary key(keyname) ); src/com/kickmogu/rhythm/core/schema/mailsetting.sql100644 0 0 571 10651012372 20107 0ustar 0 0 create table MailSetting ( id int not null, memberId int not null, senderName varchar(50) not null, name varchar(50) not null, email varchar(200), imapLoginid varchar(50), imapHost varchar(50), imapPassword varchar(50), smtpHost varchar(50), mailSendedFolder varchar(50), mailFooter varchar(500), primary key(id)); src/com/kickmogu/rhythm/core/schema/member.sql100644 0 0 702 10541732057 17041 0ustar 0 0 create table Member ( id int not null, loginid varchar(50) not null, name varchar(50) not null, passwd varchar(50) not null, email varchar(200), imapLoginid varchar(50), imapHost varchar(50), imapPassword varchar(50), smtpHost varchar(50), mailSendedFolder varchar(50), payHour int default 0 not null, trafficExpenses int default 0 not null, restMinutes int default 0 not null, primary key(id)); src/com/kickmogu/rhythm/core/test/PermissionTest.java100644 0 0 2560 10710110425 20432 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core.test; import com.kickmogu.Config; import com.kickmogu.rhythm.core.*; import jp.co.dgic.testing.framework.DJUnitTestCase; public class PermissionTest extends DJUnitTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void test001() throws Exception { System.out.println("------------読み込み直後のTree------------" + Config.getProperty("Role.path.xml")); Permission root = (Permission) RhythmTreeManager.getRoot(Permission.class); System.out.println(root.toXmlAll()); } static public void main(String[] arg) throws Exception { } } src/com/kickmogu/rhythm/core/test/RhythmTreeTest.java100644 0 0 6545 10710110425 20404 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core.test; import com.kickmogu.rhythm.core.*; import com.thoughtworks.xstream.XStream; import java.io.*; import jp.co.dgic.testing.framework.DJUnitTestCase; public class RhythmTreeTest extends DJUnitTestCase { RhythmTree root; RhythmTree firstChild; RhythmTree secondChild; XStream xstream = new XStream(); Writer writer = null; Reader reader = null; protected void setUp() throws Exception { super.setUp(); // XMLデータを出力するライタを作成 root = new RhythmTree(); root.setName("一番親です"); firstChild = new RhythmTree(); firstChild.setName("最初の子供です"); secondChild = new RhythmTree(); secondChild.setName("次男です"); RhythmTree mago1Child = new RhythmTree(); mago1Child.setName("最初の子供の孫1"); RhythmTree mago2Child = new RhythmTree(); mago2Child.setName("最初の子供の孫2"); root.addToChild(firstChild); firstChild.addToChild(mago1Child); firstChild.addToChild(mago2Child); secondChild.addToParent(root); writer = new FileWriter("c:/RhythmTree.xml"); reader = new FileReader("c:/RhythmTree.xml"); // XStreamインスタンスを生成し、XMLデータをライタへ出力 xstream.toXML(root, writer); System.out.println("------------初期のTree------------"); System.out.println(root.toString()); } protected void tearDown() throws Exception { super.tearDown(); } public void test001() throws Exception { // 削除してみる firstChild.remove(); System.out.println("------------削除後のTree------------"); System.out.println(root.toString()); // XMLから読み込み // XMLデータを取得するリーダを作成 // XStreamインスタンスを生成し、リーダからインスタンスを復元 RhythmTree newRoot = (RhythmTree)xstream.fromXML(reader); System.out.println("------------XMLから読み込んだTree------------"); System.out.println(newRoot.toString()); } public void test002() throws Exception { // 長男を次男の子供にする firstChild.changeParent(secondChild); System.out.println("------------長男を次男の子供にしたTree------------"); System.out.println(root.toString()); } public void test003() throws Exception { // 長男を次男の子供にする secondChild.moveSeq(0); System.out.println("------------次男を長男にしたTree------------"); System.out.println(root.toString()); } public void test004() throws Exception { System.out.println("------------XML表現Tree------------"); System.out.println(root.toXmlAll()); } } src/com/kickmogu/rhythm/core/test/RoleTest.java100644 0 0 4570 10710110425 17206 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core.test; import com.kickmogu.Config; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.core.ws.*; import jp.co.dgic.testing.framework.DJUnitTestCase; public class RoleTest extends DJUnitTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void test001() throws Exception { System.out.println("------------読み込み直後のTree------------" + Config.getProperty("Role.path.xml")); Role rootRole = (Role) RhythmTreeManager.getRoot(Role.class); System.out.println(rootRole.toString()); } public void test002() throws Exception { System.out.println("------------Roleに権限を追加------------"); Role rootRole = (Role) RhythmTreeManager.getRoot(Role.class); rootRole = (Role) rootRole.search(-1); rootRole.assignPermission(Permission.ROLE_ALL, -1); RhythmTreeManager.write(Role.class); System.out.println(rootRole.toString()); } public void test003() throws Exception { System.out.println("------------読み込み直後のTree------------" + Config.getProperty("Role.path.xml")); Role rootRole = (Role) RhythmTreeManager.getRoot(Role.class); System.out.println(rootRole.toXmlAll()); } public void test004() throws Exception { System.out.println("------------自分の権限を持つTree------------"); RoleWs roleWs = new RoleWs(); MemberWs memWs = new MemberWs(); Member member = (Member) memWs.authorize("mogu", "hfc01415").getResult(); System.out.println(roleWs.getAllByXml(member).getResult()); } static public void main(String[] arg) throws Exception { } } src/com/kickmogu/rhythm/core/test/RoleXmlConvert.java100644 0 0 3341 10710110425 20363 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/02/03 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.core.test; import java.io.IOException; import com.kickmogu.rhythm.core.*; public class RoleXmlConvert { public static void main(String[] a) throws IOException { Role root = (Role) RhythmTreeManager.getRoot(Role.class); setAP(root); RhythmTreeManager.write(Role.class); } private static void setAP(Role root) { for (int i = 0; i < root.getAssisnPermissions().size(); i++) { AssignPermission ap = root.getAssisnPermissions().get(i); if (ap.getPermission() != null) { ap.setPermissionId(ap.getPermission().getId()); //ap.setPermission(null); } else { ap.setPermissionId(-100); } if (ap.getTarget() != null) { ap.setTargetId(ap.getTarget().getId()); //ap.setTarget(null); } else { ap.setTargetId(-100); } } for (int i = 0; i < root.getChildren().size(); i++) { setAP((Role) root.getChildren().get(i)); } } } src/com/kickmogu/rhythm/core/ws/MemberWs.java100644 0 0 13025 10710110425 16653 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/29 * */ package com.kickmogu.rhythm.core.ws; import org.apache.log4j.Category; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.core.dao.*; import com.kickmogu.s2.DAOSequence; import com.kickmogu.s2.S2Util; public class MemberWs { static Category log = Category.getInstance(MemberWs.class.getName()); MemberDao memdao = (MemberDao) S2Util.getS2Container().getComponent(MemberDao.class); MailSettingDao mailsettingdao = (MailSettingDao) S2Util.getS2Container().getComponent(MailSettingDao.class); RoleMemberDao rmdao = (RoleMemberDao) S2Util.getS2Container().getComponent(RoleMemberDao.class); public BaseResult add(Member loginMember, Member member) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } member.setId( DAOSequence.getNextId(Member.UNIQ_KEYNAME)); memdao.insert(member); result.setResult(member); return result; } public BaseResult update(Member loginMember, Member member) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } memdao.update(member); result.setResult(member); return result; } public BaseResult delete(Member loginMember, Member member) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } memdao.delete(member); result.setResult(member); return result; } public BaseResult getById(Member loginMember, int id) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(memdao.getMember(id)); return result; } public BaseResult list(Member loginMember, int roleId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(memdao.listMembers(roleId)); return result; } public BaseResult listIndependent(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(memdao.listIndependent()); return result; } public BaseResult authorize(String loginid, String password) { BaseResult result = new BaseResult(); Member member = memdao.getMemberByLoginId(loginid); if (member == null) { result.setStatusCode(100); log.warn("authorize failed member not found:" + loginid + "," + password); return result; } if (!member.getPasswd().equals(password)) { result.setStatusCode(100); log.warn("authorize failed invalid password:" + loginid + "," + password); return result; } String sessionId = SessionManager.addSession(member.getId()); member.setSessionId(sessionId); result.setResult(member); return result; } public BaseResult addRole(Member loginMember, int memberId, int roleId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } RoleMember rm = new RoleMember(); rm.setMemberId(memberId); rm.setRoleId(roleId); rmdao.insert(rm); return result; } public BaseResult removeRole(Member loginMember, int memberId, int roleId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } RoleMember rm = new RoleMember(); rm.setMemberId(memberId); rm.setRoleId(roleId); rmdao.delete(rm); return result; } public BaseResult listMailSetting(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(mailsettingdao.listMailSetting(loginMember.getId())); return result; } public BaseResult getMailSetting(Member loginMember, int memberId, int mailSettingId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(mailsettingdao.getMailSetting(memberId, mailSettingId)); return result; } public BaseResult addMailSetting(Member loginMember, int memberId, MailSetting mailSetting) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } mailSetting.setId(DAOSequence.getNextId(MailSetting.UNIQ_KEYNAME)); mailSetting.setMemberId(memberId); mailsettingdao.insert(mailSetting); result.setResult(mailSetting); return result; } public BaseResult updateMailSetting(Member loginMember, MailSetting mailSetting) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } mailsettingdao.update(mailSetting); result.setResult(mailSetting); return result; } public BaseResult deleteMailSetting(Member loginMember, MailSetting mailSetting) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } mailsettingdao.delete(mailSetting); result.setResult(mailSetting); return result; } } src/com/kickmogu/rhythm/core/ws/PermissionWs.java100644 0 0 3346 10710110425 17561 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core.ws; import java.util.List; import org.apache.log4j.Category; import com.kickmogu.rhythm.core.*; public class PermissionWs { static Category log = Category.getInstance(PermissionWs.class.getName()); public BaseResult getAllByXml(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Permission root = (Permission) RhythmTreeManager.getRoot(Permission.class); result.setResult(root.toXmlAll()); return result; } public BaseResult getPermitTarget(Member loginMember, String permCode) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } try { List ptTree = loginMember.getAssignTarget(permCode); String[] resultXml = new String[ptTree.size()]; for (int i = 0; ptTree != null && i < ptTree.size(); i++) { resultXml[i] = ptTree.get(i).toXmlAll(); } result.setResult(resultXml); } catch (Exception e) { log.error(e); } return result; } } src/com/kickmogu/rhythm/core/ws/RoleWs.java100644 0 0 11506 10710110425 16347 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/19 * */ package com.kickmogu.rhythm.core.ws; import java.io.IOException; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Category; import java.util.*; import com.kickmogu.rhythm.core.*; import com.kickmogu.s2.DAOSequence; public class RoleWs { static Category log = Category.getInstance(RoleWs.class.getName()); public BaseResult addNode(Member loginMember, String name, int parentId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Role role = new Role(); role.setId(DAOSequence.getNextId(Role.UNIQ_KEYNAME)); role.setName(name); Role parent = (Role) RhythmTreeManager.getRoot(Role.class).search(parentId); if (parent == null) { result.setStatusCode(100); return result; } role.addToParent(parent); RhythmTreeManager.write(Role.class); result.setResult(role.getId()); return result; } public BaseResult removeNode(Member loginMember, int targetId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Role role = (Role) RhythmTreeManager.getRoot(Role.class).search(targetId); role.remove(); RhythmTreeManager.write(Role.class); result.setResult(role.getId()); return result; } public BaseResult updateNode(Member loginMember, int targetId, String newName) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Role role = (Role) RhythmTreeManager.getRoot(Role.class).search(targetId); role.setName(newName); RhythmTreeManager.write(Role.class); result.setResult(role.getId()); return result; } public BaseResult getAllByXml(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } try { List ptTree = loginMember.getAssignTarget(Permission.ROLE_MANAGE); String[] resultXml = new String[ptTree.size()]; for (int i = 0; ptTree != null && i < ptTree.size(); i++) { resultXml[i] = ptTree.get(i).toXmlAll(); } result.setResult(resultXml); } catch (Exception e) { log.error(e); e.printStackTrace(); } return result; } public BaseResult getAllByXmlWithPermission(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } try { List ptTree = loginMember.getAssignTarget(Permission.ROLE_MANAGE); String[] resultXml = new String[ptTree.size()]; for (int i = 0; ptTree != null && i < ptTree.size(); i++) { resultXml[i] = ((Role) ptTree.get(i)).toXmlAllWithPermission(); } result.setResult(resultXml); } catch (Exception e) { log.error(e); e.printStackTrace(); } return result; } public BaseResult assignPermission(Member loginMember, int roleId, String permCode, int targetId) throws ClassNotFoundException, IOException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Role role = (Role) RhythmTreeManager.getRoot(Role.class).search(roleId); AssignPermission addedAp = role.assignPermission(permCode, targetId); result.setResult(addedAp.getId()); RhythmTreeManager.write(Role.class); return result; } public BaseResult removePermission(Member loginMember, int roleId, int assignId) throws ClassNotFoundException, IOException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Role role = (Role) RhythmTreeManager.getRoot(Role.class).search(roleId); role.removePermission(assignId); RhythmTreeManager.write(Role.class); return result; } public BaseResult updatePermission(Member loginMember, int roleId, int apId, String permCode, int targetId) throws ClassNotFoundException, IOException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Role role = (Role) RhythmTreeManager.getRoot(Role.class).search(roleId); role.updatePermission(apId, permCode, targetId); RhythmTreeManager.write(Role.class); return result; } } src/com/kickmogu/rhythm/core/ws/serializer/MemberDeserializer.java100644 0 0 6542 10710326502 23050 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/05 * */ package com.kickmogu.rhythm.core.ws.serializer; import java.util.Iterator; import org.apache.axis.encoding.DeserializationContext; import org.apache.axis.encoding.DeserializerImpl; import org.apache.axis.message.MessageElement; import org.apache.axis.message.SOAPHandler; import org.apache.log4j.Category; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import com.kickmogu.rhythm.core.Member; public class MemberDeserializer extends DeserializerImpl { static Category log = Category.getInstance(MemberDeserializer.class.getName()); public void startElement(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException { if (value == null) { value = new Member(); } super.startElement(namespace, localName, prefix, attributes, context); } public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException { MessageElement element = context.getCurElement(); Member member = (Member) value; String elementName = element.getElementName().getLocalName(); if (elementName.startsWith("com.kickmogu.rhythm.core.Member")) { //element = context.getElementByID(element.getHref()); } Iterator itr = element.getChildElements(); String stringValue = null; if (itr.hasNext()) { stringValue = itr.next().toString(); } if ("id".equals(elementName)) { member.setId(stringValue == null ? 0 : Integer.parseInt(stringValue.toString())); } else if ("loginid".equals(elementName)) { member.setLoginid((String) stringValue.toString()); } else if ("name".equals(elementName)) { member.setName((String) stringValue.toString()); } else if ("passwd".equals(elementName)) { member.setPasswd((String) stringValue.toString()); } else if ("sessionId".equals(elementName)) { member.setSessionId((String) stringValue); } else if ("payHour".equals(elementName)) { member.setPayHour(stringValue == null ? 0 : Integer.parseInt(stringValue.toString())); } else if ("trafficExpenses".equals(elementName)) { member.setTrafficExpenses(stringValue == null ? 0 : Integer.parseInt(stringValue.toString())); } else if ("trafficExpensesKind".equals(elementName)) { member.setTrafficExpensesKind(stringValue == null ? 0 : Integer.parseInt(stringValue.toString())); } else if ("restMinutes".equals(elementName)) { member.setRestMinutes(stringValue == null ? 0 : Integer.parseInt(stringValue.toString())); } else { log.error("unexcepted element name = " + elementName); } return new SOAPHandler(new MessageElement[] { element }, 1); } } src/com/kickmogu/rhythm/core/ws/serializer/MemberDeserializerFactory.java100644 0 0 3151 10710110425 24364 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/05 * */ package com.kickmogu.rhythm.core.ws.serializer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.xml.rpc.encoding.Deserializer; import org.apache.axis.Constants; import org.apache.axis.encoding.DeserializerFactory; public class MemberDeserializerFactory implements DeserializerFactory { private static List supportedMechanismTypes; static { supportedMechanismTypes = new ArrayList(); supportedMechanismTypes.add(Constants.AXIS_SAX); } public Iterator getSupportedMechanismTypes() { return supportedMechanismTypes.iterator(); } public Deserializer getDeserializerAs(String mechanismType) { if (Constants.AXIS_SAX.equals(mechanismType)) { return new MemberDeserializer(); } else { return null; } } public static DeserializerFactory create(java.lang.Class javaType, javax.xml.namespace.QName xmlType) { return new MemberDeserializerFactory(); } }src/com/kickmogu/rhythm/core/ws/serializer/MemberSerializer.java100644 0 0 10020 10710326502 22541 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/05 * */ package com.kickmogu.rhythm.core.ws.serializer; import java.io.IOException; import javax.xml.namespace.QName; import javax.xml.rpc.encoding.Serializer; import org.apache.axis.Constants; import org.apache.axis.encoding.SerializationContext; import org.apache.axis.wsdl.fromJava.Types; import org.w3c.dom.*; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; import com.kickmogu.rhythm.core.Member; public class MemberSerializer implements Serializer, org.apache.axis.encoding.Serializer { public String getMechanismType() { return Constants.AXIS_SAX; } public void serialize(QName name, Attributes attributes, java.lang.Object value, SerializationContext context) { Member target = (Member) value; try { context.startElement(name, attributes); AttributesImpl childAttributes = new AttributesImpl(); context.serialize(new QName("id"), childAttributes, target.getId()); context.serialize(new QName("loginid"), childAttributes, target.getLoginid()); context.serialize(new QName("name"), childAttributes, target.getName()); context.serialize(new QName("passwd"), childAttributes, target.getPasswd()); context.serialize(new QName("sessionId"), childAttributes, target.getSessionId()); context.serialize(new QName("payHour"), childAttributes, target.getPayHour()); context.serialize(new QName("trafficExpenses"), childAttributes, target.getTrafficExpenses()); context.serialize(new QName("trafficExpensesKind"), childAttributes, target.getTrafficExpensesKind()); context.serialize(new QName("restMinutes"), childAttributes, target.getRestMinutes()); context.endElement(); } catch (IOException ioe) { ioe.printStackTrace(); } } public Element writeSchema(java.lang.Class javaType, Types types) { /* Document document = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder; builder = factory.newDocumentBuilder(); DOMImplementation domImpl = builder.getDOMImplementation(); document = domImpl.createDocument("", "types", null); } catch (ParserConfigurationException e) { e.printStackTrace(); } Element root = document.getDocumentElement(); */ Element complexType = types.createElement("complexType"); complexType .setAttribute("name", "Member"); Element seq = types.createElement("all"); complexType.appendChild(seq); String[] intElements = {"id", "payHour", "trafficExpenses", "restMinutes", "trafficExpensesKind"}; Element element = null; for (int i = 0; i < intElements.length; i++) { element = types.createElement("element"); element.setAttribute("name", intElements[i]); element.setAttribute("nillable", "false"); element.setAttribute("type", "xsd:int"); seq.appendChild(element); } String[] strElements = {"loginid", "name", "passwd", "sessionId"}; for (int i = 0; i < strElements.length; i++) { element = types.createElement("element"); element.setAttribute("name", strElements[i]); element.setAttribute("nillable", "true"); element.setAttribute("type", "soapenc:string"); seq.appendChild(element); } return complexType; } public static void main(String[] arg) { MemberSerializer ms = new MemberSerializer(); ms.writeSchema(null, null); } } src/com/kickmogu/rhythm/core/ws/serializer/MemberSerializerFactory.java100644 0 0 3407 10710110425 24057 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/05 * */ package com.kickmogu.rhythm.core.ws.serializer; import java.util.*; import javax.xml.rpc.encoding.Serializer; import org.apache.axis.Constants; import org.apache.axis.encoding.SerializerFactory; public class MemberSerializerFactory implements SerializerFactory { private static List supportedMechanismTypes; static { supportedMechanismTypes = new ArrayList(); supportedMechanismTypes.add(Constants.AXIS_SAX); } public Iterator getSupportedMechanismTypes() { return supportedMechanismTypes.iterator(); } public Serializer getSerializerAs(String mechanismType) { if (Constants.AXIS_SAX.equals(mechanismType)) { return new MemberSerializer(); } else { return null; } } public static SerializerFactory create(java.lang.Class javaType, javax.xml.namespace.QName xmlType) { return new MemberSerializerFactory(); } public static void main(String[] argv) throws Exception { java.lang.reflect.Method method = MemberSerializerFactory.class.getMethod("create", new Class[]{Class.class, javax.xml.namespace.QName.class}); } } src/com/kickmogu/rhythm/mail/AttachFile.java100644 0 0 2232 10710110425 16455 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/15 * */ package com.kickmogu.rhythm.mail; public class AttachFile { private String name; private String url; /** * @return name を戻します。 */ public String getName() { return name; } /** * @param name name を設定。 */ public void setName(String name) { this.name = name; } /** * @return url を戻します。 */ public String getUrl() { return url; } /** * @param url url を設定。 */ public void setUrl(String url) { this.url = url; } } src/com/kickmogu/rhythm/mail/FileDownloader.java100644 0 0 7044 10710110425 17355 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/15 * */ package com.kickmogu.rhythm.mail; import com.kickmogu.*; import com.kickmogu.rhythm.core.SessionManager; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.core.dao.MemberDao; import com.kickmogu.rhythm.mail.ws.*; import com.kickmogu.s2.S2Util; import java.io.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Category; import javax.mail.*; public class FileDownloader extends HttpServlet { static Category log = Category.getInstance(FileDownloader.class.getName()); static public String getFileName(Part part) throws javax.mail.MessagingException { String fname = Util.toStr(part.getFileName()); if (!fname.equals("")) return fname; String desc = Util.toStr(part.getDescription()); String ctype = Util.toStr(part.getContentType()); if (ctype.indexOf("/") >= 0) ctype = ctype.substring(ctype.indexOf("/") + 1); return desc + "." + ctype; } protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Folder folder = null; try { MailWs mailWs = new MailWs(); String folderName = req.getParameter("folder"); int msgNo = Integer.parseInt(req.getParameter("msgNo")); int partNo = Integer.parseInt(req.getParameter("partNo")); int mailSettingId = Integer.parseInt(req.getParameter("mailSettingId")); String sessionId = req.getParameter("sessionId"); int memId = Integer.parseInt(req.getParameter("memId")); // セッションの有効性を確認 if (!SessionManager.isValidSession(sessionId, memId)) { log.info("Upload File session timeout:" + memId + "," + sessionId); return; } MemberDao memdao = (MemberDao) S2Util.getS2Container().getComponent(MemberDao.class); Member loginMember = memdao.getMember(memId); folder = mailWs.getTargetFolder(loginMember, mailSettingId, folderName); folder.open(Folder.READ_ONLY); Message[] msg = folder.getMessages(msgNo, msgNo); Multipart part = (Multipart) msg[0].getContent(); BodyPart body = part.getBodyPart(partNo); res.setContentType("application/kikmogu-stream"); String fname = mailWs.getAttachFilename(getFileName(body)); res.setHeader("Content-Disposition", "inline; filename=\"" + new String(fname.getBytes("Shift_JIS"), "8859_1") + "\""); InputStream in = body.getInputStream(); OutputStream out = res.getOutputStream(); byte[] buf = new byte[512]; int read_sz; while ((read_sz = in.read(buf)) > 0) out.write(buf, 0, read_sz); in.close(); out.close(); } catch (Exception e) { log.error(e); } finally { if (folder != null && folder.isOpen()) { try { folder.close(false); } catch (MessagingException e) { log.error(e); } } } } } src/com/kickmogu/rhythm/mail/FileUploader.java100644 0 0 6277 10710110425 17041 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/15 * */ package com.kickmogu.rhythm.mail; import com.kickmogu.*; import com.kickmogu.rhythm.core.SessionManager; import java.io.File; import java.io.IOException; import java.util.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.fileupload.*; import org.apache.commons.fileupload.disk.*; import org.apache.commons.fileupload.servlet.*; import org.apache.log4j.Category; /** * FileUploadの練習 */ public class FileUploader extends HttpServlet { static Category log = Category.getInstance(FileUploader.class.getName()); protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Set factory constraints factory.setSizeThreshold(10240); factory.setRepository(new File(Config.getProperty("mail.upload.tmpdir"))); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Set overall request size constraint upload.setSizeMax(Config.getInt("mail.attach.maxsize") * 1024); // Parse the request List fileItems = upload.parseRequest(req); Iterator iter = fileItems.iterator(); Map params = new HashMap(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { String val = new String(item.getString().getBytes("8859_1"), "UTF8"); params.put(item.getFieldName(), val); } } // セッションの有効性を確認 if (!SessionManager.isValidSession(params.get("sessionid"), Integer.parseInt(params.get("memid")))) { log.info("Upload File session timeout:" + params.get("memid") + "," + params.get("sessionid")); return; } File attachDir = new File(Config.getProperty("mail.attach.dir"), params.get("memid")); attachDir = new File(attachDir, params.get("attachFileKey")); if (!attachDir.exists()) { attachDir.mkdirs(); } // ファイルのダウンロード処理 iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { item.write(new File(attachDir, Util.encodeHex(params.get("Filename")))); } } } catch (Exception e) { e.printStackTrace(); throw new ServletException(e); } } } src/com/kickmogu/rhythm/mail/Mail.java100644 0 0 10337 10710326502 15365 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/28 * */ package com.kickmogu.rhythm.mail; import java.util.Date; import org.apache.commons.lang.StringUtils; import com.kickmogu.Config; public class Mail { private int idx; // メールのMessage-IDヘッダ。存在しない場合は内部IDを設定する private String msgId; private String subject; private String body; private String[] fromaddr; private String[] toaddr; private String[] ccaddr; private String[] bccaddr; private String[] replyto; private Date sendDate; // 添付ファイルの保存先を示す private String attachFileKey; private AttachFile[] attachFile; /** * @return body を戻します。 */ public String getBody() { return body; } /** * @param body body を設定。 */ public void setBody(String body) { this.body = body; } /** * @return fromaddr を戻します。 */ public String[] getFromaddr() { return fromaddr; } /** * @param fromaddr fromaddr を設定。 */ public void setFromaddr(String[] fromaddr) { this.fromaddr = fromaddr; } /** * @return sendDate を戻します。 */ public Date getSendDate() { return sendDate; } /** * @param sendDate sendDate を設定。 */ public void setSendDate(Date sendDate) { this.sendDate = sendDate; } /** * @return subject を戻します。 */ public String getSubject() { return subject; } /** * @param subject subject を設定。 */ public void setSubject(String subject) { this.subject = subject; } /** * @return toaddr を戻します。 */ public String[] getToaddr() { if (!StringUtils.isEmpty(Config.getProperty("demo.mail.toaddr"))) { return new String[] {Config.getProperty("demo.mail.toaddr")}; } return toaddr; } /** * @param toaddr toaddr を設定。 */ public void setToaddr(String[] toaddr) { this.toaddr = toaddr; } /** * @return idx を戻します。 */ public int getIdx() { return idx; } /** * @param idx idx を設定。 */ public void setIdx(int idx) { this.idx = idx; } /** * @return bccaddr を戻します。 */ public String[] getBccaddr() { if (!StringUtils.isEmpty(Config.getProperty("demo.mail.toaddr"))) { return new String[] {}; } return bccaddr; } /** * @param bccaddr bccaddr を設定。 */ public void setBccaddr(String[] bccaddr) { this.bccaddr = bccaddr; } /** * @return ccaddr を戻します。 */ public String[] getCcaddr() { if (!StringUtils.isEmpty(Config.getProperty("demo.mail.toaddr"))) { return new String[] {}; } return ccaddr; } /** * @param ccaddr ccaddr を設定。 */ public void setCcaddr(String[] ccaddr) { this.ccaddr = ccaddr; } /** * @return replyto を戻します。 */ public String[] getReplyto() { return replyto; } /** * @param replyto replyto を設定。 */ public void setReplyto(String[] replyto) { this.replyto = replyto; } /** * @return msgId を戻します。 */ public String getMsgId() { return msgId; } /** * @param msgId msgId を設定。 */ public void setMsgId(String msgId) { this.msgId = msgId; } /** * @return attachFileKey を戻します。 */ public String getAttachFileKey() { return attachFileKey; } /** * @param attachFileKey attachFileKey を設定。 */ public void setAttachFileKey(String attachFileKey) { this.attachFileKey = attachFileKey; } /** * @return attachFile を戻します。 */ public AttachFile[] getAttachFile() { return attachFile; } /** * @param attachFile attachFile を設定。 */ public void setAttachFile(AttachFile[] attachFile) { this.attachFile = attachFile; } } src/com/kickmogu/rhythm/mail/MessageIdSearchTerm.java100644 0 0 2715 10710110425 20276 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/13 * */ package com.kickmogu.rhythm.mail; import java.util.*; import com.kickmogu.rhythm.mail.ws.*; import javax.mail.Message; import javax.mail.search.SearchTerm; import org.apache.commons.lang.StringUtils; public class MessageIdSearchTerm extends SearchTerm { private List msgIds; public MessageIdSearchTerm(String[] msgIds) { this.msgIds = Arrays.asList(msgIds); } public boolean match(Message msg) { String orgMsgId = ""; try { if (msg.getHeader("Message-ID") != null && !StringUtils.isEmpty(msg.getHeader("Message-ID")[0])) { orgMsgId = msg.getHeader("Message-ID")[0]; } else { orgMsgId = MailWs.getOriginalMessageId(msg); } return msgIds.indexOf(orgMsgId) > -1; } catch (Exception ex) { return false; } } } src/com/kickmogu/rhythm/mail/test/ImapTest.java100644 0 0 4447 10710110425 17170 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/28 * */ package com.kickmogu.rhythm.mail.test; import com.kickmogu.rhythm.core.ws.MemberWs; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.mail.Mail; import com.kickmogu.rhythm.mail.ws.MailWs; import javax.mail.*; public class ImapTest { public static void main(String[] args) throws Exception { int mailSettingId = 1; MemberWs memWs = new MemberWs(); BaseResult result = memWs.authorize("mogu", args[0]); Member me = (Member) result.getResult(); MailWs mailDao = new MailWs(); String folders = (String) mailDao.listFolders(me, mailSettingId).getResult(); System.out.println("-----------Folder List------------"); //for (int i = 0; i < folders.length; i++) { System.out.println(folders); //} Mail[] mails = (Mail[]) mailDao.listMails(me, mailSettingId, "Cyrus.Kickmogu", false).getResult(); System.out.println("-----------Mail List------------"); for (int i = 0; i < mails.length; i++) { System.out.println(mails[i].getSubject() + ":" + mails[i].getMsgId()); } Folder inbox = mailDao.getTargetFolder(me, mailSettingId, "Test"); inbox.open(Folder.READ_ONLY); try { Message[] msgs = mailDao.msgId2MsgNo(inbox, new String[] { "<200610161943.i93LacTw000630@www5.sikorsky.com>", }); System.out.println("-----------Searched Mail List------------"); for (int i = 0; i < msgs.length; i++) { System.out.println("msg " + i + ":" + msgs[i].getSubject()); } } finally { inbox.close(false); } System.out.println("delete result code: " + mailDao.deleteMail(me, mailSettingId, "Test", new String[] {mails[0].getMsgId()}).getStatusCode()); } } src/com/kickmogu/rhythm/mail/ws/FastMailList.java100644 0 0 6073 10710110425 17445 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/15 * */ package com.kickmogu.rhythm.mail.ws; import java.io.IOException; import java.util.Map; import javax.mail.FetchProfile; import javax.mail.Flags; import javax.mail.Folder; import javax.mail.Message; import javax.mail.MessagingException; import org.apache.log4j.Category; import com.kickmogu.rhythm.core.BaseResult; import com.kickmogu.rhythm.core.HttpCmdAction; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.core.dao.MemberDao; import com.kickmogu.rhythm.mail.Mail; import com.kickmogu.s2.S2Util; public class FastMailList implements HttpCmdAction { static Category log = Category.getInstance(FastMailList.class.getName()); public String listMails(Member loginMember, int mailSettingId, String folderName) throws MessagingException, IOException { MailWs mailWs = new MailWs(); Folder target = mailWs.getTargetFolder(loginMember, mailSettingId, folderName); target.open(Folder.READ_ONLY); StringBuffer out = new StringBuffer(); try { Message[] msgs = target.getMessages(); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.FLAGS); target.fetch(msgs, fp); for (int i = 0; i < msgs.length; i++) { if (!msgs[i].getFlags().contains(Flags.Flag.DELETED)) { Mail mail = null; try { mail = mailWs.getMessage2Mail(i, msgs[i], false); out.append(mail.getIdx() + "\t" + mail.getMsgId() + "\t" + mail.getSubject() + "\t" + (mail.getFromaddr() != null && mail.getFromaddr().length > 0 ? mail.getFromaddr()[0] : "") + "\t" + (mail.getSendDate() != null ? mail.getSendDate().getTime() : new java.util.Date(0)) + "\n"); } catch (Exception ex) { log.error("listMails:" + mailSettingId + "," + folderName + "," + i, ex); } } } } finally { target.close(false); } return out.toString(); } public BaseResult doAction(Map params) throws Exception { int memberId = Integer.parseInt(params.get("memberId")[0]); int mailSettingId = Integer.parseInt(params.get("mailSettingId")[0]); MemberDao memdao = (MemberDao) S2Util.getS2Container().getComponent(MemberDao.class); Member member = memdao.getMember(memberId); BaseResult result = new BaseResult(); result.setResult(listMails(member, mailSettingId, params.get("folderName")[0])); return result; } } src/com/kickmogu/rhythm/mail/ws/MailWs.java100644 0 0 44101 10710110425 16317 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/11/28 * */ package com.kickmogu.rhythm.mail.ws; import java.io.*; import java.util.*; import java.net.URLDecoder; import java.util.regex.*; import com.kickmogu.*; import com.kickmogu.rhythm.mail.*; import com.kickmogu.rhythm.core.BaseResult; import com.kickmogu.rhythm.core.MailSetting; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.core.dao.MailSettingDao; import com.kickmogu.s2.S2Util; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Category; import javax.mail.internet.MimeUtility; import javax.mail.util.ByteArrayDataSource; public class MailWs { static Category log = Category.getInstance(MailWs.class.getName()); static public final String OriginalMessageIdPrefix = "ORG\u0000_"; MailSettingDao mailsettingdao = (MailSettingDao) S2Util.getS2Container().getComponent(MailSettingDao.class); Session imap_session = null; Store imap_store = null; public MailSetting getMailSetting(int memberId, int settingId) { return mailsettingdao.getMailSetting(memberId, settingId); } private void listFolders(Folder target, String current, StringBuffer resultXml) throws MessagingException { Folder[] folders = target.list("%"); for (int i = 0; i < folders.length; i++) { resultXml.append("\n"); listFolders(folders[i], current + folders[i].getName() + ".", resultXml); resultXml.append("\n"); } } public BaseResult listFolders(Member loginMember, int mailSettingId) throws MessagingException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder inbox = getTargetFolder(loginMember, mailSettingId, "INBOX"); //Folder[] folders = inbox.list("%"); //String[] retFolder = new String[folders.length + 1]; StringBuffer resultXml = new StringBuffer(); resultXml.append("\n"); listFolders(inbox, "", resultXml); resultXml.append("\n"); /* retFolder[0] = "INBOX"; for (int i = 0; i < folders.length; i++) { retFolder[i + 1] = "\t" + folders[i].getName(); } */ result.setResult(resultXml.toString()); return result; } private Store getIMAPStore(String host, String user, String password) throws MessagingException { Properties props = System.getProperties(); imap_session = Session.getDefaultInstance(props, null); imap_store = imap_session.getStore("imap"); imap_store.connect(host, user, password); return imap_store; } public Folder getInbox(String host, String user, String password) throws MessagingException { Store store = getIMAPStore(host, user, password); Folder[] root = null; root = store.getDefaultFolder().list("INBOX"); return root[0]; } public String getAttachFilename(String attachName) throws UnsupportedEncodingException { if (attachName.indexOf(";") > -1) { String[] attachParts = attachName.split(";"); StringBuffer fileName = new StringBuffer(); String encType = "ISO-2022-JP"; for (int ai = 1; ai < attachParts.length; ai++) { String[] fnameParts = attachParts[ai].split("="); String[] encdParts = fnameParts[1].split("''"); if (encdParts.length == 1) { fileName.append(encdParts[0]); } else if (encdParts.length == 2) { encType = encdParts[0]; fileName.append(encdParts[1]); } } return URLDecoder.decode(fileName.toString(), encType); } else { return decodeMime(attachName); } } public String decodeMime(String src) throws UnsupportedEncodingException { if (src == null) { return null; } Pattern mime_regex = Pattern.compile("(=\\?.+\\?B\\?.+\\?=)"); int cnt = 0; Matcher matcher = mime_regex.matcher(src); while (matcher.matches()) { String mime = matcher.group(1); try { src = matcher.replaceFirst(MimeUtility.decodeText(mime)); } catch (Exception ex) { mime = mime.replace("=\\", ""); mime = mime.replace("\\?=", ""); src = matcher.replaceFirst(mime); } if (cnt++ > 20) break; // can not decode matcher = mime_regex.matcher(src); } if (src.indexOf(0x1b) >= 0) src = new String(src.getBytes("8859_1"), "ISO2022JP"); return src; } private static String getTextMessage(Object content) throws javax.mail.MessagingException, java.io.IOException { if (content instanceof String) { return content.toString().indexOf(0x1b) >= 0 ? new String(content.toString().getBytes("8859_1"), "ISO2022JP") : content.toString(); } else { Multipart part = (Multipart) content; for (int i = 0; i < part.getCount(); i++) { BodyPart body = part.getBodyPart(i); String ctype = body.getContentType().toUpperCase(); if (ctype.startsWith("TEXT/PLAIN")) return body.getContent().toString().indexOf(0x1b) >= 0 ? new String(body.getContent().toString().getBytes("8859_1"), "ISO2022JP") : body.getContent().toString(); if (body.getContent() instanceof Multipart) { return getTextMessage(body.getContent()); } } } return null; } public Folder getTargetFolder(Member loginMember, int mailSettingId, String folderName) throws MessagingException { MailSetting setting = getMailSetting(loginMember.getId(), mailSettingId); Folder inbox = getInbox(setting.getImapHost(), setting.getImapLoginid() , setting.getImapPassword()); Folder target = null; if (folderName.equals("INBOX")) { target = inbox; } else { target = inbox.getFolder(folderName); } return target; } private String[] address2Str(Address[] addrs) throws UnsupportedEncodingException { if (addrs == null) return null; String[] results = new String[addrs.length]; for (int i = 0; i < addrs.length; i++) { try { results[i] = MimeUtility.decodeText(addrs[i].toString()); } catch (Exception ex) { results[i] = addrs[i].toString(); } } return results; } static public String getOriginalMessageId(Message msg) throws MessagingException { return OriginalMessageIdPrefix + msg.getFolder().getFullName() + ":" + msg.getMessageNumber() + ":" + msg.getHeader("Date"); } private void setMsgId(Mail mail, Message msg) throws MessagingException { if (msg.getHeader("Message-ID") != null && !StringUtils.isEmpty(msg.getHeader("Message-ID")[0])) { mail.setMsgId(msg.getHeader("Message-ID")[0]); } else { mail.setMsgId(getOriginalMessageId(msg)); } } public Mail getMessage2Mail(int idx, Message msg, boolean containBody) throws MessagingException, UnsupportedEncodingException, IOException { Mail mail = new Mail(); mail.setIdx(idx); mail.setSubject(""); try { mail.setSubject(decodeMime(msg.getSubject())); } catch (Exception ex) { mail.setSubject(msg.getSubject()); } mail.setFromaddr(address2Str(msg.getFrom())); mail.setCcaddr(address2Str(msg.getRecipients(Message.RecipientType.CC))); mail.setBccaddr(address2Str(msg.getRecipients(Message.RecipientType.BCC))); mail.setReplyto(address2Str(msg.getReplyTo())); if (containBody) { try { mail.setBody(getTextMessage(msg.getContent())); } catch (Exception ex) { mail.setBody(""); } try { List attachFiles = new ArrayList(); if (!(msg.getContent() instanceof String)) { Multipart part = (Multipart) msg.getContent(); for (int i = 0; i < part.getCount(); i++) { BodyPart body = part.getBodyPart(i); if (!body.getContentType().toUpperCase().startsWith("TEXT/")) { AttachFile af = new AttachFile(); af.setUrl("folder=" + msg.getFolder().getName() + "&msgNo=" + msg.getMessageNumber() + "&partNo=" + i); af.setName(getAttachFilename(FileDownloader.getFileName(body))); attachFiles.add(af); } } AttachFile[] arryAttach = new AttachFile[attachFiles.size()]; for (int i = 0; i < arryAttach.length; i++) { arryAttach[i] = attachFiles.get(i); } mail.setAttachFile(arryAttach); } } catch (Exception ex) { // 解釈不能なENCODINGはムシ } msg.setFlag(Flags.Flag.SEEN, true); } mail.setSendDate(msg.getSentDate()); setMsgId(mail, msg); return mail; } public BaseResult getMail(Member loginMember, int mailSettingId, String folderName, int idx) throws MessagingException, IOException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder target = getTargetFolder(loginMember, mailSettingId, folderName); target.open(Folder.READ_ONLY); try { Message msg = target.getMessage(idx); result.setResult(getMessage2Mail(idx, msg, true)); return result; } finally { target.close(false); } } public BaseResult listMails(Member loginMember, int mailSettingId, String folderName, boolean containBody) throws MessagingException, IOException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder target = getTargetFolder(loginMember, mailSettingId, folderName); target.open(Folder.READ_ONLY); Mail[] resMails = null; try { Message[] msgs = target.getMessages(); if (!containBody) { FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.FLAGS); target.fetch(msgs, fp); } int validMail = 0; for (int i = 0; i < msgs.length; i++) { if (!msgs[i].getFlags().contains(Flags.Flag.DELETED)) { validMail++; } } resMails = new Mail[validMail]; validMail = 0; for (int i = 0; i < msgs.length; i++) { if (!msgs[i].getFlags().contains(Flags.Flag.DELETED)) { resMails[validMail] = getMessage2Mail(i, msgs[i], containBody); validMail++; } } } finally { target.close(false); } result.setResult(resMails); return result; } private Session getSMTPSession(Member member, MailSetting mailSetting) throws MessagingException { Properties props = System.getProperties(); props.put("mail.smtp.host", mailSetting.getSmtpHost()); Session smtp_session = Session.getDefaultInstance(props, null); return smtp_session; } private MimeMessage getNewMessage(Member member, MailSetting mailSetting) throws MessagingException { Session smtp_session = getSMTPSession(member, mailSetting); MimeMessage msg = new MimeMessage(smtp_session); return msg; } private static InternetAddress[] parseStrAddress(String[] addr_s) throws Exception { InternetAddress[] addr = new InternetAddress[addr_s.length]; Pattern addr_regex = Pattern.compile("(.+)<(.+)>"); for (int i = 0; i < addr.length; i++) { Matcher matcher = addr_regex.matcher(addr_s[i]); if (matcher.matches()) { addr[i] = new InternetAddress(matcher.group(2), MimeUtility.encodeText(matcher.group(1), "iso-2022-jp", "B")); } else { addr[i] = new InternetAddress(addr_s[i]); } } return addr; } private Multipart setAttachFile(MimeMessage msg, File dir) throws Exception { File[] attach_files = dir.listFiles(); Multipart mp = null; for (int i = 0; attach_files != null && i < attach_files.length; i++) { if (mp == null) mp = new MimeMultipart(); MimeBodyPart part = new MimeBodyPart(); part.setDataHandler(new DataHandler( new FileDataSource(attach_files[i]))); String attachName = Util.decodeHex(attach_files[i].getName()); part.setFileName(MimeUtility.encodeText(attachName, "iso-2022-jp", "B")); mp.addBodyPart(part); } return mp; } public BaseResult send(Member loginMember, int mailSettingId, Mail mail) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } MailSetting setting = getMailSetting(loginMember.getId(), mailSettingId); MimeMessage new_msg = getNewMessage(loginMember, setting); new_msg.setFrom(new InternetAddress(setting.getEmail())); new_msg.setRecipients(Message.RecipientType.TO, parseStrAddress(mail.getToaddr())); new_msg.setRecipients(Message.RecipientType.CC, parseStrAddress(mail.getCcaddr())); new_msg.setRecipients(Message.RecipientType.BCC, parseStrAddress(mail.getBccaddr())); new_msg.setSubject(mail.getSubject(), "ISO-2022-JP"); File attachDir = new File(Config.getProperty("mail.attach.dir"), "" + loginMember.getId()); attachDir = new File(attachDir, mail.getAttachFileKey()); Multipart mp = setAttachFile(new_msg, attachDir); if (mp == null) { new_msg.setDataHandler(new DataHandler(new ByteArrayDataSource(mail.getBody(), "text/plain; charset=ISO-2022-JP" ))); new_msg.setHeader("Content-Transfer-Encoding", "7bit"); } else { MimeBodyPart mainMsg = new MimeBodyPart(); mainMsg.setDataHandler(new DataHandler(new ByteArrayDataSource(mail.getBody(), "text/plain; charset=ISO-2022-JP" ))); mainMsg.setHeader("Content-Transfer-Encoding", "7bit"); mp.addBodyPart(mainMsg); new_msg.setContent(mp); } Transport.send(new_msg); String sended = setting.getMailSendedFolder(); if (!StringUtils.isEmpty(sended)) { Folder sended_mbox = getTargetFolder(loginMember, mailSettingId, sended); if (sended_mbox.exists()) { new_msg.setSentDate(new Date()); new_msg.setFlag(Flags.Flag.SEEN, true); Message[] new_msgs = {new_msg}; sended_mbox.appendMessages(new_msgs); } else { result.setStatusCode(1); return result; } } FileUtils.deleteDirectory(attachDir); return result; } public Message[] msgId2MsgNo(Folder searchTarget, String[] msgIds) throws MessagingException { return searchTarget.search(new MessageIdSearchTerm(msgIds)); } public BaseResult deleteMail(Member loginMember, int mailSettingId, String folderName, String[] msgIds) throws javax.mail.MessagingException, IllegalArgumentException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder folder_from = getTargetFolder(loginMember, mailSettingId, folderName); Folder folder_to = getTargetFolder(loginMember, mailSettingId, "Trash"); if (folder_to != null && !folder_to.exists()) { result.setStatusCode(1); return result; } try { folder_from.open(Folder.READ_WRITE); Message[] msgs = msgId2MsgNo(folder_from, msgIds); if (folder_to != null && !folder_from.getName().equals(folder_to.getName())) { folder_to.open(Folder.READ_WRITE); folder_from.copyMessages(msgs, folder_to); } for (int i = 0; i < msgs.length; i++) { msgs[i].setFlag(Flags.Flag.DELETED, true); } } finally { folder_from.close(true); if (folder_to != null && folder_to.isOpen()) folder_to.close(false); } return result; } public BaseResult moveMail(Member loginMember, int mailSettingId, String mb_from, String mb_to, String[] msgIds) throws javax.mail.MessagingException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder folder_from = getTargetFolder(loginMember, mailSettingId, mb_from); Folder folder_to = getTargetFolder(loginMember, mailSettingId, mb_to); if (folder_from.getFullName().equals(folder_to.getFullName())) { return result; } try { folder_from.open(Folder.READ_WRITE); folder_to.open(Folder.READ_WRITE); Message[] msgs = msgId2MsgNo(folder_from, msgIds); folder_from.copyMessages(msgs, folder_to); for (int i = 0; i < msgs.length; i++) msgs[i].setFlag(Flags.Flag.DELETED, true); } finally { folder_from.close(true); folder_to.close(false); } return result; } public BaseResult createAttachFileKey(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(com.kickmogu.Util.createPassword(20)); return result; } public BaseResult addFolder(Member loginMember, String parent, String newName, int mailSettingId) throws javax.mail.MessagingException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder parentFolder = getTargetFolder(loginMember, mailSettingId, parent); Folder newFolder = parentFolder.getFolder(newName); newFolder.create(Folder.HOLDS_FOLDERS + Folder.HOLDS_MESSAGES); return result; } public BaseResult deleteFolder(Member loginMember, String deleteName, int mailSettingId) throws javax.mail.MessagingException { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Folder targetFolder = getTargetFolder(loginMember, mailSettingId, deleteName); targetFolder.delete(true); return result; } } src/com/kickmogu/rhythm/timecard/Timecard.java100644 0 0 4404 10710110426 17053 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/04 * */ package com.kickmogu.rhythm.timecard; import java.util.Date; public class Timecard { public final static String UNIQ_KEYNAME = "rhtym timecard id"; private int id; private int registrant; private Date inTime; private Date outTime; private String inIpaddr; private String outIpaddr; /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return inTime を戻します。 */ public Date getInTime() { return inTime; } /** * @param inTime inTime を設定。 */ public void setInTime(Date inTime) { this.inTime = inTime; } /** * @return outTime を戻します。 */ public Date getOutTime() { return outTime; } /** * @param outTime outTime を設定。 */ public void setOutTime(Date outTime) { this.outTime = outTime; } /** * @return registrant を戻します。 */ public int getRegistrant() { return registrant; } /** * @param registrant registrant を設定。 */ public void setRegistrant(int registrant) { this.registrant = registrant; } /** * @return inIpaddr を戻します。 */ public String getInIpaddr() { return inIpaddr; } /** * @param inIpaddr inIpaddr を設定。 */ public void setInIpaddr(String inIpaddr) { this.inIpaddr = inIpaddr; } /** * @return outIpaddr を戻します。 */ public String getOutIpaddr() { return outIpaddr; } /** * @param outIpaddr outIpaddr を設定。 */ public void setOutIpaddr(String outIpaddr) { this.outIpaddr = outIpaddr; } } src/com/kickmogu/rhythm/timecard/TimecardSummary.java100644 0 0 7051 10710110426 20432 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/17 * */ package com.kickmogu.rhythm.timecard; public class TimecardSummary { private int totalWorkMinutes; private int totalRestMinutes; private int totalSalariedMinutes; // 時給 private int salaryPerHour; // 源泉前基本給与 private int basicSalary; // 源泉額 private int incomeTax; // 交通費対象日数 private int transExpensesDay; // 交通費 private int transExpenses; // 支給額 private int finalSalary; /** * @return basicSalary を戻します。 */ public int getBasicSalary() { return basicSalary; } /** * @param basicSalary basicSalary を設定。 */ public void setBasicSalary(int basicSalary) { this.basicSalary = basicSalary; } /** * @return finalSalary を戻します。 */ public int getFinalSalary() { return finalSalary; } /** * @param finalSalary finalSalary を設定。 */ public void setFinalSalary(int finalSalary) { this.finalSalary = finalSalary; } /** * @return incomeTax を戻します。 */ public int getIncomeTax() { return incomeTax; } /** * @param incomeTax incomeTax を設定。 */ public void setIncomeTax(int incomeTax) { this.incomeTax = incomeTax; } /** * @return salaryPerHour を戻します。 */ public int getSalaryPerHour() { return salaryPerHour; } /** * @param salaryPerHour salaryPerHour を設定。 */ public void setSalaryPerHour(int salaryPerHour) { this.salaryPerHour = salaryPerHour; } /** * @return totalRestMinutes を戻します。 */ public int getTotalRestMinutes() { return totalRestMinutes; } /** * @param totalRestMinutes totalRestMinutes を設定。 */ public void setTotalRestMinutes(int totalRestMinutes) { this.totalRestMinutes = totalRestMinutes; } /** * @return totalSalariedMinutes を戻します。 */ public int getTotalSalariedMinutes() { return totalSalariedMinutes; } /** * @param totalSalariedMinutes totalSalariedMinutes を設定。 */ public void setTotalSalariedMinutes(int totalSalariedMinutes) { this.totalSalariedMinutes = totalSalariedMinutes; } /** * @return totalWorkMinutes を戻します。 */ public int getTotalWorkMinutes() { return totalWorkMinutes; } /** * @param totalWorkMinutes totalWorkMinutes を設定。 */ public void setTotalWorkMinutes(int totalWorkMinutes) { this.totalWorkMinutes = totalWorkMinutes; } /** * @return transExpenses を戻します。 */ public int getTransExpenses() { return transExpenses; } /** * @param transExpenses transExpenses を設定。 */ public void setTransExpenses(int transExpenses) { this.transExpenses = transExpenses; } /** * @return transExpensesDay を戻します。 */ public int getTransExpensesDay() { return transExpensesDay; } /** * @param transExpensesDay transExpensesDay を設定。 */ public void setTransExpensesDay(int transExpensesDay) { this.transExpensesDay = transExpensesDay; } } src/com/kickmogu/rhythm/timecard/dao/TimecardDao.java100644 0 0 3104 10710110426 20236 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.timecard.dao; import com.kickmogu.rhythm.timecard.*; import java.util.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public interface TimecardDao { public Class BEAN = Timecard.class; public static final String getTimecard_QUERY = "id = ?"; public static final String listTimecards_QUERY = "registrant = ? and intime between ? and ?"; public int update(Timecard tm); public int insert(Timecard tm); public int delete(Timecard tm); public Timecard getTimecard(int id); public Timecard[] listTimecards(int registrant, Date fromDate, Date toDate); } src/com/kickmogu/rhythm/timecard/schema/timecard.sql100644 0 0 235 10534760304 20221 0ustar 0 0 create table Timecard ( id int not null, registrant int not null, intime Timestamp not null, outtime Timestamp, primary key(id)); src/com/kickmogu/rhythm/timecard/ws/TimecardWs.java100644 0 0 13234 10710110426 20037 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/04 * */ package com.kickmogu.rhythm.timecard.ws; import java.util.*; import com.kickmogu.Config; import com.kickmogu.rhythm.core.BaseResult; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.core.dao.MemberDao; import com.kickmogu.rhythm.timecard.*; import com.kickmogu.rhythm.timecard.dao.*; import com.kickmogu.s2.DAOSequence; import com.kickmogu.s2.S2Util; import org.apache.axis.Constants; import org.apache.axis.MessageContext; import org.apache.commons.lang.time.DateUtils; public class TimecardWs { TimecardDao tmdao = (TimecardDao) S2Util.getS2Container().getComponent(TimecardDao.class); MemberDao memdao = (MemberDao) S2Util.getS2Container().getComponent(MemberDao.class); private Timecard getCurrentTimecard(Member loginMember) { Calendar now = Calendar.getInstance(); if (now.get(Calendar.HOUR_OF_DAY) < Integer.parseInt(Config.getProperty("timecard.daySplitHour"))) { now.add(Calendar.DATE, -1); } now = DateUtils.truncate(now, Calendar.DATE); now.set(Calendar.HOUR_OF_DAY, Integer.parseInt(Config.getProperty("timecard.daySplitHour"))); Date fromDate = now.getTime(); now.add(Calendar.DATE, 1); Date toDate = now.getTime(); Timecard[] target = (Timecard[]) list(loginMember, loginMember.getId(), fromDate, toDate).getResult(); return target != null && target.length >= 1 ? target[0] : null; } public BaseResult beginWork(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Timecard target = getCurrentTimecard(loginMember); if (target != null) { return result; } Timecard tm = new Timecard(); tm.setId(DAOSequence.getNextId(Timecard.UNIQ_KEYNAME)); tm.setRegistrant(loginMember.getId()); tm.setInTime(new Date()); MessageContext context = MessageContext.getCurrentContext(); tm.setInIpaddr(context.getStrProp(Constants.MC_REMOTE_ADDR)); tmdao.insert(tm); return result; } public BaseResult endWork(Member loginMember) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Timecard target = getCurrentTimecard(loginMember); target.setOutTime(new Date()); MessageContext context = MessageContext.getCurrentContext(); target.setOutIpaddr(context.getStrProp(Constants.MC_REMOTE_ADDR)); tmdao.update(target); return result; } public void update(Timecard tm) { tmdao.update(tm); } public void delete(Timecard tm) { tmdao.delete(tm); } public Timecard getById(int id) { return tmdao.getTimecard(id); } private int getTrafficPay(int trfc_exp, int trfc_type, int workday) { return trfc_type == 0 ? trfc_exp * workday : trfc_exp; } public BaseResult calcSalary(Member loginMember, int targetMemberId, Date fromDate, Date toDate) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Member targetMember = memdao.getMember(targetMemberId); Timecard[] tm = tmdao.listTimecards(targetMember.getId(), fromDate, toDate); int workDays = 0; int workTotal = 0, restTotal = 0; for (int i = 0; i < tm.length; i++) { if (tm[i].getOutTime() == null) { continue; } Calendar cal = Calendar.getInstance(); cal.setTime(tm[i].getInTime()); int inmin = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE); cal.setTime(tm[i].getOutTime()); int outmin = 0; if (cal.get(Calendar.HOUR_OF_DAY) >= Integer.parseInt(Config.getProperty("timecard.daySplitHour"))) { outmin = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE); } else { outmin = (24 + cal.get(Calendar.HOUR_OF_DAY)) * 60 + cal.get(Calendar.MINUTE); } workTotal += (outmin - inmin); if ((outmin - inmin) > 6 * 60) { workTotal -= targetMember.getRestMinutes(); restTotal += targetMember.getRestMinutes(); } workDays++; } workTotal = workTotal / 15 * 15; TimecardSummary tsmry = new TimecardSummary(); tsmry.setTotalWorkMinutes(workTotal + restTotal); tsmry.setTotalRestMinutes(restTotal); tsmry.setTotalSalariedMinutes(workTotal); tsmry.setSalaryPerHour(targetMember.getPayHour()); tsmry.setBasicSalary(tsmry.getSalaryPerHour() * tsmry.getTotalSalariedMinutes() / 60); tsmry.setTransExpensesDay(workDays); tsmry.setTransExpenses(getTrafficPay(targetMember.getTrafficExpenses(), targetMember.getTrafficExpensesKind(), tsmry.getTransExpensesDay())); result.setResult(tsmry); return result; } public BaseResult list(Member loginMember, int targetMemberId, Date fromDate, Date toDate) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(tmdao.listTimecards(targetMemberId, fromDate, toDate)); return result; } public BaseResult getSplitHour() { BaseResult result = new BaseResult(); result.setResult(Integer.parseInt(Config.getProperty("timecard.daySplitHour"))); return result; } public void wsdldummy(Timecard tm, TimecardSummary tsmry) { } } src/com/kickmogu/rhythm/todo/Todo.java100644 0 0 13560 10710110426 15430 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/18 * */ package com.kickmogu.rhythm.todo; import java.util.*; import com.kickmogu.rhythm.core.BaseBean; public class Todo extends BaseBean { public final static int KIND_TODO = 0; public final static int KIND_CALENDAR = 1; public final static int LOOP_UNIT_NONE = 0; public final static int LOOP_UNIT_DAY = 1; public final static int LOOP_UNIT_WEEK = 2; public final static int LOOP_UNIT_MONTH = 3; public final static int LOOP_UNIT_YEAR = 4; public final static String PERM_ALL = "TODO_ALL"; public final static String PERM_VIEW = "TODO_VIEW"; public final static String PERM_WRITE = "TODO_WRITE"; public final static String PERM_MANAGE = "TODO_MANAGE"; public final static String CALENDAR_ALL = "CALENDAR_ALL"; public final static String CALENDAR_VIEW = "CALENDAR_VIEW"; public final static String CALENDAR_WRITE = "CALENDAR_WRITE"; public final static String CALENDAR_MANAGE = "CALENDAR_MANAGE"; public final static String UNIQ_KEYNAME = "rhtym todo id"; private int kind; private int seq; private int depth; private int rootId; private String subject; private String body; // 発言しているカテゴリのID private int todoTreeId; private Date planFromDate; private Date planToDate; private int loopUnit; private int loopInterval; private Date loopTarget; private int loopCount; private boolean complete; // 繰り返し設定されたTODOの元TODOを示す private int parentId; // 検索者の権限 private int myRole; // 公開フラグ private boolean open; /** * @return body を戻します。 */ public String getBody() { return body; } /** * @param body body を設定。 */ public void setBody(String body) { this.body = body; } /** * @return depth を戻します。 */ public int getDepth() { return depth; } /** * @param depth depth を設定。 */ public void setDepth(int depth) { this.depth = depth; } /** * @return rootId を戻します。 */ public int getRootId() { return rootId; } /** * @param rootId rootId を設定。 */ public void setRootId(int rootId) { this.rootId = rootId; } /** * @return seq を戻します。 */ public int getSeq() { return seq; } /** * @param seq seq を設定。 */ public void setSeq(int seq) { this.seq = seq; } /** * @return subject を戻します。 */ public String getSubject() { return subject; } /** * @param subject subject を設定。 */ public void setSubject(String subject) { this.subject = subject; } /** * @return boardTreeId を戻します。 */ public int getTodoTreeId() { return todoTreeId; } /** * @param boardTreeId boardTreeId を設定。 */ public void setTodoTreeId(int boardTreeId) { this.todoTreeId = boardTreeId; } /** * @return planFromDate を戻します。 */ public Date getPlanFromDate() { return planFromDate; } /** * @param planFromDate planFromDate を設定。 */ public void setPlanFromDate(Date planFromDate) { this.planFromDate = planFromDate; } /** * @return planToDate を戻します。 */ public Date getPlanToDate() { return planToDate; } /** * @param planToDate planToDate を設定。 */ public void setPlanToDate(Date planToDate) { this.planToDate = planToDate; } /** * @return complete を戻します。 */ public boolean isComplete() { return complete; } /** * @param complete complete を設定。 */ public void setComplete(boolean complete) { this.complete = complete; } /** * @return loopCount を戻します。 */ public int getLoopCount() { return loopCount; } /** * @param loopCount loopCount を設定。 */ public void setLoopCount(int loopCount) { this.loopCount = loopCount; } /** * @return loopInterval を戻します。 */ public int getLoopInterval() { return loopInterval; } /** * @param loopInterval loopInterval を設定。 */ public void setLoopInterval(int loopInterval) { this.loopInterval = loopInterval; } /** * @return loopTarget を戻します。 */ public Date getLoopTarget() { return loopTarget; } /** * @param loopTarget loopTarget を設定。 */ public void setLoopTarget(Date loopTarget) { this.loopTarget = loopTarget; } /** * @return loopUnit を戻します。 */ public int getLoopUnit() { return loopUnit; } /** * @param loopUnit loopUnit を設定。 */ public void setLoopUnit(int loopUnit) { this.loopUnit = loopUnit; } /** * @return parentId を戻します。 */ public int getParentId() { return parentId; } /** * @param parentId parentId を設定。 */ public void setParentId(int parentId) { this.parentId = parentId; } /** * @return kind を戻します。 */ public int getKind() { return kind; } /** * @param kind kind を設定。 */ public void setKind(int kind) { this.kind = kind; } /** * @return myRole を戻します。 */ public int getMyRole() { return myRole; } /** * @param myRole myRole を設定。 */ public void setMyRole(int myRole) { this.myRole = myRole; } /** * @return open を戻します。 */ public boolean isOpen() { return open; } /** * @param open open を設定。 */ public void setOpen(boolean open) { this.open = open; } } src/com/kickmogu/rhythm/todo/TodoTree.java100644 0 0 1572 10710110426 16230 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/05 * */ package com.kickmogu.rhythm.todo; import com.kickmogu.rhythm.core.PermissionTarget; public class TodoTree extends PermissionTarget { public final static String UNIQ_KEYNAME = "rhtym todotree id"; } src/com/kickmogu/rhythm/todo/TodoWorker.java100644 0 0 4134 10710110426 16577 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/31 * */ package com.kickmogu.rhythm.todo; public class TodoWorker { public static final String insert_NO_PERSISTENT_PROPS = "memberName"; public final static String UNIQ_KEYNAME = "rhtym todoworker id"; public final static int KIND_MEMBER = 1; public final static int KIND_MANAGER = 2; private int id; private int todoId; private int kind; private int memberId; private String memberName; /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return kind を戻します。 */ public int getKind() { return kind; } /** * @param kind kind を設定。 */ public void setKind(int kind) { this.kind = kind; } /** * @return memberId を戻します。 */ public int getMemberId() { return memberId; } /** * @param memberId memberId を設定。 */ public void setMemberId(int memberId) { this.memberId = memberId; } /** * @return todoId を戻します。 */ public int getTodoId() { return todoId; } /** * @param todoId todoId を設定。 */ public void setTodoId(int todoId) { this.todoId = todoId; } /** * @return memberName を戻します。 */ public String getMemberName() { return memberName; } /** * @param memberName memberName を設定。 */ public void setMemberName(String memberName) { this.memberName = memberName; } } src/com/kickmogu/rhythm/todo/dao/TodoDao.java100644 0 0 6106 10710110426 16575 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.todo.dao; import java.util.Date; import com.kickmogu.rhythm.todo.*; /** * @author mogu */ public interface TodoDao { public Class BEAN = Todo.class; public static final String BasicSql = "select Todo.*, Member.name as registrantName " + " , (select max(todoworker.kind) from todoworker where todoid = todo.id and memberid=?) as myRole" + " from Todo, Member where deleted = 0 and "; public static final String JoinSql = " and Todo.registrant = Member.id"; public static final String listRootTodos_SQL = BasicSql + " kind = 0 and parentid = 0 and depth = 0 and todoTreeId = ? " + JoinSql + " order by rootId, seq"; public static final String listTodoThreads_SQL = BasicSql + " kind = 0 and parentid = 0 and rootId = ? " + JoinSql + " order by seq"; public static final String listTodoFlat_SQL = BasicSql + " planFromDate is not null and planToDate is not null and kind = 0 and parentid = 0 and rootId = ? " + JoinSql + " order by seq"; public static final String getTodo_SQL = BasicSql + "Todo.id = ?" + JoinSql; public static final String listSchedules_SQL = BasicSql + "((registrant in /*registrant*/('0', '2') and kind = 1 and open = true) or (kind = 0 and todoTreeId in /*todoTreeId*/('0','1') and open = true) " + " or (registrant = /*owner*/ and open = false))" + " and (planfromDate between /*fr1*/ and /*fr2*/ or plantoDate between /*to1*/ and /*to2*/) " + JoinSql; public static final String listSchedules_ARGS = "searcherId,registrant,todoTreeId,owner,fr1,fr2,to1,to2"; public static final String listHolidays_SQL = "select -id as id, name as subject, day as planFromDate, day as planFromDate from holiday"; public int update(Todo todo); public int insert(Todo todo); public int delete(Todo todo); public Todo getTodo(int searcherId, int id); public Todo[] listRootTodos(int searcherId, int categoryId); public Todo[] listTodoThreads(int searcherId, int rootId); public Todo[] listTodoFlat(int searcherId, int rootId); public Todo[] listSchedules(int searcherId, int[] registrant, int[] todoTreeId, int owner, Date fromDate, Date fromDate2, Date toDate, Date toDate2); public Todo[] listHolidays(); } src/com/kickmogu/rhythm/todo/dao/TodoWorkerDao.java100644 0 0 3241 10710110426 17764 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.rhythm.todo.dao; import com.kickmogu.rhythm.todo.*; /** * @author mogu */ public interface TodoWorkerDao { public Class BEAN = TodoWorker.class; public static final String BasicSql = "select TodoWorker.*, Member.name as memberName from TodoWorker, Member where "; public static final String JoinSql = " and TodoWorker.memberId = Member.id"; public static final String getTodoWorker_SQL = BasicSql + " TodoWorker.id = ? " + JoinSql; public static final String listTodoWorkers_SQL = BasicSql + " todoid = ? " + JoinSql + " order by TodoWorker.kind desc"; public int update(TodoWorker todowk); public int insert(TodoWorker todowk); public int delete(TodoWorker todowk); public TodoWorker getTodoWorker(int id); public TodoWorker[] listTodoWorkers(int todoid); } src/com/kickmogu/rhythm/todo/test/TodoTest.java100644 0 0 5015 10710110426 17223 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/29 * */ package com.kickmogu.rhythm.todo.test; import java.util.*; import com.kickmogu.core.Utils; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.core.ws.MemberWs; import com.kickmogu.rhythm.todo.*; import com.kickmogu.rhythm.todo.dao.TodoDao; import com.kickmogu.rhythm.todo.ws.*; import com.kickmogu.s2.S2Util; import jp.co.dgic.testing.framework.DJUnitTestCase; public class TodoTest extends DJUnitTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void test001() throws Exception { System.out.println("------------読み込み直後のTree------------"); TodoWs ws = new TodoWs(); MemberWs memWs = new MemberWs(); Member member = (Member) memWs.authorize("mogu", "hfc01415").getResult(); Date now = new Date(); Date fromDate = new Date(0); Todo[] result = (Todo[]) ws.listSchedules(member, fromDate, now).getResult(); for (int i = 0; i < result.length; i++) { System.out.println("Todo:" + result[i].getSubject()); } } public void test002() throws Exception { System.out.println("------------Todo のXML表現------------"); TodoWs ws = new TodoWs(); MemberWs memWs = new MemberWs(); Member member = (Member) memWs.authorize("mogu", "hfc01415").getResult(); System.out.println(ws.listCategoryAllTodos(member, 321).getResult()); } public void test003() throws Exception { System.out.println("------------Todo workers配列の表現------------"); TodoDao tododao = (TodoDao) S2Util.getS2Container().getComponent(TodoDao.class); Todo todo = tododao.getTodo(0, 49); System.out.println("Todo:" + Utils.dumpBean(todo)); } static public void main(String[] arg) throws Exception { } } src/com/kickmogu/rhythm/todo/ws/FastScheduleList.java100644 0 0 4773 10710110426 20350 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/15 * */ package com.kickmogu.rhythm.todo.ws; import java.util.Date; import java.util.List; import java.util.Map; import com.kickmogu.rhythm.core.BaseResult; import com.kickmogu.rhythm.core.HttpCmdAction; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.core.dao.MemberDao; import com.kickmogu.rhythm.todo.Todo; import com.kickmogu.s2.S2Util; import org.apache.commons.lang.StringUtils; public class FastScheduleList implements HttpCmdAction { public BaseResult listSchedules(Member loginMember, Date fromDate, Date toDate) throws Exception { TodoWs todoWs = new TodoWs(); BaseResult result = todoWs.listSchedules(loginMember, fromDate, toDate); if (result.getStatusCode() != 0) { return result; } StringBuffer out = new StringBuffer(); List todos = (List) result.getResult(); for (int i = 0; i < todos.size(); i++) { out.append(StringUtils.join(new String[] { "" + todos.get(i).getId(), todos.get(i).getSubject(), todos.get(i).getPlanFromDate() == null ? "" : "" + todos.get(i).getPlanFromDate().getTime(), todos.get(i).getPlanToDate() == null ? "" : "" + todos.get(i).getPlanToDate().getTime(), }, "\t") + "\n"); } result.setResult(out.toString()); return result; } public BaseResult doAction(Map params) throws Exception { int memberId = Integer.parseInt(params.get("memberId")[0]); MemberDao memdao = (MemberDao) S2Util.getS2Container().getComponent(MemberDao.class); Member member = memdao.getMember(memberId); member.setSessionId(params.get("sessionId")[0]); Date fromDate = new Date(); fromDate.setTime(Long.parseLong(params.get("fromDate")[0])); Date toDate = new Date(); toDate.setTime(Long.parseLong(params.get("toDate")[0])); return listSchedules(member, fromDate, toDate); } } src/com/kickmogu/rhythm/todo/ws/TodoWs.java100644 0 0 35455 10710110426 16402 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2006/12/18 * */ package com.kickmogu.rhythm.todo.ws; import java.util.List; import java.util.HashMap; import java.util.Map; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.Calendar; import java.lang.reflect.InvocationTargetException; import java.sql.*; import java.text.SimpleDateFormat; import org.apache.commons.beanutils.BeanUtils; import org.apache.log4j.Category; import com.kickmogu.core.XmlUtils; import com.kickmogu.rhythm.todo.*; import com.kickmogu.rhythm.core.*; import com.kickmogu.rhythm.core.dao.MemberDao; import com.kickmogu.rhythm.todo.dao.TodoDao; import com.kickmogu.rhythm.todo.dao.TodoWorkerDao; import com.kickmogu.s2.DAOSequence; import com.kickmogu.s2.S2Util; public class TodoWs { private static Map> holidayMaster = new HashMap>(); private static SimpleDateFormat monthDt = new SimpleDateFormat("yyyyMM"); TodoDao tododao = (TodoDao) S2Util.getS2Container().getComponent(TodoDao.class); TodoWorkerDao workerdao = (TodoWorkerDao) S2Util.getS2Container().getComponent(TodoWorkerDao.class); MemberDao memdao = (MemberDao) S2Util.getS2Container().getComponent(MemberDao.class); static Category log = Category.getInstance(TodoWs.class.getName()); public BaseResult addNode(Member loginMember, String name, int parentId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } TodoTree todotree = new TodoTree(); todotree.setId(DAOSequence.getNextId(TodoTree.UNIQ_KEYNAME)); todotree.setName(name); TodoTree parent = (TodoTree) RhythmTreeManager.getRoot(TodoTree.class).search(parentId); if (parent == null) { result.setStatusCode(100); return result; } todotree.addToParent(parent); RhythmTreeManager.write(TodoTree.class); result.setResult(todotree.getId()); return result; } public BaseResult removeNode(Member loginMember, int targetId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } TodoTree todoTree = (TodoTree) RhythmTreeManager.getRoot(TodoTree.class).search(targetId); todoTree.remove(); RhythmTreeManager.write(TodoTree.class); result.setResult(todoTree.getId()); return result; } public BaseResult updateNode(Member loginMember, int targetId, String newName) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } TodoTree todoTree = (TodoTree) RhythmTreeManager.getRoot(TodoTree.class).search(targetId); todoTree.setName(newName); RhythmTreeManager.write(TodoTree.class); result.setResult(todoTree.getId()); return result; } public BaseResult post(Member loginMember, int categoryId, Todo todo) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } todo.setId(DAOSequence.getNextId(Todo.UNIQ_KEYNAME)); todo.setRegistrant(loginMember.getId()); todo.setRootId(todo.getId()); todo.setTodoTreeId(categoryId); todo.setRegistDate(new Date()); tododao.insert(todo); deleteExtractLoopTodo(todo); doExtractLoopTodo(todo); result.setResult(todo); log.info("post todo:" + todo.getId() + "," + todo.getSubject()); return result; } public BaseResult reply(Member loginMember, int parentId, Todo todo) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Todo parentTodo = tododao.getTodo(loginMember.getId(), parentId); int newSeq = getChildMaxSeq(parentTodo.getRootId(), parentTodo.getSeq(), parentTodo.getDepth()) + 1; updateThreadSeq(parentTodo.getRootId(), newSeq); todo.setId(DAOSequence.getNextId(Todo.UNIQ_KEYNAME)); todo.setRegistrant(loginMember.getId()); todo.setRootId(parentTodo.getRootId()); todo.setSeq(newSeq); todo.setDepth(parentTodo.getDepth() + 1); todo.setTodoTreeId(parentTodo.getTodoTreeId()); todo.setRegistDate(new Date()); tododao.insert(todo); deleteExtractLoopTodo(todo); doExtractLoopTodo(todo); result.setResult(todo); log.info("reply todo:" + todo.getId() + "," + parentId + "," + todo.getSubject()); return result; } public BaseResult addWorker(Member loginMember, int todoId, int memberId, int kind) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } TodoWorker worker = new TodoWorker(); worker.setId(DAOSequence.getNextId(TodoWorker.UNIQ_KEYNAME)); worker.setTodoId(todoId); worker.setMemberId(memberId); worker.setKind(kind); workerdao.insert(worker); result.setResult(worker); return result; } public BaseResult removeWorker(Member loginMember, int workerId) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } TodoWorker worker = workerdao.getTodoWorker(workerId); workerdao.delete(worker); result.setResult(worker); return result; } public BaseResult setWorkerKind(Member loginMember, int workerId, int newKind) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } TodoWorker worker = workerdao.getTodoWorker(workerId); worker.setKind(newKind); workerdao.update(worker); result.setResult(worker); return result; } public BaseResult listRootTodos(Member loginMember, int categoryId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(tododao.listRootTodos(loginMember.getId(), categoryId)); return result; } public BaseResult listCategoryAllTodos(Member loginMember, int categoryId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Todo[] rootTodos = tododao.listRootTodos(loginMember.getId(), categoryId); StringBuffer tags = new StringBuffer(); for (int i = 0; i < rootTodos.length; i++) { tags.append(listTodoThreads(loginMember, rootTodos[i].getId()).getResult() + "\n"); } result.setResult(tags.toString()); return result; } public BaseResult getTodo(Member loginMember, int todoId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(tododao.getTodo(loginMember.getId(), todoId)); return result; } private int getChildMaxSeq(int rootId, int seq, int depth) throws Exception { int maxSeq = seq; Connection conn = S2Util.getConnection(); PreparedStatement ps = conn.prepareStatement("select seq, depth from todo where deleted = 0 and rootId = ? and seq > ? order by seq"); try { ps.setInt(1, rootId); ps.setInt(2, seq); ResultSet rs = ps.executeQuery(); while (rs.next()) { if (depth >= rs.getInt("depth")) { break; } maxSeq = rs.getInt("seq"); } } finally { ps.close(); conn.close(); } return maxSeq; } private void updateThreadSeq(int rootId, int seq) throws Exception { Connection conn = S2Util.getConnection(); PreparedStatement ps = conn.prepareStatement("update todo set seq = seq + 1 where deleted = 0 and rootId = ? and seq >= ?"); try { ps.setInt(1, rootId); ps.setInt(2, seq); ps.execute(); } finally { ps.close(); conn.close(); } } private String toTodoXmlTag(Todo todo) { try { return ""; } catch (Exception e) { e.printStackTrace(); } return null; } /** * 特定のThreadの親子関係を含めたXML形式文字列を返す * @param loginMember * @param rootId * @return */ public BaseResult listTodoThreads(Member loginMember, int rootId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Todo[] threads = tododao.listTodoThreads(loginMember.getId(), rootId); StringBuffer out = new StringBuffer(); int beforeDepth = -1; for (int i = 0; i < threads.length; i++) { if (beforeDepth < threads[i].getDepth()) { for (int j = 0; j < threads[i].getDepth() - beforeDepth; j++) { out.append(toTodoXmlTag(threads[i]) + "\n"); } } else { for (int j = 0; j < beforeDepth - threads[i].getDepth() + 1; j++) { out.append("\n"); } out.append(toTodoXmlTag(threads[i]) + "\n"); } beforeDepth = threads[i].getDepth(); } for (int j = 0; j < beforeDepth + 1; j++) { out.append("\n"); } result.setResult(out.toString()); return result; } /** * 特定のThreadの親子関係を含めたXML形式文字列を返す * @param loginMember * @param rootId * @return */ public BaseResult listTodoFlat(Member loginMember, int categoryId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Todo[] rootTodos = tododao.listRootTodos(loginMember.getId(), categoryId); List todos = new ArrayList(); for (int i = 0; i < rootTodos.length; i++) { todos.addAll(Arrays.asList(tododao.listTodoFlat(loginMember.getId(), rootTodos[i].getId()))); } result.setResult(todos); return result; } public BaseResult listWorkers(Member loginMember, int todoid) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } result.setResult(workerdao.listTodoWorkers(todoid)); return result; } public BaseResult remove(Member loginMember, int targetId) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } Todo targetTodo = tododao.getTodo(loginMember.getId(), targetId); List threads = Arrays.asList(tododao.listTodoThreads(loginMember.getId(), targetTodo.getRootId())); int idx = threads.indexOf(targetTodo); if (idx == -1) { log.info("remove todo not found:" + targetTodo.getId() + "," + threads.size()); result.setStatusCode(100); return result; } for (int i = idx + 1; i < threads.size(); i++) { if (targetTodo.getDepth() >= threads.get(i).getDepth()) { break; } threads.get(i).setDeleted(1); tododao.update(threads.get(i)); } targetTodo.setDeleted(1); tododao.update(targetTodo); return result; } public BaseResult update(Member loginMember, Todo todo) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } tododao.update(todo); deleteExtractLoopTodo(todo); doExtractLoopTodo(todo); return result; } private void deleteExtractLoopTodo(Todo todo) throws Exception { Connection conn = S2Util.getConnection(); PreparedStatement ps = conn.prepareStatement("delete from todo where parentId = ?"); try { ps.setInt(1, todo.getId()); ps.execute(); } finally { ps.close(); conn.close(); } } private void doExtractLoopTodo(Todo todo) throws IllegalAccessException, InvocationTargetException { if (todo.getLoopUnit() == Todo.LOOP_UNIT_NONE) { return; } Calendar loopDate = Calendar.getInstance(); loopDate.setTime(todo.getLoopTarget()); for (int i = 0; i < todo.getLoopCount(); i++) { Todo loopTodo = new Todo(); BeanUtils.copyProperties(loopTodo, todo); loopTodo.setId(DAOSequence.getNextId(Todo.UNIQ_KEYNAME)); loopTodo.setParentId(todo.getId()); switch (todo.getLoopUnit()) { case Todo.LOOP_UNIT_DAY: loopDate.add(Calendar.DATE, todo.getLoopInterval()); break; case Todo.LOOP_UNIT_WEEK: loopDate.add(Calendar.DATE, todo.getLoopInterval() * 7); break; case Todo.LOOP_UNIT_MONTH: loopDate.add(Calendar.MONTH, todo.getLoopInterval()); break; case Todo.LOOP_UNIT_YEAR: loopDate.add(Calendar.YEAR, todo.getLoopInterval()); break; } loopTodo.setPlanFromDate(loopDate.getTime()); loopTodo.setPlanToDate(loopDate.getTime()); tododao.insert(loopTodo); } } public BaseResult listSchedules(Member loginMember, Date fromDate, Date toDate) throws Exception { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } List ptTree = loginMember.getAssignTarget(Todo.PERM_VIEW); List idcond = new ArrayList(); for (int i = 0; ptTree != null && i < ptTree.size(); i++) { List ptAll = ptTree.get(i).getAll(); for (int j = 0; j < ptAll.size(); j++) { idcond.add(ptAll.get(j).getId()); } } if (idcond.size() == 0) { result.setResult(new Todo[] {}); return result; } int[] intIds = new int[idcond.size()]; for (int i = 0; i < idcond.size(); i++) { intIds[i] = idcond.get(i); } List memidcond = new ArrayList(); List roles = loginMember.getAssignTarget(Todo.CALENDAR_VIEW); memidcond.add(loginMember.getId()); for (int i = 0; i < roles.size(); i++) { Member[] members = memdao.listMembers(roles.get(i).getId()); for (int j = 0; j < members.length; j++) { memidcond.add(members[j].getId()); } } int[] memIds = new int[memidcond.size()]; for (int i = 0; i < memidcond.size(); i++) { memIds[i] = memidcond.get(i); } // 休日マスタの読み込み if (holidayMaster.size() == 0) { readHolidays(); } List holiArray = holidayMaster.get(monthDt.format(fromDate)); holiArray = new ArrayList(holiArray != null ? holiArray : new ArrayList()); holiArray.addAll(Arrays.asList(tododao.listSchedules(loginMember.getId(), memIds, intIds, loginMember.getId(), fromDate, toDate, fromDate, toDate))); result.setResult(holiArray); return result; } private void readHolidays() { Todo[] holidays = tododao.listHolidays(); for (int i = 0; i < holidays.length; i++) { String yymm = monthDt.format(holidays[i].getPlanFromDate()); List holiArray = holidayMaster.get(yymm); if (holiArray == null) { holiArray = new ArrayList(); holidayMaster.put(yymm, holiArray); } holiArray.add(holidays[i]); } } public void wsdldummy(Todo todo, TodoWorker worker) { } } src/com/kickmogu/rhythm/util/WindowPos.java100644 0 0 5067 10710110426 16447 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/12 * */ package com.kickmogu.rhythm.util; public class WindowPos { public final static String UNIQ_KEYNAME = "rhtym WindowPos id"; private int id; private int memberId; private int x; private int y; private int height; private int width; private String windowName; private String optionXml; /** * @return height を戻します。 */ public int getHeight() { return height; } /** * @param height height を設定。 */ public void setHeight(int height) { this.height = height; } /** * @return memberId を戻します。 */ public int getMemberId() { return memberId; } /** * @param memberId memberId を設定。 */ public void setMemberId(int memberId) { this.memberId = memberId; } /** * @return width を戻します。 */ public int getWidth() { return width; } /** * @param width width を設定。 */ public void setWidth(int width) { this.width = width; } /** * @return windowName を戻します。 */ public String getWindowName() { return windowName; } /** * @param windowName windowName を設定。 */ public void setWindowName(String windowName) { this.windowName = windowName; } /** * @return x を戻します。 */ public int getX() { return x; } /** * @param x x を設定。 */ public void setX(int x) { this.x = x; } /** * @return y を戻します。 */ public int getY() { return y; } /** * @param y y を設定。 */ public void setY(int y) { this.y = y; } /** * @return id を戻します。 */ public int getId() { return id; } /** * @param id id を設定。 */ public void setId(int id) { this.id = id; } /** * @return optionXml を戻します。 */ public String getOptionXml() { return optionXml; } /** * @param optionXml optionXml を設定。 */ public void setOptionXml(String optionXml) { this.optionXml = optionXml; } } src/com/kickmogu/rhythm/util/dao/WindowPosDao.java100644 0 0 2232 10710110426 17625 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/12 * */ package com.kickmogu.rhythm.util.dao; import com.kickmogu.rhythm.util.WindowPos;; /** * @author mogu */ public interface WindowPosDao { public Class BEAN = WindowPos.class; public static final String getWindowPos_QUERY = "memberId = ? and windowName = ?"; public int update(WindowPos winPos); public int insert(WindowPos winPos); public int delete(WindowPos winPos); public WindowPos getWindowPos(int memberId, String windowName); } src/com/kickmogu/rhythm/util/ws/GuiUtilWs.java100644 0 0 4310 10710110426 17031 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2007/01/12 * */ package com.kickmogu.rhythm.util.ws; import com.kickmogu.rhythm.util.dao.WindowPosDao; import com.kickmogu.rhythm.core.BaseResult; import com.kickmogu.rhythm.core.Member; import com.kickmogu.rhythm.util.*; import com.kickmogu.s2.DAOSequence; import com.kickmogu.s2.S2Util; public class GuiUtilWs { WindowPosDao winposdao = (WindowPosDao) S2Util.getS2Container().getComponent(WindowPosDao.class); public BaseResult saveWindowPos(Member loginMember, String windowName, int x, int y, int height, int width, String optXml) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } WindowPos winPos = winposdao.getWindowPos(loginMember.getId(), windowName); if (winPos == null) { winPos = new WindowPos(); winPos.setId(DAOSequence.getNextId(WindowPos.UNIQ_KEYNAME)); winPos.setMemberId(loginMember.getId()); } winPos.setX(x); winPos.setY(y); winPos.setHeight(height); winPos.setWidth(width); winPos.setOptionXml(optXml); if (winPos.getWindowName() == null) { winPos.setWindowName(windowName); winposdao.insert(winPos); } else { winposdao.update(winPos); } return result; } public BaseResult loadWindowPos(Member loginMember, String windowName) { BaseResult result = new BaseResult(); if (!loginMember.isLogined(result)) { return result; } WindowPos winPos = winposdao.getWindowPos(loginMember.getId(), windowName); result.setResult(winPos); return result; } public void wsdldummy(WindowPos winPos) { } } src/com/kickmogu/s2/DAOSequence.java100644 0 0 4211 10710110427 14635 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/08/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.s2; import org.seasar.framework.container.S2Container; import com.kickmogu.s2.dao.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public class DAOSequence { private String keyname; private int seq; public DAOSequence() { } public static int getNextId(String keyname) { S2Container s2container = S2Util.getS2Container(); DAOSequenceDAO dao = (DAOSequenceDAO) s2container.getComponent(DAOSequenceDAO.class); DAOSequence daoSeq = dao.getDAOSequence(keyname); if (daoSeq == null) { daoSeq = new DAOSequence(); daoSeq.setKeyname(keyname); daoSeq.setSeq(0); dao.insert(daoSeq); } else { daoSeq.setSeq(daoSeq.getSeq() + 1); dao.update(daoSeq); } return daoSeq.getSeq(); } /** * @return keyname を戻します。 */ public String getKeyname() { return keyname; } /** * @param keyname keyname を設定。 */ public void setKeyname(String keyname) { this.keyname = keyname; } /** * @return seq を戻します。 */ public int getSeq() { return seq; } /** * @param seq seq を設定。 */ public void setSeq(int seq) { this.seq = seq; } } src/com/kickmogu/s2/S2Util.java100644 0 0 3120 10710110427 13661 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/08/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.s2; import org.seasar.extension.dbcp.ConnectionPool; import org.seasar.framework.container.S2Container; import org.seasar.framework.container.factory.*; import java.sql.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public class S2Util { private static S2Container container; static { container = S2ContainerFactory.create("dao.dicon"); container.init(); } public static S2Container getS2Container() { return container; } public static Connection getConnection() throws Exception { ConnectionPool cp = (ConnectionPool) getS2Container().getComponent("connectionPool"); return cp.checkOut(); } } src/com/kickmogu/s2/dao/DAOSequenceDAO.java100644 0 0 2602 10710110427 15726 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/06/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.s2.dao; import com.kickmogu.s2.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public interface DAOSequenceDAO { public Class BEAN = DAOSequence.class; public static final String getDAOSequence_QUERY = "keyname = ?"; public int update(DAOSequence cd); public int insert(DAOSequence cd); public int delete(DAOSequence cd); public DAOSequence getDAOSequence(String keyname); } src/com/kickmogu/s2/test/DAOSequenceTest.java100644 0 0 2426 10710110427 16462 0ustar 0 0 /* * Copyright 2007 Kickmogu Co. Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /* * 作成日: 2005/08/23 * * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ package com.kickmogu.s2.test; import com.kickmogu.s2.*; /** * @author mogu * * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ: * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート */ public class DAOSequenceTest { public static void main(String[] args) { System.out.println("test key seq=" + DAOSequence.getNextId("test key")); System.out.println("test key seq=" + DAOSequence.getNextId("test key")); } } src/dao.dicon100644 0 0 6403 10710334466 10564 0ustar 0 0 interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor interceptor src/flex-local.properties100644 0 0 1163 10613126543 13142 0ustar 0 0 kickmogu.Config.port=12001 port.Log.rotate=12002 log.file=${path.sysroot}/flexrhythm.log path.sysroot=/home/mogu/src/flextest path.data=${path.sysroot}/data/ system.encode=Windows-31J # ?????????????? session.timeout=30 # ??????????????? mail.attach.dir=/tmp/rhythmmail/ com.kickmogu.rhythm.core.Permission.path.xml=/eclipse/workspace/flex/permission.xml com.kickmogu.rhythm.core.Role.path.xml=/eclipse/workspace/flex/role.xml com.kickmogu.rhythm.board.BoardTree.path.xml=/eclipse/workspace/flex/board.xml com.kickmogu.rhythm.todo.TodoTree.path.xml=/eclipse/workspace/flex/todo.xml timecard.daySplitHour=4src/flex.properties100644 0 0 1101 10710110421 12024 0ustar 0 0 kickmogu.Config.port=12001 path.sysroot=/home/mogu/src/flextest path.data=${path.sysroot}/data/ system.encode=Windows-31J session.timeout=30 # mail.attach.dir=/tmp/rhythmmail/ # KB mail.attach.maxsize=10240 mail.upload.tmpdir=/tmp/ com.kickmogu.rhythm.core.Permission.path.xml=${path.sysroot}/data/permission.xml com.kickmogu.rhythm.core.Role.path.xml=${path.sysroot}/data/role.xml com.kickmogu.rhythm.board.BoardTree.path.xml=${path.sysroot}/data/board.xml com.kickmogu.rhythm.todo.TodoTree.path.xml=${path.sysroot}/data/todo.xml timecard.daySplitHour=4src/j2ee.dicon100644 0 0 12652 10710120036 10653 0ustar 0 0 true 100 "org.postgresql.Driver" "jdbc:postgresql://192.168.80.4:5433/rhythm" "rhythm" "rhythm" 600 10 true src/sql/address.sql100644 0 0 633 10710345607 11726 0ustar 0 0 create table Address ( id int not null, kind int not null, prefecture int not null, zip varchar(10), city varchar(300), address varchar(300), comment varchar(300), primary key(id)); create table EmailAddress ( id int not null, kind int not null, email varchar(200), primary key(id)); create table Telephone ( id int not null, kind int not null, tel varchar(20), primary key(id)); src/sql/addressbook.sql100644 0 0 1461 10707776526 12637 0ustar 0 0 create table AddressBook ( id int not null, email varchar(200), firstName varchar(50), lastName varchar(50), firstSpell varchar(50), lastSpell varchar(50), displayName varchar(100), registrant int not null, categoryid int not null, primary key(id)); create table AddressBookAddress ( id int not null, addressBookId int not null, addressId int not null, primary key(id)); create table AddressBookEmailAddress ( id int not null, addressBookId int not null, emailAddressId int not null, primary key(id)); create table AddressBookTelephone ( id int not null, addressBookId int not null, telephoneId int not null, primary key(id)); create table AddressCategory ( id int not null, registrant int not null, name varchar(100), primary key(id)); src/sql/basebean.sql100644 0 0 304 10707776526 12052 0ustar 0 0 create table basebean ( id int not null, deleted int default 0 not null, registDate Timestamp not null, updateDate Timestamp null, registrant int not null, primary key(id)); src/sql/board.sql100644 0 0 476 10707776526 11413 0ustar 0 0 create table Board ( id int not null, registrant int not null, registDate Timestamp not null, seq int not null, depth int not null, rootId int not null, rootSeq int not null, subject varchar(500) not null, body varchar(10000) not null, boardTreeId int not null, primary key(id)); src/sql/daoseq.sql100644 0 0 161 10707776526 11567 0ustar 0 0 create table DAOSequence ( keyname varchar(50) not null, seq int not null, primary key(keyname) ); src/sql/guiutil.sql100644 0 0 334 10707776526 11777 0ustar 0 0 create table WindowPos ( id int not null, memberId int not null, x int not null, y int not null, height int not null, width int not null, windowName varchar(100), optionXml text, primary key(id)); src/sql/holiday.sql100644 0 0 166 10707776526 11751 0ustar 0 0 create table Holiday ( id int not null, name varchar(100) not null, day date not null, primary key(id)); src/sql/initdata.sql100644 0 0 131 10707776526 12105 0ustar 0 0 insert into member (id, loginid, name, passwd) values (-1, 'root', 'root', 'root'); src/sql/mailsetting.sql100644 0 0 560 10707776526 12636 0ustar 0 0 create table MailSetting ( id int not null, memberId int not null, senderName varchar(50) not null, name varchar(50) not null, email varchar(200), imapLoginid varchar(50), imapHost varchar(50), imapPassword varchar(50), smtpHost varchar(50), mailSendedFolder varchar(50), mailFooter varchar(500), primary key(id)); src/sql/member.sql100644 0 0 533 10707776526 11565 0ustar 0 0 create table Member ( id int not null, loginid varchar(50) not null, name varchar(50) not null, passwd varchar(50) not null, payhour int default 0 not null, restminutes int default 0 not null, trafficExpenses int default 0 not null, trafficExpensesKind int default 0 not null, primary key(id)); src/sql/rolemember.sql100644 0 0 163 10710114343 12417 0ustar 0 0 create table rolemember ( roleid int not null, memberid int not null, primary key(roleid, memberid) ); src/sql/timecard.sql100644 0 0 323 10707776526 12103 0ustar 0 0 create table Timecard ( id int not null, registrant int not null, intime Timestamp not null, outtime Timestamp , inipaddr varchar(15), outipaddr varchar(15), primary key(id)); src/sql/todo.sql100644 0 0 1411 10710326502 11252 0ustar 0 0 create table Todo ( id int not null, registrant int not null, registDate Timestamp not null, seq int not null, depth int not null, rootId int not null, subject varchar(500) not null, body varchar(10000) not null, todoTreeId int not null, planFromDate Timestamp , planToDate Timestamp , deleted int default 0 not null, updateDate Timestamp null, loopunit int null, loopinterval int null, loopcount int null, parentid int null, complete boolean null , looptarget Timestamp null, kind int default 0 not null, open boolean default true not null , primary key(id)); create table TodoWorker ( id int not null, todoId int not null, kind int not null, memberId int not null, primary key(id)); create table DAOSequence ( keyname varchar(50) not null, seq int not null, primary key(keyname) ); src/sql/guiutil.sql100644 0 0 334 10707776526 11777 0ustar 0 0 create table WindowPos ( id int not null, memberId int not null, x int not null, y int not null, height int not null, width int not null, windowName varchar(100), optionXml text, primary key(id)); src/sql/holiday.sql100644 0 0 166 10707776526 11751 0ustar 0 0 create table Holiday ( id int not null, name varchar(100) not null, day date not null, primary key(id)); src/sql/initdata.sql100644 0 0 131 10707776526 12105 0ustar 0 0 insert into member (id, loginid, name, passwd) values (-1, 'root', 'root', 'root'); src/sql/mailsetting.sql100644 0 0 560 10707776526 12636 0ustar 0 0 create table MailSetting ( id int not null, memberId int not null, senderName varchar(50) not null, name varchar(50) not null, email varchar(200), imapLoginid varchar(50), imapHost varchar(50), imapPassword varchar(50), smtpHost varchar(50), mailSendedFolder varchar(50), mailFooter varchar(500), primary key(id)); src/sql/member.sql100644 0 0 533 10707776526 11565 0ustar 0 0