Skip to content

Commit

Permalink
0.4.5 リリース候補
Browse files Browse the repository at this point in the history
#13 クッキーを使ったログイン情報の保持
#15 既読・未読がわかるようにしたい
  • Loading branch information
koda-masaru committed Feb 23, 2015
1 parent 6fafe6a commit 9280d6d
Show file tree
Hide file tree
Showing 19 changed files with 322 additions and 54 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.support-project</groupId>
<artifactId>knowledge</artifactId>
<packaging>war</packaging>
<version>0.4.4</version>
<version>0.4.5-SNAPSHOT</version>
<name>webapp for knowledge</name>
<url>https://support-project.org/</url>

Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>org.support-project</groupId>
<artifactId>web</artifactId>
<version>0.4.4</version>
<version>0.4.5-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.support.project.knowledge.control;

import org.support.project.di.DI;
import org.support.project.di.Instance;

@DI(instance=Instance.Prototype)
public class KnowledgeControlBase extends Control {

protected String setViewParam() {
StringBuilder params = new StringBuilder();
params.append("?keyword=").append(getParamWithDefault("keyword", ""));
params.append("&tag=").append(getParamWithDefault("tag", ""));
params.append("&user=").append(getParamWithDefault("user", ""));
params.append("&offset=").append(getParamWithDefault("offset", ""));
setAttribute("params", params.toString());
return params.toString();
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public Boundary delete() throws Exception {
UsersEntity user = dao.selectOnKey(getParam("userId", Integer.class));
if (user != null) {
//dao.delete(user.getUserId());
UserLogic.get().withdrawal(user.getUserId(), true);
UserLogic.get().withdrawal(user.getUserId(), true, HttpUtil.getLocale(getRequest()));
}
String successMsg = "message.success.delete";
setResult(successMsg, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
import org.support.project.common.util.StringUtils;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.control.Control;
import org.support.project.knowledge.control.KnowledgeControlBase;
import org.support.project.knowledge.dao.CommentsDao;
import org.support.project.knowledge.dao.LikesDao;
import org.support.project.knowledge.dao.TagsDao;
import org.support.project.knowledge.entity.CommentsEntity;
import org.support.project.knowledge.entity.KnowledgesEntity;
import org.support.project.knowledge.entity.LikesEntity;
import org.support.project.knowledge.entity.TagsEntity;
import org.support.project.knowledge.logic.GroupLogic;
import org.support.project.knowledge.logic.KnowledgeLogic;
Expand All @@ -34,7 +35,7 @@
import org.support.project.web.exception.InvalidParamException;

@DI(instance=Instance.Prototype)
public class KnowledgeControl extends Control {
public class KnowledgeControl extends KnowledgeControlBase {
private static final int COOKIE_COUNT = 5;

/** ログ */
Expand All @@ -49,6 +50,9 @@ public class KnowledgeControl extends Control {
* @throws InvalidParamException
*/
public Boundary view() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

Long knowledgeId = super.getPathLong(Long.valueOf(-1));

KnowledgeLogic knowledgeLogic = KnowledgeLogic.get();
Expand Down Expand Up @@ -131,10 +135,14 @@ public Boundary view() throws InvalidParamException {
*/
public Boundary list() throws Exception {
LOG.trace("Call list");
Integer offset = super.getPathInteger(0);
setAttribute("offset", offset);
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

TagsDao tagsDao = TagsDao.get();
KnowledgeLogic knowledgeLogic = KnowledgeLogic.get();

Integer offset = super.getPathInteger(0);
LoginedUser loginedUser = super.getLoginedUser();
String keyword = getParam("keyword");
String tag = getParam("tag");
Expand Down Expand Up @@ -260,8 +268,52 @@ public Boundary escape(KnowledgesEntity entity) throws PolicyException, ScanExce
* @return
*/
public Boundary search() {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();
return forward("search.jsp");
}

/**
* いいねを押したユーザを一覧表示
* @return
* @throws InvalidParamException
*/
public Boundary likes() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

Long knowledgeId = super.getPathLong(Long.valueOf(-1));
setAttribute("knowledgeId", knowledgeId);
// 権限チェック(いったんアクセスできるユーザは全て表示) TODO 登録者のみにする?
KnowledgeLogic knowledgeLogic = KnowledgeLogic.get();
KnowledgesEntity entity = knowledgeLogic.select(knowledgeId, getLoginedUser());
if (entity == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND");
}

Integer page = 0;
String p = getParamWithDefault("page", "");
if (StringUtils.isInteger(p)) {
page = Integer.parseInt(p);
}

LikesDao likesDao = LikesDao.get();
List<LikesEntity> likes = likesDao.selectOnKnowledge(knowledgeId, page * PAGE_LIMIT, PAGE_LIMIT);
setAttribute("likes", likes);


int previous = page -1;
if (previous < 0) {
previous = 0;
}
setAttribute("page", page);
setAttribute("previous", previous);
setAttribute("next", page + 1);

return forward("likes.jsp");
}


}


Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Boundary delete() throws Exception {
if ("2".equals(getParam("knowledge_remove"))) {
knowledgeRemove = false;
}
UserLogic.get().withdrawal(getLoginUserId(), knowledgeRemove);
UserLogic.get().withdrawal(getLoginUserId(), knowledgeRemove, HttpUtil.getLocale(getRequest()));

// セッションを破棄
AuthenticationLogic<LoginedUser> authenticationLogic = Container.getComp(DefaultAuthenticationLogicImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.control.Control;
import org.support.project.knowledge.control.KnowledgeControlBase;
import org.support.project.knowledge.dao.CommentsDao;
import org.support.project.knowledge.dao.KnowledgesDao;
import org.support.project.knowledge.entity.CommentsEntity;
Expand All @@ -27,7 +27,7 @@
import org.support.project.web.exception.InvalidParamException;

@DI(instance=Instance.Prototype)
public class KnowledgeControl extends Control {
public class KnowledgeControl extends KnowledgeControlBase {
/** ログ */
private static Log LOG = LogFactory.getLog(KnowledgeControl.class);

Expand All @@ -39,6 +39,9 @@ public class KnowledgeControl extends Control {
* @return
*/
public Boundary view_add() {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

String offset = super.getParam("offset", String.class);
if (StringUtils.isEmpty(offset)) {
offset = "0";
Expand All @@ -53,6 +56,9 @@ public Boundary view_add() {
* @throws InvalidParamException
*/
public Boundary view_edit() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

String offset = super.getParam("offset", String.class);
if (StringUtils.isEmpty(offset)) {
offset = "0";
Expand Down Expand Up @@ -88,7 +94,9 @@ public Boundary view_edit() throws InvalidParamException {
* @throws Exception
*/
public Boundary add(KnowledgesEntity entity) throws Exception {
LOG.trace("validate");
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

String groupsstr = super.getParam("groups");
String[] groupssp = groupsstr.split(",");
List<GroupsEntity> groups = GroupLogic.get().selectGroups(groupssp);
Expand Down Expand Up @@ -150,7 +158,9 @@ public Boundary add(KnowledgesEntity entity) throws Exception {
* @throws Exception
*/
public Boundary update(KnowledgesEntity entity) throws Exception {
LOG.trace("validate");
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

String groupsstr = super.getParam("groups");
String[] groupssp = groupsstr.split(",");
List<GroupsEntity> groups = GroupLogic.get().selectGroups(groupssp);
Expand Down Expand Up @@ -224,6 +234,9 @@ public Boundary update(KnowledgesEntity entity) throws Exception {
* @throws Exception
*/
public Boundary delete() throws Exception {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

LOG.trace("validate");
KnowledgesDao dao = Container.getComp(KnowledgesDao.class);
String id = getParam("knowledgeId");
Expand Down Expand Up @@ -256,6 +269,9 @@ public Boundary delete() throws Exception {
* @throws InvalidParamException
*/
public Boundary view() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

Long knowledgeId = super.getPathLong(Long.valueOf(-1));
return super.redirect(getRequest().getContextPath() + "/open.knowledge/view/" + knowledgeId);
}
Expand All @@ -266,6 +282,9 @@ public Boundary view() throws InvalidParamException {
* @throws InvalidParamException
*/
public Boundary comment() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
String params = setViewParam();

Long knowledgeId = super.getPathLong(Long.valueOf(-1));

String comment = getParam("comment");
Expand All @@ -278,7 +297,7 @@ public Boundary comment() throws InvalidParamException {
// 一覧表示用の情報を更新
KnowledgeLogic.get().updateKnowledgeExInfo(knowledgeId);

return super.redirect(getRequest().getContextPath() + "/open.knowledge/view/" + knowledgeId);
return super.redirect(getRequest().getContextPath() + "/open.knowledge/view/" + knowledgeId + params);
}

}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/support/project/knowledge/dao/LikesDao.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package org.support.project.knowledge.dao;

import java.util.List;

import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.dao.gen.GenLikesDao;
import org.support.project.knowledge.entity.KnowledgesEntity;
import org.support.project.knowledge.entity.LikesEntity;
import org.support.project.ormapping.common.SQLManager;

/**
* いいね
Expand All @@ -28,6 +33,11 @@ public Long countOnKnowledgeId(Long knowledgeId) {
return super.executeQuerySingle(sql, Long.class, knowledgeId);
}

public List<LikesEntity> selectOnKnowledge(Long knowledgeId, int offset, int limit) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikesDao/LikesDao_selectOnKnowledge.sql");
return executeQuery(sql, LikesEntity.class, knowledgeId, limit, offset);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class LikesEntity extends GenLikesEntity {

/** SerialVersion */
private static final long serialVersionUID = 1L;


private String userName;

/**
* インスタンス取得
Expand All @@ -40,4 +43,18 @@ public LikesEntity(Long no) {
super(no);
}

/**
* @return the userName
*/
public String getUserName() {
return userName;
}

/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.support.project.aop.Aspect;
import org.support.project.common.config.INT_FLAG;
import org.support.project.common.config.Resources;
import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.common.util.RandomUtil;
Expand Down Expand Up @@ -152,17 +154,19 @@ private void insertRoles(UsersEntity user, String[] roles) {
* 退会
* @param loginUserId
* @param knowledgeRemove
* @param locale
* @throws Exception
*/
@Aspect(advice=org.support.project.ormapping.transaction.Transaction.class)
public void withdrawal(Integer loginUserId, boolean knowledgeRemove) throws Exception {
public void withdrawal(Integer loginUserId, boolean knowledgeRemove, Locale locale) throws Exception {
// アカウント削除
UsersDao usersDao = UsersDao.get();
UsersEntity user = usersDao.selectOnKey(loginUserId);
if (user != null) {
user.setPassword(RandomUtil.randamGen(32));
user.setUserKey(RandomUtil.randamGen(32));
user.setUserName("削除済ユーザー");
Resources resources = Resources.getInstance(locale);
user.setUserName(resources.getResource("knowledge.withdrawal.label.name"));
user.setDeleteFlag(INT_FLAG.ON.getValue());
usersDao.update(user);
usersDao.delete(loginUserId);
Expand Down
12 changes: 9 additions & 3 deletions src/main/resources/appresource.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ message.success.save.target={1} was Saved.
message.allready.updated=Allready updated.

# Common Label
label.version=0.4.4
label.version=0.4.5
label.login=Sign in
label.previous = Previous
label.next=Next
Expand Down Expand Up @@ -82,6 +82,7 @@ label.download=Download
label.upload=Upload
label.backup=Backup
label.restore=Restore
label.back=Back

label.public.view=<i class="fa fa-globe"></i>&nbsp;[Public]
label.protect.view=<i class="fa fa-gavel"></i>&nbsp;[Protection]
Expand Down Expand Up @@ -175,6 +176,10 @@ knowledge.edit.label.confirm.delete=Are you sure you want to delete?
knowledge.edit.noaccess=It is not possible to edit other than those that have registered their
knowledge.delete.none=Knowledge to be deleted is not specified

knowledge.likes.title=User list that was me press the "Like"
knowledge.likes.list.label.empty=In this page, the user presses the "Like" did not have
knowledge.likes.anonymous=Anonymous (not sign in user)

knowledge.signup.title=Sign Up
knowledge.signup.label.mail=Mail Address (will at the time of signin ID and / There is no published is that)
knowledge.signup.label.name=User Name (The name that display in this service)
Expand All @@ -197,6 +202,7 @@ knowledge.withdrawal.label.remove=Remove
knowledge.withdrawal.label.leave=Leave (registrant name will be "deleted user")
knowledge.withdrawal.label.bottun=The withdrawal will be made (not cancel)
knowledge.withdrawal.label.confirm=Do you really sure you want to run the withdrawal? <br/> can not be undone this process.
knowledge.withdrawal.label.name=deleted user

knowledge.registration.result.title=Registration Result
knowledge.registration.msg.wait=I accept the registration. <br/> use the start of the service, has become necessary to confirm the administrator. Please wait until the confirmation of <br/> administrator.
Expand Down Expand Up @@ -234,8 +240,8 @@ knowledge.user.list.title=User List
knowledge.user.list.label.empty=The data corresponding to the condition does not exist. Please switch the page.
knowledge.user.add.title=Add User
knowledge.user.edit.title=Edit User
knowledge.user.invalid.same.password=Password\u3068Confirm Password\u304c\u9055\u3063\u3066\u3044\u307e\u3059
knowledge.user.mail.exist=\u65e2\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308bEmail Address\u3067\u3059
knowledge.user.invalid.same.password=Password and Confirm Password has a different
knowledge.user.mail.exist=The Email Address already registered

knowledge.group.view.title=View Group
knowledge.group.view.label.groupname=Group name
Expand Down
Loading

0 comments on commit 9280d6d

Please sign in to comment.