Skip to content

Commit 1fbfda3

Browse files
committed
Merge pull request #30 from support-project/feature/issue269_user_group
Feature/issue269 user group
2 parents 2cc5f9f + 838f901 commit 1fbfda3

File tree

2 files changed

+91
-13
lines changed

2 files changed

+91
-13
lines changed

config/stylecheck.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ Slightly modified version of Sun Checks that better matches the default code for
2929
<module name="LocalFinalVariableName"/>
3030
<module name="LocalVariableName"/>
3131
<module name="MemberName"/>
32-
<module name="MethodName"/>
32+
<module name="MethodName">
33+
<property name="severity" value="ignore"/>
34+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
35+
</module>
3336
<module name="PackageName"/>
3437
<module name="ParameterName"/>
3538
<module name="StaticVariableName"/>
@@ -41,7 +44,10 @@ Slightly modified version of Sun Checks that better matches the default code for
4144
<module name="LineLength">
4245
<property name="max" value="150"/>
4346
</module>
44-
<module name="MethodLength"/>
47+
<module name="MethodLength">
48+
<property name="severity" value="ignore"/>
49+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
50+
</module>
4551
<module name="ParameterNumber"/>
4652
<module name="EmptyForIteratorPad"/>
4753
<module name="GenericWhitespace"/>

src/main/java/org/support/project/web/control/Control.java

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import javax.servlet.http.HttpServletRequest;
1313
import javax.servlet.http.HttpServletResponse;
1414

15-
import net.arnx.jsonic.JSON;
16-
import net.arnx.jsonic.JSONException;
17-
1815
import org.support.project.common.bean.ValidateError;
1916
import org.support.project.common.config.CommonBaseParameter;
2017
import org.support.project.common.config.Resources;
@@ -43,6 +40,10 @@
4340
import org.support.project.web.config.MessageStatus;
4441
import org.support.project.web.control.service.Get;
4542
import org.support.project.web.exception.InvalidParamException;
43+
import org.support.project.web.logic.impl.DefaultAuthenticationLogicImpl;
44+
45+
import net.arnx.jsonic.JSON;
46+
import net.arnx.jsonic.JSONException;
4647

4748
/**
4849
* Controlの基底クラス
@@ -69,9 +70,9 @@ public abstract class Control {
6970

7071
/** リソース */
7172
protected Resources resources = Resources.getInstance(CommonBaseParameter.APP_RESOURCE);
72-
73+
/** Viewのベースパス */
7374
public static final String BASE_PATH = "/WEB-INF/views";
74-
75+
/** HTMLエスケープして送信するかのフラグ */
7576
private boolean sendEscapeHtml = true;
7677

7778
/**
@@ -158,7 +159,7 @@ protected String getForwardDir() {
158159
if (StringUtils.isNotEmpty(subPackageName)) {
159160
if (subPackageName.indexOf("\\.") != -1) {
160161
String[] packages = StringUtils.split(subPackageName, ".");
161-
for (int i = packages.length -1; i <= 0; i--) {
162+
for (int i = packages.length - 1; i <= 0; i--) {
162163
String string = packages[i];
163164
builder.append(string).append("/");
164165
}
@@ -443,6 +444,17 @@ protected String[] getPathInfos() {
443444
public LoginedUser getLoginedUser() {
444445
return (LoginedUser) request.getSession().getAttribute(CommonWebParameter.LOGIN_USER_INFO_SESSION_KEY);
445446
}
447+
/**
448+
* ログインユーザ情報を最新の情報で更新
449+
*/
450+
public void updateLoginInfo() {
451+
DefaultAuthenticationLogicImpl authenticationLogic = Container.getComp(DefaultAuthenticationLogicImpl.class);
452+
LoginedUser loginedUser = getLoginedUser();
453+
if (loginedUser != null) {
454+
authenticationLogic.clearSession(request);
455+
authenticationLogic.setSession(loginedUser.getLoginUser().getUserKey(), request);
456+
}
457+
}
446458

447459
/**
448460
* ログインユーザのIDを取得
@@ -456,35 +468,73 @@ public Integer getLoginUserId() {
456468
return loginedUser.getLoginUser().getUserId();
457469
}
458470

459-
471+
/**
472+
* request を取得
473+
* @return
474+
*/
460475
public HttpServletRequest getRequest() {
461476
return request;
462477
}
478+
/**
479+
* request をセット
480+
* @return
481+
*/
463482
public void setRequest(HttpServletRequest request) {
464483
this.request = request;
465484
}
485+
/**
486+
* response を取得
487+
* @return
488+
*/
466489
public HttpServletResponse getResponse() {
467490
return response;
468491
}
492+
/**
493+
* response をセット
494+
* @return
495+
*/
469496
public void setResponse(HttpServletResponse response) {
470497
this.response = response;
471498
}
499+
/**
500+
* invokeTarget を取得
501+
* @return
502+
*/
472503
public InvokeTarget getInvokeTarget() {
473504
return invokeTarget;
474505
}
475-
506+
/**
507+
* invokeTarget をセット
508+
* @return
509+
*/
476510
public void setInvokeTarget(InvokeTarget invokeTarget) {
477511
this.invokeTarget = invokeTarget;
478512
}
513+
/**
514+
* path を取得
515+
* @return
516+
*/
479517
public String getPath() {
480518
return path;
481519
}
520+
/**
521+
* path をセット
522+
* @return
523+
*/
482524
public void setPath(String path) {
483525
this.path = path;
484526
}
527+
/**
528+
* pathInfo を取得
529+
* @return
530+
*/
485531
public String getPathInfo() {
486532
return pathInfo;
487533
}
534+
/**
535+
* pathInfo をセット
536+
* @return
537+
*/
488538
public void setPathInfo(String pathInfo) {
489539
this.pathInfo = pathInfo;
490540
}
@@ -611,23 +661,35 @@ protected String getParamWithDefault(String paramName, String defaultval) {
611661
}
612662
}
613663

614-
664+
/**
665+
* パラメータを取得
666+
* @param paramName
667+
* @param type
668+
* @return
669+
*/
615670
protected <T> T getParam(String paramName, Class<? extends T> type) {
616671
try {
617672
return HttpUtil.getParameter(request, paramName, type);
618673
} catch (InvalidParamException e) {
619674
throw new SystemException(e);
620675
}
621676
}
622-
677+
/**
678+
* パラメータを取得
679+
* @param type
680+
* @return
681+
*/
623682
protected <T> T getParams(Class<? extends T> type) {
624683
try {
625684
return HttpUtil.parseRequest(request, type);
626685
} catch (InstantiationException | IllegalAccessException | JSONException | IOException | InvalidParamException e) {
627686
throw new SystemException(e);
628687
}
629688
}
630-
689+
/**
690+
* パラメータをマップで取得
691+
* @return
692+
*/
631693
protected Map<String, String> getParams() {
632694
Map<String, String> map = new HashMap<>();
633695
Enumeration<String> enumeration = request.getParameterNames();
@@ -653,6 +715,16 @@ public void setSendEscapeHtml(boolean sendEscapeHtml) {
653715
this.sendEscapeHtml = sendEscapeHtml;
654716
}
655717

718+
/**
719+
* パラメータをオブジェクトにセットして取得
720+
* @param type
721+
* @return
722+
* @throws InstantiationException
723+
* @throws IllegalAccessException
724+
* @throws JSONException
725+
* @throws IOException
726+
* @throws InvalidParamException
727+
*/
656728
public <T> T getParamOnProperty(final Class<? extends T> type)
657729
throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException {
658730
return HttpUtil.parseRequest(request, type);

0 commit comments

Comments
 (0)