summaryrefslogtreecommitdiffstats
path: root/warehouse/src/main/java/app/market/web/controller
diff options
context:
space:
mode:
Diffstat (limited to 'warehouse/src/main/java/app/market/web/controller')
-rw-r--r--warehouse/src/main/java/app/market/web/controller/BreadcrumbMapping.java104
-rw-r--r--warehouse/src/main/java/app/market/web/controller/ControllerMapping.java45
-rw-r--r--warehouse/src/main/java/app/market/web/controller/PageMapping.java188
-rw-r--r--warehouse/src/main/java/app/market/web/controller/SpringBaseController.java101
-rw-r--r--warehouse/src/main/java/app/market/web/controller/account/AccountController.java336
-rw-r--r--warehouse/src/main/java/app/market/web/controller/app/AppController.java636
-rw-r--r--warehouse/src/main/java/app/market/web/controller/login/LoginController.java158
-rw-r--r--warehouse/src/main/java/app/market/web/controller/main/MainController.java96
8 files changed, 1664 insertions, 0 deletions
diff --git a/warehouse/src/main/java/app/market/web/controller/BreadcrumbMapping.java b/warehouse/src/main/java/app/market/web/controller/BreadcrumbMapping.java
new file mode 100644
index 0000000..3a3d113
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/BreadcrumbMapping.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller;
+
+import org.apache.commons.lang3.StringUtils;
+
+import app.market.web.form.breadcrumb.BreadcrumbFrom;
+import app.market.web.form.breadcrumb.BreadcrumbSubFrom;
+
+public class BreadcrumbMapping {
+
+ public static final String APP_DETAIL = "APP,APP_DETAIL";
+ public static final String APP_DETAIL_MODIFY = "APP,APP_DETAIL,APP_DETAIL_MODIFY";
+ public static final String APP_INSERT = "APP,APP_INSERT";
+ public static final String APP_MODIFY = "APP,APP_MODIFY";
+ public static final String USER_INSERT = "USER,USER_INSERT";
+ public static final String USER_DETAIL = "USER,USER_DETAIL";
+ public static final String USER_MODIFY = "USER,USER_MODIFY";
+ public static BreadcrumbFrom getBreadcrumb(String name) {
+ BreadcrumbFrom breadcrumb = new BreadcrumbFrom();
+ String[] names = name.split(",");
+ for (int i = 0; i < names.length; i++) {
+ BreadcrumbSubFrom sub = BreadcrumbEnum.getBreadcrumbSubFrom(names[i]);
+ breadcrumb.getBreadcrumb().add(sub);
+ if (i == names.length - 1) {
+ sub.setCurrent(true);
+ }
+ }
+ return breadcrumb;
+ }
+
+ public enum BreadcrumbEnum {
+ USER("USER", "User", "account"),
+ USER_DETAIL("USER_DETAIL", "Detail", "url"),
+ USER_INSERT("USER_INSERT", "Create", "url"),
+ USER_MODIFY("USER_MODIFY", "Modify", "url"),
+ APP("APP", "App", "app"),
+ APP_DETAIL("APP_DETAIL", "Detail", "app/more"),
+ APP_DETAIL_MODIFY("APP_DETAIL_MODIFY", "Modify", "url"),
+ APP_MODIFY("APP_MODIFY", "Modify", "url"),
+ APP_INSERT("APP_INSERT", "Create", "url");
+
+ private String key;
+ private String name;
+ private String url;
+
+ private BreadcrumbEnum(String key, String name, String value) {
+ this.key = key;
+ this.name = name;
+ this.url = value;
+ }
+
+ public static BreadcrumbSubFrom getBreadcrumbSubFrom(String key) {
+ for (BreadcrumbEnum c : BreadcrumbEnum.values()) {
+ if (StringUtils.equalsIgnoreCase(c.getKey(), key)) {
+ BreadcrumbSubFrom sub = new BreadcrumbSubFrom();
+ sub.setName(c.getName());
+ sub.setUrl(c.getUrl());
+ return sub;
+ }
+ }
+ return null;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/controller/ControllerMapping.java b/warehouse/src/main/java/app/market/web/controller/ControllerMapping.java
new file mode 100644
index 0000000..599dd7b
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/ControllerMapping.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller;
+
+public enum ControllerMapping {
+
+ LOGIN {
+ public String toString() {
+ return "/login";
+ }
+ },
+ MAIN {
+ public String toString() {
+ return "/main";
+ }
+ },
+ MAINDEV {
+ public String toString() {
+ return "/mainDev";
+ }
+ },
+ ACCOUNT {
+ public String toString() {
+ return "/account";
+ }
+ },
+ APP {
+ public String toString() {
+ return "/app";
+ }
+ },
+}
diff --git a/warehouse/src/main/java/app/market/web/controller/PageMapping.java b/warehouse/src/main/java/app/market/web/controller/PageMapping.java
new file mode 100644
index 0000000..938a4f9
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/PageMapping.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller;
+
+public enum PageMapping {
+
+ LOGIN {
+ // login screen
+ @Override
+ public String toString() {
+ return "index";
+ }
+ },
+ MAIN {
+ // main screen
+ @Override
+ public String toString() {
+ return "main";
+ }
+ },
+ MAINDEV {
+ // mainDev screen
+ @Override
+ public String toString() {
+ return "mainDev";
+ }
+ },
+ APP {
+ // app screen
+ @Override
+ public String toString() {
+ return "app";
+ }
+ },
+ ACCOUNT_LIST {
+ // account list screen
+ @Override
+ public String toString() {
+ return "account/list";
+ }
+ },
+ ACCOUNT_DETAIL {
+ // account detail screen
+ @Override
+ public String toString() {
+ return "account/detail";
+ }
+ },
+ ACCOUNT_MODIFY {
+ // account modify screen
+ @Override
+ public String toString() {
+ return "account/modify";
+ }
+ },
+ ACCOUNT_REGISTER {
+ // account register screen
+ @Override
+ public String toString() {
+ return "account/register";
+ }
+ },
+ APP_LIST {
+ // application list screen
+ @Override
+ public String toString() {
+ return "app/list";
+ }
+ },
+ APP_TYPE {
+ // application type screen
+ @Override
+ public String toString() {
+ return "app/type";
+ }
+ },
+ APP_MODIFY {
+ // application modify screen
+ @Override
+ public String toString() {
+ return "app/modify";
+ }
+ },
+ M3_LIST {
+ // app dev list screen
+ @Override
+ public String toString() {
+ return "appDev/listDev";
+ }
+ },
+ M3_LOCAL_LIST {
+ // app dev local list screen
+ @Override
+ public String toString() {
+ return "appDev/localListDev";
+ }
+ },
+ M3_SEARCH {
+ // app dev search screen
+ @Override
+ public String toString() {
+ return "appDev/searchDev";
+ }
+ },
+ M3_DETAIL {
+ // app dev detail screen
+ @Override
+ public String toString() {
+ return "appDev/detailDev";
+ }
+ },
+ CREATE_APP {
+ // add application screen
+ @Override
+ public String toString() {
+ return "app/createApp";
+ }
+ },
+ SAVE_APP_INFO {
+ // save application information
+ @Override
+ public String toString() {
+ return "app/saveAppInfo";
+ }
+ },
+ CHECK_APP_INFO {
+ // check application information
+ @Override
+ public String toString() {
+ return "app/checkAppInfo";
+ }
+ },
+ OTHER_404 {
+ // 404 screen
+ @Override
+ public String toString() {
+ return "other/404";
+ }
+ },
+ OTHER_500 {
+ // 500 screen
+ @Override
+ public String toString() {
+ return "other/500";
+ }
+ },
+ INIT_INFO {
+ //
+ @Override
+ public String toString() {
+ return "/app/initInfo";
+ }
+ },
+ INIT_CHECK{
+ @Override
+ public String toString() {
+ return "/app/initCheck";
+ }
+ };
+
+ public static String redirect(String pageId, String... args) {
+ String url = "redirect:" + pageId;
+ if ( args.length > 0 ) {
+ url += "?";
+ for (int i = 0; i < args.length; i++) {
+ if ( i == 0 ) {
+ url = url + "p" + i + "=" + args[i];
+ } else {
+ url = url + "&p" + i + "=" + args[i];
+ }
+ }
+ }
+ return url;
+ }
+}
diff --git a/warehouse/src/main/java/app/market/web/controller/SpringBaseController.java b/warehouse/src/main/java/app/market/web/controller/SpringBaseController.java
new file mode 100644
index 0000000..b85f1e6
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/SpringBaseController.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.servlet.HandlerExceptionResolver;
+import org.springframework.web.servlet.ModelAndView;
+
+import app.market.utils.datatable.DataTableMap;
+import app.market.utils.json.JsonMapperUtils;
+import app.market.utils.json.JsonResult;
+
+/**
+ * Base Controller
+ *
+ * @author Toyota
+ */
+public abstract class SpringBaseController implements HandlerExceptionResolver {
+
+ private static Logger logger = LoggerFactory.getLogger( SpringBaseController.class );
+
+ protected final static String MODEL_ERRORS = "modelErrors";
+
+ @Override
+ public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
+ Exception ex) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ if ( ex instanceof IOException ) {
+ logger.info( ex.getMessage() );
+ model.put( MODEL_ERRORS, "No permission to read the record of this application!" );
+ return new ModelAndView( "other/500", model );
+
+ } else if ( ex instanceof SQLException ) {
+ logger.info( ex.getMessage() );
+ model.put( MODEL_ERRORS, "The database error occurred." );
+ return new ModelAndView( "other/500", model );
+
+ } else if ( ex instanceof HttpClientErrorException ) {
+ logger.info( ex.getMessage() );
+ model.put( MODEL_ERRORS, ex.getMessage() );
+ return new ModelAndView( PageMapping.LOGIN.toString(), model );
+
+ } else if ( ex instanceof RuntimeException ) {
+ logger.info( ex.getMessage() );
+ model.put( MODEL_ERRORS, ex.getMessage() );
+ return new ModelAndView( "other/500", model );
+
+ } else if ( ex instanceof NullPointerException ) {
+ logger.info( ex.getMessage() );
+ model.put( MODEL_ERRORS, ex.getMessage() );
+ return new ModelAndView( "other/500", model );
+
+ } else if ( ex instanceof Exception ) {
+ logger.info( ex.getMessage() );
+ model.put( MODEL_ERRORS, "A server error occurred. Please contact the administrator!" );
+ // model.put( MODEL_ERRORS, "Your session has time out, please log on again.");
+ return new ModelAndView( "other/500", model );
+ }
+ return null;
+ }
+
+ protected String writeDataTableMap(JsonResult jr, String draw) {
+ DataTableMap map = new DataTableMap( draw, null );
+ map.setErrorMsg( jr.getStatus(), jr.getData().toString() );
+ return JsonMapperUtils.writeValueAsString( map.getMapData() );
+ }
+
+ protected String writeErrorList(JsonResult jr, List<String> errorList) {
+ errorList.add( jr.getData().toString() );
+ return JsonMapperUtils.getJsonString( jr.getStatus(), null, errorList );
+ }
+
+ protected String writeErrorString(JsonResult jr) {
+ return JsonMapperUtils.getJsonString( jr.getStatus(), null, jr.getData().toString() );
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/controller/account/AccountController.java b/warehouse/src/main/java/app/market/web/controller/account/AccountController.java
new file mode 100644
index 0000000..20690fa
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/account/AccountController.java
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller.account;
+
+import java.security.NoSuchAlgorithmException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import app.market.LogUtil;
+import app.market.utils.Md5Util;
+import app.market.utils.constants.Constants;
+import app.market.utils.datetime.DateTimeUtils;
+import app.market.utils.json.JsonMapperUtils;
+import app.market.utils.json.JsonResult;
+import app.market.utils.property.KeysConstants;
+import app.market.utils.property.MessageUtil;
+import app.market.utils.webservice.ApiParam;
+import app.market.web.controller.BreadcrumbMapping;
+import app.market.web.controller.PageMapping;
+import app.market.web.controller.SpringBaseController;
+import app.market.web.form.account.AccountForm;
+import app.market.web.services.account.AccountService;
+
+/**
+ *
+ * @author Toyota
+ *
+ * User Manager
+ *
+ */
+@Controller
+@RequestMapping(value = "account")
+public class AccountController extends SpringBaseController {
+ private static Logger logger = LoggerFactory.getLogger(AccountController.class);
+
+ @Autowired
+ private AccountService accountService;
+
+ /**
+ * User Manager Init
+ *
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "")
+ public ModelAndView init(HttpSession session) throws Exception {
+ LinkedHashMap<String, Object> model = new LinkedHashMap<>();
+ // Unauthorized Exception
+ JsonResult jr = accountService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ model.put(MODEL_ERRORS, jr.getData().toString());
+ return new ModelAndView(PageMapping.ACCOUNT_LIST.toString(), model);
+ }
+ try {
+ accountService.getAuthorityList(model, true, session);
+
+ } catch (Exception e) {
+ LogUtil.printCatchLog(logger, e);
+ e.printStackTrace();
+ }
+ return new ModelAndView(PageMapping.ACCOUNT_LIST.toString(), model);
+ }
+
+ /**
+ * User Manager modify
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ *
+ */
+ @RequestMapping(value = "modify")
+ @ResponseBody
+ public ModelAndView modify(@RequestParam(value = "userId", required = false) String userId,
+ @RequestParam(value = "isDetail", required = false) boolean isDetail, HttpSession session)
+ throws Exception {
+ logger.debug("Modify User, start search--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName());
+ Map<String, Object> modal = new LinkedHashMap<String, Object>();
+ // Unauthorized Exception
+ JsonResult jr = accountService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ modal.put(MODEL_ERRORS, jr.getData().toString());
+ return new ModelAndView(PageMapping.ACCOUNT_LIST.toString(), modal);
+ }
+
+ AccountForm acForm;
+ String breadcrumb;
+ String viewName;
+ try {
+ if (StringUtils.isNotEmpty(userId)) {
+ // Search AccountForm By UserId
+ acForm = accountService.searchFormById(userId, session);
+ String createDate = DateTimeUtils.getDate(DateTimeUtils.DATE_FORMAT_YYYYMMDDHHMMSS_DASH,
+ acForm.getCreateDate());
+ String updateDate = DateTimeUtils.getDate(DateTimeUtils.DATE_FORMAT_YYYYMMDDHHMMSS_DASH,
+ acForm.getUpdateDate());
+ modal.put("updateDate", updateDate);
+ modal.put("createDate", createDate);
+
+ if (isDetail) {
+ breadcrumb = BreadcrumbMapping.USER_DETAIL;
+ } else {
+ breadcrumb = BreadcrumbMapping.USER_MODIFY;
+ }
+ } else {
+ acForm = new AccountForm();
+ breadcrumb = BreadcrumbMapping.USER_INSERT;
+ }
+ // Get Account List
+ acForm.getBreadcrumb().addAll(BreadcrumbMapping.getBreadcrumb(breadcrumb).getBreadcrumb());
+ } catch (Exception e) {
+ LogUtil.printCatchLog(logger, e);
+ modal.put(MODEL_ERRORS, e.getMessage());
+ return new ModelAndView(PageMapping.ACCOUNT_LIST.toString(), modal);
+ }
+ // Get Account List
+ accountService.getAuthorityList(modal, false, session);
+ modal.put("appInfo", acForm);
+ if (isDetail) {
+ viewName = PageMapping.ACCOUNT_DETAIL.toString();
+ } else {
+ viewName = PageMapping.ACCOUNT_MODIFY.toString();
+ }
+
+ logger.debug("Modify User, stop search");
+ return new ModelAndView(viewName, modal);
+ }
+
+ /**
+ * User Manager Search
+ *
+ * @param draw
+ * @param length
+ * @param start
+ * @param sort
+ * @param mailAddress
+ * @param userName
+ * @param order
+ * @return
+ * @throws ParseException
+ */
+ @RequestMapping(value = "search")
+ @ResponseBody
+ public String search(@RequestParam(value = "draw") String draw, @RequestParam(value = "length") int length,
+ @RequestParam(value = "start") int start, @RequestParam(value = "orderColumn") String sort,
+ @RequestParam(value = "keyWord") String keyWord, @RequestParam(value = "orderDir") String order,
+ @RequestParam(value = "auId") String auId, @RequestParam(value = "createDate") String createDate,
+ HttpSession session) throws ParseException {
+ logger.debug("Start search list--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() + keyWord);
+ Map<String, Object> modal = new LinkedHashMap<String, Object>();
+ // Unauthorized exception
+ JsonResult jr = accountService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ return writeDataTableMap(jr, draw);
+ }
+ String ret = "";
+ try {
+ AccountForm form = new AccountForm();
+ // Assign value To Form
+ form.setDraw(draw);
+ form.setKeyWord(keyWord);
+ form.setAuId(auId);
+ form.setOffset(start);
+ form.setLimit(length);
+ sort = ApiParam.UserQueryParamWeb.getFieldNameById(Integer.valueOf(sort));
+ form.setSort(sort);
+ form.setOrder(order);
+ form.setIsDel("0");
+ // Page Search
+ ret = accountService.selectPaginationData(form, session);
+
+ // Get Account List
+ accountService.getAuthorityList(modal, true, session);
+ } catch (Exception e) {
+ LogUtil.printCatchLog(logger, e);
+ e.printStackTrace();
+ }
+ logger.debug("Stop search list");
+ return ret;
+ }
+
+ /**
+ * User Manager update and save
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "update")
+ @ResponseBody
+ public String update(@RequestParam(value = "form") String formString, HttpSession session)
+ throws NoSuchAlgorithmException {
+ logger.debug("Start save user--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName());
+ String ret = "";
+ List<String> errorList = new ArrayList<String>();
+
+ // Unauthorized Exception
+ JsonResult jr = accountService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ return writeErrorList(jr, errorList);
+ }
+
+ AccountForm form = JsonMapperUtils.readValue(formString, AccountForm.class);
+ checkUpdateInfo(form, errorList);
+
+ form.setIsDel("0");
+ if (CollectionUtils.isEmpty(errorList)) {
+ // Account Save
+ if (StringUtils.isEmpty(form.getUserId())) {
+ // MD5 encrypt
+ String userPwMd = Md5Util.md5(form.getUserPw());
+ form.setUserPw(userPwMd);
+ }
+ ret = accountService.save(form, session);
+ } else {
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, errorList);
+ }
+ logger.debug("Stop save user");
+ return ret;
+ }
+
+ /**
+ * User Manager Delete
+ *
+ */
+ @RequestMapping(value = "delete")
+ @ResponseBody
+ public String delete(@RequestParam(value = "id") String id, HttpSession session) {
+ logger.debug("Delete user start, id=" + id);
+ // Unauthorized Exception
+ JsonResult jr = accountService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ return writeErrorString(jr);
+ }
+ // Account Delete By UserId
+ String ret = accountService.delete(id, session);
+ logger.debug("Delete user stop");
+ return ret;
+ }
+
+ /**
+ * check userinfo
+ * @param errorList
+ *
+ */
+ private List<String> checkUpdateInfo(AccountForm form, List<String> errorList) {
+
+
+ /**
+ * @ can only have numbers、letters、underscores、dots、minus numbers. There is only
+ * one between @ and dots numbers、letters、underscores、dots、minus numbers,And two
+ * points can't be next to. The content after dots can only is
+ * letters、numbers,the length is less than 1 less than 7.
+ */
+ String szReg = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$";
+ Pattern pattern = Pattern.compile(szReg);
+ Matcher matcher = pattern.matcher(form.getMailAddress());
+
+ // Input Check
+ if (StringUtils.isEmpty(form.getUserName().replace(" ", ""))) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_USERNAME_IS_NOT_EMPTY));
+ }
+ if (form.getUserName().length() > ApiParam.API_PARAM_USERNAME_LENGTH) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_USERNAME_MAX_ERROR));
+ }
+ // save Need password verification,update not Need password verification
+ if (StringUtils.isEmpty(form.getUserId())) {
+ if (form.getUserPw().indexOf(" ") != -1) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_PASSWORD_IS_NOT_SPACES));
+ }
+ if (StringUtils.isEmpty(form.getUserPw())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_PASSWORD_IS_NOT_EMPTY));
+ }
+ if (form.getUserPw().length() > 0 && form.getUserPw().length() < ApiParam.API_PARAM_USERPASSMIN_LENGTH) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_PASSWORD_ERROR));
+ }
+ if (form.getUserPw().length() > ApiParam.API_PARAM_USERPASSMAX_LENGTH) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_PASSWORD_MAX_ERROR));
+ }
+ if (StringUtils.isEmpty(form.getReuserPw())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_REPASSWORD_IS_NOT_EMPTY));
+ }
+ if (form.getReuserPw().length() > 0 && !StringUtils.equals(form.getUserPw(), form.getReuserPw())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_NEW_REPASSWORD_IS_NOT_EQUALS));
+ }
+ }
+
+ if (StringUtils.isEmpty(form.getMailAddress())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_MAILADDRESS_IS_NOT_EMPTY));
+ }
+ if (form.getMailAddress().length() > ApiParam.API_PARAM_MAILADDRESS_LENGTH) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_MAILADDRESS_MAX_ERROR));
+ }
+ if (!matcher.matches() && form.getMailAddress().length() > 0) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.USER_MAILADDRESS_IS_NOT_EQUALS));
+ }
+ if (StringUtils.isEmpty(form.getAuId())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.AUTHORITY_ID_IS_NOT_EMPTY));
+ }
+ return errorList;
+ }
+}
diff --git a/warehouse/src/main/java/app/market/web/controller/app/AppController.java b/warehouse/src/main/java/app/market/web/controller/app/AppController.java
new file mode 100644
index 0000000..afb070a
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/app/AppController.java
@@ -0,0 +1,636 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller.app;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+
+import app.market.LogUtil;
+import app.market.model.user.User;
+import app.market.utils.SpringWebUtil;
+import app.market.utils.constants.Constants;
+import app.market.utils.datetime.DateTimeUtils;
+import app.market.utils.json.JsonMapperUtils;
+import app.market.utils.json.JsonResult;
+import app.market.utils.property.KeysConstants;
+import app.market.utils.property.MessageUtil;
+import app.market.utils.webservice.ApiParam;
+import app.market.web.controller.BreadcrumbMapping;
+import app.market.web.controller.PageMapping;
+import app.market.web.controller.SpringBaseController;
+import app.market.web.form.app.AppForm;
+import app.market.web.services.app.AppService;
+import app.market.web.services.main.MainService;
+import app.market.web.services.user.UserService;
+
+
+/**
+ *
+ * @author Toyota
+ *
+ * App Manager
+ */
+@Controller
+@RequestMapping(value = "app")
+public class AppController extends SpringBaseController {
+ private static Logger logger = LoggerFactory.getLogger( AppController.class );
+
+ @Autowired
+ private AppService appService;
+
+ @Autowired
+ private MainService mainService;
+
+ @Autowired
+ private UserService userService;
+
+ @RequestMapping(value = "")
+ public ModelAndView init(@RequestParam(value = "token", required = false) String token, HttpSession session) throws Exception {
+ logger.debug( "APPinit--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() );
+ LinkedHashMap<String, Object> model = new LinkedHashMap<>();
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ model.put( MODEL_ERRORS, jr.getData().toString() );
+ return new ModelAndView( PageMapping.APP_LIST.toString(), model );
+ }
+ try {
+ // Get App Option
+ appService.getAppTypeOption(model, true, session);
+ appService.getDeviceTypeOption(model, true, session);
+ } catch ( Exception e ) {
+ model.put( MODEL_ERRORS, e.getMessage() );
+ return new ModelAndView( PageMapping.APP_LIST.toString(), model );
+ }
+ // Search User name
+ if(!StringUtils.isEmpty(token)){
+ User user = userService.selectCurrentUser(session);
+ model.put( "username", user.getUserName() );
+ model.put( "userid",user.getUserId() );
+ model.put( "auid", user.getAuId());
+ }
+ model.put( "menuPathString", mainService.selectMenuResourceByLoginId(session) );
+ return new ModelAndView( PageMapping.APP_LIST.toString(), model );
+ }
+
+ /**
+ * App Manager Detail
+ *
+ * @param appId
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "more")
+ @ResponseBody
+ public ModelAndView more(@RequestParam(value = "appId", required = false) String appId
+ , @RequestParam(value = "token", required = false) String token
+ , HttpSession session) throws Exception {
+ logger.debug( "APP modify--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() );
+
+ Map<String, Object> model = new LinkedHashMap<String, Object>();
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ model.put( MODEL_ERRORS, jr.getData().toString() );
+ return new ModelAndView( PageMapping.APP_LIST.toString(), model );
+ }
+ AppForm apForm = new AppForm();
+ try {
+ // Search AppForm By AppId
+ apForm = appService.searchFormById(appId, session);
+ // Get App Option
+ appService.getAppTypeOption( model, true, session );
+ apForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(BreadcrumbMapping.APP_DETAIL).getBreadcrumb() );
+ } catch ( Exception e ) {
+ model.put( MODEL_ERRORS, e.getMessage() );
+ return new ModelAndView( PageMapping.APP_LIST.toString(), model );
+ }
+
+ // Get App Option
+ appService.getAppTypeOption( model, true, session );
+ String date = DateTimeUtils.getDate(DateTimeUtils.DATE_FORMAT_YYYYMMDD, apForm.getCreateDate());
+ model.put( "appInfo", apForm );
+ model.put("date", date);
+ model.put( Constants.TOKEN_AUTHORIZATION,token);
+ logger.debug( "APP modify" );
+ return new ModelAndView( PageMapping.APP_MODIFY.toString(), model );
+ }
+
+ /**
+ * App Manager initCreate
+ *
+ * @param appId
+ * @param token
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "initCreate")
+ public ModelAndView initCreate(@RequestParam(value = "appId", required = false) String appId,
+ @RequestParam(value = "token", required = false) String token, HttpSession session) throws Exception {
+ logger.debug( "APP save--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() );
+
+ Map<String, Object> model = new LinkedHashMap<String, Object>();
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ model.put( MODEL_ERRORS, jr.getData().toString() );
+ return new ModelAndView( PageMapping.APP_LIST.toString(), model );
+ }
+
+ AppForm apForm;
+ String breadcrumb;
+ try {
+ // Get App Option
+ appService.getDeviceTypeOption(model, false, session);
+ apForm = new AppForm();
+ breadcrumb = BreadcrumbMapping.APP_INSERT;
+ apForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(breadcrumb).getBreadcrumb() );
+ } catch (Exception e) {
+ LogUtil.printCatchLog(logger, e);
+ model.put(MODEL_ERRORS, e.getMessage());
+ return new ModelAndView(PageMapping.APP_LIST.toString(), model);
+ }
+
+ // Search Userid
+ model.put( "appInfo", apForm );
+ model.put( "userid", userService.selectCurrentUser( session ).getUserId() );
+ logger.debug( "APP save" );
+ return new ModelAndView( PageMapping.CREATE_APP.toString(), model );
+ }
+
+ /**
+ * App Manager createApp
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "createApp")
+ @ResponseBody
+ public String createApp(@RequestParam(value = "file",required = false) MultipartFile file,
+ @RequestParam(value = "form") String formString, HttpSession session) {
+ logger.debug("APP update start --Class: " + this.getClass().getName() + "--method: " + Thread.currentThread().getStackTrace()[1].getMethodName());
+ logger.debug("formString= " + formString);
+
+ List<String> errorList = new ArrayList<String>();
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ return writeErrorList(jr, errorList);
+ }
+ AppForm appForm = JsonMapperUtils.readValue(formString, AppForm.class);
+ checkUpdateInfo(appForm, errorList, file);
+
+ String ret="";
+ if (CollectionUtils.isEmpty(errorList)) {
+ try {
+ String token = SpringWebUtil.getRequest().getParameter("token");
+ User curUser = userService.selectCurrentUser(session);
+ appForm.setDeveloper(curUser.getUserId());
+ ret = appService.save(appForm, session);
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, errorList);
+ }
+ } else {
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, errorList);
+ }
+ logger.debug("APP update stop");
+ return ret;
+ }
+
+ /**
+ * App Manager initInfo
+ *
+ * @param appId
+ * @param isCreate
+ * @return
+ */
+ @RequestMapping(value = "initInfo")
+ public ModelAndView initInfo(String appId, int modifyFlag, HttpSession session){
+ LinkedHashMap<String, Object> model = new LinkedHashMap<>();
+ AppForm appForm = new AppForm();
+ String breadcrumb;
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ model.put(MODEL_ERRORS, jr.getData());
+ //return writeErrorList(jr, jr.getData());
+ }else {
+ try{
+ appForm = appService.searchFormById(appId, session);
+ appService.getAppTypeOption( model, false, session);
+ appService.getIsPublicOption(model, false, session);
+
+ if(modifyFlag == Constants.APP_CREATE_DETAIL){
+ //create
+ breadcrumb = BreadcrumbMapping.APP_INSERT;
+ appForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(breadcrumb).getBreadcrumb() );
+ }else{
+ if(modifyFlag == Constants.APP_MODIFY){
+ //list modfiy
+ breadcrumb = BreadcrumbMapping.APP_MODIFY;
+ appForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(breadcrumb).getBreadcrumb() );
+ }else if(modifyFlag == Constants.APP_DETAIL_MODIFY){
+ //detail modfiy
+ breadcrumb = BreadcrumbMapping.APP_DETAIL_MODIFY;
+ appForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(breadcrumb).getBreadcrumb() );
+ }
+ String url = appForm.getBreadcrumb().get(1).getUrl();
+ url = url+"?"+"appId="+appId;
+ appForm.getBreadcrumb().get(1).setUrl(url);
+ }
+ }catch (Exception e) {
+ logger.error(e.getMessage());
+ model.put(MODEL_ERRORS, e.getMessage());
+ }
+ model.put("appInfo", appForm);
+ }
+
+ return new ModelAndView( PageMapping.SAVE_APP_INFO.toString(), model );
+ }
+
+ /**
+ * App Manager saveAppInfo
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "saveInfo")
+ @ResponseBody
+ public String saveInfo(@RequestParam(value = "file",required = false) MultipartFile file,
+ @RequestParam(value = "form") String formString, HttpSession session) {
+ logger.debug("APP update start --Class: " + this.getClass().getName() + "--method: " + Thread.currentThread().getStackTrace()[1].getMethodName());
+ logger.debug("formString= " + formString);
+
+ List<String> errorList = new ArrayList<String>();
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ return writeErrorList(jr, errorList);
+ }
+ AppForm appForm = JsonMapperUtils.readValue(formString, AppForm.class);
+ checkUpdateInfo(appForm, errorList, file);
+ String ret = "";
+ if (CollectionUtils.isEmpty(errorList)) {
+ try {
+ User curUser = userService.selectCurrentUser(session);
+ appForm.setIsDel("0");
+ appForm.setDeveloper(curUser.getUserId());
+ ret = appService.save(appForm, session);
+ if(JsonMapperUtils.getResult(ret)) {
+ if (file != null) {
+ // Picture name is fileName
+ String fileName = file.getOriginalFilename();
+ appForm.setImagePath(null);
+ ret = appService.upload(appForm, file, fileName, true, session);
+ }
+ ret = appService.saveVersion(appForm, session);
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, errorList);
+ }
+ } else {
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null,errorList);
+ }
+ logger.debug("APP update stop");
+ return ret;
+ }
+
+ /**
+ * App Manager initCheck
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "initCheck")
+ public ModelAndView initCheck(String appId, HttpSession session){
+ LinkedHashMap<String, Object> model = new LinkedHashMap<>();
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ model.put(MODEL_ERRORS, jr.getData());
+ //return writeErrorList(jr, jr.getData());
+ }
+ AppForm appForm = new AppForm();
+ String date = "";
+ try{
+ appForm = appService.searchFormById(appId, session);
+ date = DateTimeUtils.getDate(DateTimeUtils.DATE_FORMAT_YYYYMMDD, appForm.getCreateDate());
+ appForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(BreadcrumbMapping.APP_INSERT).getBreadcrumb() );
+ }catch (Exception e) {
+ logger.error(e.getMessage());
+ model.put(MODEL_ERRORS, e.getMessage());
+ }
+ model.put("date", date);
+ model.put("appInfo", appForm);
+ return new ModelAndView( PageMapping.CHECK_APP_INFO.toString(), model );
+ }
+
+ /**
+ * App Manager check
+ *
+ * @param
+ * @return
+ */
+ @RequestMapping(value = "check")
+ @ResponseBody
+ public String check(String appId){
+ String ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, PageMapping.APP.toString(), null);
+ return ret;
+ }
+
+ /**
+ * App Manager Search
+ *
+ * @param draw
+ * @param length
+ * @param start
+ * @param sort
+ * @param appDeveloper
+ * @param appTypeId
+ * @param appName
+ * @param order
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "search")
+ @ResponseBody
+ public String search(@RequestParam(value = "draw") String draw, @RequestParam(value = "length") int length,
+ @RequestParam(value = "start") int start, @RequestParam(value = "orderColumn") String sort,
+ @RequestParam(value = "typeId") String appTypeId,@RequestParam(value = "orderDir") String order,
+ @RequestParam(value = "deviceTypeId") String appDeviceTypeId,@RequestParam(value = "token", required = false) String token,
+ @RequestParam(value = "keyWord") String keyWord, HttpSession session) throws Exception {
+ logger.debug( "Search list start --Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() + keyWord );
+
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ return writeDataTableMap( jr, draw );
+ }
+ // Assign value To AppForm
+ AppForm form = new AppForm();
+ form.setDraw( draw );
+ form.setAppDeviceTypeId(appDeviceTypeId);
+ form.setTypeId(appTypeId);
+ form.setOffset( start );
+ form.setLimit( length );
+ form.setSort( "createDate" );
+ form.setOrder( ApiParam.API_PARAM_VALUE_ORDER_DESC );
+ form.setIsDel( "0" );
+ form.setKeyWord(keyWord);
+ User user = userService.selectCurrentUser(session);
+ if(user == null){
+ form.setAppIsPublic(ApiParam.API_PARAM_DEFAULT_IS_PUBLIC);
+ }
+ // Page Search
+ String ret = appService.selectPaginationData( form, session );
+ logger.debug( "Search list stop" );
+ return ret;
+ }
+
+ @RequestMapping(value = "downloadenter")
+ @ResponseBody
+ public void downloadtest() {
+ logger.debug( "download done" );
+ }
+ /**
+ * App Manager Download File
+ *
+ * @param appId
+ * @param typeId
+ * @param filePath
+ * @param response
+ * @throws HttpException
+ * @throws FileNotFoundException
+ */
+ @RequestMapping(value = "download")
+ @ResponseBody
+ public void download(@RequestParam(value = "appId", required = false) String appId,
+ @RequestParam(value = "typeId", required = false) String typeId,
+ @RequestParam(value = "filePath", required = false) String filePath,
+ HttpServletResponse response, HttpSession session)
+ throws HttpException, FileNotFoundException {
+ logger.debug( "download--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() + filePath );
+ // Assign value To AppForm
+ AppForm form = new AppForm();
+ form.setAppId(appId);
+ form.setTypeId(typeId);
+ form.setVerFilePath(filePath);
+
+ try {
+ // App Download
+ ResponseEntity<byte[]> rEntity = appService.download(form, session);
+ response.setContentType(rEntity.getHeaders().getContentType().toString());
+ response.setContentLength((int) rEntity.getHeaders().getContentLength());
+ String headerKey = "Content-Disposition";
+ String contentDisponsition = rEntity.getHeaders().get(headerKey).get(0);
+ response.setHeader(headerKey, contentDisponsition);
+
+ OutputStream outStream = response.getOutputStream();
+ outStream.write(rEntity.getBody(), 0, rEntity.getBody().length);
+ outStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ logger.debug( "download done" );
+ }
+ /**
+ * App Manager uploadFile
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "uploadFile")
+ @ResponseBody
+ public String uploadFile(@RequestParam(value = "file",required = false) MultipartFile file,
+ @RequestParam(value = "form") String formString, HttpSession session) {
+ logger.debug("APP update start --Class: " + this.getClass().getName() + "--method: " + Thread.currentThread().getStackTrace()[1].getMethodName());
+ logger.debug("formString= " + formString);
+ String ret ="";
+
+ AppForm appForm = JsonMapperUtils.readValue(formString, AppForm.class);
+ List<String> errorList = new ArrayList<String>();
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if (jr.getStatus() != Constants.STATUS_SUCCESS) {
+ return writeErrorList(jr, errorList);
+ }
+ try {
+ String fileName = appForm.getVerFilePath();
+ ret = appService.upload(appForm, file, fileName, false, session);
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, e.getMessage());
+ }
+ logger.debug("APP update stop");
+ return ret;
+ }
+
+ /**
+ * App Manager Delete
+ *
+ * @param id
+ * @return
+ */
+ @RequestMapping(value = "delete")
+ @ResponseBody
+ public String delete(@RequestParam(value = "id") String id, HttpSession session) {
+ logger.debug( "APP delete start, id=" + id );
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ return writeErrorString( jr );
+ }
+ // App Delete By AppId。
+ String ret = appService.delete( id, session );
+ logger.debug( "APP delete stop" );
+ return JsonMapperUtils.getJsonString( ret, null, "" );
+ }
+
+ /**
+ * App Manager type
+ *
+ * @param
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "type")
+ @ResponseBody
+ public ModelAndView type(String type, HttpSession session) throws Exception{
+ LinkedHashMap<String, Object> model = new LinkedHashMap<>();
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ model.put( MODEL_ERRORS, jr.getData().toString() );
+ return new ModelAndView( PageMapping.APP_TYPE.toString(), model );
+ }
+
+ try {
+ // Get App Option
+ appService.getAppTypeOption( model, false, session );
+ appService.getDeviceTypeOption(model, false, session);
+ } catch ( Exception e ) {
+ model.put( MODEL_ERRORS, e.getMessage() );
+ return new ModelAndView( PageMapping.APP_TYPE.toString(), model );
+ }
+
+ return new ModelAndView( PageMapping.APP_TYPE.toString(), model );
+
+
+ }
+
+ /**
+ * Add Or Update Type/Device Type
+ *
+ * @param dicType
+ * @param dicValue
+ * @param dicLabel
+ * @return
+ */
+ @RequestMapping(value = "saveType")
+ @ResponseBody
+ public String saveType(@RequestParam(value = "type", required = false) String dicType,
+ @RequestParam(value = "typeValue", required = false) String dicValue,
+ @RequestParam(value = "typeLabel", required = false) String dicLabel,
+ HttpSession session) {
+ String ret = "";
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ return JsonMapperUtils.getJsonString(jr.getStatus(), null, jr.getData());
+ }
+ try {
+ ret = appService.saveDictionary(dicType, dicValue, dicLabel, session);
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, e.getMessage());
+ }
+ logger.debug("Add Or Update Type/Device Type stop");
+ return ret;
+ }
+
+ /**
+ * check update info
+ * @param appForm
+ * @return
+ */
+ private List<String> checkUpdateInfo(AppForm appForm, List<String> errorList, MultipartFile imageFile) {
+
+ if(StringUtils.isEmpty(appForm.getAppId())){
+ if (StringUtils.isEmpty(appForm.getAppDeviceTypeId())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_DEVICETYPE_IS_NOT_EMPTY));
+ }
+ }else {
+ if(StringUtils.isEmpty(appForm.getVerFilePath())){
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_FILEPATH_IS_NOT_EMPTY));
+ }
+ if (StringUtils.isEmpty(appForm.getTypeId())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_TYPEID_IS_NOT_EMPTY));
+ }
+ if (appForm.getVerFilePath().length() > ApiParam.API_PARAM_VERFILEPATH_LENGTH) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_FILEPATH_MAX_ERROR));
+ }
+ if (StringUtils.isEmpty(appForm.getAppAbstract().replace(" ", ""))) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_ABSTRACT_IS_NOT_EMPTY));
+ }
+ if (appForm.getAppAbstract().length() > ApiParam.API_PARAM_APPABSTRACT_LENGTH) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_ABSTRACT_MAX_ERROR));
+ }
+ if(StringUtils.isEmpty(appForm.getAppName())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_APPNAME_IS_NOT_EMPTY));
+ }
+ if(imageFile == null && StringUtils.isEmpty(appForm.getImagePath())) {
+ errorList.add(MessageUtil.getPropertites(KeysConstants.APP_IMAGRPATH_IS_NOT_EMPTY));
+ }
+ }
+
+ return errorList;
+ }
+} \ No newline at end of file
diff --git a/warehouse/src/main/java/app/market/web/controller/login/LoginController.java b/warehouse/src/main/java/app/market/web/controller/login/LoginController.java
new file mode 100644
index 0000000..316d0e8
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/login/LoginController.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller.login;
+
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import app.market.utils.Md5Util;
+import app.market.utils.constants.Constants;
+import app.market.utils.json.JsonMapperUtils;
+import app.market.utils.property.KeysConstants;
+import app.market.utils.property.MessageUtil;
+import app.market.utils.webservice.ApiParam;
+import app.market.web.controller.ControllerMapping;
+import app.market.web.controller.PageMapping;
+import app.market.web.controller.SpringBaseController;
+import app.market.web.services.login.LoginService;
+
+/**
+ * login
+ *
+ * @author Toyota
+ * @date 2017/10/10
+ */
+@Controller
+@RequestMapping(value = "login")
+public class LoginController extends SpringBaseController {
+
+ @Autowired
+ private LoginService loginService;
+
+ @RequestMapping(value = "")
+ public ModelAndView init() {
+ return new ModelAndView( PageMapping.LOGIN.toString(), null );
+ }
+
+ /**
+ * signin
+ *
+ * @param loginId
+ * @param userPw
+ * @param httpSession
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "signin")
+ @ResponseBody
+ public String login(@RequestParam(value = "loginId") String loginId,
+ @RequestParam(value = "userPw") String userPw,
+ HttpSession session) throws Exception {
+ //MD5 encrypt
+ String userPwMd = Md5Util.md5(userPw);
+ List<String> errList = new LinkedList<String>();
+ if ( StringUtils.isEmpty( loginId ) ) {
+ errList.add( MessageUtil.getPropertites( KeysConstants.LOGIN_LOGINID_IS_NOT_EMPTY ) );
+ }
+ if ( StringUtils.isEmpty( userPw ) ) {
+ errList.add( MessageUtil.getPropertites( KeysConstants.LOGIN_PASSWORD_IS_NOT_EMPTY ) );
+ }
+ if ( errList.size() > 0 ) {
+ return JsonMapperUtils.getJsonString( Constants.STATUS_UNAUTHORIZED, null, errList );
+ }
+
+ try {
+ String port = (String)session.getAttribute(Constants.SESSION_PORT);
+ String systemToken = (String)session.getAttribute(Constants.SESSION_SYSTEM_TOKEN);
+ String installPath = (String)session.getAttribute(Constants.SESSION_INSTALL_PATH);
+ String jsonStr = loginService.loginUser( loginId, userPwMd, session);
+ Map<String,String> value = JSON.parseObject(jsonStr, Map.class);
+ boolean result = JsonMapperUtils.getResult(jsonStr);
+ if(result){
+ String message = (String)JsonMapperUtils.getMessage(jsonStr);
+ JSONObject jsonObj = JsonMapperUtils.getJsonObject(message);
+ String token = jsonObj.getString(ApiParam.API_RESPONSE_TOKEN);
+ String refreshtoken = jsonObj.getString(ApiParam.API_RESPONSE_REFRESHTOKEN);
+ session.setAttribute( Constants.SESSION_TOKEN, token );
+ session.setAttribute( Constants.SESSION_REFRESH_TOKEN, refreshtoken );
+
+ if(StringUtils.isNotEmpty(port) && StringUtils.isNotEmpty(systemToken) && StringUtils.isNotEmpty(installPath)){
+ String param = "?" + Constants.ACCESS_PORT + "=" + port + "&" + Constants.ACCESS_SYSTEM_TOKEN + "=" + systemToken + "&" + Constants.ACCESS_INSTALL_PATH + "=" + installPath;
+ value.put("forward",ControllerMapping.MAINDEV.toString() + param);
+ }else{
+ value.put("forward",ControllerMapping.MAIN.toString());
+ }
+ jsonStr = JSON.toJSONString(value);
+ }
+ return jsonStr;
+ } catch ( Exception e ) {
+ e.getMessage();
+ throw new RuntimeException( e.getMessage() );
+ }
+ }
+
+ /**
+ * login screen init
+ *
+ * @param httpSession
+ * @return
+ */
+ @RequestMapping(value = "init")
+ @ResponseBody
+ public String init(HttpSession httpSession) {
+ // Enumeration<String> attributes = httpSession.getAttributeNames();
+ // while ( attributes.hasMoreElements() ) {
+ // String name = attributes.nextElement();
+ // httpSession.removeAttribute( name );
+ // }
+ /* httpSession.invalidate();*/
+ return JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, ControllerMapping.LOGIN.toString(), null );
+ }
+
+ /**
+ * logout
+ *
+ * @param httpSession
+ * @return
+ */
+ @RequestMapping(value = "logout")
+ @ResponseBody
+ public String logout(HttpSession httpSession) {
+ Enumeration<String> attributes = httpSession.getAttributeNames();
+ while (attributes.hasMoreElements()) {
+ String name = attributes.nextElement();
+ httpSession.removeAttribute(name);
+ }
+ httpSession.invalidate();
+ return "";
+ }
+
+} \ No newline at end of file
diff --git a/warehouse/src/main/java/app/market/web/controller/main/MainController.java b/warehouse/src/main/java/app/market/web/controller/main/MainController.java
new file mode 100644
index 0000000..c867225
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controller/main/MainController.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
+ *
+ * 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 app.market.web.controller.main;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.ModelAndView;
+
+import app.market.utils.constants.Constants;
+import app.market.utils.json.JsonResult;
+import app.market.web.controller.PageMapping;
+import app.market.web.controller.SpringBaseController;
+import app.market.web.services.account.AccountService;
+import app.market.web.services.app.AppService;
+import app.market.web.services.main.MainService;
+import app.market.web.services.user.UserService;
+
+/**
+ * ログイン
+ *
+ * @author Toyota
+ * @date 2017/10/10
+ */
+@Controller
+@RequestMapping(value = "main")
+public class MainController extends SpringBaseController {
+
+ @Autowired
+ private MainService mainService;
+
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private AccountService accountService;
+
+ @Autowired
+ private AppService appService;
+
+ /**
+ * init
+ *
+ * @param token
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "")
+ public ModelAndView init(HttpSession session) throws Exception {
+ LinkedHashMap<String, Object> modal = new LinkedHashMap<>();
+ Map<String, Object> model = new LinkedHashMap<String, Object>();
+
+ String token = (String) session.getAttribute(Constants.SESSION_TOKEN);
+ String refreshToken = (String) session.getAttribute(Constants.SESSION_TOKEN);
+ if(StringUtils.isNotEmpty(token) && StringUtils.isNotEmpty(refreshToken)){
+ JsonResult jr = mainService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ modal.put( MODEL_ERRORS, jr.getData().toString() );
+ return new ModelAndView( PageMapping.MAIN.toString(), modal );
+ }
+
+ model.put("username", userService.selectCurrentUser(session).getUserName());
+ model.put("userid", userService.selectCurrentUser(session).getUserId());
+ model.put("auid", userService.selectCurrentUser(session).getAuId());
+ model.put("menuPathString", mainService.selectMenuResourceByLoginId(session));
+ model.put( Constants.TOKEN_AUTHORIZATION, token );
+ model.put( Constants.TOKEN_AUTHORIZATION_REFRESH, refreshToken );
+ }
+
+ appService.getAppTypeOption(model, true, session);
+ appService.getDeviceTypeOption(model, true, session);
+ accountService.getAuthorityList(model, true, session);
+ return new ModelAndView( PageMapping.MAIN.toString(), model );
+ }
+
+}