summaryrefslogtreecommitdiffstats
path: root/warehouse/src/main/java/app
diff options
context:
space:
mode:
Diffstat (limited to 'warehouse/src/main/java/app')
-rw-r--r--warehouse/src/main/java/app/market/LogUtil.java25
-rw-r--r--warehouse/src/main/java/app/market/PropertyTool.java55
-rw-r--r--warehouse/src/main/java/app/market/WebServiceClient.java81
-rw-r--r--warehouse/src/main/java/app/market/filter/Filter.java37
-rw-r--r--warehouse/src/main/java/app/market/filter/Log4jlistener.java53
-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
-rw-r--r--warehouse/src/main/java/app/market/web/controllerDev/appDev/AppControllerDev.java367
-rw-r--r--warehouse/src/main/java/app/market/web/controllerDev/login/package-info.java20
-rw-r--r--warehouse/src/main/java/app/market/web/controllerDev/mainDev/MainControllerDev.java86
-rw-r--r--warehouse/src/main/java/app/market/web/form/PaginationForm.java84
-rw-r--r--warehouse/src/main/java/app/market/web/form/TokenForm.java45
-rw-r--r--warehouse/src/main/java/app/market/web/form/account/AccountForm.java139
-rw-r--r--warehouse/src/main/java/app/market/web/form/app/AppForm.java255
-rw-r--r--warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbFrom.java36
-rw-r--r--warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbSubFrom.java52
-rw-r--r--warehouse/src/main/java/app/market/web/form/login/LoginForm.java99
-rw-r--r--warehouse/src/main/java/app/market/web/form/login/SessionForm.java79
-rw-r--r--warehouse/src/main/java/app/market/web/form/user/UserForm.java79
-rw-r--r--warehouse/src/main/java/app/market/web/services/SpringBaseService.java248
-rw-r--r--warehouse/src/main/java/app/market/web/services/account/AccountService.java76
-rw-r--r--warehouse/src/main/java/app/market/web/services/account/impl/AccountServiceImpl.java220
-rw-r--r--warehouse/src/main/java/app/market/web/services/app/AppService.java124
-rw-r--r--warehouse/src/main/java/app/market/web/services/app/impl/AppServiceImpl.java511
-rw-r--r--warehouse/src/main/java/app/market/web/services/login/LoginService.java25
-rw-r--r--warehouse/src/main/java/app/market/web/services/login/impl/LoginServiceImpl.java81
-rw-r--r--warehouse/src/main/java/app/market/web/services/main/MainService.java27
-rw-r--r--warehouse/src/main/java/app/market/web/services/main/impl/MainServiceImpl.java71
-rw-r--r--warehouse/src/main/java/app/market/web/services/user/UserService.java35
-rw-r--r--warehouse/src/main/java/app/market/web/services/user/impl/UserServiceImpl.java141
36 files changed, 4815 insertions, 0 deletions
diff --git a/warehouse/src/main/java/app/market/LogUtil.java b/warehouse/src/main/java/app/market/LogUtil.java
new file mode 100644
index 0000000..cd9ac0c
--- /dev/null
+++ b/warehouse/src/main/java/app/market/LogUtil.java
@@ -0,0 +1,25 @@
+/*
+ * 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;
+
+import org.slf4j.Logger;
+
+public class LogUtil {
+
+ public static void printCatchLog(final Logger logger, Exception e){
+ logger.error("Thread.currentThread().getStackTrace()[1].getMethodName()" + e.getMessage());
+ }
+}
diff --git a/warehouse/src/main/java/app/market/PropertyTool.java b/warehouse/src/main/java/app/market/PropertyTool.java
new file mode 100644
index 0000000..24f2cda
--- /dev/null
+++ b/warehouse/src/main/java/app/market/PropertyTool.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+import app.market.utils.constants.Constants;
+
+
+public class PropertyTool {
+
+ public static Properties prop;
+
+ private static Properties getPropertyInstance() {
+ if ( prop == null ) {
+ prop = new Properties();
+ try {
+ prop.load( new InputStreamReader(
+ PropertyTool.class.getClassLoader().getResourceAsStream( Constants.PROPERTIES_FILE_NAME_PROPERTIES ), Constants.CHARACTER_UTF8 ) );
+ } catch ( FileNotFoundException e ) {
+ throw new RuntimeException();
+ } catch ( IOException e ) {
+ throw new RuntimeException();
+ }
+ }
+ return PropertyTool.prop;
+ }
+
+ /**
+ * get propertites
+ *
+ * @param type
+ * @return String
+ */
+ public static String getPropertites(String type) {
+ prop = getPropertyInstance();
+ return prop.getProperty( type );
+ }
+}
diff --git a/warehouse/src/main/java/app/market/WebServiceClient.java b/warehouse/src/main/java/app/market/WebServiceClient.java
new file mode 100644
index 0000000..528af0e
--- /dev/null
+++ b/warehouse/src/main/java/app/market/WebServiceClient.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import app.market.utils.webservice.WebServiceURI;
+
+public class WebServiceClient {
+
+ private static final String REST_SERVICE_URI = PropertyTool.getPropertites( "webservice_base_uri" );
+
+ /** token expire */
+ public static final String REST_TOKEN_VALIDATETOKENEXPIRE = REST_SERVICE_URI.concat( WebServiceURI.REST_TOKEN_VALIDATETOKENEXPIRE_LF );
+
+ public static final String REST_TOKEN_VALIDATETOKENAUTHORTICATION = REST_SERVICE_URI.concat( WebServiceURI.REST_TOKEN_VALIDATETOKENAUTHORTICATION_LF );
+
+ public static final String REST_TOKEN = REST_SERVICE_URI.concat( WebServiceURI.REST_TOKEN_LF );
+
+
+ /** ▼▼▼▼▼▼▼▼▼▼ user ▼▼▼▼▼▼▼▼▼▼ */
+ /** login */
+ public static final String REST_USER_SELECTLOGINUSER = REST_SERVICE_URI.concat( WebServiceURI.REST_USER_SELECTLOGINUSER_LF );
+ /** get user collection */
+ public static final String REST_USER_SELECTPAGINATIONDATABYEXAMPLE = REST_SERVICE_URI.concat( WebServiceURI.REST_USER_SELECTPAGINATIONDATABYEXAMPLE_LF );
+ /** get user information */
+ public static final String REST_USER_BY_USERNAME = REST_SERVICE_URI.concat( WebServiceURI.REST_USER_BY_USERNAME_LF );
+ /** get current user */
+ public static final String REST_USER_SELECT_CURRENT = REST_SERVICE_URI.concat( WebServiceURI.REST_USER_SELECT_CURRENT_LF );
+ /** save user */
+ public static final String REST_USER = REST_SERVICE_URI.concat( WebServiceURI.REST_USER_LF );
+ /** delete user */
+ public static final String REST_USER_BY_USERID = REST_SERVICE_URI.concat( WebServiceURI.REST_USER_BY_USERID_LF );
+ /** ▲▲▲▲▲▲▲▲▲▲ user ▲▲▲▲▲▲▲▲▲▲ */
+
+ /** ▼▼▼▼▼▼▼▼▼▼ application ▼▼▼▼▼▼▼▼▼▼ */
+ /** get application collection */
+ public static final String REST_APP_COLLECTION_APP = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_COLLECTION_APP_LF );
+ /** get application information */
+ public static final String REST_APP_INFO = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_INFO_LF );
+
+ public static final String REST_APP_INFO_PARM_ID = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_INFO_PARM_ID_LF );
+ /** get application authority */
+ public static final String REST_APP_INFO_PARM_CUSTOMID = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_INFO_PARM_CUSTOMID_LF );
+
+ public static final String REST_APP_VERSION_INFO = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_VERSION_INFO_LF );
+
+ /** upload application */
+ public static final String REST_APP_FILE = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_FILE_LF );
+
+ public static final String REST_APP_FILE_PARM_FILENAME_TYPEID_APPID = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_FILE_PARM_FILENAME_TYPEID_APPID_LF );
+
+ public static final String REST_APP_IMAGE = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_IMAGE_LF );
+ public static final String REST_APP_FILE_PARM_FILEPATH = REST_SERVICE_URI.concat( WebServiceURI.REST_APP_FILE_PARM_FILEPATH_LF );
+ /** ▲▲▲▲▲▲▲▲▲▲ application ▲▲▲▲▲▲▲▲▲▲ */
+
+ /** ▼▼▼▼▼▼▼▼▼▼ authority ▼▼▼▼▼▼▼▼▼▼ */
+ /** get authority list */
+ public static final String REST_AUTHORITY_GET_LIST_OPTION = REST_SERVICE_URI.concat( WebServiceURI.REST_AUTHORITY_GET_LIST_OPTION_LF );
+ /** ▲▲▲▲▲▲▲▲▲▲ authority ▲▲▲▲▲▲▲▲▲▲ */
+
+ /** ▼▼▼▼▼▼▼▼▼▼ resource ▼▼▼▼▼▼▼▼▼▼ */
+ public static final String REST_RESOURCE_GET_MENU_RESOURCES_BY_LOGINID = REST_SERVICE_URI.concat( WebServiceURI.REST_RESOURCE_GET_MENU_RESOURCES_BY_LOGINID_LF );
+ /** ▲▲▲▲▲▲▲▲▲▲ resource ▲▲▲▲▲▲▲▲▲▲ */
+
+ /** ▼▼▼▼▼▼▼▼▼▼ dictionary ▼▼▼▼▼▼▼▼▼▼ */
+ public static final String REST_DICTIONARY_COLLECTION = REST_SERVICE_URI.concat( WebServiceURI.REST_DICTIONARY_COLLECTION_LF );
+ public static final String REST_DICTIONARY_INFO = REST_SERVICE_URI.concat( WebServiceURI.REST_DICTIONARY_INFO_LF );
+ /** ▲▲▲▲▲▲▲▲▲▲ dictionary ▲▲▲▲▲▲▲▲▲▲ */
+}
diff --git a/warehouse/src/main/java/app/market/filter/Filter.java b/warehouse/src/main/java/app/market/filter/Filter.java
new file mode 100644
index 0000000..68465c1
--- /dev/null
+++ b/warehouse/src/main/java/app/market/filter/Filter.java
@@ -0,0 +1,37 @@
+/*
+ * 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.filter;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.filter.OncePerRequestFilter;
+
+public class Filter extends OncePerRequestFilter {
+
+ @Override
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws ServletException, IOException {
+
+ filterChain.doFilter( request, response );
+
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/filter/Log4jlistener.java b/warehouse/src/main/java/app/market/filter/Log4jlistener.java
new file mode 100644
index 0000000..b7b2325
--- /dev/null
+++ b/warehouse/src/main/java/app/market/filter/Log4jlistener.java
@@ -0,0 +1,53 @@
+/*
+ * 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.filter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+public class Log4jlistener implements ServletContextListener {
+
+ public void contextDestroyed(ServletContextEvent servletcontextevent) {
+ // System.getProperties().clear();
+ }
+
+ public void contextInitialized(ServletContextEvent servletcontextevent) {
+ Properties prop = new Properties();
+ try {
+ prop.load( new InputStreamReader(
+ Log4jlistener.class.getClassLoader().getResourceAsStream( "config/properties.properties" ) ) );
+ } catch ( IOException e ) {
+ e.printStackTrace();
+ }
+ Enumeration<Object> e = prop.keys();
+ while ( e.hasMoreElements() ) {
+ String key = e.nextElement().toString();
+ String path = prop.getProperty( key );
+ System.setProperty( key, path );
+ File f = new File( path );
+ if ( !f.getParentFile().exists() ) {
+ f.getParentFile().mkdirs();
+ }
+ }
+ }
+
+}
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 );
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/controllerDev/appDev/AppControllerDev.java b/warehouse/src/main/java/app/market/web/controllerDev/appDev/AppControllerDev.java
new file mode 100644
index 0000000..4a5f0ce
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controllerDev/appDev/AppControllerDev.java
@@ -0,0 +1,367 @@
+/*
+ * 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.controllerDev.appDev;
+
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+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.codehaus.jackson.type.JavaType;
+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.web.bind.annotation.RequestBody;
+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.JSONObject;
+
+import app.market.model.resource.Resource;
+import app.market.model.user.User;
+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.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 = "appDev")
+public class AppControllerDev extends SpringBaseController {
+ private static Logger logger = LoggerFactory.getLogger( AppControllerDev.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.M3_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.M3_LIST.toString(), model );
+ }
+
+ /**
+ * App Manager Detail
+ * @param appId
+ * @param token
+ * @param isListDev
+ * @param appStatus //button word(install:0,update:2,launch:1)
+ * @param session
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "detail")
+ @ResponseBody
+ public ModelAndView detail(@RequestParam(value = "appId", required = false) String appId
+ , @RequestParam(value = "token", required = false) String token
+ , @RequestParam(value = "isListDev") boolean isListDev
+ , @RequestParam(value = "appStatus") String appStatus
+ , 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.M3_DETAIL.toString(), model );
+ }
+ AppForm apForm = new AppForm();
+ try {
+ // Search AppForm By AppId
+ apForm = appService.searchFormById(appId, session);
+ apForm.getBreadcrumb().addAll( BreadcrumbMapping.getBreadcrumb(BreadcrumbMapping.APP_DETAIL).getBreadcrumb() );
+ } catch ( Exception e ) {
+ model.put( MODEL_ERRORS, e.getMessage() );
+ return new ModelAndView( PageMapping.M3_DETAIL.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);
+ model.put( "isListDev", isListDev);
+ model.put( "appStatus", appStatus);
+ logger.debug( "APP modify" );
+ return new ModelAndView( PageMapping.M3_DETAIL.toString(), model );
+ }
+
+ /**
+ * App Manager localApp
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "localApp")
+ public ModelAndView localApp(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().toString() );
+ return new ModelAndView( PageMapping.M3_LOCAL_LIST.toString(), model );
+ }
+ try {
+ appService.getAppTypeOption( model, false, session );
+ appService.getDeviceTypeOption(model, false, session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return new ModelAndView( PageMapping.M3_LOCAL_LIST.toString(), model );
+ }
+
+ /**
+ * App Manager localApp
+ *
+ * @param formString
+ * @return
+ */
+ @RequestMapping(value = "SearchDev")
+ public ModelAndView SearchDev(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().toString() );
+ return new ModelAndView( PageMapping.M3_SEARCH.toString(), model );
+ }
+ try {
+ appService.getAppTypeOption( model, false, session );
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return new ModelAndView( PageMapping.M3_SEARCH.toString(), model );
+ }
+
+ /**
+ * 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(ApiParam.API_PARAM_DEFAULT_SORT_NAME);
+ form.setOrder(ApiParam.API_PARAM_VALUE_ORDER_DESC);
+ form.setIsDel(ApiParam.API_PARAM_DEFAULT_DEL);
+ 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 = "CheckUpdateInfoDev")
+ @ResponseBody
+ public String checkUpdateInfo(@RequestBody String localStr, HttpSession session) throws Exception{
+ logger.debug( "CheckDataDev--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() );
+ // Unauthorized Exception
+ JsonResult jr = appService.validateAuthentication1(session);
+ if ( jr.getStatus() != Constants.STATUS_SUCCESS ) {
+ return writeDataTableMap( jr, localStr );
+ }
+ String id = "";
+ String localversion = "";
+ String dbVersion = "";
+ List<AppForm> appList = new ArrayList<>();
+
+ try {
+ List<Object> localAppList = JSONObject.parseArray(localStr);//installed local app list
+
+ for(Object item : localAppList){
+ String localid = ((JSONObject) item).getString(Constants.CONFIG_APP_PARAM_ID);
+ id = localid.substring(0,localid.lastIndexOf(Constants.APP_ID_SEPARATOR));
+ localversion = ((JSONObject) item).getString(Constants.CONFIG_APP_PARAM_VERSION);
+ //check weather the app in locallist is from server or not
+ AppForm form = appService.searchFormByCustomId( id, session );
+ //set local information for local app
+ if(form == null){
+ form = new AppForm();
+ form.setAppName(((JSONObject) item).getString(Constants.CONFIG_APP_PARAM_NAME));
+ //form.setImagePath(((JSONObject) item).getString(Constants.CONFIG_APP_PARAM_ICON));
+ form.setImagePath(null);
+ form.setAppAbstract(((JSONObject) item).getString(Constants.CONFIG_APP_PARAM_DESCRIPTION));
+ form.setVersionName(localversion);
+ form.setCreateDate(null);
+ form.setAppDeviceTypeName(null);
+ form.setAppDeviceTypeId(null);
+ form.setUpdateFlag(false);
+ }
+ //check the systemAPP use localid
+ if(localid.equals(Constants.APP_ID_LAUNCHER) || localid.equals(Constants.APP_ID_HOMESCREEN) || localid.equals(Constants.APP_ID_WAREHOUSE)){
+ form.setSystemApp(true);
+ }else{
+ //check app's versionName for update
+ dbVersion = form.getVersionName();
+ if( !dbVersion.equals(localversion)){
+ form.setUpdateFlag(true);
+ }
+ else{
+ form.setUpdateFlag(false);
+ }
+ }
+ appList.add(form);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return JsonMapperUtils.writeValueAsString( appList );
+ }
+
+ @RequestMapping(value = "downloadenter")
+ @ResponseBody
+ public void downloadtest() {
+ logger.debug( "downloadenter 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 {
+ ResponseEntity<byte[]> rEntity = appService.download(form, session);
+
+ response.setContentType(rEntity.getHeaders().getContentType().toString());
+ response.setContentLength((int) rEntity.getHeaders().getContentLength());
+ String fileInsName = filePath.substring(filePath.lastIndexOf(Constants.PATH_SEPARATOR) + 1);
+ response.addHeader(Constants.APP_HEADER_KEY, Constants.APP_HEADER_VALUE+fileInsName);
+
+ OutputStream outStream = response.getOutputStream();
+ outStream.write(rEntity.getBody(), 0, rEntity.getBody().length);
+ outStream.close();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ logger.debug( "download done" );
+ }
+}
+
+
diff --git a/warehouse/src/main/java/app/market/web/controllerDev/login/package-info.java b/warehouse/src/main/java/app/market/web/controllerDev/login/package-info.java
new file mode 100644
index 0000000..7f0cb67
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controllerDev/login/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+/**
+ * @author Toyota
+ *
+ */
+package app.market.web.controllerDev.login; \ No newline at end of file
diff --git a/warehouse/src/main/java/app/market/web/controllerDev/mainDev/MainControllerDev.java b/warehouse/src/main/java/app/market/web/controllerDev/mainDev/MainControllerDev.java
new file mode 100644
index 0000000..1247a0b
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/controllerDev/mainDev/MainControllerDev.java
@@ -0,0 +1,86 @@
+/*
+ * 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.controllerDev.mainDev;
+
+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.main.MainService;
+import app.market.web.services.user.UserService;
+
+/**
+ * login
+ *
+ * @author Toyota
+ * @date 2017/10/10
+ */
+@Controller
+@RequestMapping(value = "mainDev")
+public class MainControllerDev extends SpringBaseController {
+
+ @Autowired
+ private MainService mainService;
+
+ @Autowired
+ private UserService userService;
+
+ /**
+ * init
+ *
+ * @param token
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping(value = "")
+ public ModelAndView init(@RequestParam(value = "token", required = false) String token, @RequestParam(value = "port") String port, @RequestParam(value = "systemToken") String systemToken, @RequestParam(value = "installPath") String installPath,HttpSession session) throws Exception {
+ LinkedHashMap<String, Object> modal = new LinkedHashMap<>();
+ Map<String, Object> model = new LinkedHashMap<String, Object>();
+
+ session.setAttribute(Constants.SESSION_PORT, port);
+ session.setAttribute(Constants.SESSION_SYSTEM_TOKEN, systemToken);
+ session.setAttribute(Constants.SESSION_INSTALL_PATH, installPath);
+
+ // Not authentication
+ if(StringUtils.isNotEmpty(token)){
+ 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);
+ return new ModelAndView( PageMapping.MAINDEV.toString(), model );
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/form/PaginationForm.java b/warehouse/src/main/java/app/market/web/form/PaginationForm.java
new file mode 100644
index 0000000..06583bb
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/PaginationForm.java
@@ -0,0 +1,84 @@
+/*
+ * 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.form;
+
+public class PaginationForm extends TokenForm {
+
+ private static final long serialVersionUID = 8535085706943416467L;
+
+ private String draw;
+
+ private int offset;
+
+ private int limit;
+
+ private String order;
+
+ private String sort;
+
+ public PaginationForm() {
+ super();
+ }
+
+ public PaginationForm(String draw, int offset, int limit, String sort, String order) {
+ this.draw = draw;
+ this.offset = offset;
+ this.limit = limit;
+ this.order = order;
+ this.sort = sort;
+ }
+
+ public String getDraw() {
+ return draw;
+ }
+
+ public void setDraw(String draw) {
+ this.draw = draw;
+ }
+
+ public int getOffset() {
+ return offset;
+ }
+
+ public void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public String getOrder() {
+ return order;
+ }
+
+ public void setOrder(String order) {
+ this.order = order;
+ }
+
+ public String getSort() {
+ return sort;
+ }
+
+ public void setSort(String sort) {
+ this.sort = sort;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/form/TokenForm.java b/warehouse/src/main/java/app/market/web/form/TokenForm.java
new file mode 100644
index 0000000..cffd23d
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/TokenForm.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.form;
+
+import java.io.Serializable;
+
+import app.market.web.form.breadcrumb.BreadcrumbFrom;
+
+public class TokenForm extends BreadcrumbFrom implements Serializable {
+
+ private static final long serialVersionUID = 2059875376580332152L;
+
+ private String token;
+ private String servletPath;
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getServletPath() {
+ return servletPath;
+ }
+
+ public void setServletPath(String servletPath) {
+ this.servletPath = servletPath;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/form/account/AccountForm.java b/warehouse/src/main/java/app/market/web/form/account/AccountForm.java
new file mode 100644
index 0000000..3e3de7b
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/account/AccountForm.java
@@ -0,0 +1,139 @@
+/*
+ * 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.form.account;
+
+import java.util.Date;
+
+import app.market.web.form.PaginationForm;
+
+public class AccountForm extends PaginationForm {
+
+ private static final long serialVersionUID = -6199786133496150679L;
+
+ private String auId;
+ private String auName;
+ private String baseName;
+ private String userName;
+ private String mailAddress;
+ private String userId;
+ private String userPw;
+ private String reuserPw;
+ private Date createDate;
+ private Date updateDate;
+ private String isDel;
+ private String keyWord;
+
+ public String getKeyWord() {
+ return keyWord;
+ }
+
+ public void setKeyWord(String keyWord) {
+ this.keyWord = keyWord;
+ }
+
+ public String getAuName() {
+ return auName;
+ }
+
+ public void setAuName(String auName) {
+ this.auName = auName;
+ }
+
+ public String getIsDel() {
+ return isDel;
+ }
+
+ public void setIsDel(String isDel) {
+ this.isDel = isDel;
+ }
+
+ public String getBaseName() {
+ return baseName;
+ }
+
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ public String getReuserPw() {
+ return reuserPw;
+ }
+
+ public void setReuserPw(String reuserPw) {
+ this.reuserPw = reuserPw;
+ }
+
+ public String getUserPw() {
+ return userPw;
+ }
+
+ public void setUserPw(String userPw) {
+ this.userPw = userPw;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getMailAddress() {
+ return mailAddress;
+ }
+
+ public void setMailAddress(String mailAddress) {
+ this.mailAddress = mailAddress;
+ }
+
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+
+ public Date getUpdateDate() {
+ return updateDate;
+ }
+
+ public void setUpdateDate(Date updateDate) {
+ this.updateDate = updateDate;
+ }
+
+ public String getAuId() {
+ return auId;
+ }
+
+ public void setAuId(String auId) {
+ this.auId = auId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/form/app/AppForm.java b/warehouse/src/main/java/app/market/web/form/app/AppForm.java
new file mode 100644
index 0000000..f8bb77b
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/app/AppForm.java
@@ -0,0 +1,255 @@
+/*
+ * 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.form.app;
+
+import java.util.Date;
+
+import app.market.web.form.PaginationForm;
+
+public class AppForm extends PaginationForm {
+
+ private static final long serialVersionUID = -6199786133496150679L;
+
+ private String appId;
+
+ private String appName;
+
+ private long appSize;
+
+ private String appAbstract;
+
+ private String typeId;
+
+ private String typeName;
+
+ private String developer;
+
+ private String developerName;
+
+ private String verFilePath;
+
+ private String versionName;
+
+ private String appVersionId;
+
+ private Date createDate;
+
+ private Date updateDate;
+
+ private String isDel;
+
+ private String hashcode;
+
+ private String appIsPublic;
+
+ private String appDeviceTypeId;
+
+ private String appDeviceTypeName;
+
+ private String keyWord;
+
+ private String imagePath;
+
+ private String appIdCustom;//config.xml中のid
+
+ private boolean updateFlag;
+
+ private boolean systemApp;
+
+ public String getAppIdCustom() {
+ return appIdCustom;
+ }
+
+ public void setAppIdCustom(String appIdCustom) {
+ this.appIdCustom = appIdCustom;
+ }
+
+ public String getImagePath() {
+ return imagePath;
+ }
+
+ public void setImagePath(String imagePath) {
+ this.imagePath = imagePath;
+ }
+
+ public String getKeyWord() {
+ return keyWord;
+ }
+
+ public void setKeyWord(String keyWord) {
+ this.keyWord = keyWord;
+ }
+
+ public String getAppDeviceTypeName() {
+ return appDeviceTypeName;
+ }
+
+ public void setAppDeviceTypeName(String appDeviceTypeName) {
+ this.appDeviceTypeName = appDeviceTypeName;
+ }
+
+ public String getAppDeviceTypeId() {
+ return appDeviceTypeId;
+ }
+
+ public void setAppDeviceTypeId(String appDeviceTypeId) {
+ this.appDeviceTypeId = appDeviceTypeId;
+ }
+
+ public String getAppIsPublic() {
+ return appIsPublic;
+ }
+
+ public void setAppIsPublic(String appIsPublic) {
+ this.appIsPublic = appIsPublic;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public String getVerFilePath() {
+ return verFilePath;
+ }
+
+ public void setVerFilePath(String verFilePath) {
+ this.verFilePath = verFilePath;
+ }
+
+ public void setAppId(String appId) {
+ this.appId = appId;
+ }
+
+ public String getAppName() {
+ return appName;
+ }
+
+ public void setAppName(String appName) {
+ this.appName = appName;
+ }
+
+ public long getAppSize() {
+ return appSize;
+ }
+
+ public void setAppSize(long l) {
+ this.appSize = l;
+ }
+
+ public String getAppAbstract() {
+ return appAbstract;
+ }
+
+ public void setAppAbstract(String appAbstract) {
+ this.appAbstract = appAbstract;
+ }
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getDeveloper() {
+ return developer;
+ }
+
+ public void setDeveloper(String developer) {
+ this.developer = developer;
+ }
+
+ public String getDeveloperName() {
+ return developerName;
+ }
+
+ public void setDeveloperName(String developerName) {
+ this.developerName = developerName;
+ }
+
+ public String getVersionName() {
+ return versionName;
+ }
+
+ public void setVersionName(String versionName) {
+ this.versionName = versionName;
+ }
+
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+
+ public Date getUpdateDate() {
+ return updateDate;
+ }
+
+ public void setUpdateDate(Date updateDate) {
+ this.updateDate = updateDate;
+ }
+
+ public String getIsDel() {
+ return isDel;
+ }
+
+ public void setIsDel(String isDel) {
+ this.isDel = isDel;
+ }
+
+ public String getHashcode() {
+ return hashcode;
+ }
+
+ public void setHashcode(String hashcode) {
+ this.hashcode = hashcode;
+ }
+
+ public String getAppVersionId() {
+ return appVersionId;
+ }
+
+ public void setAppVersionId(String appVersionId) {
+ this.appVersionId = appVersionId;
+ }
+
+ public boolean isUpdateFlag() {
+ return updateFlag;
+ }
+
+ public void setUpdateFlag(boolean updateFlag) {
+ this.updateFlag = updateFlag;
+ }
+
+ public boolean isSystemApp() {
+ return systemApp;
+ }
+
+ public void setSystemApp(boolean systemApp) {
+ this.systemApp = systemApp;
+ }
+}
diff --git a/warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbFrom.java b/warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbFrom.java
new file mode 100644
index 0000000..de7533b
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbFrom.java
@@ -0,0 +1,36 @@
+/*
+ * 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.form.breadcrumb;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BreadcrumbFrom implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private List<BreadcrumbSubFrom> breadcrumb = new ArrayList<BreadcrumbSubFrom>();
+
+ public List<BreadcrumbSubFrom> getBreadcrumb() {
+ return breadcrumb;
+ }
+
+ public void setBreadcrumb(List<BreadcrumbSubFrom> breadcrumb) {
+ this.breadcrumb = breadcrumb;
+ }
+
+} \ No newline at end of file
diff --git a/warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbSubFrom.java b/warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbSubFrom.java
new file mode 100644
index 0000000..41b3a5b
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/breadcrumb/BreadcrumbSubFrom.java
@@ -0,0 +1,52 @@
+/*
+ * 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.form.breadcrumb;
+
+import java.io.Serializable;
+
+public class BreadcrumbSubFrom implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private boolean current;
+ private String url;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isCurrent() {
+ return current;
+ }
+
+ public void setCurrent(boolean current) {
+ this.current = current;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+} \ No newline at end of file
diff --git a/warehouse/src/main/java/app/market/web/form/login/LoginForm.java b/warehouse/src/main/java/app/market/web/form/login/LoginForm.java
new file mode 100644
index 0000000..c27575c
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/login/LoginForm.java
@@ -0,0 +1,99 @@
+/*
+ * 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.form.login;
+
+import java.io.Serializable;
+
+import app.market.web.form.TokenForm;
+
+public class LoginForm extends TokenForm implements Serializable {
+
+ private static final long serialVersionUID = -4180140313384911198L;
+
+ private Integer userId;
+ private String loginId;
+ private String userPw;
+ private String reuserPw;
+ private String userName;
+ private Integer baseId;
+ private String mailAddress;
+ private Integer isDel;
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ public Integer getBaseId() {
+ return baseId;
+ }
+
+ public void setBaseId(Integer baseId) {
+ this.baseId = baseId;
+ }
+
+ public String getLoginId() {
+ return loginId;
+ }
+
+ public void setLoginId(String loginId) {
+ this.loginId = loginId;
+ }
+
+ public String getUserPw() {
+ return userPw;
+ }
+
+ public void setUserPw(String userPw) {
+ this.userPw = userPw;
+ }
+
+ public String getReuserPw() {
+ return reuserPw;
+ }
+
+ public void setReuserPw(String reuserPw) {
+ this.reuserPw = reuserPw;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getMailAddress() {
+ return mailAddress;
+ }
+
+ public void setMailAddress(String mailAddress) {
+ this.mailAddress = mailAddress;
+ }
+
+ public Integer getIsDel() {
+ return isDel;
+ }
+
+ public void setIsDel(Integer isDel) {
+ this.isDel = isDel;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/form/login/SessionForm.java b/warehouse/src/main/java/app/market/web/form/login/SessionForm.java
new file mode 100644
index 0000000..1fe5e50
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/login/SessionForm.java
@@ -0,0 +1,79 @@
+/*
+ * 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.form.login;
+
+import java.io.Serializable;
+
+public class SessionForm implements Serializable {
+
+ private static final long serialVersionUID = -6526850562963464567L;
+
+ private String userId;
+ private String loginId;
+ private String userName;
+ private String loginTime;
+ private String token;
+ private String i18n;
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getLoginId() {
+ return loginId;
+ }
+
+ public void setLoginId(String loginId) {
+ this.loginId = loginId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getLoginTime() {
+ return loginTime;
+ }
+
+ public void setLoginTime(String loginTime) {
+ this.loginTime = loginTime;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getI18n() {
+ return i18n;
+ }
+
+ public void setI18n(String i18n) {
+ this.i18n = i18n;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/form/user/UserForm.java b/warehouse/src/main/java/app/market/web/form/user/UserForm.java
new file mode 100644
index 0000000..c373579
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/form/user/UserForm.java
@@ -0,0 +1,79 @@
+/*
+ * 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.form.user;
+
+import app.market.web.form.PaginationForm;
+
+public class UserForm extends PaginationForm {
+
+ private static final long serialVersionUID = 6226317264592601313L;
+
+ private Integer userId;
+ private String userPw;
+ private String reuserPw;
+ private String userName;
+ private String mailAddress;
+ private Integer isDel;
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ public String getUserPw() {
+ return userPw;
+ }
+
+ public void setUserPw(String userPw) {
+ this.userPw = userPw;
+ }
+
+ public String getReuserPw() {
+ return reuserPw;
+ }
+
+ public void setReuserPw(String reuserPw) {
+ this.reuserPw = reuserPw;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getMailAddress() {
+ return mailAddress;
+ }
+
+ public void setMailAddress(String mailAddress) {
+ this.mailAddress = mailAddress;
+ }
+
+ public Integer getIsDel() {
+ return isDel;
+ }
+
+ public void setIsDel(Integer isDel) {
+ this.isDel = isDel;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/services/SpringBaseService.java b/warehouse/src/main/java/app/market/web/services/SpringBaseService.java
new file mode 100644
index 0000000..8c54aaf
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/SpringBaseService.java
@@ -0,0 +1,248 @@
+/*
+ * 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.services;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.client.HttpClientErrorException;
+
+import com.alibaba.fastjson.JSONObject;
+
+import app.market.WebServiceClient;
+import app.market.model.app.App;
+import app.market.utils.constants.Constants;
+import app.market.utils.datatable.DataTableMap;
+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.rest.RestTemplateUtil;
+import app.market.utils.webservice.ApiParam;
+
+public abstract class SpringBaseService {
+
+ protected String convertEmptyStr(Object obj) {
+ if ( obj == null ) {
+ return Constants.EMPTY_STRING_FALG;
+ }
+ if ( obj instanceof String ) {
+ String s = (String) obj;
+ return StringUtils.isEmpty( s ) ? Constants.EMPTY_STRING_FALG : s;
+
+ } else if ( obj instanceof Integer ) {
+ Integer i = (Integer) obj;
+ return i == null ? Constants.EMPTY_STRING_FALG : i + "";
+
+ } else {
+ return obj.toString();
+ }
+ }
+
+ protected JsonResult validateAuthentication(HttpSession session) {
+ JsonResult jr = new JsonResult();
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ try {
+ String jsonStr = restTemplate.get( WebServiceClient.REST_TOKEN_VALIDATETOKENAUTHORTICATION, session, new String[] {} );
+ jr = JsonMapperUtils.readValue( jsonStr, JsonResult.class );
+ return jr;
+ } catch ( Exception e ) {
+ if ( e instanceof HttpClientErrorException ) {
+ HttpClientErrorException hcee = (HttpClientErrorException) e;
+ switch ( hcee.getStatusCode().value() ) {
+ case Constants.STATUS_UNAUTHORIZED:
+ if (updateAccessToken(jr, session)) {
+ jr = validateAuthentication(session);
+ } else {
+ jr.setStatus(Constants.STATUS_UNAUTHORIZED);
+ jr.setData(MessageUtil.getPropertites(KeysConstants.STATUS_UNAUTHORIZED));
+ }
+ break;
+ case Constants.STATUS_TOO_MANY_CONNECTIONS:
+ jr.setStatus( Constants.STATUS_TOO_MANY_CONNECTIONS );
+ jr.setData( MessageUtil.getPropertites( KeysConstants.STATUS_TOO_MANY_CONNECTIONS ) );
+ break;
+ case Constants.STATUS_FORBIDDEN:
+ jr.setStatus( Constants.STATUS_FORBIDDEN );
+ jr.setData( MessageUtil.getPropertites( KeysConstants.STATUS_FORBIDDEN ) );
+ break;
+ default:
+ jr.setStatus( Constants.STATUS_ERROR );
+ jr.setData( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ break;
+ }
+ } else {
+ jr.setStatus( Constants.STATUS_ERROR );
+ jr.setData( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ return jr;
+ }
+ }
+
+ /**
+ * update acess token
+ * @param jr
+ * @param session
+ * @return
+ */
+ private boolean updateAccessToken(JsonResult jr, HttpSession session) {
+ boolean ret = false;
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ try {
+ String refreshToken = (String) session.getAttribute(Constants.SESSION_REFRESH_TOKEN);
+
+ String jsonStr = restTemplate.get(WebServiceClient.REST_TOKEN, session, new String[] { refreshToken });
+ JSONObject json = JsonMapperUtils.getJsonObject(jsonStr);
+ String token = json.getString(ApiParam.API_RESPONSE_TOKEN);
+ //String refreshtoken = json.getString(ApiParam.API_RESPONSE_REFRESHTOKEN);
+ session.setAttribute( Constants.SESSION_TOKEN, token );
+ //session.setAttribute( Constants.SESSION_REFRESH_TOKEN, refreshtoken );
+ ret = true;
+ } catch (HttpClientErrorException e) {
+ switch (e.getStatusCode().value()) {
+ case Constants.STATUS_UNAUTHORIZED:
+ jr.setStatus(Constants.STATUS_UNAUTHORIZED);
+ jr.setData(MessageUtil.getPropertites(KeysConstants.STATUS_UNAUTHORIZED));
+ break;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return ret;
+ }
+
+// private JsonResult updateAccessToken(JsonResult jr) {
+// RestTemplateUtil restTemplate = new RestTemplateUtil();
+// try {
+// String refreshToken = SpringWebUtil.getRequest().getParameter(ApiParam.API_RESPONSE_REFRESHTOKEN);
+// String jsonStr = restTemplate.get(WebServiceClient.REST_TOKEN, new String[] { refreshToken });
+// jr.setStatus( Constants.STATUS_REFRESH_TOKEN );
+// jr.setData( jsonStr);
+// } catch (HttpClientErrorException e) {
+// switch (e.getStatusCode().value()) {
+// case Constants.STATUS_UNAUTHORIZED:
+// jr.setStatus( Constants.STATUS_UNAUTHORIZED );
+// jr.setData( MessageUtil.getPropertites( KeysConstants.STATUS_UNAUTHORIZED ) );
+// break;
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// return jr;
+// }
+ /**
+ * search start
+ *
+ * @param restURI
+ * @param obj
+ * @param model
+ * @param params
+ * @return
+ */
+ protected String selectPaginationData(String restURI, Object obj, Object model, Map<String, Object> params, HttpSession session) {
+ Class<?> form = obj.getClass();
+ List<Object> dataList = new ArrayList<Object>();
+ DataTableMap map = null;
+ List<String> errList = new ArrayList<String>();
+
+ try {
+ map = new DataTableMap(form.getMethod("getDraw", null).invoke(obj).toString(), dataList);
+
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.getByQueryParam(restURI, params, session);
+
+ JSONObject json = JsonMapperUtils.getJsonObject(jsonStr);
+ int counter = json.getInteger(Constants.PAGINATION_COUNTER);
+ List<App> list = json.getObject(Constants.PAGINATION_DATA, List.class);
+
+ map.setTotal(counter);
+ dataList.addAll(list);
+ } catch ( Exception e ) {
+ exceptionHandler( e, map );
+ }
+ return JsonMapperUtils.writeValueAsString( map.getMapData() );
+ }
+
+ protected void exceptionHandler(Exception e, DataTableMap map) {
+ if (e instanceof HttpClientErrorException) {
+ HttpClientErrorException hcee = (HttpClientErrorException) e;
+ if (hcee.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED) {
+ map.setErrorMsg(Constants.STATUS_UNAUTHORIZED,
+ MessageUtil.getPropertites(KeysConstants.STATUS_UNAUTHORIZED));
+ } else if (hcee.getStatusCode().value() == Constants.STATUS_BAD_REQUEST) {
+ map.setErrorMsg(Constants.STATUS_BAD_REQUEST, MessageUtil.getPropertites(KeysConstants.STATUS_BAD_REQUEST));
+ } else {
+ map.setErrorMsg(Constants.STATUS_UNAUTHORIZED, MessageUtil.getPropertites(KeysConstants.PROJECT_ERROR));
+ }
+ } else {
+ // failed
+ map.setErrorMsg(Constants.STATUS_ERROR, MessageUtil.getPropertites(KeysConstants.PROJECT_ERROR));
+ }
+ }
+
+ protected String exceptionHandler(Exception e, List<String> msgList) {
+ if ( e instanceof HttpClientErrorException ) {
+ HttpClientErrorException hcee = (HttpClientErrorException) e;
+ // unauthorized
+ if ( hcee.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED ) {
+ msgList.add( MessageUtil.getPropertites( KeysConstants.STATUS_UNAUTHORIZED ) );
+ } else {
+ msgList.add( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, msgList );
+ } else {
+ msgList.add( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, msgList );
+ }
+ }
+
+ protected void exceptionHandler(Exception e, JsonResult jr) {
+ jr.setStatus( Constants.STATUS_ERROR );
+ if ( e instanceof HttpClientErrorException ) {
+ HttpClientErrorException hcee = (HttpClientErrorException) e;
+ // unauthorized
+ if ( hcee.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED ) {
+ jr.setData( MessageUtil.getPropertites( KeysConstants.STATUS_UNAUTHORIZED ) );
+ } else {
+ jr.setData( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ } else {
+ jr.setData( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ }
+
+ protected void exceptionHandler(Exception e) throws Exception {
+ if ( e instanceof HttpClientErrorException ) {
+ HttpClientErrorException hcee = (HttpClientErrorException) e;
+ if ( hcee.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED ) {
+ throw new Exception( MessageUtil.getPropertites( KeysConstants.STATUS_UNAUTHORIZED ) );
+ } else {
+ throw new Exception( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ } else {
+ throw new Exception( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ }
+
+ public void initPageList(Map<String, Object> model, boolean hasSpace) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/warehouse/src/main/java/app/market/web/services/account/AccountService.java b/warehouse/src/main/java/app/market/web/services/account/AccountService.java
new file mode 100644
index 0000000..69f8cc0
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/account/AccountService.java
@@ -0,0 +1,76 @@
+/*
+ * 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.services.account;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import app.market.utils.json.JsonResult;
+import app.market.web.form.account.AccountForm;
+
+public interface AccountService {
+
+ /**
+ * Authentication
+ *
+ * @return
+ */
+ JsonResult validateAuthentication1(HttpSession session);
+
+ /**
+ * Search AccountForm By UserId
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ AccountForm searchFormById(String id, HttpSession session) throws Exception;
+
+ /**
+ *
+ * Page Search
+ *
+ * @param form
+ * @return
+ */
+ String selectPaginationData(AccountForm form, HttpSession session);
+
+ /**
+ * Account Delete
+ *
+ * @param id
+ * @return
+ */
+ String delete(String id, HttpSession session);
+
+ /**
+ * Account Save
+ *
+ * @param form
+ * @return
+ */
+ String save(AccountForm form, HttpSession session);
+
+ /**
+ * Get Account List
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ void getAuthorityList(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception;
+}
diff --git a/warehouse/src/main/java/app/market/web/services/account/impl/AccountServiceImpl.java b/warehouse/src/main/java/app/market/web/services/account/impl/AccountServiceImpl.java
new file mode 100644
index 0000000..5d8e7ec
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/account/impl/AccountServiceImpl.java
@@ -0,0 +1,220 @@
+/*
+ * 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.services.account.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.HttpClientErrorException;
+
+import com.alibaba.fastjson.JSONObject;
+
+import app.market.WebServiceClient;
+import app.market.model.user.User;
+import app.market.utils.Utils;
+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.property.Option;
+import app.market.utils.property.PropertyUtil;
+import app.market.utils.rest.RestTemplateUtil;
+import app.market.utils.webservice.ApiParam;
+
+import app.market.web.controller.ControllerMapping;
+import app.market.web.form.account.AccountForm;
+import app.market.web.services.SpringBaseService;
+import app.market.web.services.account.AccountService;
+
+@Service
+public class AccountServiceImpl extends SpringBaseService implements AccountService {
+ private static Logger logger = LoggerFactory.getLogger(AccountServiceImpl.class);
+
+ /**
+ * Authentication
+ *
+ * @return
+ */
+ @Override
+ public JsonResult validateAuthentication1(HttpSession session) {
+ return super.validateAuthentication(session);
+ }
+
+ /**
+ *
+ * Page Search
+ *
+ * @param form
+ * @return
+ */
+ @Override
+ public String selectPaginationData(AccountForm form, HttpSession session) {
+ logger.debug("account list start --Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() + form.getUserId());
+ String date = null;
+ if(form.getCreateDate() != null){
+ date = DateTimeUtils.getDate(DateTimeUtils.DATE_FORMAT_YYYYMMDD,form.getCreateDate());
+ }
+ Map<String, Object> param = new HashMap<>();
+ param.put( ApiParam.API_USER_PARAM_USERNAME, form.getUserName() );
+ param.put( ApiParam.API_USER_PARAM_AUID, form.getAuId() );
+ param.put( ApiParam.API_USER_PARAM_MAIL, form.getMailAddress() );
+ param.put( ApiParam.API_USER_PARAM_CREATEDATE, date );
+ param.put( ApiParam.API_PARAM_ORDER, form.getOrder() );
+ param.put( ApiParam.API_PARAM_SORT, form.getSort());
+ param.put( ApiParam.API_PARAM_OFFSET, form.getOffset() );
+ param.put( ApiParam.API_PARAM_LIMIT, form.getLimit() );
+ param.put( ApiParam.API_APP_PARAM_KEYWORD, form.getKeyWord() );
+ return super.selectPaginationData( WebServiceClient.REST_USER_SELECTPAGINATIONDATABYEXAMPLE, form, null, param, session);
+ }
+
+ /**
+ * Account Save
+ *
+ * @param form
+ * @return
+ */
+ @Override
+ public String save(AccountForm form, HttpSession session) {
+ logger.debug("save account start");
+ User record = new User();
+ String ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, null, null);
+ List<String> msgList = new ArrayList<String>();
+ try {
+ Utils.reflect(form, record);
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ // Resttemplate Operation
+ String jsonStr = restTemplate.post(WebServiceClient.REST_USER, record, session);
+
+ JSONObject json = JsonMapperUtils.getJsonObject(jsonStr);
+ String userId = json.getString(ApiParam.API_RESPONSE_APPID);
+ form.setUserId(userId);
+
+ msgList.add(MessageUtil.getPropertites(KeysConstants.USER_SAVE_IS_SUCCESS));
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, ControllerMapping.ACCOUNT.toString(), msgList);
+ } catch (HttpClientErrorException e) {
+ if (e.getStatusCode().value() == Constants.STATUS_BAD_REQUEST) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.INVALID_QUERYPARAM));
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ }
+ if (e.getStatusCode().value() == Constants.STATUS_ALREADY_EXISTS) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.RESOURCE_ALREADY_EXISTS));
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_ALREADY_EXISTS, null, msgList);
+ }
+ return JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ } catch (Exception e) {
+ ret = exceptionHandler(e, msgList);
+ }
+ logger.debug("save account stop");
+ return ret;
+ }
+
+ /**
+ * Account Delete
+ *
+ * @param id
+ * @return
+ */
+ @Override
+ public String delete(String id, HttpSession session) {
+ logger.debug("delete account start");
+ List<String> msgList = new ArrayList<String>();
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ // Rest template operation
+ restTemplate.delete( WebServiceClient.REST_USER_BY_USERID, id, session );
+ } catch (HttpClientErrorException e ) {
+ if(e.getStatusCode().value() == Constants.STATUS_ALREADY_EXISTS){
+ msgList.add(MessageUtil.getPropertites(KeysConstants.USER_NOT_DELETE));
+ return JsonMapperUtils.getJsonString(Constants.STATUS_ALREADY_EXISTS, null, msgList);
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, "" );
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, "" );
+ }
+ logger.debug("delete account stop ");
+ return JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, null, "" );
+ }
+
+ /**
+ * Get Account List
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ @Override
+ public void getAuthorityList(Map<String, Object> model,boolean hasSpace, HttpSession session) throws Exception {
+ logger.debug( "getAccounList" );
+ try{
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ List<Option> list = new ArrayList<Option>();
+ // Resttemplate operation
+ String jsonStr = restTemplate.get( WebServiceClient.REST_AUTHORITY_GET_LIST_OPTION, session );
+ @SuppressWarnings("unchecked")
+ List<Option> typelist = (List<Option>)JsonMapperUtils.getJsonList(jsonStr, Option.class);
+
+ if ( hasSpace ) {
+ Option option = new Option( PropertyUtil.DEFAULLABEL, "" );
+ list.add( option );
+ }
+ for (Option type : typelist) {
+ Option option1 = new Option( type.getLabel(), type.getValue().toString() );
+ list.add( option1 );
+ }
+ model.put( "authorityList", list );
+ } catch (Exception e) {
+ logger.debug(e.getMessage());
+ model.put("authorityList", new ArrayList<Option>());
+ }
+ }
+
+
+ /**
+ * Search AccountForm By UserId
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public AccountForm searchFormById(String id, HttpSession session) throws Exception {
+ AccountForm acForm = new AccountForm();
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ // Rest template Operation
+ String jsonStr = restTemplate.get(WebServiceClient.REST_USER_BY_USERID, session, new String[] { id });
+ User user = JsonMapperUtils.readValue( jsonStr, User.class );
+ Utils.reflect(user, acForm);
+ } catch (Exception e) {
+ logger.debug(this.getClass().getName() + ".searchFormById(id) failed.");
+ logger.debug(e.getMessage());
+ super.exceptionHandler(e);
+ }
+ return acForm;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/services/app/AppService.java b/warehouse/src/main/java/app/market/web/services/app/AppService.java
new file mode 100644
index 0000000..5655bd8
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/app/AppService.java
@@ -0,0 +1,124 @@
+/*
+ * 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.services.app;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.multipart.MultipartFile;
+
+import app.market.utils.json.JsonResult;
+import app.market.web.form.app.AppForm;
+
+public interface AppService {
+
+ /**
+ * Authentication
+ *
+ * @return
+ */
+ JsonResult validateAuthentication1(HttpSession session);
+
+ /**
+ * Search AppForm By AppId
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ AppForm searchFormById(String id, HttpSession session) throws Exception;
+
+ /***
+ * Search AppForm By AppIdCustom
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ AppForm searchFormByCustomId(String id, HttpSession session) throws Exception;
+
+ /**
+ * Page Search
+ *
+ * @param form
+ * @return
+ */
+ String selectPaginationData(AppForm form, HttpSession session);
+
+ /**
+ * App Delete
+ *
+ * @param id
+ * @return
+ */
+ String delete(String id, HttpSession session);
+
+ /**
+ * App Save
+ *
+ * @param form
+ * @return
+ */
+ String save(AppForm form, HttpSession session);
+
+ /**
+ * Get App type Option
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ void getAppTypeOption(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception;
+
+ /**
+ * Get App devicetype Option
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ void getDeviceTypeOption(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception;
+
+ /**
+ * App Upload
+ *
+ * @param form
+ * @param file
+ * @return
+ */
+ String upload(AppForm form, MultipartFile file, String fileName, boolean isImage, HttpSession session);
+
+ /**
+ * App Version Save
+ *
+ * @param form
+ * @return
+ */
+ String saveVersion(AppForm form, HttpSession session);
+
+ /**
+ * App Download
+ *
+ * @param form
+ * @return
+ */
+ ResponseEntity<byte[]> download(AppForm form, HttpSession session);
+
+ void getIsPublicOption(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception;
+
+ String saveDictionary(String dicType, String dicValue, String dicLabel, HttpSession session);
+}
diff --git a/warehouse/src/main/java/app/market/web/services/app/impl/AppServiceImpl.java b/warehouse/src/main/java/app/market/web/services/app/impl/AppServiceImpl.java
new file mode 100644
index 0000000..77a0e56
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/app/impl/AppServiceImpl.java
@@ -0,0 +1,511 @@
+/*
+ * 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.services.app.impl;
+
+import java.io.File;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.alibaba.fastjson.JSONObject;
+
+import app.market.LogUtil;
+import app.market.WebServiceClient;
+import app.market.model.app.App;
+import app.market.model.app.AppVersion;
+import app.market.model.app.FileInfo;
+import app.market.model.resource.Dictionary;
+import app.market.utils.Utils;
+import app.market.utils.constants.Constants;
+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.property.Option;
+import app.market.utils.property.PropertyUtil;
+import app.market.utils.rest.RestTemplateUtil;
+import app.market.utils.webservice.ApiParam;
+import app.market.web.controller.ControllerMapping;
+import app.market.web.controller.PageMapping;
+import app.market.web.form.app.AppForm;
+import app.market.web.services.SpringBaseService;
+import app.market.web.services.app.AppService;
+
+@Service
+public class AppServiceImpl extends SpringBaseService implements AppService {
+ private static Logger logger = LoggerFactory.getLogger( AppServiceImpl.class );
+
+ /**
+ * Authentication
+ *
+ * @return
+ */
+ @Override
+ public JsonResult validateAuthentication1(HttpSession session) {
+ return super.validateAuthentication(session);
+ }
+
+ /**
+ * Page Search
+ *
+ * @param form
+ * @return
+ */
+ @Override
+ public String selectPaginationData(AppForm form, HttpSession session) {
+ logger.debug( "search app list start--Class: " + this.getClass().getName() + "--method: "
+ + Thread.currentThread().getStackTrace()[1].getMethodName() + form.getAppId() );
+
+ Map<String, Object> param = new HashMap<>();
+ param.put( ApiParam.API_APP_PARAM_APPNAME, form.getAppName() );
+ param.put( ApiParam.API_APP_PARAM_APPTYPEID, form.getTypeId() );
+ param.put( ApiParam.API_APP_PARAM_DEVELOPER, form.getDeveloper() );
+ param.put( ApiParam.API_PARAM_ORDER, form.getOrder() );
+ param.put( ApiParam.API_APP_PARAM_APPISPUBLIC, form.getAppIsPublic() );
+ param.put( ApiParam.API_PARAM_SORT, form.getSort());
+ param.put( ApiParam.API_PARAM_OFFSET, form.getOffset() );
+ param.put( ApiParam.API_PARAM_LIMIT, form.getLimit() );
+ param.put( ApiParam.API_APP_PARAM_APPDEVICETYPEID, form.getAppDeviceTypeId() );
+ param.put( ApiParam.API_APP_PARAM_KEYWORD, form.getKeyWord());
+
+ return super.selectPaginationData( WebServiceClient.REST_APP_COLLECTION_APP, form, null, param , session);
+ }
+
+ /**
+ * App Save
+ *
+ * @param form
+ * @return
+ */
+ @Override
+ public String save(AppForm form, HttpSession session) {
+ logger.debug("save app --S--");
+ App record = new App();
+ String ret = "";
+ List<String> msgList = new ArrayList<String>();
+ String appId;
+ try {
+ Utils.reflect(form, record);
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.post(WebServiceClient.REST_APP_INFO, record, session);
+
+ JSONObject json = JsonMapperUtils.getJsonObject(jsonStr);
+ appId = json.getString(ApiParam.API_RESPONSE_APPID);
+ form.setAppId(appId);
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, PageMapping.INIT_INFO.toString(), form);
+ } catch (HttpClientErrorException e) {
+ if (e.getStatusCode().value() == Constants.STATUS_BAD_REQUEST) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.INVALID_QUERYPARAM));
+ return ret = JsonMapperUtils.getJsonString(Constants.STATUS_BAD_REQUEST, null, msgList);
+ }else if( e.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED){
+ msgList.add( MessageUtil.getPropertites( KeysConstants.STATUS_UNAUTHORIZED ) );
+ return ret = JsonMapperUtils.getJsonString(Constants.STATUS_UNAUTHORIZED, null, msgList);
+ }else if( e.getStatusCode().value() == Constants.STATUS_ALREADY_EXISTS){
+ msgList.add( MessageUtil.getPropertites( KeysConstants.RESOURCE_APP_ALREADY_EXISTS ) );
+ return ret = JsonMapperUtils.getJsonString(Constants.STATUS_ALREADY_EXISTS, null, msgList);
+ }else if( e.getStatusCode().value() == Constants.STATUS_FORBIDDEN){
+ msgList.add( MessageUtil.getPropertites( KeysConstants.STATUS_FORBIDDEN ) );
+ return ret = JsonMapperUtils.getJsonString(Constants.STATUS_ALREADY_EXISTS, null, msgList);
+ }
+ else{
+ msgList.add(MessageUtil.getPropertites(KeysConstants.PROJECT_ERROR));
+ return ret = JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ }
+
+ } catch (Exception e) {
+ return ret = exceptionHandler(e, msgList);
+ }
+
+ logger.debug("save app --E-- ret=" + ret);
+ return ret;
+ }
+
+ /**
+ * App Upload
+ *
+ * @param form
+ * @return
+ */
+ @Override
+ public String upload(AppForm form, MultipartFile multFile, String fileName,boolean isImage, HttpSession session) {
+ logger.debug("upload app start");
+ String ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, null, null);
+ List<String> msgList = new ArrayList<String>();
+ FileInfo fileInfo = null;
+ String[] pathParam = null;
+ String httpUrl = WebServiceClient.REST_APP_IMAGE;
+
+ try {
+ //create fileResource
+
+ File file = getResource(multFile, fileName);
+ if (file == null) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.APP_UPLOAD_PARAM_FILE_IS_NULL));
+ return JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ }
+ MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
+ FileSystemResource fileSystemResource = new FileSystemResource(file);
+ param.add(ApiParam.API_APP_PARAM_MULTIPARTFILE, fileSystemResource);
+ param.add(ApiParam.API_APP_PARAM_FILE_NAME, fileName);
+
+ if (!isImage) {
+ // create md5
+ String md5Hex = DigestUtils.md5Hex(fileSystemResource.getInputStream());
+ param.add(ApiParam.API_APP_PARAM_FILE_HASH, md5Hex);
+
+ // create pathParam
+ String id = form.getAppId();
+ String appDeviceTypeId = form.getAppDeviceTypeId();
+ pathParam = new String[] { URLDecoder.decode(fileName, Constants.CHARACTER_UTF8), appDeviceTypeId, id };
+
+ httpUrl = WebServiceClient.REST_APP_FILE_PARM_FILENAME_TYPEID_APPID;
+ }
+
+ //http post
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.post(httpUrl, param, String.class, pathParam, session);
+
+ //delete tempFile
+ deleteFile(file);
+
+ //
+ fileInfo = JsonMapperUtils.readValue(jsonStr, FileInfo.class);
+ if (!isImage) {
+ form.setVerFilePath(fileInfo.getFilePath());
+ form.setAppSize(fileInfo.getFileSize());
+ }else{
+ form.setImagePath(fileInfo.getIconPath());
+ }
+ ret = JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, null, fileInfo );
+ } catch ( HttpClientErrorException e ) {
+ if ( e.getStatusCode().value() == Constants.STATUS_BAD_FILE ) {
+ msgList.add( MessageUtil.getPropertites( KeysConstants.APP_UPLOAD_MD5 ) );
+ } else if(e.getStatusCode().value() == Constants.STATUS_UNSUPPORT){
+ msgList.add( MessageUtil.getPropertites( KeysConstants.APP_FILE_TYPE_IS_UNSUPPORTED ) );
+ } else if(e.getStatusCode().value() == Constants.STATUS_BAD_REQUEST){
+ msgList.add( MessageUtil.getPropertites( KeysConstants.APP_FILE_UNCOMPRESS_FAILED ) );
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, msgList );
+ } catch (Exception e) {
+ msgList.add(e.getMessage());
+ logger.debug(this.getClass().getName());
+ logger.debug(e.getMessage());
+ return JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ }
+ return ret;
+ }
+
+ /**
+ * MultipartFile-> File
+ * @param multfile
+ * @param fileName2
+ * @return
+ * @throws Exception
+ */
+ public File getResource(MultipartFile multfile, String fileName) throws Exception {
+ File file = null;
+ try {
+ String suffix = fileName.substring(fileName.lastIndexOf("."));
+ String prefix = FilenameUtils.getBaseName(fileName);
+ if(prefix.length() < 3) {
+ prefix += "aaa";
+ }
+ file = File.createTempFile(prefix, suffix);
+ multfile.transferTo(file);
+ //deleteFile(file);
+ } catch (Exception e) {
+ LogUtil.printCatchLog(logger, e);
+ logger.error( e.getMessage() );
+ }
+ return file;
+ }
+
+ /**
+ * delete file
+ * @param files
+ */
+ private void deleteFile(File... files) {
+ for (File file : files) {
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+ }
+
+
+ /**
+ * App Version Save
+ *
+ * @param form
+ * @return
+ */
+
+ @Override
+ public String saveVersion(AppForm form, HttpSession session) {
+ logger.debug( "save app version start" );
+ AppVersion record = new AppVersion();
+ String ret = JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, null, null );
+ List<String> msgList = new ArrayList<String>();
+ try {
+ record.setFilePath(form.getVerFilePath());
+ record.setSize((int)form.getAppSize());
+ record.setvAppId(form.getAppId());
+ record.setVersionName(form.getVersionName());
+ record.setMd5(form.getHashcode());
+ record.setVersionId(form.getAppVersionId());
+ record.setImagePath(form.getImagePath());
+ //Size is equal to 0 when modified, and should be assigned to null
+ if(StringUtils.isNotEmpty(form.getAppVersionId())){
+ record.setSize(null);
+ }
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.post( WebServiceClient.REST_APP_VERSION_INFO, record, session);
+
+ JSONObject json = JsonMapperUtils.getJsonObject(jsonStr);
+ String versionId = json.getString(ApiParam.API_RESPONSE_APPVERSIONID);
+ ret = JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, PageMapping.INIT_CHECK.toString(), form );
+ } catch (HttpClientErrorException e) {
+ if (e.getStatusCode().value() == Constants.STATUS_BAD_REQUEST) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.INVALID_QUERYPARAM));
+ }else if(e.getStatusCode().value() == Constants.STATUS_CONFLICT) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.ALREADY_EXIST));
+ }
+ return JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ } catch (Exception e) {
+ ret = exceptionHandler(e, msgList);
+ }
+ return ret;
+ }
+
+ /**
+ * App Delete
+ *
+ * @param id
+ * @return
+ */
+ @Override
+ public String delete(String id, HttpSession session) {
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ // Rest template operation
+ restTemplate.delete( WebServiceClient.REST_APP_INFO_PARM_ID, id, session);
+ } catch ( Exception e ) {
+ return String.valueOf( Constants.STATUS_ERROR );
+ }
+
+ return String.valueOf( Constants.STATUS_SUCCESS );
+ }
+
+ /**
+ * Search AppForm By AppId
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public AppForm searchFormById(String id, HttpSession session) throws Exception {
+ AppForm appForm = null;
+ try {
+ appForm = getAppInfoById(WebServiceClient.REST_APP_INFO_PARM_ID, id, session);
+ } catch ( Exception e ) {
+ super.exceptionHandler( e );
+ }
+ return appForm;
+ }
+
+ /**
+ * Search AppForm By CustomId
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public AppForm searchFormByCustomId(String id, HttpSession session) throws Exception {
+ AppForm appForm = new AppForm();
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ // Rest template operation
+ String jsonStr = restTemplate.get( WebServiceClient.REST_APP_INFO_PARM_CUSTOMID, session, new String[] { id } );
+ App app = JsonMapperUtils.readValue( jsonStr, App.class );
+ Utils.reflect( app, appForm );
+ } catch ( Exception e ) {
+ appForm = null;
+ }
+ return appForm;
+ }
+
+ /***
+ * Search AppInfo By Id
+ * @param url
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ private AppForm getAppInfoById(String url,String id, HttpSession session) throws Exception {
+ AppForm appForm = new AppForm();
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ // Rest template operation
+ String jsonStr = restTemplate.get( url, session, new String[] { id } );
+ App app = JsonMapperUtils.readValue( jsonStr, App.class );
+ Utils.reflect( app, appForm );
+ } catch ( Exception e ) {
+ super.exceptionHandler( e );
+ }
+ return appForm;
+ }
+
+ /**
+ * Get App type Option
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ @Override
+ public void getAppTypeOption(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception {
+ List<Option> list = getOption(hasSpace, ApiParam.API_PARAM_VALUE_DICTIONARY_CATEGORY, session);
+ model.put("appTypeList", list);
+ }
+
+ /**
+ * Get device type Option
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ @Override
+ public void getDeviceTypeOption(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception {
+ List<Option> list = getOption(hasSpace, ApiParam.API_PARAM_VALUE_DICTIONARY_DEVICETYPE, session);
+ model.put("appDeviceTypeList", list);
+ }
+
+ /**
+ * Get device type Option
+ *
+ * @param model
+ * @param hasSpace
+ * @throws Exception
+ */
+ @Override
+ public void getIsPublicOption(Map<String, Object> model, boolean hasSpace, HttpSession session) throws Exception {
+ List<Option> list = getOption(hasSpace, ApiParam.API_PARAM_VALUE_DICTIONARY_ISPUBLIC, session);
+ model.put("appIsPublicList", list);
+ }
+
+ private List<Option> getOption( boolean hasSpace,String optionType, HttpSession session) throws Exception {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ List<Option> list = new ArrayList<Option>();
+ // Rest template operation
+ try {
+ String jsonStr = restTemplate.get(WebServiceClient.REST_DICTIONARY_COLLECTION, session, optionType);
+ List<Dictionary> typelist = (List<Dictionary>)JsonMapperUtils.getJsonList(jsonStr, Dictionary.class);
+
+ if (hasSpace) {
+ Option option = new Option(PropertyUtil.DEFAULLABEL, "");
+ list.add(option);
+ }
+ for (Dictionary type : typelist) {
+ Option option = new Option(type.getDicLabel(), type.getDicValue().toString());
+ list.add(option);
+ }
+ } catch (Exception e) {
+ super.exceptionHandler(e);
+ }
+
+ return list;
+ }
+
+ /**
+ * App Download
+ *
+ * @param form
+ * @return
+ */
+ @Override
+ public ResponseEntity<byte[]> download(AppForm form, HttpSession session) {
+ String url = WebServiceClient.REST_APP_FILE_PARM_FILEPATH;
+ ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(null, null, HttpStatus.FORBIDDEN);;
+
+ try {
+ Map<String, Object> param = new HashMap<>();
+ param.put( ApiParam.API_APP_PARAM_FILE_PATH, form.getVerFilePath() );
+
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ response = restTemplate.download(url, param, session);
+ } catch (Exception e) {
+ LogUtil.printCatchLog(logger, e);
+ e.printStackTrace();
+ }
+ return response;
+ }
+
+ /**
+ * Add Or Update Type/Device Type
+ *
+ * @param dicType
+ * @param dicValue
+ * @param dicLabel
+ * @return
+ */
+ public String saveDictionary(String dicType, String dicValue, String dicLabel, HttpSession session) {
+ logger.debug("APPを更新・新規する");
+ Dictionary record = new Dictionary();
+ String ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, null, null);
+ List<String> msgList = new ArrayList<String>();
+ try {
+ record.setDicType(dicType);
+ record.setDicValue(dicValue);
+ record.setDicLabel(dicLabel);
+
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ restTemplate.post(WebServiceClient.REST_DICTIONARY_INFO, record, session);
+ ret = JsonMapperUtils.getJsonString(Constants.STATUS_SUCCESS, PageMapping.APP_TYPE.toString(), null);
+ } catch (HttpClientErrorException e) {
+ if (e.getStatusCode().value() == Constants.STATUS_BAD_REQUEST) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.INVALID_QUERYPARAM));
+ } else if (e.getStatusCode().value() == Constants.STATUS_CONFLICT) {
+ msgList.add(MessageUtil.getPropertites(KeysConstants.ALREADY_EXIST));
+ }
+ return JsonMapperUtils.getJsonString(Constants.STATUS_ERROR, null, msgList);
+ } catch (Exception e) {
+ ret = exceptionHandler(e, msgList);
+ }
+ return ret;
+ }
+}
diff --git a/warehouse/src/main/java/app/market/web/services/login/LoginService.java b/warehouse/src/main/java/app/market/web/services/login/LoginService.java
new file mode 100644
index 0000000..688b043
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/login/LoginService.java
@@ -0,0 +1,25 @@
+/*
+ * 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.services.login;
+
+import javax.servlet.http.HttpSession;
+
+public interface LoginService {
+
+ String loginUser(String loginId, String userPw, HttpSession session) throws Exception;
+
+ int deleteUserById(int id);
+}
diff --git a/warehouse/src/main/java/app/market/web/services/login/impl/LoginServiceImpl.java b/warehouse/src/main/java/app/market/web/services/login/impl/LoginServiceImpl.java
new file mode 100644
index 0000000..8ec66e6
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/login/impl/LoginServiceImpl.java
@@ -0,0 +1,81 @@
+/*
+ * 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.services.login.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpSession;
+
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.HttpClientErrorException;
+
+import com.alibaba.fastjson.JSONObject;
+
+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.rest.RestTemplateUtil;
+import app.market.utils.webservice.ApiParam;
+import app.market.WebServiceClient;
+import app.market.web.controller.ControllerMapping;
+import app.market.web.services.login.LoginService;
+
+@Service
+public class LoginServiceImpl implements LoginService {
+
+ //private static Logger logger = LoggerFactory.getLogger( LoginServiceImpl.class );
+
+ @Override
+ public String loginUser(String loginId, String userPw, HttpSession session) {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ ResponseEntity<String> rEntity;
+
+ List<String> errList = new ArrayList<String>();
+ try {
+ JSONObject postData = new JSONObject();
+ postData.put(ApiParam.API_APP_PARAM_LOGINID, loginId);
+ postData.put(ApiParam.API_APP_PARAM_PASSWORD, userPw);
+ rEntity = restTemplate.Post(WebServiceClient.REST_USER_SELECTLOGINUSER, postData, session);
+
+// JSONObject json = JsonMapperUtils.getJsonObject(rEntity.getBody());
+// String token = json.getString(ApiParam.API_RESPONSE_TOKEN);
+// String refreshtoken = json.getString(ApiParam.API_RESPONSE_REFRESHTOKEN);
+ return JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, ControllerMapping.MAIN.toString(), rEntity.getBody());
+ } catch ( HttpClientErrorException e ) {
+ if ( e.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED ) {
+ errList.add( MessageUtil.getPropertites( KeysConstants.LOGIN_LOGINID_IS_NOT_EXIST ) );
+ }else if( e.getStatusCode().value() == Constants.STATUS_ERROR){
+ errList.add( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }else if( e.getStatusCode().value() == Constants.NOT_FOUND){
+ errList.add( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, errList );
+ } catch ( Exception e ) {
+ errList.add( MessageUtil.getPropertites( KeysConstants.USER_LOGINID_IS_FAILED ) );
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, errList );
+ }
+ }
+
+ @Override
+ public int deleteUserById(int id) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/services/main/MainService.java b/warehouse/src/main/java/app/market/web/services/main/MainService.java
new file mode 100644
index 0000000..2002eed
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/main/MainService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.services.main;
+
+import javax.servlet.http.HttpSession;
+
+import app.market.utils.json.JsonResult;
+
+public interface MainService {
+
+ JsonResult validateAuthentication1(HttpSession session);
+
+ String selectMenuResourceByLoginId(HttpSession session) throws Exception;
+}
diff --git a/warehouse/src/main/java/app/market/web/services/main/impl/MainServiceImpl.java b/warehouse/src/main/java/app/market/web/services/main/impl/MainServiceImpl.java
new file mode 100644
index 0000000..3d4cc4e
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/main/impl/MainServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * 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.services.main.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpSession;
+
+import org.codehaus.jackson.type.JavaType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import app.market.model.resource.Resource;
+import app.market.utils.constants.Constants;
+import app.market.utils.json.JsonMapperUtils;
+import app.market.utils.json.JsonResult;
+import app.market.utils.rest.RestTemplateUtil;
+import app.market.WebServiceClient;
+import app.market.web.services.SpringBaseService;
+import app.market.web.services.main.MainService;
+
+@Service
+public class MainServiceImpl extends SpringBaseService implements MainService {
+
+ private static Logger logger = LoggerFactory.getLogger( MainServiceImpl.class );
+
+ @Override
+ public JsonResult validateAuthentication1(HttpSession session) {
+ return super.validateAuthentication(session);
+ }
+
+ @Override
+ public String selectMenuResourceByLoginId(HttpSession session) throws Exception {
+ String path = "";
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.get( WebServiceClient.REST_RESOURCE_GET_MENU_RESOURCES_BY_LOGINID, session);
+ JsonResult jr = JsonMapperUtils.readValue( jsonStr, JsonResult.class );
+ if ( Constants.STATUS_SUCCESS == jr.getStatus() ) {
+ JavaType javaType = JsonMapperUtils.getInstance().getTypeFactory().constructParametricType( ArrayList.class, Resource.class );
+ List<Resource> list = JsonMapperUtils.readValue( jr.getData().toString(), javaType );
+ for (Resource r : list) {
+ path += r.getAccessPath();
+ }
+ } else {
+ throw new Exception( jr.getData().toString() );
+ }
+ } catch ( Exception e ) {
+ logger.debug( this.getClass().getName() + ".selectMenuResourceByLoginId(token) failed." );
+ logger.debug( e.getMessage() );
+ super.exceptionHandler( e );
+ }
+ return path;
+ }
+
+}
diff --git a/warehouse/src/main/java/app/market/web/services/user/UserService.java b/warehouse/src/main/java/app/market/web/services/user/UserService.java
new file mode 100644
index 0000000..dc31b48
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/user/UserService.java
@@ -0,0 +1,35 @@
+/*
+ * 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.services.user;
+
+import javax.servlet.http.HttpSession;
+
+import app.market.model.user.User;
+import app.market.utils.json.JsonResult;
+import app.market.web.form.user.UserForm;
+
+public interface UserService {
+
+ User selectCurrentUser(HttpSession session) throws Exception;
+
+ User selectUserByUserName(String userName, String token, HttpSession session) throws Exception;
+
+ String saveInfo(UserForm form, HttpSession session);
+
+ String saveUser(UserForm form, HttpSession session);
+
+ JsonResult validateAuthentication1(HttpSession session);
+}
diff --git a/warehouse/src/main/java/app/market/web/services/user/impl/UserServiceImpl.java b/warehouse/src/main/java/app/market/web/services/user/impl/UserServiceImpl.java
new file mode 100644
index 0000000..23cbb42
--- /dev/null
+++ b/warehouse/src/main/java/app/market/web/services/user/impl/UserServiceImpl.java
@@ -0,0 +1,141 @@
+/*
+ * 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.services.user.impl;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.HttpClientErrorException;
+
+import app.market.WebServiceClient;
+import app.market.model.user.User;
+import app.market.utils.Utils;
+import app.market.utils.constants.Constants;
+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.rest.RestTemplateUtil;
+import app.market.web.form.user.UserForm;
+import app.market.web.services.SpringBaseService;
+import app.market.web.services.user.UserService;
+
+@Service
+public class UserServiceImpl extends SpringBaseService implements UserService {
+
+ private static Logger logger = LoggerFactory.getLogger( UserServiceImpl.class );
+
+ @Override
+ public User selectCurrentUser(HttpSession session) throws Exception {
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String token = (String) session.getAttribute(Constants.SESSION_TOKEN);
+ String jsonStr = restTemplate.get( WebServiceClient.REST_USER_SELECT_CURRENT, session, token );
+ JsonResult jr = JsonMapperUtils.readValue( jsonStr, JsonResult.class );
+ if ( Constants.STATUS_SUCCESS == jr.getStatus() ) {
+ return JsonMapperUtils.readValue( jr.getData().toString(), User.class );
+ }
+ return null;
+ } catch ( Exception e ) {
+ logger.debug( this.getClass().getName() + ".selectCurrentUser() failed" );
+ logger.debug( e.getMessage() );
+ super.exceptionHandler( e );
+ }
+ return null;
+ }
+
+ @Override
+ public User selectUserByUserName(String userName, String token, HttpSession session) throws Exception {
+ try {
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.get( WebServiceClient.REST_USER_BY_USERNAME, session, userName );
+ JsonResult jr = JsonMapperUtils.readValue( jsonStr, JsonResult.class );
+ if ( Constants.STATUS_SUCCESS == jr.getStatus() ) {
+ return JsonMapperUtils.readValue( jr.getData().toString(), User.class );
+ }
+ return null;
+ } catch ( Exception e ) {
+ super.exceptionHandler( e );
+ }
+ return null;
+ }
+
+ @Override
+ public String saveUser(UserForm form, HttpSession session) {
+ User user = new User();
+ List<String> errList = new ArrayList<String>();
+ try {
+ Utils.reflect( form, user );
+ user.setToken( form.getToken() );
+ user.setIsDel( "0" );
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.post( WebServiceClient.REST_USER, user, session );
+ JsonResult jr = JsonMapperUtils.readValue( jsonStr, JsonResult.class );
+ if ( jr.getStatus() == Constants.STATUS_ERROR ) {
+ errList.add( jr.getData().toString() );
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, errList );
+ }
+ errList.add( MessageUtil.getPropertites( KeysConstants.USER_IS_SUCCESS ) );
+ } catch ( HttpClientErrorException e ) {
+ // unauthorized
+ if ( e.getStatusCode().value() == Constants.STATUS_UNAUTHORIZED ) {
+ errList.add( MessageUtil.getPropertites( KeysConstants.STATUS_UNAUTHORIZED ) );
+ } else {
+ errList.add( MessageUtil.getPropertites( KeysConstants.PROJECT_ERROR ) );
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, errList );
+ } catch ( Exception e ) {
+ errList.add( MessageUtil.getPropertites( KeysConstants.USER_SAVE_IS_FAILED ) );
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, errList );
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, null, errList );
+ }
+
+ @Override
+ public String saveInfo(UserForm form, HttpSession session) {
+ List<String> msgList = new LinkedList<String>();
+ try {
+ User user = new User();
+ Utils.reflect( form, user );
+ user.setToken( form.getToken() );
+ RestTemplateUtil restTemplate = new RestTemplateUtil();
+ String jsonStr = restTemplate.post( WebServiceClient.REST_USER, user, session );
+ JsonResult jr = JsonMapperUtils.readValue( jsonStr, JsonResult.class );
+ if ( jr.getStatus() == Constants.STATUS_ERROR ) {
+ msgList.add( jr.getData().toString() );
+ return JsonMapperUtils.getJsonString( Constants.STATUS_ERROR, null, msgList );
+ }
+ msgList.add( MessageUtil.getPropertites( KeysConstants.USER_INFO_CHANGE_SUCCESS ) );
+ } catch ( Exception e ) {
+ logger.debug( this.getClass().getName() + ".info() failed." );
+ logger.debug( e.getMessage() );
+ super.exceptionHandler( e, msgList );
+ }
+ return JsonMapperUtils.getJsonString( Constants.STATUS_SUCCESS, null, msgList );
+ }
+
+ @Override
+ public JsonResult validateAuthentication1(HttpSession session) {
+ return super.validateAuthentication(session);
+ }
+
+}