diff --git a/.metadata/.log b/.metadata/.log index 62cfd1d8..022b6ebd 100644 --- a/.metadata/.log +++ b/.metadata/.log @@ -2873,3 +2873,2098 @@ java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2 at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 4 0 2023-03-02 20:55:21.028 +!MESSAGE org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed +!STACK 0 +java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed + at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$10(LanguageServerWrapper.java:547) + at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) + at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) +Caused by: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed + at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$3(LanguageServerWrapper.java:315) + at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.request(RemoteEndpoint.java:161) + at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:91) + at jdk.proxy15/jdk.proxy15.$Proxy51.shutdown(Unknown Source) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$10(LanguageServerWrapper.java:545) + ... 7 more +Caused by: java.io.IOException: The pipe is being closed + at java.base/java.io.FileOutputStream.writeBytes(Native Method) + at java.base/java.io.FileOutputStream.write(FileOutputStream.java:349) + at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81) + at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142) + at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:69) + ... 12 more + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-02 20:55:49.996 +!MESSAGE Timeout waiting for data to generate LS hover +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.jdt.LSJavaHoverProvider.getHoverInfo2(LSJavaHoverProvider.java:70) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:163) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130) + at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89) + at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-02 20:56:44.072 +!MESSAGE Javadoc unavailable. Failed to obtain it. +!STACK 0 +java.lang.InterruptedException + at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:386) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096) + at org.eclipse.lsp4e.jdt.LSJavaHoverProvider.getHoverInfo2(LSJavaHoverProvider.java:70) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:163) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130) + at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89) + at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155) + +!ENTRY org.eclipse.lsp4e 1 0 2023-03-02 23:15:48.946 +!MESSAGE [Log] Scanner.scan has not advanced at offset 1755, state before: 10 after: 4 + +!ENTRY org.eclipse.lsp4e 4 0 2023-03-02 23:15:51.539 +!MESSAGE Marker id 2766 not found. +!STACK 1 +org.eclipse.core.internal.resources.ResourceException: Marker id 2766 not found. + at org.eclipse.core.internal.resources.Marker.checkInfo(Marker.java:63) + at org.eclipse.core.internal.resources.Marker.setAttribute(Marker.java:260) + at org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.lambda$1(LSPCodeActionMarkerResolution.java:149) + at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) + at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) +!SUBENTRY 1 org.eclipse.core.resources 4 376 2023-03-02 23:15:51.539 +!MESSAGE Marker id 2766 not found. + +!ENTRY org.eclipse.lsp4e 4 0 2023-03-02 23:15:51.540 +!MESSAGE Marker id 2766 not found. +!STACK 1 +org.eclipse.core.internal.resources.ResourceException: Marker id 2766 not found. + at org.eclipse.core.internal.resources.Marker.checkInfo(Marker.java:63) + at org.eclipse.core.internal.resources.Marker.getAttribute(Marker.java:108) + at org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.hasResolutions(LSPCodeActionMarkerResolution.java:237) + at org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry.hasResolution(MarkerHelpRegistry.java:264) + at org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry.hasResolutions(MarkerHelpRegistry.java:234) + at org.eclipse.ui.views.markers.MarkerField.annotateImage(MarkerField.java:87) + at org.eclipse.ui.internal.views.markers.MarkerProblemSeverityAndMessageField.update(MarkerProblemSeverityAndMessageField.java:80) + at org.eclipse.ui.internal.views.markers.MarkerColumnLabelProvider.update(MarkerColumnLabelProvider.java:57) + at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:144) + at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:970) + at org.eclipse.ui.internal.views.markers.MarkersTreeViewer.doUpdateItem(MarkersTreeViewer.java:70) + at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:126) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174) + at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:1048) + at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:427) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174) + at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2107) + at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:864) + at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:842) + at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:611) + at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1821) + at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1144) + at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1116) + at org.eclipse.ui.internal.views.markers.ExtendedMarkersView.reexpandCategories(ExtendedMarkersView.java:1196) + at org.eclipse.ui.internal.views.markers.UIUpdateJob.runInUIThread(UIUpdateJob.java:106) + at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:148) + at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) + at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132) + at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4029) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3645) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) +!SUBENTRY 1 org.eclipse.core.resources 4 376 2023-03-02 23:15:51.540 +!MESSAGE Marker id 2766 not found. +!SESSION 2023-03-03 12:08:56.910 ----------------------------------------------- +eclipse.buildId=4.17.2.202301310704 +java.version=17.0.6 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US +Framework arguments: -product org.springframework.boot.ide.branding.sts4 +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4 + +!ENTRY ch.qos.logback.classic 1 0 2023-03-03 12:09:13.273 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY ch.qos.logback.classic 1 0 2023-03-03 12:12:05.181 +!MESSAGE Logback config file: C:\Users\User\Desktop\ShopmeEcommerce\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.1.0.20221015-0744.xml + +!ENTRY org.eclipse.jface 2 0 2023-03-03 12:12:19.961 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2023-03-03 12:12:19.961 +!MESSAGE A conflict occurred for CTRL+SHIFT+T: +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, + Open a type in a Java editor, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, + , + Category(org.eclipse.lsp4e.category,Language Servers,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolinworkspace"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2023-03-03 12:12:19.961 +!MESSAGE A conflict occurred for ALT+SHIFT+R: +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , + Rename the selected element, + Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.edit.text.java.rename.element"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, + Rename the selected item, + Category(org.eclipse.ui.category.file,File,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.ui.edit.rename"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.wildwebdeveloper.embedder.node 4 0 2023-03-03 12:12:37.908 +!MESSAGE failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 +!STACK 0 +java.io.IOException: failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.extractArchive(CompressUtils.java:81) + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.unarchive(CompressUtils.java:52) + at org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager.getNodeJsLocation(NodeJSManager.java:83) + at org.eclipse.wildwebdeveloper.angular.AngularLanguageServer.(AngularLanguageServer.java:43) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) + at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) + at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:204) + at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:920) + at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246) + at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63) + at org.eclipse.lsp4e.LanguageServersRegistry$ExtensionLanguageServerDefinition.createConnectionProvider(LanguageServersRegistry.java:161) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$0(LanguageServerWrapper.java:294) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) + +!ENTRY org.eclipse.wildwebdeveloper.embedder.node 4 0 2023-03-03 12:12:37.911 +!MESSAGE failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 +!STACK 0 +java.io.IOException: failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.extractArchive(CompressUtils.java:81) + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.unarchive(CompressUtils.java:52) + at org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager.getNodeJsLocation(NodeJSManager.java:83) + at org.eclipse.wildwebdeveloper.html.HTMLLanguageServer.(HTMLLanguageServer.java:44) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) + at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) + at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:204) + at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:920) + at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246) + at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63) + at org.eclipse.lsp4e.LanguageServersRegistry$ExtensionLanguageServerDefinition.createConnectionProvider(LanguageServersRegistry.java:161) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$0(LanguageServerWrapper.java:294) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) + +!ENTRY org.eclipse.egit.ui 2 0 2023-03-03 12:12:43.966 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\User'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.springframework.tooling.ls.eclipse.commons 1 0 2023-03-03 12:14:20.885 +!MESSAGE executing callback sts4.classpath.CIQeZQHj FAILED + +!ENTRY org.springframework.tooling.ls.eclipse.commons 4 0 2023-03-03 12:14:20.887 +!MESSAGE TimeoutException +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.springframework.tooling.ls.eclipse.commons.LSP4ECommandExecutor.executeClientCommand(LSP4ECommandExecutor.java:37) + at org.springframework.tooling.jdt.ls.commons.classpath.SendClasspathNotificationsJob.flush(SendClasspathNotificationsJob.java:178) + at org.springframework.tooling.jdt.ls.commons.classpath.SendClasspathNotificationsJob.run(SendClasspathNotificationsJob.java:149) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) + +!ENTRY org.eclipse.equinox.p2.repository 2 0 2023-03-03 13:27:59.101 +!MESSAGE Using unsafe http transport to retrieve http://download.eclipse.org/usssdk/updates/release/latest, see CVE-2021-41033. Consider using https instead. + +!ENTRY org.eclipse.equinox.p2.repository 2 0 2023-03-03 13:28:02.903 +!MESSAGE Using unsafe http transport to retrieve http://download.eclipse.org/usssdk/drops/release/1.2.2/content.xml.xz, see CVE-2021-41033. Consider using https instead. + +!ENTRY org.eclipse.equinox.p2.repository 2 0 2023-03-03 13:28:23.381 +!MESSAGE Using unsafe http transport to retrieve http://downloads.genuitec.com/downloads/products/codetogether/updates/ct20221214/content.xml.xz, see CVE-2021-41033. Consider using https instead. + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2023-03-03 14:04:41.214 +!MESSAGE The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2023-03-03 14:04:41.953 +!MESSAGE The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2023-03-03 14:04:46.792 +!MESSAGE The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 14:06:47.171 +!MESSAGE Javadoc unavailable. Failed to obtain it. +!STACK 0 +java.lang.InterruptedException + at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:386) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096) + at org.eclipse.lsp4e.jdt.LSJavaHoverProvider.getHoverInfo2(LSJavaHoverProvider.java:70) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:163) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130) + at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89) + at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155) +!SESSION 2023-03-03 15:49:16.344 ----------------------------------------------- +eclipse.buildId=4.17.2.202301310704 +java.version=17.0.6 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US +Framework arguments: -product org.springframework.boot.ide.branding.sts4 +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4 + +!ENTRY ch.qos.logback.classic 1 0 2023-03-03 15:49:27.434 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY ch.qos.logback.classic 1 0 2023-03-03 15:51:26.020 +!MESSAGE Logback config file: C:\Users\User\Desktop\ShopmeEcommerce\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.1.0.20221015-0744.xml + +!ENTRY org.eclipse.jface 2 0 2023-03-03 15:51:40.021 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2023-03-03 15:51:40.021 +!MESSAGE A conflict occurred for CTRL+SHIFT+T: +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, + Open a type in a Java editor, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, + , + Category(org.eclipse.lsp4e.category,Language Servers,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolinworkspace"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2023-03-03 15:51:40.021 +!MESSAGE A conflict occurred for ALT+SHIFT+R: +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , + Rename the selected element, + Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.edit.text.java.rename.element"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, + Rename the selected item, + Category(org.eclipse.ui.category.file,File,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.ui.edit.rename"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.egit.ui 2 0 2023-03-03 15:52:15.786 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\User'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.springframework.tooling.ls.eclipse.commons 1 0 2023-03-03 15:52:30.173 +!MESSAGE executing callback sts4.classpath.CPRexzXi FAILED + +!ENTRY org.springframework.tooling.ls.eclipse.commons 4 0 2023-03-03 15:52:30.174 +!MESSAGE TimeoutException +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.springframework.tooling.ls.eclipse.commons.LSP4ECommandExecutor.executeClientCommand(LSP4ECommandExecutor.java:37) + at org.springframework.tooling.jdt.ls.commons.classpath.SendClasspathNotificationsJob.flush(SendClasspathNotificationsJob.java:178) + at org.springframework.tooling.jdt.ls.commons.classpath.SendClasspathNotificationsJob.run(SendClasspathNotificationsJob.java:149) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2023-03-03 15:59:05.996 +!MESSAGE The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2023-03-03 15:59:06.661 +!MESSAGE The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. + +!ENTRY org.eclipse.m2e.logback.appender 2 0 2023-03-03 15:59:11.965 +!MESSAGE The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 16:03:59.283 +!MESSAGE Javadoc unavailable. Failed to obtain it. +!STACK 0 +java.lang.InterruptedException + at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:386) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096) + at org.eclipse.lsp4e.jdt.LSJavaHoverProvider.getHoverInfo2(LSJavaHoverProvider.java:70) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:163) + at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:130) + at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89) + at org.eclipse.jface.text.TextViewerHoverManager$1.run(TextViewerHoverManager.java:155) + +!ENTRY org.eclipse.wildwebdeveloper.embedder.node 4 0 2023-03-03 16:14:59.750 +!MESSAGE failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 +!STACK 0 +java.io.IOException: failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.extractArchive(CompressUtils.java:81) + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.unarchive(CompressUtils.java:52) + at org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager.getNodeJsLocation(NodeJSManager.java:83) + at org.eclipse.wildwebdeveloper.angular.AngularLanguageServer.(AngularLanguageServer.java:43) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) + at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) + at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:204) + at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:920) + at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246) + at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63) + at org.eclipse.lsp4e.LanguageServersRegistry$ExtensionLanguageServerDefinition.createConnectionProvider(LanguageServersRegistry.java:161) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$0(LanguageServerWrapper.java:294) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) + +!ENTRY org.eclipse.wildwebdeveloper.embedder.node 4 0 2023-03-03 16:14:59.751 +!MESSAGE failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 +!STACK 0 +java.io.IOException: failed to create directory C:\Program Files\Java\STS4\sts-4.17.2.RELEASE\.node\node-v18.12.1-win-x64 + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.extractArchive(CompressUtils.java:81) + at org.eclipse.wildwebdeveloper.embedder.node.CompressUtils.unarchive(CompressUtils.java:52) + at org.eclipse.wildwebdeveloper.embedder.node.NodeJSManager.getNodeJsLocation(NodeJSManager.java:83) + at org.eclipse.wildwebdeveloper.html.HTMLLanguageServer.(HTMLLanguageServer.java:44) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) + at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) + at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:204) + at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:920) + at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:246) + at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:63) + at org.eclipse.lsp4e.LanguageServersRegistry$ExtensionLanguageServerDefinition.createConnectionProvider(LanguageServersRegistry.java:161) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$0(LanguageServerWrapper.java:294) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) + +!ENTRY org.eclipse.jface 2 0 2023-03-03 20:33:12.069 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2023-03-03 20:33:12.069 +!MESSAGE A conflict occurred for CTRL+SHIFT+C: +Binding(CTRL+SHIFT+C, + ParameterizedCommand(Command(org.eclipse.tm4e.languageconfiguration.toggleLineCommentCommand,Toggle Line Comment, + , + Category(org.eclipse.tm4e.languageconfiguration.category,TM4E Language Configuration,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.tm4e.languageconfiguration.toggleLineCommentCommand"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.textEditorScope,,,system) +Binding(CTRL+SHIFT+C, + ParameterizedCommand(Command(org.springframework.tooling.boot.ls.ToggleComment,Toggle Comment, + , + Category(org.springframework.ide.eclipse.commands,Spring Generic Text Editor,Spring Language Server Commands,true), + WorkbenchHandlerServiceHandler("org.springframework.tooling.boot.ls.ToggleComment"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.textEditorScope,,,system) + +!ENTRY org.eclipse.lsp4e 4 0 2023-03-03 20:33:36.611 +!MESSAGE org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed +!STACK 0 +java.util.concurrent.ExecutionException: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed + at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$10(LanguageServerWrapper.java:547) + at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) + at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) +Caused by: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: The pipe is being closed + at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$3(LanguageServerWrapper.java:315) + at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.request(RemoteEndpoint.java:161) + at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:91) + at jdk.proxy15/jdk.proxy15.$Proxy51.shutdown(Unknown Source) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$10(LanguageServerWrapper.java:545) + ... 7 more +Caused by: java.io.IOException: The pipe is being closed + at java.base/java.io.FileOutputStream.writeBytes(Native Method) + at java.base/java.io.FileOutputStream.write(FileOutputStream.java:349) + at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81) + at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142) + at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:69) + ... 12 more + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:37.664 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:106) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:38.670 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:100) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:39.724 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:106) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:40.728 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:100) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:76) + at jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:41.784 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:106) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:76) + at jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:42.788 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:100) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:64) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:43.868 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:106) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:64) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:44.872 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:100) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:76) + at jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:64) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:45.928 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:106) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:76) + at jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:64) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.ui.menus.CommandContributionItem.lambda$2(CommandContributionItem.java:323) + at org.eclipse.ui.menus.CommandContributionItem.updateCommandProperties(CommandContributionItem.java:327) + at org.eclipse.ui.menus.CommandContributionItem.lambda$1(CommandContributionItem.java:294) + at org.eclipse.core.commands.Command$1.run(Command.java:529) + at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) + at org.eclipse.core.commands.Command.fireCommandChanged(Command.java:522) + at org.eclipse.core.commands.Command.lambda$0(Command.java:1002) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.fireHandlerChanged(HandlerServiceHandler.java:180) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.handlerChanged(E4HandlerProxy.java:115) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.ui.internal.handlers.HandlerProxy.lambda$1(HandlerProxy.java:372) + at org.eclipse.core.commands.AbstractHandler.fireHandlerChanged(AbstractHandler.java:77) + at org.eclipse.core.commands.AbstractHandler.setBaseEnabled(AbstractHandler.java:111) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:121) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.setEnabled(E4HandlerProxy.java:133) + at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.setEnabled(HandlerServiceHandler.java:84) + at org.eclipse.core.commands.Command.setEnabled(Command.java:856) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:916) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:46.932 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:100) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:76) + at jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.eclipse.lsp4e 2 0 2023-03-03 20:33:47.987 +!MESSAGE Could not get if the workspace folder capability is supported due to timeout after 1 second +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.eclipse.lsp4e.LanguageServerWrapper.supportsWorkspaceFolderCapability(LanguageServerWrapper.java:650) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:639) + at org.eclipse.lsp4e.LanguageServerWrapper.canOperate(LanguageServerWrapper.java:1029) + at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$6(LanguageServiceAccessor.java:348) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLSWrappers(LanguageServiceAccessor.java:356) + at org.eclipse.lsp4e.LanguageServiceAccessor.getLanguageServers(LanguageServiceAccessor.java:623) + at org.eclipse.lsp4e.operations.rename.LSPRenameHandler.setEnabled(LSPRenameHandler.java:106) + at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:229) + at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:76) + at jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.isEnabled(HandlerServiceHandler.java:62) + at org.eclipse.core.commands.Command.isEnabled(Command.java:832) + at org.eclipse.ui.menus.CommandContributionItem.isEnabled(CommandContributionItem.java:917) + at org.eclipse.ui.menus.CommandContributionItem.updateMenuItem(CommandContributionItem.java:531) + at org.eclipse.ui.menus.CommandContributionItem.update(CommandContributionItem.java:484) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.jface.action.MenuManager.update(MenuManager.java:858) + at org.eclipse.ui.internal.Workbench.updateActiveWorkbenchWindowMenuManager(Workbench.java:3138) + at org.eclipse.ui.internal.Workbench.lambda$0(Workbench.java:3120) + at org.eclipse.jface.bindings.BindingManager.fireBindingManagerChanged(BindingManager.java:901) + at org.eclipse.jface.bindings.BindingManager.setActiveBindings(BindingManager.java:2181) + at org.eclipse.jface.bindings.BindingManager.recomputeBindings(BindingManager.java:1742) + at org.eclipse.jface.bindings.BindingManager.contextManagerChanged(BindingManager.java:691) + at org.eclipse.core.commands.contexts.ContextManager.fireContextManagerChanged(ContextManager.java:164) + at org.eclipse.core.commands.contexts.ContextManager.setEventCaching(ContextManager.java:323) + at org.eclipse.core.commands.contexts.ContextManager.deferUpdates(ContextManager.java:85) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:781) + at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:683) + at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:97) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.lambda$0(ContributedPartRenderer.java:63) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1530) + at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1493) + at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2954) + at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2321) + at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:5424) + at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:437) + at org.eclipse.swt.widgets.Control.windowProc(Control.java:4815) + at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) + at org.eclipse.swt.widgets.Display.windowProc(Display.java:5022) + at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) + at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1091) + at org.eclipse.swt.widgets.Control.setFocus(Control.java:3439) + at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1081) + at org.eclipse.swt.custom.StyledText.setFocus(StyledText.java:8742) + at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6186) + at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:149) + at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setFocus(JavaEditor.java:2353) + at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.delegateSetFocus(CompatibilityPart.java:226) + at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:323) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:245) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:147) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.focusGui(PartRenderingEngine.java:790) + at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.setFocus(ContributedPartRenderer.java:106) + at org.eclipse.swt.custom.CTabItem.setFocus(CTabItem.java:379) + at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2683) + at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1049) + at org.eclipse.swt.widgets.Control.setVisible(Control.java:3951) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3236) + at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3244) + at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1882) + at org.eclipse.swt.custom.CTabFolder.lambda$0(CTabFolder.java:332) + at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) + at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256) + at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) + at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4054) + at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3642) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046) + at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY org.springframework.tooling.ls.eclipse.commons 1 0 2023-03-03 20:33:56.737 +!MESSAGE executing callback sts4.classpath.OPyineLm FAILED + +!ENTRY org.springframework.tooling.ls.eclipse.commons 4 0 2023-03-03 20:33:56.738 +!MESSAGE TimeoutException +!STACK 0 +java.util.concurrent.TimeoutException + at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960) + at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095) + at org.springframework.tooling.ls.eclipse.commons.LSP4ECommandExecutor.executeClientCommand(LSP4ECommandExecutor.java:37) + at org.springframework.tooling.jdt.ls.commons.classpath.SendClasspathNotificationsJob.flush(SendClasspathNotificationsJob.java:178) + at org.springframework.tooling.jdt.ls.commons.classpath.SendClasspathNotificationsJob.run(SendClasspathNotificationsJob.java:149) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) + +!ENTRY org.eclipse.equinox.p2.repository 2 0 2023-03-03 20:39:07.053 +!MESSAGE Using unsafe http transport to retrieve http://download.eclipse.org/usssdk/updates/release/latest, see CVE-2021-41033. Consider using https instead. + +!ENTRY org.eclipse.equinox.p2.repository 2 0 2023-03-03 20:39:10.304 +!MESSAGE Using unsafe http transport to retrieve http://download.eclipse.org/usssdk/drops/release/1.2.2/content.xml.xz, see CVE-2021-41033. Consider using https instead. + +!ENTRY org.eclipse.equinox.p2.repository 2 0 2023-03-03 20:39:28.730 +!MESSAGE Using unsafe http transport to retrieve http://downloads.genuitec.com/downloads/products/codetogether/updates/ct20221214/content.xml.xz, see CVE-2021-41033. Consider using https instead. + +!ENTRY org.eclipse.ui 2 2 2023-03-03 22:24:07.442 +!MESSAGE Invalid property category path: org.springframework.ide.eclipse.beans.ui.properties.ProjectPropertyPage (bundle: org.springframework.ide.eclipse.xml.namespaces, propertyPage: org.springframework.ide.eclipse.beans.ui.namespaces.projectPropertyPage) diff --git a/.metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json b/.metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json index 34581e73..12c60066 100644 --- a/.metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json +++ b/.metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json @@ -1 +1 @@ -{"lastUsed":1677752506975,"path":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","projectCount":5,"recentFiles":[{"path":"\/ShopmeBackEnd","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1677155680077,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/static\/js","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"common.js","lastModified":1677741168380,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/static\/js\/common.js"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"categories.html","lastModified":1677740873467,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories\/categories.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserController.java","lastModified":1677466069813,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller\/UserController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"MainController.java","lastModified":1677217115874,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/MainController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/users","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"user_form.html","lastModified":1677467322866,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/users\/user_form.html"},{"path":"\/ShopmeFrontEnd\/src\/main\/resources","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"application.properties","lastModified":1676283960183,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/src\/main\/resources\/application.properties"},{"path":"\/ShopmeBackEnd\/src\/main\/resources","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"application.properties","lastModified":1677508301870,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/application.properties"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryController.java","lastModified":1677752176932,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryController.java"},{"path":"\/ShopmeFrontEnd\/src\/main\/java\/com\/shopme\/site","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"MainController.java","lastModified":1676289534507,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/src\/main\/java\/com\/shopme\/site\/MainController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"category_form.html","lastModified":1677744090339,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories\/category_form.html"},{"path":"\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/target\/classes\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRepository.class","lastModified":1677229460809,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/target\/classes\/com\/shopme\/admin\/user\/UserRepository.class"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/static\/js","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"common_form.js","lastModified":1677467253790,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/static\/js\/common_form.js"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/error","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"404.html","lastModified":1677478592367,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error\/404.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"WebSecurityConfig.java","lastModified":1677578435114,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security\/WebSecurityConfig.java"},{"path":"\/ShopmeWebParent","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1677229487576,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRepository.java","lastModified":1677132400134,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/UserRepository.java"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"PasswordEncoderTest.java","lastModified":1677556633916,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user\/PasswordEncoderTest.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"ShopmeUserDetails.java","lastModified":1677308467553,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security\/ShopmeUserDetails.java"},{"path":"\/ShopmeProject\/ShopmeCommon\/target\/classes\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"User.class","lastModified":1677226090850,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/target\/classes\/com\/shopme\/common\/entity\/User.class"},{"path":"\/ShopmeProject","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676222003209,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"navigation.html","lastModified":1677410844649,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/navigation.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/error","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"500.html","lastModified":1677478845429,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error\/500.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRestController.java","lastModified":1676886778703,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller\/UserRestController.java"},{"path":"\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"Category.java","lastModified":1677751967290,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity\/Category.java"},{"path":"\/ShopmeWebParent\/ShopmeBackEnd","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676222003209,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"ShopmeBackEndApplication.java","lastModified":1676544146510,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/ShopmeBackEndApplication.java"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRepositoryTests.java","lastModified":1677556399974,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user\/UserRepositoryTests.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/static","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"style.css","lastModified":1677166116629,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/static\/style.css"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/export","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserCsvExporter.java","lastModified":1677157446759,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/export\/UserCsvExporter.java"},{"path":"\/ShopmeCommon","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676541672655,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryRepositoryTests.java","lastModified":1677751817903,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/category\/CategoryRepositoryTests.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryService.java","lastModified":1677752507177,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryService.java"},{"path":"\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"User.java","lastModified":1677226090850,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity\/User.java"},{"path":"\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"Role.java","lastModified":1676954212002,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity\/Role.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserNotFoundException.java","lastModified":1676879518482,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/UserNotFoundException.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"index.html","lastModified":1677389989130,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/index.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"AccountController.java","lastModified":1677494555729,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller\/AccountController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"login.html","lastModified":1677245871792,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/login.html"},{"path":"\/ShopmeFrontEnd","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676348025599,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/pom.xml"},{"path":"\/ShopmeFrontEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"index.html","lastModified":1676284076822,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/src\/main\/resources\/templates\/index.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"FileUploadUtil.java","lastModified":1677494843707,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/FileUploadUtil.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserService.java","lastModified":1677306762024,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/UserService.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"error.html","lastModified":1677478580858,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"RoleRepository.java","lastModified":1676541672655,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/RoleRepository.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/users","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"users.html","lastModified":1677307765208,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/users\/users.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"fragments.html","lastModified":1677591060743,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/fragments.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"MvcConfig.java","lastModified":1676990349408,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/MvcConfig.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryRepository.java","lastModified":1677750248333,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryRepository.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/error","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"403.html","lastModified":1677478669863,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error\/403.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/users","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"account_form.html","lastModified":1677467603206,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/users\/account_form.html"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"RoleRepositoryTests.java","lastModified":1677556469813,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user\/RoleRepositoryTests.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"ShopmeUserDetailsService.java","lastModified":1677225020383,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security\/ShopmeUserDetailsService.java"},{"path":"\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"index.html","lastModified":1676220716827,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/index.html"}]} \ No newline at end of file +{"lastUsed":1677855217658,"path":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","projectCount":5,"recentFiles":[{"path":"\/ShopmeBackEnd","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1677155680077,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryNotFoundException.java","lastModified":1677823516531,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryNotFoundException.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/static\/js","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"common.js","lastModified":1677741168380,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/static\/js\/common.js"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"categories.html","lastModified":1677849115103,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories\/categories.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserController.java","lastModified":1677466069813,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller\/UserController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"MainController.java","lastModified":1677217115874,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/MainController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/users","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"user_form.html","lastModified":1677467322866,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/users\/user_form.html"},{"path":"\/ShopmeFrontEnd\/src\/main\/resources","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"application.properties","lastModified":1676283960183,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/src\/main\/resources\/application.properties"},{"path":"\/ShopmeBackEnd\/src\/main\/resources","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"application.properties","lastModified":1677508301870,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/application.properties"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryController.java","lastModified":1677831872296,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryController.java"},{"path":"\/ShopmeFrontEnd\/src\/main\/java\/com\/shopme\/site","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"MainController.java","lastModified":1676289534507,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/src\/main\/java\/com\/shopme\/site\/MainController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"category_form.html","lastModified":1677831444564,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/categories\/category_form.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/static\/js","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"common_form.js","lastModified":1677467253790,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/static\/js\/common_form.js"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/error","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"404.html","lastModified":1677478592367,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error\/404.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"WebSecurityConfig.java","lastModified":1677578435114,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security\/WebSecurityConfig.java"},{"path":"\/ShopmeWebParent","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1677229487576,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRepository.java","lastModified":1677132400134,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/UserRepository.java"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"PasswordEncoderTest.java","lastModified":1677556633916,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user\/PasswordEncoderTest.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"ShopmeUserDetails.java","lastModified":1677308467553,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security\/ShopmeUserDetails.java"},{"path":"\/ShopmeProject\/ShopmeCommon\/target\/classes\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"User.class","lastModified":1677226090850,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/target\/classes\/com\/shopme\/common\/entity\/User.class"},{"path":"\/ShopmeProject","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676222003209,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"navigation.html","lastModified":1677410844649,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/navigation.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/error","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"500.html","lastModified":1677478845429,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error\/500.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRestController.java","lastModified":1676886778703,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller\/UserRestController.java"},{"path":"\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"Category.java","lastModified":1677831563880,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity\/Category.java"},{"path":"\/ShopmeWebParent\/ShopmeBackEnd","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676222003209,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"ShopmeBackEndApplication.java","lastModified":1676544146510,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/ShopmeBackEndApplication.java"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserRepositoryTests.java","lastModified":1677556399974,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user\/UserRepositoryTests.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/static","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"style.css","lastModified":1677166116629,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/static\/style.css"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/export","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserCsvExporter.java","lastModified":1677157446759,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/export\/UserCsvExporter.java"},{"path":"\/ShopmeCommon","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676541672655,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/pom.xml"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryRepositoryTests.java","lastModified":1677769562924,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/category\/CategoryRepositoryTests.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryService.java","lastModified":1677853530550,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryService.java"},{"path":"\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"User.java","lastModified":1677226090850,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity\/User.java"},{"path":"\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"Role.java","lastModified":1676954212002,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeCommon\/src\/main\/java\/com\/shopme\/common\/entity\/Role.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserNotFoundException.java","lastModified":1676879518482,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/UserNotFoundException.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"index.html","lastModified":1677389989130,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/index.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"AccountController.java","lastModified":1677494555729,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/controller\/AccountController.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"login.html","lastModified":1677245871792,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/login.html"},{"path":"\/ShopmeFrontEnd","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"pom.xml","lastModified":1676348025599,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/pom.xml"},{"path":"\/ShopmeFrontEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"index.html","lastModified":1676284076822,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeFrontEnd\/src\/main\/resources\/templates\/index.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"FileUploadUtil.java","lastModified":1677494843707,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/FileUploadUtil.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"UserService.java","lastModified":1677306762024,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/UserService.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"error.html","lastModified":1677478580858,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"RoleRepository.java","lastModified":1676541672655,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/user\/RoleRepository.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/users","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"users.html","lastModified":1677307765208,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/users\/users.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"fragments.html","lastModified":1677849095456,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/fragments.html"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"MvcConfig.java","lastModified":1677769420026,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/MvcConfig.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"CategoryRepository.java","lastModified":1677750248333,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/category\/CategoryRepository.java"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/error","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"403.html","lastModified":1677478669863,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/error\/403.html"},{"path":"\/ShopmeBackEnd\/src\/main\/resources\/templates\/users","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"account_form.html","lastModified":1677467603206,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/users\/account_form.html"},{"path":"\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"RoleRepositoryTests.java","lastModified":1677556469813,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/test\/java\/com\/shopme\/admin\/user\/RoleRepositoryTests.java"},{"path":"\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"ShopmeUserDetailsService.java","lastModified":1677225020383,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/java\/com\/shopme\/admin\/security\/ShopmeUserDetailsService.java"},{"path":"\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates","parentWorkspace":"C:\/Users\/User\/Desktop\/ShopmeEcommerce","name":"index.html","lastModified":1676220716827,"locationURI":"file:\/C:\/Users\/User\/Desktop\/ShopmeEcommerce\/ShopmeProject\/ShopmeWebParent\/ShopmeBackEnd\/src\/main\/resources\/templates\/index.html"}]} \ No newline at end of file diff --git a/.metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties b/.metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties index 32c0e414..fdb34815 100644 --- a/.metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties +++ b/.metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties @@ -1,45 +1,45 @@ #MyEclipse Usage Data -#Thu Mar 02 18:06:09 SGT 2023 +#Fri Mar 03 22:53:49 SGT 2023 misc/arch=x86_64 view/org.eclipse.pde.runtime.LogView=3 misc/eclipseVersion/4.17.2.202301310704=1 -bundle/com.genuitec.eclipse.startup.workspace=294 -bundle/com.genuitec.eclipse.theming.ui=294 +bundle/com.genuitec.eclipse.startup.workspace=315 +bundle/com.genuitec.eclipse.theming.ui=315 bundle/com.genuitec.eclipse.theming.elevation.win32=-1 -view/org.eclipse.ui.console.ConsoleView=81 +view/org.eclipse.ui.console.ConsoleView=82 bundle/com.genuitec.eclipse.theming.css=-1 editor/org.eclipse.wst.css.core.csssource.source=25 perspective/org.eclipse.egit.ui.GitRepositoryExploring=1 view/org.eclipse.ui.navigator.ProjectExplorer=1 -misc/timestamp=Mar 2, 2023, 10\:06\:09 AM +misc/timestamp=Mar 3, 2023, 2\:53\:49 PM editor/org.eclipse.ui.genericeditor.GenericEditor=87 -editor/org.eclipse.jdt.ui.CompilationUnitEditor=1005 -bundle/com.genuitec.eclipse.theming.scrollbar=294 -bundle/com.genuitec.eclipse.theming.base=294 +editor/org.eclipse.jdt.ui.CompilationUnitEditor=1043 +bundle/com.genuitec.eclipse.theming.scrollbar=315 +bundle/com.genuitec.eclipse.theming.base=315 devstyle/state/iconsColor/primary=1 -bundle/com.genuitec.eclipse.inlinesearch=294 -bundle/com.genuitec.eclipse.monitor=294 +bundle/com.genuitec.eclipse.inlinesearch=315 +bundle/com.genuitec.eclipse.monitor=315 devstyle/state/enabled=1 -editor/org.eclipse.jdt.ui.ClassFileEditor=35 -bundle/com.genuitec.eclipse.webclipse.evergreen=294 +editor/org.eclipse.jdt.ui.ClassFileEditor=36 +bundle/com.genuitec.eclipse.webclipse.evergreen=315 editor/SpringBootPropertyEditor=71 misc/product/org.springframework.boot.ide.branding.sts4=1 bundle/com.genuitec.eclipse.news=-1 bundle/com.genuitec.eclipse.theming.scrollbar.win=-1 -misc/period=654627250 +misc/period=713573554 bundle/com.genuitec.eclipse.theming.icon.designer=-1 devstyle/state/inlinesearch=1 -bundle/com.genuitec.eclipse.ui.common.platform=339 -misc/count=339 +bundle/com.genuitec.eclipse.ui.common.platform=363 +misc/count=363 view/org.eclipse.ui.views.ProblemView=3 -bundle/com.genuitec.eclipse.meexplorer=294 +bundle/com.genuitec.eclipse.meexplorer=315 misc/productType/devstyle=1 misc/os=win32 -bundle/com.genuitec.eclipse.meexplorer.jdt=294 -editor/org.eclipse.wst.html.core.htmlsource.source=557 +bundle/com.genuitec.eclipse.meexplorer.jdt=315 +editor/org.eclipse.wst.html.core.htmlsource.source=594 devstyle/state/workbenchColor/Dark_Gray=1 -view/org.eclipse.jdt.ui.PackageExplorer=433 -bundle/com.genuitec.eclipse.webicons=339 +view/org.eclipse.jdt.ui.PackageExplorer=445 +bundle/com.genuitec.eclipse.webicons=363 misc/core_version= view/org.eclipse.help.ui.HelpView=1 view/org.eclipse.ui.views.ContentOutline=2 @@ -51,19 +51,19 @@ editor/org.eclipse.m2e.editor.MavenPomEditor=246 misc/ws=win32 view/org.eclipse.jdt.junit.ResultView=20 view/org.eclipse.egit.ui.RepositoriesView=1 -bundle/com.genuitec.eclipse.patches=339 -bundle/com.genuitec.eclipse.startup=294 +bundle/com.genuitec.eclipse.patches=363 +bundle/com.genuitec.eclipse.startup=315 view/org.eclipse.search.ui.views.SearchView=4 devstyle/state/editorColor/IntelliJ_IDEA_Dark=1 bundle/com.genuitec.eclipse.theming.base.win=-1 misc/installmode/standalone=0 misc/locale=en_US misc/workspace_hash=-2114249626 -view/org.springframework.ide.eclipse.boot.dash.views.BootDashView=122 -perspective/org.eclipse.jdt.ui.JavaPerspective=49 +view/org.springframework.ide.eclipse.boot.dash.views.BootDashView=123 +perspective/org.eclipse.jdt.ui.JavaPerspective=51 bundle/com.genuitec.eclipse.theming.epl=-1 -bundle/com.genuitec.eclipsecolortheme.api=339 +bundle/com.genuitec.eclipsecolortheme.api=363 view/org.eclipse.wst.server.ui.ServersView=1 -bundle/com.genuitec.eclipse.theming.core=294 -bundle/com.genuitec.eclipse.core.common.platform=339 +bundle/com.genuitec.eclipse.theming.core=315 +bundle/com.genuitec.eclipse.core.common.platform=363 view/org.eclipse.debug.ui.DebugView=3 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/70f9861f2ab8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/0/70f9861f2ab8001d1d97982e354adf88 deleted file mode 100644 index 4b477ae0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/0/70f9861f2ab8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category(category.getName())); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/900ad9c130b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/0/900ad9c130b4001d1d079a924effdc9e deleted file mode 100644 index fc5c3ef9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/0/900ad9c130b4001d1d079a924effdc9e +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/b01f881077b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/0/b01f881077b3001d19bbb001c1a81c20 deleted file mode 100644 index 1ddaf760..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/0/b01f881077b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,192 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - - @GetMapping("/users/export/excel") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - } - - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/c01c784f99b9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/0/c01c784f99b9001d10d0f9513979f945 new file mode 100644 index 00000000..04eede00 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/0/c01c784f99b9001d10d0f9513979f945 @@ -0,0 +1,78 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/0/d024f4ac8fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/0/d024f4ac8fb3001d19bbb001c1a81c20 deleted file mode 100644 index 20d75cb3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/0/d024f4ac8fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1/60393c1f8bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/1/60393c1f8bb3001d19bbb001c1a81c20 deleted file mode 100644 index 51ddff93..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1/60393c1f8bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1/708626a79cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/1/708626a79cb9001d10d0f9513979f945 new file mode 100644 index 00000000..b0d431ae --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1/708626a79cb9001d10d0f9513979f945 @@ -0,0 +1,95 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, + RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1/c0aa97a252b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/1/c0aa97a252b4001d1d079a924effdc9e deleted file mode 100644 index b5a92016..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1/c0aa97a252b4001d1d079a924effdc9e +++ /dev/null @@ -1,17 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/11/80cf7a2413b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/11/80cf7a2413b4001d128fb79045552177 deleted file mode 100644 index d1db7c1f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/11/80cf7a2413b4001d128fb79045552177 +++ /dev/null @@ -1,71 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/12/00b42dda13b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/12/00b42dda13b4001d128fb79045552177 deleted file mode 100644 index 065554c4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/12/00b42dda13b4001d128fb79045552177 +++ /dev/null @@ -1,78 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/12/708113159cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/12/708113159cb9001d10d0f9513979f945 new file mode 100644 index 00000000..939a94b2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/12/708113159cb9001d10d0f9513979f945 @@ -0,0 +1,168 @@ +package com.shopme.common.entity; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; + +@Entity +@Table(name = "categories") +public class Category { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(length = 128, nullable = false, unique = true) + private String name; + + @Column(length = 64, nullable = false, unique = true) + private String alias; + + @Column(length = 128, nullable = false) + private String image; + + private boolean enabled; + + @OneToOne + @JoinColumn(name = "parent_id") + private Category parent; + + @OneToMany(mappedBy = "parent") + private Set children = new HashSet<>(); + + public Category() { + } + + public Category(Integer id) { + this.id = id; + } + + public static Category copyIdAndName(Category category) { + + Category copyCategory = new Category(); + copyCategory.setName(category.getName()); + copyCategory.setId(category.getId()); + + return copyCategory; + } + + public static Category copyIdAndName(Integer id, String name) { + + Category copyCategory = new Category(); + copyCategory.setName(name); + copyCategory.setId(id); + + return copyCategory; + } + + /* create a copy of a category object in order to append the -- symbol to denote hierarchy level + * */ + public static Category copyFull(Category category) { + + Category copyCategory = new Category(); + copyCategory.setName(category.getName()); + copyCategory.setId(category.getId()); + copyCategory.setImage(category.getImage()); + copyCategory.setAlias(category.getAlias()); + copyCategory.setEnabled(category.isEnabled()); + + return copyCategory; + } + + /* create a copy of a category object in order to append the -- symbol to denote hierarchy level + * */ + public static Category copyFull(Category category, String name) { + + Category copyCategory = Category.copyFull(category); + copyCategory.setName(name); + + return copyCategory; + } + + + + public Category(String name) { + this.name = name; + this.alias = name; + this.image = "default.png"; + + } + + public Category(String name, Category parent) { + this(name); + this.parent = parent; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Category getParent() { + return parent; + } + + public void setParent(Category parent) { + this.parent = parent; + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children = children; + } + + @Transient + public String getImagePath() { + + return "/category-images/" + this.id + "/" + this.image; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/13/20ccac9e7ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/13/20ccac9e7ab3001d19bbb001c1a81c20 deleted file mode 100644 index e497c222..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/13/20ccac9e7ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,194 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - - @GetMapping("/users/export/excel") - public void exportToExcel(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - - UserExcelExporter exporter = new UserExcelExporter(); - } - - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/13/301308bb2db4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/13/301308bb2db4001d1d079a924effdc9e deleted file mode 100644 index f5a4c507..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/13/301308bb2db4001d1d079a924effdc9e +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/14/6008667f8cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/14/6008667f8cb3001d19bbb001c1a81c20 deleted file mode 100644 index 953609ae..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/14/6008667f8cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/204d4a901fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/16/204d4a901fb3001d1e75aa5ef0815903 deleted file mode 100644 index d3a88ab7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/16/204d4a901fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users - - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/7003c42190b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/16/7003c42190b3001d19bbb001c1a81c20 deleted file mode 100644 index eee1c1a5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/16/7003c42190b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/7074bb4918b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/16/7074bb4918b4001d128fb79045552177 deleted file mode 100644 index 70698262..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/16/7074bb4918b4001d128fb79045552177 +++ /dev/null @@ -1,62 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/a0c9c93e99b9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/16/a0c9c93e99b9001d10d0f9513979f945 new file mode 100644 index 00000000..b48a50dd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/16/a0c9c93e99b9001d10d0f9513979f945 @@ -0,0 +1,78 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("") + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/17/10414bcb30b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/17/10414bcb30b4001d1d079a924effdc9e deleted file mode 100644 index ee91d8e2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/17/10414bcb30b4001d1d079a924effdc9e +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/17/a0915c1315b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/17/a0915c1315b4001d128fb79045552177 deleted file mode 100644 index 07c75100..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/17/a0915c1315b4001d128fb79045552177 +++ /dev/null @@ -1,25 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - - - @Override - public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/17/a0ddc50446b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/17/a0ddc50446b4001d1d079a924effdc9e deleted file mode 100644 index 7023c32f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/17/a0ddc50446b4001d1d079a924effdc9e +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - -
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/18/400279a26db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/18/400279a26db3001d19bbb001c1a81c20 deleted file mode 100644 index 47bf74e1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/18/400279a26db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,17 +0,0 @@ -package com.shopme.admin.user; - -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/18/701ef4fc4ab4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/18/701ef4fc4ab4001d1d079a924effdc9e deleted file mode 100644 index 037ef79e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/18/701ef4fc4ab4001d1d079a924effdc9e +++ /dev/null @@ -1,83 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); - // set a fix key used for the md5 hash algorithm to encrypt cookie content - //each time the application is restarted a new key will be generated - //so, in order for the cookie to be a fix key - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/18/90c2ac7645b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/18/90c2ac7645b4001d1d079a924effdc9e deleted file mode 100644 index eb0de705..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/18/90c2ac7645b4001d1d079a924effdc9e +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1a/507029fa87b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/1a/507029fa87b3001d19bbb001c1a81c20 deleted file mode 100644 index 0f12883c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1a/507029fa87b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,6 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1a/704368b5f9b8001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/1a/704368b5f9b8001d11addcb4256c67f9 new file mode 100644 index 00000000..fdde1043 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1a/704368b5f9b8001d11addcb4256c67f9 @@ -0,0 +1,44 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not locoated in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/20565b3f05b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/20565b3f05b4001d128fb79045552177 deleted file mode 100644 index 378fd419..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/20565b3f05b4001d128fb79045552177 +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- - -
-

Custom login page

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/80fc0b8b26b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/80fc0b8b26b8001d1d97982e354adf88 deleted file mode 100644 index ddd094c6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/80fc0b8b26b8001d1d97982e354adf88 +++ /dev/null @@ -1,23 +0,0 @@ -package com.shopme.admin.category; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/a02bce3609b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/a02bce3609b4001d128fb79045552177 deleted file mode 100644 index 7fe2dcf7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/a02bce3609b4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/30b98d238bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/30b98d238bb3001d19bbb001c1a81c20 deleted file mode 100644 index 41bc2dca..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/30b98d238bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
- - -
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/604aa35e4bb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/604aa35e4bb4001d1d079a924effdc9e deleted file mode 100644 index 6c9dc19d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/604aa35e4bb4001d1d079a924effdc9e +++ /dev/null @@ -1,87 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); - - /* - * set a fix key used for the md5 hash algorithm to encrypt cookie content each - * time the application is restarted, a new key will be generated; this key will - * be used to encrypt the cookie content so, in order for the cookie to be - * permanent; a fix key is needed. - */ - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/a0be049f13b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/a0be049f13b4001d128fb79045552177 deleted file mode 100644 index e0332645..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/a0be049f13b4001d128fb79045552177 +++ /dev/null @@ -1,77 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/f06238e929b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/f06238e929b8001d1d97982e354adf88 deleted file mode 100644 index 4b477ae0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/f06238e929b8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category(category.getName())); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1e/e0dd64f229b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/1e/e0dd64f229b8001d1d97982e354adf88 deleted file mode 100644 index a61dfe94..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1e/e0dd64f229b8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category(category.getName())); - - categoriesUsedInForm.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/20/00b8af2b46b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/20/00b8af2b46b4001d1d079a924effdc9e deleted file mode 100644 index 6339824a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/20/00b8af2b46b4001d1d079a924effdc9e +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/20/00ed8abc09b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/20/00ed8abc09b4001d128fb79045552177 deleted file mode 100644 index 26a9656e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/20/00ed8abc09b4001d128fb79045552177 +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/21/20c1dbba2fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/21/20c1dbba2fb4001d1d079a924effdc9e deleted file mode 100644 index ac3f05c8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/21/20c1dbba2fb4001d1d079a924effdc9e +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/21/90513610f8b3001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/21/90513610f8b3001d128fb79045552177 deleted file mode 100644 index 05667546..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/21/90513610f8b3001d128fb79045552177 +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/35/a0aeab1b46b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/22/30d088250db9001d11addcb4256c67f9 similarity index 69% rename from .metadata/.plugins/org.eclipse.core.resources/.history/35/a0aeab1b46b4001d1d079a924effdc9e rename to .metadata/.plugins/org.eclipse.core.resources/.history/22/30d088250db9001d11addcb4256c67f9 index 4a08b73d..99321d7c 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/35/a0aeab1b46b4001d1d079a924effdc9e +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/22/30d088250db9001d11addcb4256c67f9 @@ -1,33 +1,30 @@ - +
- +
-

Manage Users

- +

Manage Categories

+ - +
- - - +
[[${message}]]
+
-
+ - - Filter:     @@ -47,53 +44,27 @@ - - - - - - - - - - + + + + - - - + + - - - - - + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/22/70ea77204bb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/22/70ea77204bb4001d1d079a924effdc9e deleted file mode 100644 index a231e376..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/22/70ea77204bb4001d1d079a924effdc9e +++ /dev/null @@ -1,83 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); - // set a fix key used for the md5 hash algorithm to encrypt cookie content - //each time the application is restarted, a new key will be generated; this key will be used to encrypt the cookie content - //so, in order for the cookie to be permanent; a fix key is needed. - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/23/403f0d373fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/23/403f0d373fb3001d1e75aa5ef0815903 deleted file mode 100644 index b7b46809..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/23/403f0d373fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,51 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh" - */ - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a0cfb58ad8b4001d1dd58082704b0bec b/.metadata/.plugins/org.eclipse.core.resources/.history/23/d0f49f2b0db9001d11addcb4256c67f9 similarity index 70% rename from .metadata/.plugins/org.eclipse.core.resources/.history/a7/a0cfb58ad8b4001d1dd58082704b0bec rename to .metadata/.plugins/org.eclipse.core.resources/.history/23/d0f49f2b0db9001d11addcb4256c67f9 index eedc7a97..f8d6e79d 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a0cfb58ad8b4001d1dd58082704b0bec +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/23/d0f49f2b0db9001d11addcb4256c67f9 @@ -1,7 +1,7 @@ - +
@@ -10,24 +10,21 @@
-

Manage Users

- +

Manage Categories

+ - +
- - - +
[[${message}]]
+
- + - - Filter:     @@ -47,53 +44,27 @@
- - Photos - - - - Roles + IDCategory ImageCategory NameAliasEnabled
[[${user.id}]] - - +
[[${cat.id}]] + [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]][[${cat.name}]][[${cat.alias}]] - - - +
- -   - +
- - - - - - - - - - + + + + - - - + + - - - - - + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/24/10a3c00c09b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/24/10a3c00c09b4001d128fb79045552177 deleted file mode 100644 index 5e767394..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/24/10a3c00c09b4001d128fb79045552177 +++ /dev/null @@ -1,44 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/24/20f0f4a209b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/24/20f0f4a209b4001d128fb79045552177 deleted file mode 100644 index cf67136e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/24/20f0f4a209b4001d128fb79045552177 +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/24/609567f8c4b9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/24/609567f8c4b9001d10d0f9513979f945 new file mode 100644 index 00000000..c2bf7e7e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/24/609567f8c4b9001d10d0f9513979f945 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + + + +
+ + +
+
- - Photos - - - - Roles + IDCategory ImageCategory NameAliasEnabled
[[${user.id}]] - - +
[[${cat.id}]] + [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]][[${cat.name}]][[${cat.alias}]] - - - +
- -   - +
+ + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/24/a023f76177b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/24/a023f76177b3001d19bbb001c1a81c20 deleted file mode 100644 index cddcf6c1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/24/a023f76177b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.admin.user; - -public class UserExcelExporter { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/24/c02b9e4f8db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/24/c02b9e4f8db3001d19bbb001c1a81c20 deleted file mode 100644 index a15e2204..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/24/c02b9e4f8db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/25/c0127da08fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/25/c0127da08fb3001d19bbb001c1a81c20 deleted file mode 100644 index 12b2dc2a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/25/c0127da08fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/10b52e3218b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/26/10b52e3218b4001d128fb79045552177 deleted file mode 100644 index 98d2cf16..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/26/10b52e3218b4001d128fb79045552177 +++ /dev/null @@ -1,62 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService UserDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/20f3cd8d7ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/26/20f3cd8d7ab3001d19bbb001c1a81c20 deleted file mode 100644 index 1f7bf9f2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/26/20f3cd8d7ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter extends AbstractExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timestamp = dateFormatter.format(new Date()); - String fileName = "users_" + timestamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/a073217714b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/26/a073217714b4001d128fb79045552177 deleted file mode 100644 index d137072f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/26/a073217714b4001d128fb79045552177 +++ /dev/null @@ -1,78 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/26/c01512a452b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/26/c01512a452b4001d1d079a924effdc9e deleted file mode 100644 index 453c8ff5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/26/c01512a452b4001d1d079a924effdc9e +++ /dev/null @@ -1,17 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - -function customizeDropDownMenu(); - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/704b374a0bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/27/704b374a0bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..fda90d77 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/27/704b374a0bb9001d11addcb4256c67f9 @@ -0,0 +1,49 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + Path userPhotoDir = Paths.get(dirName); + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDirName = "category-images"; + Path categoryImagesDir = Paths.get(categoryImagesDirName); + String categoryImagesPath = categoryImagesDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/" + categoryImagesDirName + "/**") + .addResourceLocations("file:/" + categoryImagesPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0de25c83fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0de25c83fb3001d1e75aa5ef0815903 deleted file mode 100644 index ba6b153e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0de25c83fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,55 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh". - * - * Instead we should concatenate the fields separated by space as the query below - */ - @Query("SELECT u FROM User u WHERE CONCAT(u.id, ' ', u.email, ' ', u.firstName, ' '," - + " u.email) LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2a/303ce6a432b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/2a/303ce6a432b4001d1d079a924effdc9e deleted file mode 100644 index c6dc59ca..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2a/303ce6a432b4001d1d079a924effdc9e +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- - -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2a/903ee6de09b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/2a/903ee6de09b4001d128fb79045552177 deleted file mode 100644 index 2961db9b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2a/903ee6de09b4001d128fb79045552177 +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e06a1040cfb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e06a1040cfb9001d10d0f9513979f945 new file mode 100644 index 00000000..a405ff0f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e06a1040cfb9001d10d0f9513979f945 @@ -0,0 +1,131 @@ +package com.shopme.admin.category; + +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.support.Repositories; +import org.springframework.stereotype.Service; + +import com.shopme.common.entity.Category; + +@Service +public class CategoryService { + + @Autowired + private CategoryRepository repo; + + public List listAll() { + + List rootCategories = repo.findRootCategories(); + + return listHierarchicalCategories(rootCategories); + } + + private List listHierarchicalCategories(List rootCategories) { + + List hierarchicalCategories = new ArrayList<>(); + + for (Category rootCategory : rootCategories) { + hierarchicalCategories.add(Category.copyFull(rootCategory)); + + Set children = rootCategory.getChildren(); + + for (Category subCategory : children) { + String name = "--" + subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, 1); + } + } + + return hierarchicalCategories; + + } + + // recursive method + private void listHierarchicalCategories(List hierarchicalCategories, Category parent, int subLevel) { + + Set children = parent.getChildren(); + int newSubLevel = subLevel + 1; + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + + name += subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, newSubLevel); + + } + + } + + public Category save(Category category) { + return repo.save(category); + } + + public List listCategoriesUsedInForm() { + + List categoriesUsedInForm = new ArrayList<>(); + + Iterable categoriesInDB = repo.findAll(); + + for (Category category : categoriesInDB) { + + // root category + if (category.getParent() == null) { + categoriesUsedInForm.add(Category.copyIdAndName(category)); + + category.getChildren().forEach(subCategory -> { + String name = "--" + subCategory.getName(); + + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, 1); + }); + } + + } + + return categoriesUsedInForm; + } + + // recursive method + private void listSubCategoriesUsedInForm(List categoriesUsedInForm, Category parent, int subLevel) { + + int newSubLevel = subLevel + 1; + Set children = parent.getChildren(); + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + name += subCategory.getName(); + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, newSubLevel); + } + + } + + public Category get(Integer id) throws CategoryNotFoundException { + + try { + return repo.findById(id).get(); + + } catch (NoSuchElementException ex) { + + throw new CategoryNotFoundException("could not find any category with the integer: " + id); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2c/b05f62752eb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/2c/b05f62752eb4001d1d079a924effdc9e deleted file mode 100644 index 01dc5d83..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2c/b05f62752eb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d084db878bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d084db878bb3001d19bbb001c1a81c20 deleted file mode 100644 index 5f2b9c1e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d084db878bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${}]]
- -
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/f062a65aabb6001d1567bacd2f52a0b7 b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/f062a65aabb6001d1567bacd2f52a0b7 deleted file mode 100644 index 89135fb2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/f062a65aabb6001d1567bacd2f52a0b7 +++ /dev/null @@ -1,198 +0,0 @@ -package com.shopme.admin.user; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@DataJpaTest(showSql = false) -//configure to run on real database(MySQL) instead of a test database -@AutoConfigureTestDatabase(replace = Replace.NONE) -/* - * Datajpatest will rollback the transaction after executing the test method - * everytime, so that the transaction will not be committed. if we want to - * commit the transaction(aka "save the record"), we can disable rollback by - * setting it to false. Now, all transactions will be committed - */ -@Rollback(false) -public class UserRepositoryTests { - - @Autowired - private UserRepository repo; - - @Autowired - private TestEntityManager entityManager; - - // On the very first execution of testCreateUser() method; hibernate will create - // the users table & users_roles table - @Test - public void testCreateUserWithOneRole() { - - Role roleAdmin = entityManager.find(Role.class, 1); - User userChow = new User("chow@gmail.com", "password", "chow", "seng fung"); - userChow.addRoles(roleAdmin); - User savedUser = repo.save(userChow); - assertThat(savedUser.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateUserWithTwoRole() { - - User userRavi = new User("ravi@gmail.com", "ravipass", "ravi", "kumar"); - Role roleEditor = new Role(3); - Role roleAssistant = new Role(5); - - userRavi.addRoles(roleEditor); - userRavi.addRoles(roleAssistant); - - User savedUser = repo.save(userRavi); - assertThat(savedUser.getId()).isGreaterThan(0); - } - - @Test - public void testListAllUsers() { - Iterable listUsers = repo.findAll(); - - // use method reference instead of lambda expression here - listUsers.forEach(System.out::println); - - } - - @Test - public void testGetUserById() { - - User userChow = repo.findById(1).get(); - System.out.println(userChow); - // use method reference instead of lambda expression here - assertThat(userChow).isNotNull(); - } - - @Test - public void testUpdateUserDetails() { - - User userChow = repo.findById(1).get(); - userChow.setEnabled(true); - userChow.setEmail("chow22@gmail.com"); - - repo.save(userChow); - } - - @Test - public void testUpdateUserRoles() { - - User userRavi = repo.findById(4).get(); - Role roleEditor = new Role(3); - Role roleSalesperson= new Role(2); - - //change role from editor to salesperson - - /* take note of overriding/implementing the hashcode and equals method in roles - * class. need to override those two methods for remove() to work. - * The remove() method removes an element "e" such that Objects.equals(o, e), - * this will invoke the overwritten equals() method in Role Class. - * */ - userRavi.getRoles().remove(roleEditor); - userRavi.addRoles(roleSalesperson); - - repo.save(userRavi); - } - - @Test - public void testDeleteUser() { - - Integer userId = 4; - repo.deleteById(userId); - } - - - @Test - public void testGetUserByEmail() { - String email = "ravi@gmail.com"; - User user = repo.getUserByEmail(email); - - assertThat(user).isNotNull(); - } - - /* - * count the number of records in database with a particular id. - * return value should be 1, - * because id is unique. - * - * use countById() method to test whether a user exists. - */ - @Test - public void testCountById() { - - Integer userId = 1; - Long countById = repo.countById(userId); - - assertThat(countById).isNotNull().isGreaterThan(0).isEqualTo(1); - } - - @Test - public void testDisableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, false); - } - - @Test - public void testEnableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, true); - } - - @Test - public void testListFirstPage() { - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isEqualTo(pageSize); - } - - - @Test - public void testSearchUsers() { - - String keyword = "bruce"; - - - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(keyword, pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isGreaterThan(0); - - } - - -} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/a08e0d3451b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/2e/a08e0d3451b3001d1e75aa5ef0815903 deleted file mode 100644 index 92adf271..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/a08e0d3451b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,176 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/d02a033d40b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/2e/d02a033d40b3001d1e75aa5ef0815903 deleted file mode 100644 index 9e481997..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/d02a033d40b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,54 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh". - * - * Instead we should concatenate the fields separated by space as the query below - */ - @Query("SELECT u FROM User u WHERE CONCAT(u.id, ' ', u.email, ' ', u.lastName, ' ', u.firstName) LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f0c9f7e523b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f0c9f7e523b4001d1216d7fff398b3d6 deleted file mode 100644 index c57b8d47..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f0c9f7e523b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/508d3e8b88b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/508d3e8b88b3001d19bbb001c1a81c20 deleted file mode 100644 index c0c685e7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/508d3e8b88b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,19 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ -} - - -@media screen and (mini-width: 1024px) { - /* large screen */ -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/a07c5f9d1fb4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/a07c5f9d1fb4001d1216d7fff398b3d6 deleted file mode 100644 index 1dc8bcbb..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/a07c5f9d1fb4001d1216d7fff398b3d6 +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.2 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - ShopmeWebParent - pom - parent spring web project - - 15 - - - ShopmeBackEnd - ShopmeFrontEnd - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - mysql - mysql-connector-java - runtime - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - test - - - org.webjars - bootstrap - 4.3.1 - - - org.webjars - jquery - 3.4.1 - - - - org.webjars - webjars-locator-core - - - com.shopme - ShopmeCommon - 0.0.1-SNAPSHOT - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/b0842adc2fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/b0842adc2fb4001d1d079a924effdc9e deleted file mode 100644 index 1a1f3668..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/b0842adc2fb4001d1d079a924effdc9e +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/1012d6ef0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/3/1012d6ef0ab4001d128fb79045552177 deleted file mode 100644 index 6b02fea1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/1012d6ef0ab4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/2014c1192fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/3/2014c1192fb4001d1d079a924effdc9e deleted file mode 100644 index 43e5b902..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/2014c1192fb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0a8827b05b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0a8827b05b4001d128fb79045552177 deleted file mode 100644 index e0fa1ae9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0a8827b05b4001d128fb79045552177 +++ /dev/null @@ -1,22 +0,0 @@ -package com.shopme.admin; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class MainController { - - @GetMapping("") - public String viewHomePage() { - return "index"; - } - - - @GetMapping("/login") - public String viewLoginPage() { - return "login"; - } - - - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/f007dfc3d9b4001d1dd58082704b0bec b/.metadata/.plugins/org.eclipse.core.resources/.history/3/f007dfc3d9b4001d1dd58082704b0bec deleted file mode 100644 index f2350b57..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/f007dfc3d9b4001d1dd58082704b0bec +++ /dev/null @@ -1,86 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * this class for spring security - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - - public String getFullname() { - - return this.user.getFirstName() + " " + this.user.getLastName(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3/f0fbbf178ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/3/f0fbbf178ab3001d19bbb001c1a81c20 deleted file mode 100644 index 11e0279b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3/f0fbbf178ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
-

Showing user list on small screen

-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/30/1041f76819b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/30/1041f76819b4001d128fb79045552177 deleted file mode 100644 index 6166eecc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/30/1041f76819b4001d128fb79045552177 +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
- - -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/30/a00a193d2eb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/30/a00a193d2eb4001d1d079a924effdc9e deleted file mode 100644 index 5b03a2a5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/30/a00a193d2eb4001d1d079a924effdc9e +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/00e0a4eb50b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/31/00e0a4eb50b3001d1e75aa5ef0815903 deleted file mode 100644 index 35f4bc6f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/31/00e0a4eb50b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,177 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - - - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/31/b0a778ba6db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/31/b0a778ba6db3001d19bbb001c1a81c20 deleted file mode 100644 index 4231566b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/31/b0a778ba6db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,20 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat(); - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/1086895c22b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/1086895c22b3001d1e75aa5ef0815903 deleted file mode 100644 index 1d6ef52f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/33/1086895c22b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/40d2ccb18db5001d12b59aa089645058 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/40d2ccb18db5001d12b59aa089645058 deleted file mode 100644 index 13a2a8c5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/33/40d2ccb18db5001d12b59aa089645058 +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- - -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/8057c27b0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/8057c27b0ab4001d128fb79045552177 deleted file mode 100644 index 01711bee..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/33/8057c27b0ab4001d128fb79045552177 +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- - - -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/34/9010050c1fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/34/9010050c1fb3001d1e75aa5ef0815903 deleted file mode 100644 index 39e08738..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/34/9010050c1fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - // - - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/34/e0cadb1452b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/34/e0cadb1452b4001d1d079a924effdc9e deleted file mode 100644 index 171e68c9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/34/e0cadb1452b4001d1d079a924effdc9e +++ /dev/null @@ -1,78 +0,0 @@ - - - - - -
- - -
- -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/35/105cab7228b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/35/105cab7228b3001d1e75aa5ef0815903 deleted file mode 100644 index 9baa5f64..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/35/105cab7228b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,165 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc"); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/35/601c5db89cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/35/601c5db89cb9001d10d0f9513979f945 new file mode 100644 index 00000000..d641832d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/35/601c5db89cb9001d10d0f9513979f945 @@ -0,0 +1,102 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + if(!multipartFile.isEmpty()) { + + } + + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + + FileUploadUtil.cleanDir(uploadDir); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, + RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/509b2f778eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/38/509b2f778eb3001d19bbb001c1a81c20 deleted file mode 100644 index 9290942b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/38/509b2f778eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,35 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} - - th, td .hideable-column{display: none;} - -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - - th, td .hideable-column{display: table-cell;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/6011d82931b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/38/6011d82931b7001d19ef99be8d31e273 deleted file mode 100644 index 13060d50..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/38/6011d82931b7001d19ef99be8d31e273 +++ /dev/null @@ -1,59 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 - Category parent = new Category(1); - -// Category subCategory = new Category("Desktops", parent); - Category laptops = new Category("Laptops", parent); - Category components = new Category("Computer Components", parent); - - - - Category savedCategory = repo.save(subCategory); - - assertThat(savedCategory.getId()).isGreaterThan(0); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/38/706b056189b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/38/706b056189b3001d19bbb001c1a81c20 deleted file mode 100644 index 326826e3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/38/706b056189b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,27 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} - div.less-details{ display: none;} -} - - -@media screen and (min-width: 1024px) { - /* large screen */ - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70c3eae345b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70c3eae345b4001d1d079a924effdc9e deleted file mode 100644 index 9223f895..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70c3eae345b4001d1d079a924effdc9e +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - [[${title}]] - - - - - - - - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/8096942951b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/8096942951b3001d1e75aa5ef0815903 deleted file mode 100644 index c2a37d3b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/8096942951b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,177 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - - //default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/b0337b518eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/3a/b0337b518eb3001d19bbb001c1a81c20 deleted file mode 100644 index ea64857a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3a/b0337b518eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908f7a8326b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908f7a8326b3001d1e75aa5ef0815903 deleted file mode 100644 index e4dd5019..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908f7a8326b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,200 +0,0 @@ -package com.shopme.admin.user; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.hibernate.internal.build.AllowSysOut; -import org.hibernate.query.sqm.mutation.internal.TableKeyExpressionCollector; -import org.junit.jupiter.api.Test; -import org.springframework.aot.nativex.NativeConfigurationWriter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@DataJpaTest(showSql = false) -//configure to run on real database(MySQL) instead of a test database -@AutoConfigureTestDatabase(replace = Replace.NONE) -/* - * Datajpatest will rollback the transaction after executing the test method - * everytime, so that the transaction will not be committed. if we want to - * commit the transaction(aka "save the record"), we can disable rollback by - * setting it to false. Now, all transactions will be committed - */ -@Rollback(false) -public class UserRepositoryTests { - - @Autowired - private UserRepository repo; - - @Autowired - private TestEntityManager entityManager; - - // On the very first execution of testCreateUser() method; hibernate will create - // the users table & users_roles table - @Test - public void testCreateUserWithOneRole() { - - Role roleAdmin = entityManager.find(Role.class, 1); - User userChow = new User("chow@gmail.com", "password", "chow", "seng fung"); - userChow.addRoles(roleAdmin); - User savedUser = repo.save(userChow); - assertThat(savedUser.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateUserWithTwoRole() { - - User userRavi = new User("ravi@gmail.com", "ravipass", "ravi", "kumar"); - Role roleEditor = new Role(3); - Role roleAssistant = new Role(5); - - userRavi.addRoles(roleEditor); - userRavi.addRoles(roleAssistant); - - User savedUser = repo.save(userRavi); - assertThat(savedUser.getId()).isGreaterThan(0); - } - - @Test - public void testListAllUsers() { - Iterable listUsers = repo.findAll(); - - // use method reference instead of lambda expression here - listUsers.forEach(System.out::println); - - } - - @Test - public void testGetUserById() { - - User userChow = repo.findById(1).get(); - System.out.println(userChow); - // use method reference instead of lambda expression here - assertThat(userChow).isNotNull(); - } - - @Test - public void testUpdateUserDetails() { - - User userChow = repo.findById(1).get(); - userChow.setEnabled(true); - userChow.setEmail("chow22@gmail.com"); - - repo.save(userChow); - } - - @Test - public void testUpdateUserRoles() { - - User userRavi = repo.findById(4).get(); - Role roleEditor = new Role(3); - Role roleSalesperson= new Role(2); - - //change role from editor to salesperson - - /* take note of overriding/implementing the hashcode and equals method in roles - * class. need to override those two methods for remove() to work. - * The remove() method removes an element "e" such that Objects.equals(o, e), - * this will invoke the overwritten equals() method in Role Class. - * */ - userRavi.getRoles().remove(roleEditor); - userRavi.addRoles(roleSalesperson); - - repo.save(userRavi); - } - - @Test - public void testDeleteUser() { - - Integer userId = 4; - repo.deleteById(userId); - } - - - @Test - public void testGetUserByEmail() { - String email = "ravi@gmail.com"; - User user = repo.getUserByEmail(email); - - assertThat(user).isNotNull(); - } - - /* - * count the number of records in database with a particular id. - * return value should be 1, - * because id is unique. - * - * use countById() method to test whether a user exists. - */ - @Test - public void testCountById() { - - Integer userId = 1; - Long countById = repo.countById(userId); - - assertThat(countById).isNotNull().isGreaterThan(0).isEqualTo(1); - } - - @Test - public void testDisableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, false); - } - - @Test - public void testEnableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, true); - } - - @Test - public void testListFirstPage() { - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isEqualTo(pageSize); - } - - - @Test - public void testSearchUsers() { - - String keyword = "bruce"; - - - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - - } - - -} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/907eac1f13b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/907eac1f13b4001d128fb79045552177 deleted file mode 100644 index ad973fe3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/907eac1f13b4001d128fb79045552177 +++ /dev/null @@ -1,68 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/c08e70cc52b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/c08e70cc52b4001d1d079a924effdc9e deleted file mode 100644 index 4519c95e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/c08e70cc52b4001d1d079a924effdc9e +++ /dev/null @@ -1,22 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - - -function customizeDropDownMenu() { - - $(".dropdown > a") - -} - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/f0e9afc917b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/3c/f0e9afc917b4001d128fb79045552177 deleted file mode 100644 index e773b580..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3c/f0e9afc917b4001d128fb79045552177 +++ /dev/null @@ -1,61 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public UserDetailsService UserDetailsService() { - return ShopmeUserDetailsService(); - } - - - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3d/a0658ce279b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/3d/a0658ce279b3001d19bbb001c1a81c20 deleted file mode 100644 index 1d35e7d4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3d/a0658ce279b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,25 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import jakarta.servlet.http.HttpServletResponse; - -public class AbstractExporter { - - public void setResponseHeader(HttpServletResponse response, String contentType, - String extension, String prefix) throws IOException { - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timestamp = dateFormatter.format(new Date()); - String fileName = prefix + timestamp + extension; - - response.setContentType(contentType); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3d/c041215f3fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/3d/c041215f3fb3001d1e75aa5ef0815903 deleted file mode 100644 index b71406e6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3d/c041215f3fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,53 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh". - * - * Instead we should concatenate the fields separated by space - */ - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1097dea54fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1097dea54fb3001d1e75aa5ef0815903 deleted file mode 100644 index 1e92ab6a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1097dea54fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,170 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user - //email is unique field, so - - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/00f9bacf9bb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/00f9bacf9bb9001d10d0f9513979f945 new file mode 100644 index 00000000..7a325648 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/00f9bacf9bb9001d10d0f9513979f945 @@ -0,0 +1,115 @@ + + + + + + +
+ + +
+ +
+

Manage Categories | [[${pageTitle}]]

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + +
+ Image preview +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+
+
+ + + + + +
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/c0955a2d2eb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/c0955a2d2eb4001d1d079a924effdc9e deleted file mode 100644 index 10f404e9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/c0955a2d2eb4001d1d079a924effdc9e +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4/8069acbb2db4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/4/8069acbb2db4001d1d079a924effdc9e deleted file mode 100644 index 54dcf8f5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4/8069acbb2db4001d1d079a924effdc9e +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4/b01cd6ac67b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4/b01cd6ac67b3001d19bbb001c1a81c20 deleted file mode 100644 index e38d47de..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4/b01cd6ac67b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,185 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV() { - - - - UserCsvExporter exporter = new UserCsvExporter(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/40/20d456cec4b4001d1dd58082704b0bec b/.metadata/.plugins/org.eclipse.core.resources/.history/40/20d456cec4b4001d1dd58082704b0bec deleted file mode 100644 index 0f13c89d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/40/20d456cec4b4001d1dd58082704b0bec +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - -
- - -
- -
-

Manage Users | [[${pageTitle}]]

-
- -
- -
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- - - - - -
-
- -
- -
- - - - [[${role.description}]] -
-
-
-
- -
- -
- -
-
- -
- -
- - - Photos preview -
-
- - -
- - -
-
-
- - - - - -
- -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/40/50109a0e40b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/40/50109a0e40b3001d1e75aa5ef0815903 deleted file mode 100644 index a3938bbc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/40/50109a0e40b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,54 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh". - * - * Instead we should concatenate the fields separated by space as the query below - */ - @Query("SELECT u FROM User u WHERE CONCAT(u.id, ' ', u.email, ' ', u.firstName, ' ', u.email) LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/40/901814860ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/40/901814860ab4001d128fb79045552177 deleted file mode 100644 index 64b6b6d1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/40/901814860ab4001d128fb79045552177 +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- - - -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/41/304b56b34ab4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/41/304b56b34ab4001d1d079a924effdc9e deleted file mode 100644 index b2b52ff5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/41/304b56b34ab4001d1d079a924effdc9e +++ /dev/null @@ -1,80 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); // set a random key used for the md5 hash algorithm - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/43/20d7994922b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/43/20d7994922b4001d1216d7fff398b3d6 deleted file mode 100644 index 326b2fc6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/43/20d7994922b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,77 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.2 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - ShopmeWebParent - pom - parent spring web project - - 15 - - - ShopmeBackEnd - ShopmeFrontEnd - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - mysql - mysql-connector-java - runtime - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - test - - - org.webjars - bootstrap - 4.3.1 - - - org.webjars - jquery - 3.4.1 - - - - org.webjars - webjars-locator-core - - - com.shopme - ShopmeCommon - 0.0.1-SNAPSHOT - - - org.thymeleaf.extras - thymeleaf-extras-springsecurity6 - 3.1.1.RELEASE - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/43/306fff2b05b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/43/306fff2b05b4001d128fb79045552177 deleted file mode 100644 index 528181af..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/43/306fff2b05b4001d128fb79045552177 +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- - -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/44/706177d2dbb4001d1dd58082704b0bec b/.metadata/.plugins/org.eclipse.core.resources/.history/44/706177d2dbb4001d1dd58082704b0bec deleted file mode 100644 index 93eddcea..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/44/706177d2dbb4001d1dd58082704b0bec +++ /dev/null @@ -1,80 +0,0 @@ - - - - - -
- - -
- -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e055d03f43b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e055d03f43b4001d1d079a924effdc9e deleted file mode 100644 index 31a2392c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e055d03f43b4001d1d079a924effdc9e +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- - -
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e0f3b6178db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e0f3b6178db3001d19bbb001c1a81c20 deleted file mode 100644 index e3cf9d4f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e0f3b6178db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- -   - - - - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/46/d0234a8526b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/46/d0234a8526b8001d1d97982e354adf88 deleted file mode 100644 index 9c910862..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/46/d0234a8526b8001d1d97982e354adf88 +++ /dev/null @@ -1,21 +0,0 @@ -package com.shopme.admin.category; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/47/4012e31f3fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/47/4012e31f3fb3001d1e75aa5ef0815903 deleted file mode 100644 index d98fd941..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/47/4012e31f3fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - + " OR u.email LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/47/905601da44b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/47/905601da44b4001d1d079a924effdc9e deleted file mode 100644 index 31d03d89..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/47/905601da44b4001d1d079a924effdc9e +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - -
- s -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/47/e08542708ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/47/e08542708ab3001d19bbb001c1a81c20 deleted file mode 100644 index 08e94f07..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/47/e08542708ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/2004d58f32b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/48/2004d58f32b4001d1d079a924effdc9e deleted file mode 100644 index 143676e5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/48/2004d58f32b4001d1d079a924effdc9e +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/7063b4dd29b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/48/7063b4dd29b8001d1d97982e354adf88 deleted file mode 100644 index 0d2fd684..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/48/7063b4dd29b8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - System.out.println(category.getName()); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/49/706a0d7889b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/49/706a0d7889b3001d19bbb001c1a81c20 deleted file mode 100644 index a9e38c41..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/49/706a0d7889b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,29 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} - div.less-details{ display: none;} -} - - -@media screen and (min-width: 1024px) { - /* large screen */ - - div.less-details{ display: block;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/49/8051ea5144b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/49/8051ea5144b4001d1d079a924effdc9e deleted file mode 100644 index 7296ca15..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/49/8051ea5144b4001d1d079a924effdc9e +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/8032bec417b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/8032bec417b4001d128fb79045552177 deleted file mode 100644 index c116d38f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/8032bec417b4001d128fb79045552177 +++ /dev/null @@ -1,53 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/c0538aaa6eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4a/c0538aaa6eb3001d19bbb001c1a81c20 deleted file mode 100644 index 824c4fd0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4a/c0538aaa6eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,23 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/206f600a0db4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/206f600a0db4001d128fb79045552177 deleted file mode 100644 index ce145eba..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/206f600a0db4001d128fb79045552177 +++ /dev/null @@ -1,57 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - -public class ShopmeUserDetails implements UserDetails { - - private User user; - - - @Override - public Collection getAuthorities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/70f421b24bb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/70f421b24bb4001d1d079a924effdc9e deleted file mode 100644 index a9015c4d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/70f421b24bb4001d1d079a924effdc9e +++ /dev/null @@ -1,88 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890") - .tokenValiditySeconds(7 * 24 * 60 * 60); // cookie expires after one week - - /* - * set a fix key used for the md5 hash algorithm to encrypt cookie content each - * time the application is restarted, a new key will be generated; this key will - * be used to encrypt the cookie content so, in order for the cookie to be - * permanent; a fix key is needed. - */ - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/a05021d70eb4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/4b/a05021d70eb4001d128fb79045552177 deleted file mode 100644 index 853877f2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4b/a05021d70eb4001d128fb79045552177 +++ /dev/null @@ -1,60 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/60e897468bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4c/60e897468bb3001d19bbb001c1a81c20 deleted file mode 100644 index 9388982a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/60e897468bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
- - -
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/e0424e858eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4c/e0424e858eb3001d19bbb001c1a81c20 deleted file mode 100644 index 95d58fe1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/e0424e858eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,36 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} - - /*hide the columns id and email when in tablet screen*/ - th, td .hideable-column{display: none;} - -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - - th, td .hideable-column{display: table-cell;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4d/f0975d174bb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/4d/f0975d174bb4001d1d079a924effdc9e deleted file mode 100644 index 4863f9b7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4d/f0975d174bb4001d1d079a924effdc9e +++ /dev/null @@ -1,83 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); - // set a fix key used for the md5 hash algorithm to encrypt cookie content - //each time the application is restarted, a new key will be generated; this key will be used to encrypt the cookie - //so, in order for the cookie to be a fix key - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/2090b97177b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/2090b97177b3001d19bbb001c1a81c20 deleted file mode 100644 index 3201937e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/2090b97177b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,96 +0,0 @@ -package com.shopme.admin.user.export; - -import java.io.IOException; -import java.util.List; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; - -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.xssf.usermodel.XSSFCell; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFFont; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import com.shopme.admin.AbstractExporter; -import com.shopme.common.entity.User; - -public class UserExcelExporter extends AbstractExporter { - private XSSFWorkbook workbook; - private XSSFSheet sheet; - - public UserExcelExporter() { - workbook = new XSSFWorkbook(); - } - - private void writeHeaderLine() { - sheet = workbook.createSheet("Users"); - XSSFRow row = sheet.createRow(0); - - XSSFCellStyle cellStyle = workbook.createCellStyle(); - XSSFFont font = workbook.createFont(); - font.setBold(true); - font.setFontHeight(16); - cellStyle.setFont(font); - - createCell(row, 0, "User Id", cellStyle); - createCell(row, 1, "E-mail", cellStyle); - createCell(row, 2, "First Name", cellStyle); - createCell(row, 3, "Last Name", cellStyle); - createCell(row, 4, "Roles", cellStyle); - createCell(row, 5, "Enabled", cellStyle); - - } - - private void createCell(XSSFRow row, int columnIndex, Object value, CellStyle style) { - XSSFCell cell = row.createCell(columnIndex); - sheet.autoSizeColumn(columnIndex); - - if (value instanceof Integer) { - cell.setCellValue((Integer) value); - } else if (value instanceof Boolean) { - cell.setCellValue((Boolean) value); - } else { - cell.setCellValue((String) value); - } - - cell.setCellStyle(style); - } - - public void export(List listUsers, HttpServletResponse response) throws IOException { - super.setResponseHeader(response, "application/octet-stream", ".xlsx", "users_"); - - writeHeaderLine(); - writeDataLines(listUsers); - - ServletOutputStream outputStream = response.getOutputStream(); - workbook.write(outputStream); - workbook.close(); - outputStream.close(); - - - } - - private void writeDataLines(List listUsers) { - int rowIndex = 1; - - XSSFCellStyle cellStyle = workbook.createCellStyle(); - XSSFFont font = workbook.createFont(); - font.setFontHeight(14); - cellStyle.setFont(font); - - for (User user : listUsers) { - XSSFRow row = sheet.createRow(rowIndex++); - int columnIndex = 0; - - createCell(row, columnIndex++, user.getId(), cellStyle); - createCell(row, columnIndex++, user.getEmail(), cellStyle); - createCell(row, columnIndex++, user.getFirstName(), cellStyle); - createCell(row, columnIndex++, user.getLastName(), cellStyle); - createCell(row, columnIndex++, user.getRoles().toString(), cellStyle); - createCell(row, columnIndex++, user.isEnabled(), cellStyle); - } - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/20d64f1515b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/20d64f1515b4001d128fb79045552177 deleted file mode 100644 index caa3ad58..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/20d64f1515b4001d128fb79045552177 +++ /dev/null @@ -1,25 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/906bce7365b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/906bce7365b3001d19bbb001c1a81c20 deleted file mode 100644 index b681cda2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/906bce7365b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,183 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV() { - - UserCsvExporter exporter = new UserCsvExporter(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/b0eb0b3477b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/b0eb0b3477b3001d19bbb001c1a81c20 deleted file mode 100644 index edf23be8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/b0eb0b3477b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,192 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - - @GetMapping("/users/export/excel") - public void exportToExcel(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - } - - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/f03cfeb246b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/4e/f03cfeb246b4001d1d079a924effdc9e deleted file mode 100644 index 6bcdfb2e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4e/f03cfeb246b4001d1d079a924effdc9e +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- - -
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5/30f248120cb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/5/30f248120cb9001d11addcb4256c67f9 new file mode 100644 index 00000000..ee7e5ca1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5/30f248120cb9001d11addcb4256c67f9 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/50/80ac0abf0bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/50/80ac0abf0bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..5ba9b5cf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/50/80ac0abf0bb9001d11addcb4256c67f9 @@ -0,0 +1,161 @@ +package com.shopme.common.entity; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; + +@Entity +@Table(name = "categories") +public class Category { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(length = 128, nullable = false, unique = true) + private String name; + + @Column(length = 64, nullable = false, unique = true) + private String alias; + + @Column(length = 128, nullable = false) + private String image; + + private boolean enabled; + + @OneToOne + @JoinColumn(name = "parent_id") + private Category parent; + + @OneToMany(mappedBy = "parent") + private Set children = new HashSet<>(); + + public Category() { + } + + public Category(Integer id) { + this.id = id; + } + + public static Category copyIdAndName(Category category) { + + Category copyCategory = new Category(); + copyCategory.setName(category.getName()); + copyCategory.setId(category.getId()); + + return copyCategory; + } + + public static Category copyIdAndName(Integer id, String name) { + + Category copyCategory = new Category(); + copyCategory.setName(name); + copyCategory.setId(id); + + return copyCategory; + } + + /* create a copy of a category object in order to append the -- symbol to denote hierarchy level + * */ + public static Category copyFull(Category category) { + + Category copyCategory = new Category(); + copyCategory.setName(category.getName()); + copyCategory.setId(category.getId()); + copyCategory.setImage(category.getImage()); + copyCategory.setAlias(category.getAlias()); + copyCategory.setEnabled(category.isEnabled()); + + return copyCategory; + } + + /* create a copy of a category object in order to append the -- symbol to denote hierarchy level + * */ + public static Category copyFull(Category category, String name) { + + Category copyCategory = Category.copyFull(category); + copyCategory.setName(name); + + return copyCategory; + } + + + + public Category(String name) { + this.name = name; + this.alias = name; + this.image = "default.png"; + + } + + public Category(String name, Category parent) { + this(name); + this.parent = parent; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Category getParent() { + return parent; + } + + public void setParent(Category parent) { + this.parent = parent; + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children = children; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/50/e0fc5c199ab9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/50/e0fc5c199ab9001d10d0f9513979f945 new file mode 100644 index 00000000..b86d3076 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/50/e0fc5c199ab9001d10d0f9513979f945 @@ -0,0 +1,94 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, + RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/51/1032ce610db9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/51/1032ce610db9001d11addcb4256c67f9 new file mode 100644 index 00000000..56a32ccb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/51/1032ce610db9001d11addcb4256c67f9 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/51/40822ea552b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/51/40822ea552b4001d1d079a924effdc9e deleted file mode 100644 index b46b772c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/51/40822ea552b4001d1d079a924effdc9e +++ /dev/null @@ -1,20 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - -function customizeDropDownMenu() { - - -} - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/51/408addd452b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/51/408addd452b4001d1d079a924effdc9e deleted file mode 100644 index 94dadb40..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/51/408addd452b4001d1d079a924effdc9e +++ /dev/null @@ -1,22 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - - -function customizeDropDownMenu() { - - $(".dropdown > a").click() - -} - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/51/60301fde8db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/51/60301fde8db3001d19bbb001c1a81c20 deleted file mode 100644 index 0bab05ad..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/51/60301fde8db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,33 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} - - th, td .hidable-column{display: none;} - -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/52/6009e6e94ab4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/52/6009e6e94ab4001d1d079a924effdc9e deleted file mode 100644 index 6b7cc469..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/52/6009e6e94ab4001d1d079a924effdc9e +++ /dev/null @@ -1,81 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); - // set a fix key used for the md5 hash algorithm to encrypt cookie content - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/43/20f2666066b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/52/e07f7eb8c4b9001d10d0f9513979f945 similarity index 78% rename from .metadata/.plugins/org.eclipse.core.resources/.history/43/20f2666066b7001d19ef99be8d31e273 rename to .metadata/.plugins/org.eclipse.core.resources/.history/52/e07f7eb8c4b9001d10d0f9513979f945 index 839672aa..0dc26190 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/43/20f2666066b7001d19ef99be8d31e273 +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/52/e07f7eb8c4b9001d10d0f9513979f945 @@ -46,5 +46,27 @@ th:href= "@{'/users/page/' + ${pageNum} + '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir} + ${keyword != null ? '&keyword=' + keyword : ''}}">[[${label}]] +
+ + + + + +
+ +
+ + +   + +
+ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/53/70cf4a9763b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/53/70cf4a9763b3001d19bbb001c1a81c20 deleted file mode 100644 index ee067bc5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/53/70cf4a9763b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,179 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0adeb7853b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0adeb7853b4001d1d079a924effdc9e deleted file mode 100644 index b13801b8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0adeb7853b4001d1d079a924effdc9e +++ /dev/null @@ -1,183 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/53/e04cd8f530b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/53/e04cd8f530b7001d19ef99be8d31e273 deleted file mode 100644 index 474462f6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/53/e04cd8f530b7001d19ef99be8d31e273 +++ /dev/null @@ -1,55 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 - Category parent = new Category(1); - - Category subCategory = new Category("Desktops", parent); - - Category savedCategory = repo.save(subCategory); - - assertThat(savedCategory.getId()).isGreaterThan(0); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/55/f031650788b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/55/f031650788b3001d19bbb001c1a81c20 deleted file mode 100644 index 62efbf7c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/55/f031650788b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,19 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* small screen */ -} - - -@media screen and (mini-width: 1024px) { - /* small screen */ -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/40106cd745b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/56/40106cd745b4001d1d079a924effdc9e deleted file mode 100644 index ddd3ad9c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/56/40106cd745b4001d1d079a924effdc9e +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - [[${title}]] - - - - - - - - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/57/f0bed4e38bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/57/f0bed4e38bb3001d19bbb001c1a81c20 deleted file mode 100644 index 5946588f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/57/f0bed4e38bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/59/50f6512d46b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/59/50f6512d46b4001d1d079a924effdc9e deleted file mode 100644 index 5b4f0b08..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/59/50f6512d46b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- - -
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/80d228f58cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/5b/80d228f58cb3001d19bbb001c1a81c20 deleted file mode 100644 index eba3c84d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/80d228f58cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/f0a15f9a52b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/5b/f0a15f9a52b4001d1d079a924effdc9e deleted file mode 100644 index 11331458..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/f0a15f9a52b4001d1d079a924effdc9e +++ /dev/null @@ -1,12 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - }); \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/50bcd2b388b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/5c/50bcd2b388b3001d19bbb001c1a81c20 deleted file mode 100644 index 200a327a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/50bcd2b388b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,25 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none} -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: none} -} - - -@media screen and (mini-width: 1024px) { - /* large screen */ - - div.full-details{ display: none} -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/90785f2614b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/5c/90785f2614b4001d128fb79045552177 deleted file mode 100644 index e15da191..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/90785f2614b4001d128fb79045552177 +++ /dev/null @@ -1,76 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/1077a16019b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/5d/1077a16019b4001d128fb79045552177 deleted file mode 100644 index 3b8d77e4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/1077a16019b4001d128fb79045552177 +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
- - -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/20b6400f78b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/5d/20b6400f78b3001d19bbb001c1a81c20 deleted file mode 100644 index b11647a2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/20b6400f78b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,25 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.servlet.http.HttpServletResponse; - -public class AbstractExporter { - - public void setResponseHeader(HttpServletResponse response, String contentType, - String extension, String prefix) throws IOException { - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timestamp = dateFormatter.format(new Date()); - String fileName = prefix + timestamp + extension; - - response.setContentType(contentType); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/f032d91259b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/5d/f032d91259b7001d19ef99be8d31e273 deleted file mode 100644 index 7df7a190..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5d/f032d91259b7001d19ef99be8d31e273 +++ /dev/null @@ -1,18 +0,0 @@ -package com.shopme.admin.category; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class CategoryController { - - @Autowired - private CategoryService service; - - @GetMapping("/categories") - public String listAll(Model model) { - - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/108b0ae80ab9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/5e/108b0ae80ab9001d11addcb4256c67f9 new file mode 100644 index 00000000..f51ab93c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5e/108b0ae80ab9001d11addcb4256c67f9 @@ -0,0 +1,57 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDir = "category-images"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/2088ad0c78b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/5e/2088ad0c78b3001d19bbb001c1a81c20 deleted file mode 100644 index 506f3563..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/2088ad0c78b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.admin.user; - -public class AbstractExporter { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/301eb89b6fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/5e/301eb89b6fb3001d19bbb001c1a81c20 deleted file mode 100644 index 23f12080..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5e/301eb89b6fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,36 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/8066b7e227b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/5f/8066b7e227b3001d1e75aa5ef0815903 deleted file mode 100644 index fde794d6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/8066b7e227b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,140 +0,0 @@ -package com.shopme.admin.user; - -import java.util.List; -import java.util.NoSuchElementException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.transaction.Transactional; - -@Service -@Transactional -public class UserService { - - public static final int USERS_PER_PAGE = 4; - - @Autowired - private UserRepository userRepo; - - @Autowired - private RoleRepository roleRepo; - - @Autowired - private PasswordEncoder passwordEncoder; - - public List listAll() { - - return (List) userRepo.findAll(); - } - - - public Page listByPage(int pageNum, String sortField, String sortDir, String keyword) { - - Sort sort = Sort.by(sortField); - - sort = sortDir.equals("asc") ? sort.ascending() : sort.descending(); - - //page number start with 0 for pageable, so need to minus 1. - Pageable pageable = PageRequest.of(pageNum - 1, USERS_PER_PAGE, sort); - - if(keyword != null) { - return userRepo.findAll(keyword, pageable); - } - - - return userRepo.findAll(pageable); - } - - - public List listRoles() { - - return (List) roleRepo.findAll(); - } - - public User save(User user) { - - boolean isUpdatingUser = (user.getId() != null); - - if (isUpdatingUser) { - - User existingUser = userRepo.findById(user.getId()).get(); - - if (user.getPassword().isEmpty()) { - /* - * if we do not set the user password to existing user password, password field - * will be an empty string. When the user object is saved to database, the empty - * string will replace the encoded password. - */ - user.setPassword(existingUser.getPassword()); - } else { - encodePassword(user); - } - - } else { - encodePassword(user); - } - - return userRepo.save(user); - } - - private void encodePassword(User user) { - - String encodedPassword = passwordEncoder.encode(user.getPassword()); - user.setPassword(encodedPassword); - } - - public boolean isEmailUnique(Integer id, String email) { - User userByEmail = userRepo.getUserByEmail(email); - - if (userByEmail == null) - return true; - - boolean isCreatingNew = (id == null); - - if (isCreatingNew) { - if (userByEmail != null) - return false; - } else { - if (userByEmail.getId() != id) { - return false; - } - } - - return true; - } - - public User get(Integer id) throws UserNotFoundException { - try { - return userRepo.findById(id).get(); - } catch (NoSuchElementException ex) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - } - - public void delete(Integer id) throws UserNotFoundException { - - Long countById = userRepo.countById(id); - - if (countById == null || countById == 0) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - - userRepo.deleteById(id); - } - - public void updateUserEnabledStatus(Integer id, boolean enabled) { - - userRepo.updateEnabledStatus(id, enabled); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/90b02f8d28b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/5f/90b02f8d28b3001d1e75aa5ef0815903 deleted file mode 100644 index 9f2cf770..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/90b02f8d28b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,165 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/002d439a15b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/002d439a15b4001d128fb79045552177 deleted file mode 100644 index 20b3c7cc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/60/002d439a15b4001d128fb79045552177 +++ /dev/null @@ -1,27 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/108a688d08b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/108a688d08b4001d128fb79045552177 deleted file mode 100644 index cf78f7f0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/60/108a688d08b4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/8086e27076b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/8086e27076b3001d19bbb001c1a81c20 deleted file mode 100644 index 46f89966..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/60/8086e27076b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - - - ShopmeBackEnd - - ShopmeBackEnd - Shopme Admin project - - 15 - - - - - org.springframework.boot - spring-boot-devtools - - - - - net.sf.supercsv - super-csv - 2.4.0 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/60/e01e499931b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/60/e01e499931b7001d19ef99be8d31e273 deleted file mode 100644 index fc22c5e1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/60/e01e499931b7001d19ef99be8d31e273 +++ /dev/null @@ -1,64 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 -// Category parent = new Category(1); - -// Category subCategory = new Category("Desktops", parent); -// Category savedCategory = repo.save(subCategory); -// assertThat(savedCategory.getId()).isGreaterThan(0); - - Category laptops = new Category("Laptops", parent); - Category components = new Category("Computer Components", parent); - - repo.saveAll(List.of(laptops, components)); - - // ID for root category "Electronics" is 2 - Category parent = new Category(2); - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/61/c0fb6cd46eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/61/c0fb6cd46eb3001d19bbb001c1a81c20 deleted file mode 100644 index 6080b408..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/61/c0fb6cd46eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,29 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(fileName, headerValue); - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/62/40d7570d8bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/62/40d7570d8bb3001d19bbb001c1a81c20 deleted file mode 100644 index 0b89258b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/62/40d7570d8bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/62/50a7cf0558b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/62/50a7cf0558b4001d1d079a924effdc9e deleted file mode 100644 index ae2a4bf4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/62/50a7cf0558b4001d1d079a924effdc9e +++ /dev/null @@ -1,24 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - - -function customizeDropDownMenu() { - - $(".dropdown > a").click(function() { - location.href = this.href; - }); - -} - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/62/903f78c950b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/62/903f78c950b3001d1e75aa5ef0815903 deleted file mode 100644 index a71799e8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/62/903f78c950b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,172 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/6035509e29b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/63/6035509e29b8001d1d97982e354adf88 deleted file mode 100644 index 3d0101eb..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/63/6035509e29b8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - System.out.println(category.getName()); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - printChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void printChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/7021ca408eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/63/7021ca408eb3001d19bbb001c1a81c20 deleted file mode 100644 index 4a855f8b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/63/7021ca408eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/203640a29bb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/203640a29bb9001d10d0f9513979f945 new file mode 100644 index 00000000..4dd231f4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/203640a29bb9001d10d0f9513979f945 @@ -0,0 +1,115 @@ + + + + + + +
+ + +
+ +
+

Manage Categories | [[${pageTitle}]]

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + +
+ Image preview +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+
+
+ + + + + +
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/65/f0e214be9cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/65/f0e214be9cb9001d10d0f9513979f945 new file mode 100644 index 00000000..3844263e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/65/f0e214be9cb9001d10d0f9513979f945 @@ -0,0 +1,105 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + if(!multipartFile.isEmpty()) { + + } + else { + service.save(category); + } + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + + FileUploadUtil.cleanDir(uploadDir); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, + RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/66/101d4cd017b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/66/101d4cd017b4001d128fb79045552177 deleted file mode 100644 index cd3b69b6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/66/101d4cd017b4001d128fb79045552177 +++ /dev/null @@ -1,60 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public UserDetailsService UserDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/66/9077a96465b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/66/9077a96465b3001d19bbb001c1a81c20 deleted file mode 100644 index c9e5fbd5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/66/9077a96465b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,9 +0,0 @@ -package com.shopme.admin.user; - -public class UserCsvExporter { - - public void export() { - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/66/a0cf551b08b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/66/a0cf551b08b4001d128fb79045552177 deleted file mode 100644 index bbfab156..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/66/a0cf551b08b4001d128fb79045552177 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { -// return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/68/702b80538eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/68/702b80538eb3001d19bbb001c1a81c20 deleted file mode 100644 index 489d0443..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/68/702b80538eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,35 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} - - th, td .hidable-column{display: none;} - -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - - th, td .hidable-column{display: table-cell;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/68/a0b09ae879b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/68/a0b09ae879b3001d19bbb001c1a81c20 deleted file mode 100644 index c23d0172..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/68/a0b09ae879b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,37 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter extends AbstractExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - super.setResponseHeader(response, ".csv", "text/csv"); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/68/e0ba267953b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/68/e0ba267953b4001d1d079a924effdc9e deleted file mode 100644 index 50e0421e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/68/e0ba267953b4001d1d079a924effdc9e +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timestamp = dateFormatter.format(new Date()); - String fileName = "users_" + timestamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/a0ac5efe26b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/a0ac5efe26b3001d1e75aa5ef0815903 deleted file mode 100644 index 680a3f3c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/a0ac5efe26b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/00ddff6014b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/00ddff6014b4001d128fb79045552177 deleted file mode 100644 index 3d75e2ab..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/00ddff6014b4001d128fb79045552177 +++ /dev/null @@ -1,76 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/10aa2f7444b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/10aa2f7444b4001d1d079a924effdc9e deleted file mode 100644 index adf75865..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/10aa2f7444b4001d1d079a924effdc9e +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6c/00a2efd39bb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/6c/00a2efd39bb9001d10d0f9513979f945 new file mode 100644 index 00000000..c630a54e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6c/00a2efd39bb9001d10d0f9513979f945 @@ -0,0 +1,115 @@ + + + + + + +
+ + +
+ +
+

Manage Categories | [[${pageTitle}]]

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + +
+ Image preview +
+ +
+
+ +
+ +
+ +
+
+ +
+ + +
+
+
+ + + + + +
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6c/80f96fae0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/6c/80f96fae0ab4001d128fb79045552177 deleted file mode 100644 index a9a2eae3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6c/80f96fae0ab4001d128fb79045552177 +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c05bcd4989b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c05bcd4989b3001d19bbb001c1a81c20 deleted file mode 100644 index 2bdd6aa8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c05bcd4989b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,24 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} -} - - -@media screen and (min-width: 1024px) { - /* large screen */ - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/90d922cd67b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/90d922cd67b3001d19bbb001c1a81c20 deleted file mode 100644 index 017ea2e3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/90d922cd67b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,186 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV() { - - List listUsers = service.listAll(); - - - UserCsvExporter exporter = new UserCsvExporter(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/b01162862fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/6d/b01162862fb4001d1d079a924effdc9e deleted file mode 100644 index c23d32f8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6d/b01162862fb4001d1d079a924effdc9e +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6f/009c60c918b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/6f/009c60c918b4001d128fb79045552177 deleted file mode 100644 index 5544b20b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6f/009c60c918b4001d128fb79045552177 +++ /dev/null @@ -1,75 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6f/00a00e3415b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/6f/00a00e3415b4001d128fb79045552177 deleted file mode 100644 index c3d5c2cf..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6f/00a00e3415b4001d128fb79045552177 +++ /dev/null @@ -1,28 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7/5097a69e8ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/7/5097a69e8ab3001d19bbb001c1a81c20 deleted file mode 100644 index c9736522..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7/5097a69e8ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7/700c3f2d29b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/7/700c3f2d29b8001d1d97982e354adf88 deleted file mode 100644 index 470ed56b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7/700c3f2d29b8001d1d97982e354adf88 +++ /dev/null @@ -1,31 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - - - - - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7/80a0f9b919b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/7/80a0f9b919b4001d128fb79045552177 deleted file mode 100644 index 9bafef44..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7/80a0f9b919b4001d128fb79045552177 +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION_MESSAGE}]]

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/71/30c143c944b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/71/30c143c944b4001d1d079a924effdc9e deleted file mode 100644 index 83af8627..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/71/30c143c944b4001d1d079a924effdc9e +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - -
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/71/60ae73ff8fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/71/60ae73ff8fb3001d19bbb001c1a81c20 deleted file mode 100644 index 4865826d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/71/60ae73ff8fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/71/704c7b9c46b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/71/704c7b9c46b4001d1d079a924effdc9e deleted file mode 100644 index b28fdd7f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/71/704c7b9c46b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- - -
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/71/e0ecd92d29b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/71/e0ecd92d29b8001d1d97982e354adf88 deleted file mode 100644 index b1f51691..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/71/e0ecd92d29b8001d1d97982e354adf88 +++ /dev/null @@ -1,31 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - - - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/72/30533bea77b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/72/30533bea77b3001d19bbb001c1a81c20 deleted file mode 100644 index a9a17122..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/72/30533bea77b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,96 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletResponse; - -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.xssf.usermodel.XSSFCell; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFFont; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import com.shopme.admin.AbstractExporter; -import com.shopme.common.entity.User; - -public class UserExcelExporter extends AbstractExporter { - private XSSFWorkbook workbook; - private XSSFSheet sheet; - - public UserExcelExporter() { - workbook = new XSSFWorkbook(); - } - - private void writeHeaderLine() { - sheet = workbook.createSheet("Users"); - XSSFRow row = sheet.createRow(0); - - XSSFCellStyle cellStyle = workbook.createCellStyle(); - XSSFFont font = workbook.createFont(); - font.setBold(true); - font.setFontHeight(16); - cellStyle.setFont(font); - - createCell(row, 0, "User Id", cellStyle); - createCell(row, 1, "E-mail", cellStyle); - createCell(row, 2, "First Name", cellStyle); - createCell(row, 3, "Last Name", cellStyle); - createCell(row, 4, "Roles", cellStyle); - createCell(row, 5, "Enabled", cellStyle); - - } - - private void createCell(XSSFRow row, int columnIndex, Object value, CellStyle style) { - XSSFCell cell = row.createCell(columnIndex); - sheet.autoSizeColumn(columnIndex); - - if (value instanceof Integer) { - cell.setCellValue((Integer) value); - } else if (value instanceof Boolean) { - cell.setCellValue((Boolean) value); - } else { - cell.setCellValue((String) value); - } - - cell.setCellStyle(style); - } - - public void export(List listUsers, HttpServletResponse response) throws IOException { - super.setResponseHeader(response, "application/octet-stream", ".xlsx", "users_"); - - writeHeaderLine(); - writeDataLines(listUsers); - - ServletOutputStream outputStream = response.getOutputStream(); - workbook.write(outputStream); - workbook.close(); - outputStream.close(); - - - } - - private void writeDataLines(List listUsers) { - int rowIndex = 1; - - XSSFCellStyle cellStyle = workbook.createCellStyle(); - XSSFFont font = workbook.createFont(); - font.setFontHeight(14); - cellStyle.setFont(font); - - for (User user : listUsers) { - XSSFRow row = sheet.createRow(rowIndex++); - int columnIndex = 0; - - createCell(row, columnIndex++, user.getId(), cellStyle); - createCell(row, columnIndex++, user.getEmail(), cellStyle); - createCell(row, columnIndex++, user.getFirstName(), cellStyle); - createCell(row, columnIndex++, user.getLastName(), cellStyle); - createCell(row, columnIndex++, user.getRoles().toString(), cellStyle); - createCell(row, columnIndex++, user.isEnabled(), cellStyle); - } - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/72/608e101b9cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/72/608e101b9cb9001d10d0f9513979f945 new file mode 100644 index 00000000..9a1c0c0c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/72/608e101b9cb9001d10d0f9513979f945 @@ -0,0 +1,170 @@ +package com.shopme.common.entity; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; + +@Entity +@Table(name = "categories") +public class Category { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(length = 128, nullable = false, unique = true) + private String name; + + @Column(length = 64, nullable = false, unique = true) + private String alias; + + @Column(length = 128, nullable = false) + private String image; + + private boolean enabled; + + @OneToOne + @JoinColumn(name = "parent_id") + private Category parent; + + @OneToMany(mappedBy = "parent") + private Set children = new HashSet<>(); + + public Category() { + } + + public Category(Integer id) { + this.id = id; + } + + public static Category copyIdAndName(Category category) { + + Category copyCategory = new Category(); + copyCategory.setName(category.getName()); + copyCategory.setId(category.getId()); + + return copyCategory; + } + + public static Category copyIdAndName(Integer id, String name) { + + Category copyCategory = new Category(); + copyCategory.setName(name); + copyCategory.setId(id); + + return copyCategory; + } + + /* create a copy of a category object in order to append the -- symbol to denote hierarchy level + * */ + public static Category copyFull(Category category) { + + Category copyCategory = new Category(); + copyCategory.setName(category.getName()); + copyCategory.setId(category.getId()); + copyCategory.setImage(category.getImage()); + copyCategory.setAlias(category.getAlias()); + copyCategory.setEnabled(category.isEnabled()); + + return copyCategory; + } + + /* create a copy of a category object in order to append the -- symbol to denote hierarchy level + * */ + public static Category copyFull(Category category, String name) { + + Category copyCategory = Category.copyFull(category); + copyCategory.setName(name); + + return copyCategory; + } + + + + public Category(String name) { + this.name = name; + this.alias = name; + this.image = "default.png"; + + } + + public Category(String name, Category parent) { + this(name); + this.parent = parent; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Category getParent() { + return parent; + } + + public void setParent(Category parent) { + this.parent = parent; + } + + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children = children; + } + + @Transient + public String getImagePath() { + + if(this.id == null) return "/images/image-thumbnail.pnh"; + + return "/category-images/" + this.id + "/" + this.image; + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/72/a0042b0f0fb4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/72/a0042b0f0fb4001d128fb79045552177 deleted file mode 100644 index 6e8f8abe..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/72/a0042b0f0fb4001d128fb79045552177 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/72/e0fea88230b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/72/e0fea88230b7001d19ef99be8d31e273 deleted file mode 100644 index 9c9d0e0d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/72/e0fea88230b7001d19ef99be8d31e273 +++ /dev/null @@ -1,53 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 - Category parent = new Category(1); - - Category subCategory = new Category("Desktops", parent); - - - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/20e058778cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/73/20e058778cb3001d19bbb001c1a81c20 deleted file mode 100644 index f35f43ba..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/73/20e058778cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/30823fce2db4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/73/30823fce2db4001d1d079a924effdc9e deleted file mode 100644 index 4a24c5bb..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/73/30823fce2db4001d1d079a924effdc9e +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/7006a91423b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/73/7006a91423b4001d1216d7fff398b3d6 deleted file mode 100644 index dc498f0a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/73/7006a91423b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,85 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - - public String getFullname() { - - return this.user.getFirstName() + " " + this.user.getLastName(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/74/003b84ca45b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/74/003b84ca45b4001d1d079a924effdc9e deleted file mode 100644 index c9ef4bdf..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/74/003b84ca45b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - [[${title}]] - - - - - - - - - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/75/50205b4b8cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/75/50205b4b8cb3001d19bbb001c1a81c20 deleted file mode 100644 index 194ee8c0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/75/50205b4b8cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/77/002f11cf9cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/77/002f11cf9cb9001d10d0f9513979f945 new file mode 100644 index 00000000..e457fabc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/77/002f11cf9cb9001d10d0f9513979f945 @@ -0,0 +1,105 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + if(!multipartFile.isEmpty()) { + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + + FileUploadUtil.cleanDir(uploadDir); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + } + else { + service.save(category); + } + + + + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, + RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/77/7041e35289b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/77/7041e35289b3001d19bbb001c1a81c20 deleted file mode 100644 index 3e90a3be..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/77/7041e35289b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,26 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} -} - - -@media screen and (min-width: 1024px) { - /* large screen */ - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/78/2054eb1f46b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/78/2054eb1f46b4001d1d079a924effdc9e deleted file mode 100644 index 403c54dc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/78/2054eb1f46b4001d1d079a924effdc9e +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - -
- - -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/78/70b8eb0595b6001d1567bacd2f52a0b7 b/.metadata/.plugins/org.eclipse.core.resources/.history/78/70b8eb0595b6001d1567bacd2f52a0b7 deleted file mode 100644 index fa008be1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/78/70b8eb0595b6001d1567bacd2f52a0b7 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.common.entity; - -public class Category { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/79/a0f704090cb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/79/a0f704090cb9001d11addcb4256c67f9 new file mode 100644 index 00000000..cd372d8a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/79/a0f704090cb9001d11addcb4256c67f9 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/10dec5814fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/10dec5814fb3001d1e75aa5ef0815903 deleted file mode 100644 index eab4337a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/10dec5814fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,166 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/20c90d6730b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/7a/20c90d6730b4001d1d079a924effdc9e deleted file mode 100644 index 0e9acc08..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7a/20c90d6730b4001d1d079a924effdc9e +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7c/506847b452b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/7c/506847b452b4001d1d079a924effdc9e deleted file mode 100644 index 476e5561..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7c/506847b452b4001d1d079a924effdc9e +++ /dev/null @@ -1,21 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - - -function customizeDropDownMenu() { - - -} - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/005d698c1db4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/005d698c1db4001d128fb79045552177 deleted file mode 100644 index 405ed235..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/005d698c1db4001d128fb79045552177 +++ /dev/null @@ -1,201 +0,0 @@ -package com.shopme.admin.user; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.hibernate.internal.build.AllowSysOut; -import org.hibernate.query.sqm.mutation.internal.TableKeyExpressionCollector; -import org.junit.jupiter.api.Test; -import org.springframework.aot.nativex.NativeConfigurationWriter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@DataJpaTest(showSql = false) -//configure to run on real database(MySQL) instead of a test database -@AutoConfigureTestDatabase(replace = Replace.NONE) -/* - * Datajpatest will rollback the transaction after executing the test method - * everytime, so that the transaction will not be committed. if we want to - * commit the transaction(aka "save the record"), we can disable rollback by - * setting it to false. Now, all transactions will be committed - */ -@Rollback(false) -public class UserRepositoryTests { - - @Autowired - private UserRepository repo; - - @Autowired - private TestEntityManager entityManager; - - // On the very first execution of testCreateUser() method; hibernate will create - // the users table & users_roles table - @Test - public void testCreateUserWithOneRole() { - - Role roleAdmin = entityManager.find(Role.class, 1); - User userChow = new User("chow@gmail.com", "password", "chow", "seng fung"); - userChow.addRoles(roleAdmin); - User savedUser = repo.save(userChow); - assertThat(savedUser.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateUserWithTwoRole() { - - User userRavi = new User("ravi@gmail.com", "ravipass", "ravi", "kumar"); - Role roleEditor = new Role(3); - Role roleAssistant = new Role(5); - - userRavi.addRoles(roleEditor); - userRavi.addRoles(roleAssistant); - - User savedUser = repo.save(userRavi); - assertThat(savedUser.getId()).isGreaterThan(0); - } - - @Test - public void testListAllUsers() { - Iterable listUsers = repo.findAll(); - - // use method reference instead of lambda expression here - listUsers.forEach(System.out::println); - - } - - @Test - public void testGetUserById() { - - User userChow = repo.findById(1).get(); - System.out.println(userChow); - // use method reference instead of lambda expression here - assertThat(userChow).isNotNull(); - } - - @Test - public void testUpdateUserDetails() { - - User userChow = repo.findById(1).get(); - userChow.setEnabled(true); - userChow.setEmail("chow22@gmail.com"); - - repo.save(userChow); - } - - @Test - public void testUpdateUserRoles() { - - User userRavi = repo.findById(4).get(); - Role roleEditor = new Role(3); - Role roleSalesperson= new Role(2); - - //change role from editor to salesperson - - /* take note of overriding/implementing the hashcode and equals method in roles - * class. need to override those two methods for remove() to work. - * The remove() method removes an element "e" such that Objects.equals(o, e), - * this will invoke the overwritten equals() method in Role Class. - * */ - userRavi.getRoles().remove(roleEditor); - userRavi.addRoles(roleSalesperson); - - repo.save(userRavi); - } - - @Test - public void testDeleteUser() { - - Integer userId = 4; - repo.deleteById(userId); - } - - - @Test - public void testGetUserByEmail() { - String email = "ravi@gmail.com"; - User user = repo.getUserByEmail(email); - - assertThat(user).isNotNull(); - } - - /* - * count the number of records in database with a particular id. - * return value should be 1, - * because id is unique. - * - * use countById() method to test whether a user exists. - */ - @Test - public void testCountById() { - - Integer userId = 1; - Long countById = repo.countById(userId); - - assertThat(countById).isNotNull().isGreaterThan(0).isEqualTo(1); - } - - @Test - public void testDisableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, false); - } - - @Test - public void testEnableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, true); - } - - @Test - public void testListFirstPage() { - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isEqualTo(pageSize); - } - - - @Test - public void testSearchUsers() { - - String keyword = "bruce"; - - - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(keyword, pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isGreaterThan(0); - - } - - -} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10c9e4380bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10c9e4380bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..ca3bdf11 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10c9e4380bb9001d11addcb4256c67f9 @@ -0,0 +1,49 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + Path userPhotoDir = Paths.get(dirName); + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDirName = "category-images"; + Path categoryImagesDir = Paths.get(categoryImagesDirName); + String categoryImagesPath = categoryImagesDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/" + categoryImagesDirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/2008510750b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/2008510750b3001d1e75aa5ef0815903 deleted file mode 100644 index 18b3cfd0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/2008510750b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,172 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - //get first part of email - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword="; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/b012c7ec6db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/7d/b012c7ec6db3001d19bbb001c1a81c20 deleted file mode 100644 index 02baf860..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7d/b012c7ec6db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,20 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00e11d2245b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00e11d2245b4001d1d079a924effdc9e deleted file mode 100644 index 97dce6a5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00e11d2245b4001d1d079a924effdc9e +++ /dev/null @@ -1,78 +0,0 @@ - - - - - -
- - -
- -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/50c942418db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/7e/50c942418db3001d19bbb001c1a81c20 deleted file mode 100644 index 14e7197e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/50c942418db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/c0cfed9b15b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/7e/c0cfed9b15b4001d128fb79045552177 deleted file mode 100644 index f27705a1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7e/c0cfed9b15b4001d128fb79045552177 +++ /dev/null @@ -1,29 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - if( user != null) { - return new ShopmeUserDetails(user); - } - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/7f/30ccc0e405b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/7f/30ccc0e405b4001d128fb79045552177 deleted file mode 100644 index c8eb64a1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/7f/30ccc0e405b4001d128fb79045552177 +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
-

Custom login page

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/70f66b968ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/8/70f66b968ab3001d19bbb001c1a81c20 deleted file mode 100644 index ce52e493..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8/70f66b968ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/b0648b9832b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/8/b0648b9832b4001d1d079a924effdc9e deleted file mode 100644 index fa0f2d2b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8/b0648b9832b4001d1d079a924effdc9e +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- - -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/d0b8b48963b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/8/d0b8b48963b3001d19bbb001c1a81c20 deleted file mode 100644 index c4e504ce..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8/d0b8b48963b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,176 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/80/10222fe71eb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/80/10222fe71eb3001d1e75aa5ef0815903 deleted file mode 100644 index 24488001..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/80/10222fe71eb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/81/20e535847ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/81/20e535847ab3001d19bbb001c1a81c20 deleted file mode 100644 index c9a99a93..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/81/20e535847ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,37 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter extends AbstractExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/81/30090d538cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/81/30090d538cb3001d19bbb001c1a81c20 deleted file mode 100644 index 2d10bd2b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/81/30090d538cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/81/e029fefe87b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/81/e029fefe87b3001d19bbb001c1a81c20 deleted file mode 100644 index 1ce84fd6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/81/e029fefe87b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,19 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ -} - -@media screen and (min-width: 768px) and (max-width: px) { - /* small screen */ -} - - -@media screen and (max-width: 768px) { - /* small screen */ -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/81/f0e3cb253cb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/81/f0e3cb253cb4001d1d079a924effdc9e deleted file mode 100644 index ac4a18fe..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/81/f0e3cb253cb4001d1d079a924effdc9e +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - - - Home - Shopme Admin - - - - - - - - - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/10df271846b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/82/a04758690db9001d11addcb4256c67f9 similarity index 70% rename from .metadata/.plugins/org.eclipse.core.resources/.history/c8/10df271846b4001d1d079a924effdc9e rename to .metadata/.plugins/org.eclipse.core.resources/.history/82/a04758690db9001d11addcb4256c67f9 index d5147a2b..c05f24fb 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/10df271846b4001d1d079a924effdc9e +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/82/a04758690db9001d11addcb4256c67f9 @@ -1,32 +1,30 @@ - +
+
-

Manage Users

- +

Manage Categories

+ - +
- - - +
[[${message}]]
+
-
+ - - Filter:     @@ -46,53 +44,27 @@ - - - - - - - - - - + + + + - - - + + - - - - - + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/82/f014bb9426b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/82/f014bb9426b8001d1d97982e354adf88 deleted file mode 100644 index eefcbe0d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/82/f014bb9426b8001d1d97982e354adf88 +++ /dev/null @@ -1,26 +0,0 @@ -package com.shopme.admin.category; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - - - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/83/a0defe7a45b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/83/a0defe7a45b4001d1d079a924effdc9e deleted file mode 100644 index 83af8627..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/83/a0defe7a45b4001d1d079a924effdc9e +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - -
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
- - - - - Filter:  - -    - -    - - - -
- - -
-
- - Photos - - - - Roles + IDCategory ImageCategory NameAliasEnabled
[[${user.id}]] - - +
[[${cat.id}]] + [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]][[${cat.name}]][[${cat.alias}]] - - - +
- -   - +
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/84/104d26af4db3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/84/104d26af4db3001d1e75aa5ef0815903 deleted file mode 100644 index 391ecaf7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/84/104d26af4db3001d1e75aa5ef0815903 +++ /dev/null @@ -1,34 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/84/907fd54243b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/84/907fd54243b4001d1d079a924effdc9e deleted file mode 100644 index 655697f1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/84/907fd54243b4001d1d079a924effdc9e +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - -
-
- - -
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/85/40872ffc8cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/85/40872ffc8cb3001d19bbb001c1a81c20 deleted file mode 100644 index a46cbeed..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/85/40872ffc8cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - - - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/85/d073f39b30b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/85/d073f39b30b7001d19ef99be8d31e273 deleted file mode 100644 index c05c5d0a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/85/d073f39b30b7001d19ef99be8d31e273 +++ /dev/null @@ -1,54 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 - Category parent = new Category(1); - - Category subCategory = new Category("Desktops", parent); - - Category savedCategory = repo.save(subCategory); - - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/87/30b6e61a70b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/87/30b6e61a70b3001d19bbb001c1a81c20 deleted file mode 100644 index a6d2547b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/87/30b6e61a70b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; -// String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - -// for (User user : listUsers) { -// csvWriter.write(user, fieldMapping); -// } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/87/803456f817b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/87/803456f817b4001d128fb79045552177 deleted file mode 100644 index 37a50410..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/87/803456f817b4001d128fb79045552177 +++ /dev/null @@ -1,62 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - - @Bean - public UserDetailsService UserDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/88/702044d746b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/89/8084aaecc4b9001d10d0f9513979f945 similarity index 76% rename from .metadata/.plugins/org.eclipse.core.resources/.history/88/702044d746b4001d1d079a924effdc9e rename to .metadata/.plugins/org.eclipse.core.resources/.history/89/8084aaecc4b9001d10d0f9513979f945 index b809a7c4..963c580c 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/88/702044d746b4001d1d079a924effdc9e +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/89/8084aaecc4b9001d10d0f9513979f945 @@ -12,6 +12,7 @@ + @@ -45,5 +46,27 @@ th:href= "@{'/users/page/' + ${pageNum} + '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir} + ${keyword != null ? '&keyword=' + keyword : ''}}">[[${label}]] +
+ + + + + +
+ +
+ + +   + +
+ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/10ad72ea0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/8b/10ad72ea0ab4001d128fb79045552177 deleted file mode 100644 index c0dd229d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8b/10ad72ea0ab4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/405a2b7314b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/405a2b7314b4001d128fb79045552177 deleted file mode 100644 index 9615a63a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/405a2b7314b4001d128fb79045552177 +++ /dev/null @@ -1,78 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/f07d881529b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/8d/f07d881529b8001d1d97982e354adf88 deleted file mode 100644 index 8a20817c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8d/f07d881529b8001d1d97982e354adf88 +++ /dev/null @@ -1,24 +0,0 @@ -package com.shopme.admin.category; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/607be6510cb4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/607be6510cb4001d128fb79045552177 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/807173e642b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/807173e642b4001d1d079a924effdc9e deleted file mode 100644 index 46a050bd..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/807173e642b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/a0b2ca7131b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/8e/a0b2ca7131b4001d1d079a924effdc9e deleted file mode 100644 index 9d962edd..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8e/a0b2ca7131b4001d1d079a924effdc9e +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- - -
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/20c53fc544b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/8f/20c53fc544b4001d1d079a924effdc9e deleted file mode 100644 index fb1c9477..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/20c53fc544b4001d1d079a924effdc9e +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/30b7300706b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/8f/30b7300706b4001d128fb79045552177 deleted file mode 100644 index 3937d2de..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/30b7300706b4001d128fb79045552177 +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/c00291c731b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/8f/c00291c731b4001d1d079a924effdc9e deleted file mode 100644 index b6aee643..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/c00291c731b4001d1d079a924effdc9e +++ /dev/null @@ -1,78 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f02059fa89b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f02059fa89b3001d19bbb001c1a81c20 deleted file mode 100644 index 81fd3378..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f02059fa89b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - -
-

Showing user list on small screen

-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/20d367bd43b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/9/20d367bd43b4001d1d079a924effdc9e deleted file mode 100644 index a9ed860a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9/20d367bd43b4001d1d079a924effdc9e +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/30e7716d2eb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/9/30e7716d2eb4001d1d079a924effdc9e deleted file mode 100644 index 6c25acd2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9/30e7716d2eb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/701a355e89b9001d14fea12e82c90085 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/701a355e89b9001d14fea12e82c90085 new file mode 100644 index 00000000..8fde603c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9/701a355e89b9001d14fea12e82c90085 @@ -0,0 +1,118 @@ +package com.shopme.admin.category; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.shopme.common.entity.Category; + +@Service +public class CategoryService { + + @Autowired + private CategoryRepository repo; + + public List listAll() { + + List rootCategories = repo.findRootCategories(); + + return listHierarchicalCategories(rootCategories); + } + + private List listHierarchicalCategories(List rootCategories) { + + List hierarchicalCategories = new ArrayList<>(); + + for (Category rootCategory : rootCategories) { + hierarchicalCategories.add(Category.copyFull(rootCategory)); + + Set children = rootCategory.getChildren(); + + for (Category subCategory : children) { + String name = "--" + subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, 1); + } + } + + return hierarchicalCategories; + + } + + // recursive method + private void listHierarchicalCategories(List hierarchicalCategories, Category parent, int subLevel) { + + Set children = parent.getChildren(); + int newSubLevel = subLevel + 1; + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + + name += subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, newSubLevel); + + } + + } + + public Category save(Category category) { + return repo.save(category); + } + + public List listCategoriesUsedInForm() { + + List categoriesUsedInForm = new ArrayList<>(); + + Iterable categoriesInDB = repo.findAll(); + + for (Category category : categoriesInDB) { + + // root category + if (category.getParent() == null) { + categoriesUsedInForm.add(Category.copyIdAndName(category)); + + category.getChildren().forEach(subCategory -> { + String name = "--" + subCategory.getName(); + + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, 1); + }); + } + + } + + return categoriesUsedInForm; + } + + // recursive method + private void listSubCategoriesUsedInForm(List categoriesUsedInForm, Category parent, int subLevel) { + + int newSubLevel = subLevel + 1; + Set children = parent.getChildren(); + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + + name += subCategory.getName(); + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, newSubLevel); + } + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/905937d722b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/905937d722b4001d1216d7fff398b3d6 deleted file mode 100644 index 9d81efaf..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9/905937d722b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,81 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/a01aad2f15b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/a01aad2f15b4001d128fb79045552177 deleted file mode 100644 index 9f07bd11..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9/a01aad2f15b4001d128fb79045552177 +++ /dev/null @@ -1,27 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/90/901a290114b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/90/901a290114b4001d128fb79045552177 deleted file mode 100644 index a88c7614..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/90/901a290114b4001d128fb79045552177 +++ /dev/null @@ -1,76 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/92/60d5b1d29cb9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/92/60d5b1d29cb9001d10d0f9513979f945 new file mode 100644 index 00000000..83ca8f2a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/92/60d5b1d29cb9001d10d0f9513979f945 @@ -0,0 +1,99 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + if(!multipartFile.isEmpty()) { + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + + FileUploadUtil.cleanDir(uploadDir); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + } + else { + service.save(category); + } + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, + RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/93/00d1020b0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/93/00d1020b0ab4001d128fb79045552177 deleted file mode 100644 index a7b3c72e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/93/00d1020b0ab4001d128fb79045552177 +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- - -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/93/206313010bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/93/206313010bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..31815102 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/93/206313010bb9001d11addcb4256c67f9 @@ -0,0 +1,57 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesName = "category-images"; + + Path categoryImagesDir = Paths.get(categoryImagesName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/93/e0daf1a94bb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/93/e0daf1a94bb4001d1d079a924effdc9e deleted file mode 100644 index 20df00dd..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/93/e0daf1a94bb4001d1d079a924effdc9e +++ /dev/null @@ -1,88 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890") - .tokenValiditySeconds(7 * 24 * 60 * 60); - - /* - * set a fix key used for the md5 hash algorithm to encrypt cookie content each - * time the application is restarted, a new key will be generated; this key will - * be used to encrypt the cookie content so, in order for the cookie to be - * permanent; a fix key is needed. - */ - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/94/a0f199e608b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/94/a0f199e608b4001d128fb79045552177 deleted file mode 100644 index b290357d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/94/a0f199e608b4001d128fb79045552177 +++ /dev/null @@ -1,44 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/00649a3019b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/95/00649a3019b4001d128fb79045552177 deleted file mode 100644 index e9764c34..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/95/00649a3019b4001d128fb79045552177 +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/40e0093562b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/95/40e0093562b3001d19bbb001c1a81c20 deleted file mode 100644 index 7314e367..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/95/40e0093562b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - - - ShopmeBackEnd - - ShopmeBackEnd - Shopme Admin project - - 15 - - - - - org.springframework.boot - spring-boot-devtools - - - - net.sf.supercsv - super-csv - 2.4.0 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/95/a08782086eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/95/a08782086eb3001d19bbb001c1a81c20 deleted file mode 100644 index 523bee72..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/95/a08782086eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,20 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/96/705b30598fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/96/705b30598fb3001d19bbb001c1a81c20 deleted file mode 100644 index a18316d7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/96/705b30598fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,33 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/96/f00d31aa23b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/96/f00d31aa23b4001d1216d7fff398b3d6 deleted file mode 100644 index a47b01d9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/96/f00d31aa23b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/97/0037727629b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/97/0037727629b8001d1d97982e354adf88 deleted file mode 100644 index d7d60b1a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/97/0037727629b8001d1d97982e354adf88 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categories) { - - // root category - if (category.getParent() == null) { - System.out.println(category.getName()); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - printChildren(subCategory, 1); - }); - } - - } - - - - return categoriesUsedInForm; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/97/20628b6c0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/97/20628b6c0ab4001d128fb79045552177 deleted file mode 100644 index 69df4b17..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/97/20628b6c0ab4001d128fb79045552177 +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- - - -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/97/e068239826b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/97/e068239826b3001d1e75aa5ef0815903 deleted file mode 100644 index 3bc232b6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/97/e068239826b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,200 +0,0 @@ -package com.shopme.admin.user; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.hibernate.internal.build.AllowSysOut; -import org.hibernate.query.sqm.mutation.internal.TableKeyExpressionCollector; -import org.junit.jupiter.api.Test; -import org.springframework.aot.nativex.NativeConfigurationWriter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@DataJpaTest(showSql = false) -//configure to run on real database(MySQL) instead of a test database -@AutoConfigureTestDatabase(replace = Replace.NONE) -/* - * Datajpatest will rollback the transaction after executing the test method - * everytime, so that the transaction will not be committed. if we want to - * commit the transaction(aka "save the record"), we can disable rollback by - * setting it to false. Now, all transactions will be committed - */ -@Rollback(false) -public class UserRepositoryTests { - - @Autowired - private UserRepository repo; - - @Autowired - private TestEntityManager entityManager; - - // On the very first execution of testCreateUser() method; hibernate will create - // the users table & users_roles table - @Test - public void testCreateUserWithOneRole() { - - Role roleAdmin = entityManager.find(Role.class, 1); - User userChow = new User("chow@gmail.com", "password", "chow", "seng fung"); - userChow.addRoles(roleAdmin); - User savedUser = repo.save(userChow); - assertThat(savedUser.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateUserWithTwoRole() { - - User userRavi = new User("ravi@gmail.com", "ravipass", "ravi", "kumar"); - Role roleEditor = new Role(3); - Role roleAssistant = new Role(5); - - userRavi.addRoles(roleEditor); - userRavi.addRoles(roleAssistant); - - User savedUser = repo.save(userRavi); - assertThat(savedUser.getId()).isGreaterThan(0); - } - - @Test - public void testListAllUsers() { - Iterable listUsers = repo.findAll(); - - // use method reference instead of lambda expression here - listUsers.forEach(System.out::println); - - } - - @Test - public void testGetUserById() { - - User userChow = repo.findById(1).get(); - System.out.println(userChow); - // use method reference instead of lambda expression here - assertThat(userChow).isNotNull(); - } - - @Test - public void testUpdateUserDetails() { - - User userChow = repo.findById(1).get(); - userChow.setEnabled(true); - userChow.setEmail("chow22@gmail.com"); - - repo.save(userChow); - } - - @Test - public void testUpdateUserRoles() { - - User userRavi = repo.findById(4).get(); - Role roleEditor = new Role(3); - Role roleSalesperson= new Role(2); - - //change role from editor to salesperson - - /* take note of overriding/implementing the hashcode and equals method in roles - * class. need to override those two methods for remove() to work. - * The remove() method removes an element "e" such that Objects.equals(o, e), - * this will invoke the overwritten equals() method in Role Class. - * */ - userRavi.getRoles().remove(roleEditor); - userRavi.addRoles(roleSalesperson); - - repo.save(userRavi); - } - - @Test - public void testDeleteUser() { - - Integer userId = 4; - repo.deleteById(userId); - } - - - @Test - public void testGetUserByEmail() { - String email = "ravi@gmail.com"; - User user = repo.getUserByEmail(email); - - assertThat(user).isNotNull(); - } - - /* - * count the number of records in database with a particular id. - * return value should be 1, - * because id is unique. - * - * use countById() method to test whether a user exists. - */ - @Test - public void testCountById() { - - Integer userId = 1; - Long countById = repo.countById(userId); - - assertThat(countById).isNotNull().isGreaterThan(0).isEqualTo(1); - } - - @Test - public void testDisableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, false); - } - - @Test - public void testEnableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, true); - } - - @Test - public void testListFirstPage() { - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isEqualTo(pageSize); - } - - - @Test - public void testSearchUsers() { - - String keyword = "bruce"; - - - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(keyword, pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - - } - - -} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/98/707ba5ce58b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/98/707ba5ce58b7001d19ef99be8d31e273 deleted file mode 100644 index 7a5ec799..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/98/707ba5ce58b7001d19ef99be8d31e273 +++ /dev/null @@ -1,8 +0,0 @@ -package com.shopme.admin.category; - -import org.springframework.stereotype.Controller; - -@Controller -public class CategoryController { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/99/d01a1f7029b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/99/d01a1f7029b8001d1d97982e354adf88 deleted file mode 100644 index 8f6ad9ea..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/99/d01a1f7029b8001d1d97982e354adf88 +++ /dev/null @@ -1,33 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - - - - - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9a/10dcae6728b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/9a/10dcae6728b3001d1e75aa5ef0815903 deleted file mode 100644 index 15ca0afa..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9a/10dcae6728b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,165 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc"); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9a/80a0fd5f1ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/9a/80a0fd5f1ab4001d128fb79045552177 deleted file mode 100644 index 675d3dbe..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9a/80a0fd5f1ab4001d128fb79045552177 +++ /dev/null @@ -1,154 +0,0 @@ -package com.shopme.common.entity; - -import java.util.HashSet; -import java.util.Set; - -import org.hibernate.grammars.hql.HqlParser.NthSideClauseContext; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.Table; -import jakarta.persistence.Transient; - -@Entity -@Table(name = "users") -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(length = 128, nullable = false, unique = true) - private String email; - - @Column(length = 64, nullable = false) - private String password; - - @Column(name = "first_name", length = 45, nullable = false) - private String firstName; - - @Column(name = "last_name", length = 45, nullable = false) - private String lastName; - - @Column(length = 64) - private String photos; - - private boolean enabled; - - // intermediate table - - @ManyToMany - @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) - private Set roles = new HashSet<>(); - - public User() { - - } - - public User(String email, String password, String firstName, String lastName) { - this.email = email; - this.password = password; - this.firstName = firstName; - this.lastName = lastName; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getPhotos() { - return photos; - } - - public void setPhotos(String photos) { - this.photos = photos; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public Set getRoles() { - return roles; - } - - public void setRoles(Set roles) { - this.roles = roles; - } - - public void addRoles(Role role) { - this.roles.add(role); - } - - @Override - public String toString() { - return "User [id=" + id + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName - + ", roles=" + roles + "]"; - } - - // Transient annotation to indicate this getter method is not mapped to any - // field in database - @Transient - public String getPhotosImagePath() { - - if(id == null || photos == null) return "/images/default-user.png"; - - return "/user-photos/" + this.id + "/" + this.photos; - - } - - // Transient annotation to indicate this getter method is not mapped to any - // field in database - @Transient - public String getFullName() { - - return firstName + " " + lastName; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/70bb9c9d19b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/9b/70bb9c9d19b4001d128fb79045552177 deleted file mode 100644 index 74a6b6fa..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/70bb9c9d19b4001d128fb79045552177 +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
- - -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/801d865948b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/9b/801d865948b4001d1d079a924effdc9e deleted file mode 100644 index 730fd1a7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9b/801d865948b4001d1d079a924effdc9e +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- - -
-

you have been logged out

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- - -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/30c5862105b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/30c5862105b4001d128fb79045552177 deleted file mode 100644 index 37d92c92..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/30c5862105b4001d128fb79045552177 +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b0c857a743b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b0c857a743b4001d1d079a924effdc9e deleted file mode 100644 index b38e4a99..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b0c857a743b4001d1d079a924effdc9e +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9e/704397fd22b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/9e/704397fd22b4001d1216d7fff398b3d6 deleted file mode 100644 index 5502069e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9e/704397fd22b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,84 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - - public String getFullname() { - - return this.user.getFirstName() + " " + user.getLastName(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9f/10f4a31f08b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/9f/10f4a31f08b4001d128fb79045552177 deleted file mode 100644 index 243ffe0c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9f/10f4a31f08b4001d128fb79045552177 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9f/90a9b2ba14b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/9f/90a9b2ba14b4001d128fb79045552177 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a/b0fcdeff76b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/a/b0fcdeff76b3001d19bbb001c1a81c20 deleted file mode 100644 index b13801b8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a/b0fcdeff76b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,183 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/80be9e140bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/80be9e140bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..5ef21c55 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/80be9e140bb9001d11addcb4256c67f9 @@ -0,0 +1,57 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDirName = "category-images"; + + Path categoryImagesDir = Paths.get(categoryImagesDirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d0b274b789b9001d14fea12e82c90085 b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d0b274b789b9001d14fea12e82c90085 new file mode 100644 index 00000000..d86849ef --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d0b274b789b9001d14fea12e82c90085 @@ -0,0 +1,125 @@ +package com.shopme.admin.category; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.support.Repositories; +import org.springframework.stereotype.Service; + +import com.shopme.common.entity.Category; + +@Service +public class CategoryService { + + @Autowired + private CategoryRepository repo; + + public List listAll() { + + List rootCategories = repo.findRootCategories(); + + return listHierarchicalCategories(rootCategories); + } + + private List listHierarchicalCategories(List rootCategories) { + + List hierarchicalCategories = new ArrayList<>(); + + for (Category rootCategory : rootCategories) { + hierarchicalCategories.add(Category.copyFull(rootCategory)); + + Set children = rootCategory.getChildren(); + + for (Category subCategory : children) { + String name = "--" + subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, 1); + } + } + + return hierarchicalCategories; + + } + + // recursive method + private void listHierarchicalCategories(List hierarchicalCategories, Category parent, int subLevel) { + + Set children = parent.getChildren(); + int newSubLevel = subLevel + 1; + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + + name += subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, newSubLevel); + + } + + } + + public Category save(Category category) { + return repo.save(category); + } + + public List listCategoriesUsedInForm() { + + List categoriesUsedInForm = new ArrayList<>(); + + Iterable categoriesInDB = repo.findAll(); + + for (Category category : categoriesInDB) { + + // root category + if (category.getParent() == null) { + categoriesUsedInForm.add(Category.copyIdAndName(category)); + + category.getChildren().forEach(subCategory -> { + String name = "--" + subCategory.getName(); + + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, 1); + }); + } + + } + + return categoriesUsedInForm; + } + + // recursive method + private void listSubCategoriesUsedInForm(List categoriesUsedInForm, Category parent, int subLevel) { + + int newSubLevel = subLevel + 1; + Set children = parent.getChildren(); + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + name += subCategory.getName(); + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, newSubLevel); + } + + } + + + public Category get(Integer id) throws CategoryNotFoundException { + + repo.findById(id).get(); + + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/f050330b88b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/f050330b88b3001d19bbb001c1a81c20 deleted file mode 100644 index a90799e7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/f050330b88b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,19 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ -} - - -@media screen and (mini-width: 1024px) { - /* small screen */ -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a1/e080e5b889b9001d14fea12e82c90085 b/.metadata/.plugins/org.eclipse.core.resources/.history/a1/e080e5b889b9001d14fea12e82c90085 new file mode 100644 index 00000000..a974ed92 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a1/e080e5b889b9001d14fea12e82c90085 @@ -0,0 +1,131 @@ +package com.shopme.admin.category; + +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.support.Repositories; +import org.springframework.stereotype.Service; + +import com.shopme.common.entity.Category; + +@Service +public class CategoryService { + + @Autowired + private CategoryRepository repo; + + public List listAll() { + + List rootCategories = repo.findRootCategories(); + + return listHierarchicalCategories(rootCategories); + } + + private List listHierarchicalCategories(List rootCategories) { + + List hierarchicalCategories = new ArrayList<>(); + + for (Category rootCategory : rootCategories) { + hierarchicalCategories.add(Category.copyFull(rootCategory)); + + Set children = rootCategory.getChildren(); + + for (Category subCategory : children) { + String name = "--" + subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, 1); + } + } + + return hierarchicalCategories; + + } + + // recursive method + private void listHierarchicalCategories(List hierarchicalCategories, Category parent, int subLevel) { + + Set children = parent.getChildren(); + int newSubLevel = subLevel + 1; + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + + name += subCategory.getName(); + hierarchicalCategories.add(Category.copyFull(subCategory, name)); + + listHierarchicalCategories(hierarchicalCategories, subCategory, newSubLevel); + + } + + } + + public Category save(Category category) { + return repo.save(category); + } + + public List listCategoriesUsedInForm() { + + List categoriesUsedInForm = new ArrayList<>(); + + Iterable categoriesInDB = repo.findAll(); + + for (Category category : categoriesInDB) { + + // root category + if (category.getParent() == null) { + categoriesUsedInForm.add(Category.copyIdAndName(category)); + + category.getChildren().forEach(subCategory -> { + String name = "--" + subCategory.getName(); + + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, 1); + }); + } + + } + + return categoriesUsedInForm; + } + + // recursive method + private void listSubCategoriesUsedInForm(List categoriesUsedInForm, Category parent, int subLevel) { + + int newSubLevel = subLevel + 1; + Set children = parent.getChildren(); + + for (Category subCategory : children) { + + String name = ""; + for (int i = 0; i < newSubLevel; i++) { + name += "--"; + } + name += subCategory.getName(); + categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); + + listSubCategoriesUsedInForm(categoriesUsedInForm, subCategory, newSubLevel); + } + + } + + public Category get(Integer id) throws CategoryNotFoundException { + + try { + return repo.findById(id).get(); + + } catch (NoSuchElementException ex) { + + throw new CategoryNotFoundException("could not find any category with the integer: " + id); + } +S + } + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a2/0075215705b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/a2/0075215705b4001d128fb79045552177 deleted file mode 100644 index e13fda86..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a2/0075215705b4001d128fb79045552177 +++ /dev/null @@ -1,22 +0,0 @@ -package com.shopme.admin; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class MainController { - - @GetMapping("") - public String viewHomePage() { - return "index"; - } - - - @GetMapping("/login") - public String viewHomePage() { - return "index"; - } - - - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a2/90bce4387ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/a2/90bce4387ab3001d19bbb001c1a81c20 deleted file mode 100644 index d59113e5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a2/90bce4387ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,37 +0,0 @@ -//package com.shopme.admin.user; -// -//import java.io.IOException; -//import java.text.DateFormat; -//import java.text.SimpleDateFormat; -//import java.util.Date; -//import java.util.List; -// -//import org.supercsv.io.CsvBeanWriter; -//import org.supercsv.io.ICsvBeanWriter; -//import org.supercsv.prefs.CsvPreference; -// -//import com.shopme.common.entity.User; -// -//import jakarta.servlet.http.HttpServletResponse; -// -//public class UserCsvExporter extends AbstractExporter { -// -// public void export(List listUsers, HttpServletResponse response) throws IOException { -// -// -// -// ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); -// -// String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; -// String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; -// -// csvWriter.writeHeader(csvHeader); -// -// for (User user : listUsers) { -// csvWriter.write(user, fieldMapping); -// } -// -// csvWriter.close(); -// } -// -//} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a2/b09926430db9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/a2/b09926430db9001d11addcb4256c67f9 new file mode 100644 index 00000000..52608403 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a2/b09926430db9001d11addcb4256c67f9 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a3/305a51c407b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/a3/305a51c407b4001d128fb79045552177 deleted file mode 100644 index cf78f7f0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a3/305a51c407b4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a3/40e365e952b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/a3/40e365e952b4001d1d079a924effdc9e deleted file mode 100644 index ac620dd0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a3/40e365e952b4001d1d079a924effdc9e +++ /dev/null @@ -1,24 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - - customizeDropDownMenu(); - }); - - -function customizeDropDownMenu() { - - $(".dropdown > a").click(function() { - - }); - -} - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a3/d0c01bc38db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/a3/d0c01bc38db3001d19bbb001c1a81c20 deleted file mode 100644 index b770ed39..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a3/d0c01bc38db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,30 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/00428b3522b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/00428b3522b4001d1216d7fff398b3d6 deleted file mode 100644 index 62fc5091..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/00428b3522b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,77 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.2 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - ShopmeWebParent - pom - parent spring web project - - 15 - - - ShopmeBackEnd - ShopmeFrontEnd - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - mysql - mysql-connector-java - runtime - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - test - - - org.webjars - bootstrap - 4.3.1 - - - org.webjars - jquery - 3.4.1 - - - - org.webjars - webjars-locator-core - - - com.shopme - ShopmeCommon - 0.0.1-SNAPSHOT - - - org.thymeleaf.extras - thymeleaf-extras-springsecurity5 - 3.0.4.RELEASE - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/20dd130a0ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/20dd130a0ab4001d128fb79045552177 deleted file mode 100644 index 8c229541..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/20dd130a0ab4001d128fb79045552177 +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/70c991c507b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/70c991c507b4001d128fb79045552177 deleted file mode 100644 index a838b3fc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/70c991c507b4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { -// return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/90a54ebdc4b9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/90a54ebdc4b9001d10d0f9513979f945 new file mode 100644 index 00000000..56a32ccb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/90a54ebdc4b9001d10d0f9513979f945 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/a01985cd6eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/a01985cd6eb3001d19bbb001c1a81c20 deleted file mode 100644 index 98ecc6e4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/a01985cd6eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,30 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - - String headerValue = "attachment; filename=" + fileName; - - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/00d4374165b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/00d4374165b3001d19bbb001c1a81c20 deleted file mode 100644 index 6b0e33ec..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/00d4374165b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.admin.user; - -public class UserCsvExporter { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/f054629629b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/a7/f054629629b8001d1d97982e354adf88 deleted file mode 100644 index 0f4d36cc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/f054629629b8001d1d97982e354adf88 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - System.out.println(category.getName()); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - printChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a8/f01d1d7953b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/a8/f01d1d7953b4001d1d079a924effdc9e deleted file mode 100644 index 50e0421e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a8/f01d1d7953b4001d1d079a924effdc9e +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timestamp = dateFormatter.format(new Date()); - String fileName = "users_" + timestamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a9/7091d16a3cb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/a9/7091d16a3cb4001d1d079a924effdc9e deleted file mode 100644 index db751af4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a9/7091d16a3cb4001d1d079a924effdc9e +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - Home - Shopme Admin - - - - - - - - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/10fe246c2cb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/10fe246c2cb3001d1e75aa5ef0815903 deleted file mode 100644 index 74a87d1b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/10fe246c2cb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/90defb6c07b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/90defb6c07b4001d128fb79045552177 deleted file mode 100644 index 807e802d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/90defb6c07b4001d128fb79045552177 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/b0c03a8090b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/b0c03a8090b3001d19bbb001c1a81c20 deleted file mode 100644 index 6fa7c395..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/b0c03a8090b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,33 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/b0d2431b62b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/b0d2431b62b3001d19bbb001c1a81c20 deleted file mode 100644 index 580da4d9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/b0d2431b62b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - - - ShopmeBackEnd - - ShopmeBackEnd - Shopme Admin project - - 15 - - - - - org.springframework.boot - spring-boot-devtools - - - - org.springframework.boot - spring-boot-devtools - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ab/e05be7918eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ab/e05be7918eb3001d19bbb001c1a81c20 deleted file mode 100644 index 5a8e8c95..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ab/e05be7918eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,36 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} - - /*hide the columns id and email when in tablet screen size*/ - th, td .hideable-column{display: none;} - -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - - th, td .hideable-column{display: table-cell;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ab/f069cc9731b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/ab/f069cc9731b7001d19ef99be8d31e273 deleted file mode 100644 index 0d6c7159..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ab/f069cc9731b7001d19ef99be8d31e273 +++ /dev/null @@ -1,60 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 - Category parent = new Category(1); - -// Category subCategory = new Category("Desktops", parent); -// Category savedCategory = repo.save(subCategory); -// assertThat(savedCategory.getId()).isGreaterThan(0); - - Category laptops = new Category("Laptops", parent); - Category components = new Category("Computer Components", parent); - - repo.saveAll(List.of(laptops, components)); - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ac/20fe4c553cb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ac/20fe4c553cb4001d1d079a924effdc9e deleted file mode 100644 index a6879fb6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ac/20fe4c553cb4001d1d079a924effdc9e +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - - - Home - Shopme Admin - - - - - - - - - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ad/70b3b06226b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/ad/70b3b06226b3001d1e75aa5ef0815903 deleted file mode 100644 index 03b4af5d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ad/70b3b06226b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,188 +0,0 @@ -package com.shopme.admin.user; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.hibernate.internal.build.AllowSysOut; -import org.hibernate.query.sqm.mutation.internal.TableKeyExpressionCollector; -import org.junit.jupiter.api.Test; -import org.springframework.aot.nativex.NativeConfigurationWriter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@DataJpaTest(showSql = false) -//configure to run on real database(MySQL) instead of a test database -@AutoConfigureTestDatabase(replace = Replace.NONE) -/* - * Datajpatest will rollback the transaction after executing the test method - * everytime, so that the transaction will not be committed. if we want to - * commit the transaction(aka "save the record"), we can disable rollback by - * setting it to false. Now, all transactions will be committed - */ -@Rollback(false) -public class UserRepositoryTests { - - @Autowired - private UserRepository repo; - - @Autowired - private TestEntityManager entityManager; - - // On the very first execution of testCreateUser() method; hibernate will create - // the users table & users_roles table - @Test - public void testCreateUserWithOneRole() { - - Role roleAdmin = entityManager.find(Role.class, 1); - User userChow = new User("chow@gmail.com", "password", "chow", "seng fung"); - userChow.addRoles(roleAdmin); - User savedUser = repo.save(userChow); - assertThat(savedUser.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateUserWithTwoRole() { - - User userRavi = new User("ravi@gmail.com", "ravipass", "ravi", "kumar"); - Role roleEditor = new Role(3); - Role roleAssistant = new Role(5); - - userRavi.addRoles(roleEditor); - userRavi.addRoles(roleAssistant); - - User savedUser = repo.save(userRavi); - assertThat(savedUser.getId()).isGreaterThan(0); - } - - @Test - public void testListAllUsers() { - Iterable listUsers = repo.findAll(); - - // use method reference instead of lambda expression here - listUsers.forEach(System.out::println); - - } - - @Test - public void testGetUserById() { - - User userChow = repo.findById(1).get(); - System.out.println(userChow); - // use method reference instead of lambda expression here - assertThat(userChow).isNotNull(); - } - - @Test - public void testUpdateUserDetails() { - - User userChow = repo.findById(1).get(); - userChow.setEnabled(true); - userChow.setEmail("chow22@gmail.com"); - - repo.save(userChow); - } - - @Test - public void testUpdateUserRoles() { - - User userRavi = repo.findById(4).get(); - Role roleEditor = new Role(3); - Role roleSalesperson= new Role(2); - - //change role from editor to salesperson - - /* take note of overriding/implementing the hashcode and equals method in roles - * class. need to override those two methods for remove() to work. - * The remove() method removes an element "e" such that Objects.equals(o, e), - * this will invoke the overwritten equals() method in Role Class. - * */ - userRavi.getRoles().remove(roleEditor); - userRavi.addRoles(roleSalesperson); - - repo.save(userRavi); - } - - @Test - public void testDeleteUser() { - - Integer userId = 4; - repo.deleteById(userId); - } - - - @Test - public void testGetUserByEmail() { - String email = "ravi@gmail.com"; - User user = repo.getUserByEmail(email); - - assertThat(user).isNotNull(); - } - - /* - * count the number of records in database with a particular id. - * return value should be 1, - * because id is unique. - * - * use countById() method to test whether a user exists. - */ - @Test - public void testCountById() { - - Integer userId = 1; - Long countById = repo.countById(userId); - - assertThat(countById).isNotNull().isGreaterThan(0).isEqualTo(1); - } - - @Test - public void testDisableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, false); - } - - @Test - public void testEnableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, true); - } - - @Test - public void testListFirstPage() { - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isEqualTo(pageSize); - } - - - @Test - public void testSearchUsers() { - - - - } - - -} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ad/905aed061fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/ad/905aed061fb3001d1e75aa5ef0815903 deleted file mode 100644 index 3b6397db..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ad/905aed061fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - - - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/af/00455c320bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/af/00455c320bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..005ceaee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/af/00455c320bb9001d11addcb4256c67f9 @@ -0,0 +1,57 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDirName = "category-images"; + + Path categoryImagesDir = Paths.get(categoryImagesDirName); + + String categoryImagesPath = categoryImagesDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + categoryImagesDirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/af/e034e9314ab4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/af/e034e9314ab4001d1d079a924effdc9e deleted file mode 100644 index ad9dde00..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/af/e034e9314ab4001d1d079a924effdc9e +++ /dev/null @@ -1,80 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890"); - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/af/e094f98e09b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/af/e094f98e09b4001d128fb79045552177 deleted file mode 100644 index 8783eb85..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/af/e094f98e09b4001d128fb79045552177 +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b/5019036f90b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/b/5019036f90b3001d19bbb001c1a81c20 deleted file mode 100644 index 75d38d20..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b/5019036f90b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,33 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b/90c543e50ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/b/90c543e50ab4001d128fb79045552177 deleted file mode 100644 index af13283c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b/90c543e50ab4001d128fb79045552177 +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/201948c40cb4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/201948c40cb4001d128fb79045552177 deleted file mode 100644 index 1a46bc4d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/201948c40cb4001d128fb79045552177 +++ /dev/null @@ -1,52 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -public class ShopmeUserDetails implements UserDetails { - - @Override - public Collection getAuthorities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/90ce18bf2fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/90ce18bf2fb4001d1d079a924effdc9e deleted file mode 100644 index d461f540..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/90ce18bf2fb4001d1d079a924effdc9e +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/30758cd46fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/30758cd46fb3001d19bbb001c1a81c20 deleted file mode 100644 index c202012b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/30758cd46fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/502f91bd8eb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/502f91bd8eb3001d19bbb001c1a81c20 deleted file mode 100644 index 0159db81..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/502f91bd8eb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,35 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen eg:mobile*/ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen eg:tablet*/ - - div.full-details{ display: block;} - div.less-details{ display: none;} - - /*hide the columns id and email when in tablet screen size*/ - th, td .hideable-column{display: none;} -} - - -@media screen and (min-width: 1024px) { - /* large screen eg:laptop*/ - - div.less-details{ display: none;} - - th, td .hideable-column{display: table-cell;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/80d1616f48b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/b2/80d1616f48b4001d1d079a924effdc9e deleted file mode 100644 index 597547b0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b2/80d1616f48b4001d1d079a924effdc9e +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- - -
-

you have been logged out

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/00b62c5e89b9001d14fea12e82c90085 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/00b62c5e89b9001d14fea12e82c90085 new file mode 100644 index 00000000..a16b1ae3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/00b62c5e89b9001d14fea12e82c90085 @@ -0,0 +1,5 @@ +package com.shopme.admin.category; + +public class CategoryNotFoundException extends Exception { + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/106feb9c64b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/106feb9c64b3001d19bbb001c1a81c20 deleted file mode 100644 index 55dfe291..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/106feb9c64b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,182 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV() { - - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/2022f27313b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/2022f27313b4001d128fb79045552177 deleted file mode 100644 index d97b124b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/2022f27313b4001d128fb79045552177 +++ /dev/null @@ -1,76 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - - - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/20d90aeb30b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/20d90aeb30b4001d1d079a924effdc9e deleted file mode 100644 index 75abab76..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/20d90aeb30b4001d1d079a924effdc9e +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/50bb53b3f9b8001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/50bb53b3f9b8001d11addcb4256c67f9 new file mode 100644 index 00000000..a2b41655 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/50bb53b3f9b8001d11addcb4256c67f9 @@ -0,0 +1,44 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assests are not locoated in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/90606b370ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/b3/90606b370ab4001d128fb79045552177 deleted file mode 100644 index 3b7f777e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b3/90606b370ab4001d128fb79045552177 +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- - - -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/a06330e515b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/a06330e515b4001d128fb79045552177 deleted file mode 100644 index 708b0769..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/a06330e515b4001d128fb79045552177 +++ /dev/null @@ -1,37 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -/* - * This class will be called by spring security when performing authentication service - * - * - * */ - - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - if( user != null) { - return new ShopmeUserDetails(user); - } - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/d06240968eb9001d14fea12e82c90085 b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/d06240968eb9001d14fea12e82c90085 new file mode 100644 index 00000000..6f9eea2e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/d06240968eb9001d14fea12e82c90085 @@ -0,0 +1,73 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b6/00e34ba164b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/b6/00e34ba164b3001d19bbb001c1a81c20 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b7/60d76c6845b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/b7/60d76c6845b4001d1d079a924effdc9e deleted file mode 100644 index 94950f4f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b7/60d76c6845b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/108d750f0db4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/108d750f0db4001d128fb79045552177 deleted file mode 100644 index e09cae02..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/108d750f0db4001d128fb79045552177 +++ /dev/null @@ -1,63 +0,0 @@ -package com.shopme.admin.security; - -import java.util.Collection; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - -public class ShopmeUserDetails implements UserDetails { - - private User user; - - - - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/80ca171445b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/80ca171445b4001d1d079a924effdc9e deleted file mode 100644 index da304a1c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/80ca171445b4001d1d079a924effdc9e +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e03289ef31b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e03289ef31b7001d19ef99be8d31e273 deleted file mode 100644 index 4585f982..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e03289ef31b7001d19ef99be8d31e273 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 -// Category parent = new Category(1); - -// Category subCategory = new Category("Desktops", parent); -// Category savedCategory = repo.save(subCategory); -// assertThat(savedCategory.getId()).isGreaterThan(0); - - Category laptops = new Category("Laptops", parent); - Category components = new Category("Computer Components", parent); - - repo.saveAll(List.of(laptops, components)); - - // ID for root category "Electronics" is 2 - Category parent = new Category(2); - - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/809e93f40ab9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/809e93f40ab9001d11addcb4256c67f9 new file mode 100644 index 00000000..507b300b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/809e93f40ab9001d11addcb4256c67f9 @@ -0,0 +1,57 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesName = "category-images"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/a0408e0d77b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/a0408e0d77b3001d19bbb001c1a81c20 deleted file mode 100644 index b344552f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/a0408e0d77b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,192 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) throws IOException { - - List listUsers = service.listAll(); - } - - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/f0caad0d45b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/b9/f0caad0d45b4001d1d079a924effdc9e deleted file mode 100644 index a4ca3cd0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b9/f0caad0d45b4001d1d079a924effdc9e +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - -
-
- - -
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/201cb23830b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/201cb23830b4001d1d079a924effdc9e deleted file mode 100644 index f9c58010..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/201cb23830b4001d1d079a924effdc9e +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/407cb60c8db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ba/407cb60c8db3001d19bbb001c1a81c20 deleted file mode 100644 index e0f98970..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ba/407cb60c8db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - - - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/a01ea16b09b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/a01ea16b09b4001d128fb79045552177 deleted file mode 100644 index 34fbcff9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/a01ea16b09b4001d128fb79045552177 +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/b082793ea7b5001d12b59aa089645058 b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/b082793ea7b5001d12b59aa089645058 deleted file mode 100644 index c46239ed..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bb/b082793ea7b5001d12b59aa089645058 +++ /dev/null @@ -1,88 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890") - .tokenValiditySeconds(7 * 24 * 60 * 60); // cookie is valid for one week - - /* - * set a fix key used for the md5 hash algorithm to encrypt cookie content each - * time the application is restarted, a new key will be generated; this key will - * be used to encrypt the cookie content so, in order for the cookie to be - * permanent; a fix key is needed. - */ - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/10123b0946b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/b09cc4330db9001d11addcb4256c67f9 similarity index 70% rename from .metadata/.plugins/org.eclipse.core.resources/.history/73/10123b0946b4001d1d079a924effdc9e rename to .metadata/.plugins/org.eclipse.core.resources/.history/bb/b09cc4330db9001d11addcb4256c67f9 index 00c4c4c5..21853c41 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/73/10123b0946b4001d1d079a924effdc9e +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bb/b09cc4330db9001d11addcb4256c67f9 @@ -1,32 +1,30 @@ - +
+
-

Manage Users

- +

Manage Categories

+ - +
- - - +
[[${message}]]
+
-
+ - - Filter:     @@ -46,53 +44,27 @@ - - - - - - - - - - + + + + - - - + + - - - - - + + @@ -200,7 +172,7 @@ - +
diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/d0e126368ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/d0e126368ab3001d19bbb001c1a81c20 deleted file mode 100644 index 4cf966f8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/d0e126368ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
- - - - - Filter:  - -    - -    - - - -
- - -
-
- - Photos - - - - Roles + IDCategory ImageCategory NameAliasEnabled
[[${user.id}]] - - +
[[${cat.id}]] + [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]][[${cat.name}]][[${cat.alias}]] - - - +
- -   - +
- - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/1073eed609b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/1073eed609b4001d128fb79045552177 deleted file mode 100644 index 21847db6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/1073eed609b4001d128fb79045552177 +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/70e9cb0488b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/70e9cb0488b3001d19bbb001c1a81c20 deleted file mode 100644 index 874d337d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/70e9cb0488b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,19 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* small screen */ -} - - -@media screen and (max-width: 768px) { - /* small screen */ -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/be/1016e13515b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/be/1016e13515b4001d128fb79045552177 deleted file mode 100644 index e44e1c15..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/be/1016e13515b4001d128fb79045552177 +++ /dev/null @@ -1,28 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/be/1091f08413b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/be/1091f08413b4001d128fb79045552177 deleted file mode 100644 index dc2e8f6a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/be/1091f08413b4001d128fb79045552177 +++ /dev/null @@ -1,77 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/be/60cfa01049b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/be/60cfa01049b4001d1d079a924effdc9e deleted file mode 100644 index e5ae31d0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/be/60cfa01049b4001d1d079a924effdc9e +++ /dev/null @@ -1,79 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll(); - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bf/d0cf087746b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/bf/d0cf087746b4001d1d079a924effdc9e deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bf/e0fcb99288b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/bf/e0fcb99288b3001d19bbb001c1a81c20 deleted file mode 100644 index 88d518eb..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bf/e0fcb99288b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,21 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none} -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ -} - - -@media screen and (mini-width: 1024px) { - /* large screen */ -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c/70f8274a45b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/c/70f8274a45b4001d1d079a924effdc9e deleted file mode 100644 index 595a5061..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c/70f8274a45b4001d1d079a924effdc9e +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - -
- - -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6012d27558b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6012d27558b7001d19ef99be8d31e273 deleted file mode 100644 index 904bf6e3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/6012d27558b7001d19ef99be8d31e273 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.admin.category; - -public class CategoryService { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/907f9e8014b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/907f9e8014b4001d128fb79045552177 deleted file mode 100644 index 9ee39645..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/907f9e8014b4001d128fb79045552177 +++ /dev/null @@ -1,78 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this repo class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/f0fb70a663b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/f0fb70a663b3001d19bbb001c1a81c20 deleted file mode 100644 index bc9f7e15..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/f0fb70a663b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,180 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - //NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public String - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/0098c52651b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/c1/0098c52651b3001d1e75aa5ef0815903 deleted file mode 100644 index 14a26e1b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/0098c52651b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,174 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/8075fcea15b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/c1/8075fcea15b4001d128fb79045552177 deleted file mode 100644 index 31adc275..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c1/8075fcea15b4001d128fb79045552177 +++ /dev/null @@ -1,33 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -/* - * This class will be called by spring security when performing authentication - * - * */ - -public class ShopmeUserDetailsService implements UserDetailsService { - - @Autowired - private UserRepository userRepo; - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - if (user != null) { - return new ShopmeUserDetails(user); - } - - throw new UsernameNotFoundException("could not find user with the email" + email); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/30a222260ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/c2/30a222260ab4001d128fb79045552177 deleted file mode 100644 index 540461dc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/30a222260ab4001d128fb79045552177 +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- - - -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/30ae20482eb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/c2/30ae20482eb4001d1d079a924effdc9e deleted file mode 100644 index c274e0b8..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/30ae20482eb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/d0b655fa8fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/c2/d0b655fa8fb3001d19bbb001c1a81c20 deleted file mode 100644 index 14a9d30d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/d0b655fa8fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c5/50dda86d8cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/c5/50dda86d8cb3001d19bbb001c1a81c20 deleted file mode 100644 index 002a123e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c5/50dda86d8cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c6/50e87de10ab9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/c6/50e87de10ab9001d11addcb4256c67f9 new file mode 100644 index 00000000..03d14327 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c6/50e87de10ab9001d11addcb4256c67f9 @@ -0,0 +1,44 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c6/90bdcfbd4fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/c6/90bdcfbd4fb3001d1e75aa5ef0815903 deleted file mode 100644 index fa2d6307..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c6/90bdcfbd4fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,170 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is unique field, so - - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c7/a0c13e9f27b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/c7/a0c13e9f27b3001d1e75aa5ef0815903 deleted file mode 100644 index 5609cff0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c7/a0c13e9f27b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,135 +0,0 @@ -package com.shopme.admin.user; - -import java.util.List; -import java.util.NoSuchElementException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.transaction.Transactional; - -@Service -@Transactional -public class UserService { - - public static final int USERS_PER_PAGE = 4; - - @Autowired - private UserRepository userRepo; - - @Autowired - private RoleRepository roleRepo; - - @Autowired - private PasswordEncoder passwordEncoder; - - public List listAll() { - - return (List) userRepo.findAll(); - } - - - public Page listByPage(int pageNum, String sortField, String sortDir) { - - Sort sort = Sort.by(sortField); - - sort = sortDir.equals("asc") ? sort.ascending() : sort.descending(); - - //page number start with 0 for pageable, so need to minus 1. - Pageable pageable = PageRequest.of(pageNum - 1, USERS_PER_PAGE, sort); - - return userRepo.findAll(pageable); - } - - - public List listRoles() { - - return (List) roleRepo.findAll(); - } - - public User save(User user) { - - boolean isUpdatingUser = (user.getId() != null); - - if (isUpdatingUser) { - - User existingUser = userRepo.findById(user.getId()).get(); - - if (user.getPassword().isEmpty()) { - /* - * if we do not set the user password to existing user password, password field - * will be an empty string. When the user object is saved to database, the empty - * string will replace the encoded password. - */ - user.setPassword(existingUser.getPassword()); - } else { - encodePassword(user); - } - - } else { - encodePassword(user); - } - - return userRepo.save(user); - } - - private void encodePassword(User user) { - - String encodedPassword = passwordEncoder.encode(user.getPassword()); - user.setPassword(encodedPassword); - } - - public boolean isEmailUnique(Integer id, String email) { - User userByEmail = userRepo.getUserByEmail(email); - - if (userByEmail == null) - return true; - - boolean isCreatingNew = (id == null); - - if (isCreatingNew) { - if (userByEmail != null) - return false; - } else { - if (userByEmail.getId() != id) { - return false; - } - } - - return true; - } - - public User get(Integer id) throws UserNotFoundException { - try { - return userRepo.findById(id).get(); - } catch (NoSuchElementException ex) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - } - - public void delete(Integer id) throws UserNotFoundException { - - Long countById = userRepo.countById(id); - - if (countById == null || countById == 0) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - - userRepo.deleteById(id); - } - - public void updateUserEnabledStatus(Integer id, boolean enabled) { - - userRepo.updateEnabledStatus(id, enabled); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c7/d08911957ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/c7/d08911957ab3001d19bbb001c1a81c20 deleted file mode 100644 index 55f1aca0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c7/d08911957ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,96 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletResponse; - -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.xssf.usermodel.XSSFCell; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFFont; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import com.shopme.admin.user.AbstractExporter; -import com.shopme.common.entity.User; - -public class UserExcelExporter extends AbstractExporter { - private XSSFWorkbook workbook; - private XSSFSheet sheet; - - public UserExcelExporter() { - workbook = new XSSFWorkbook(); - } - - private void writeHeaderLine() { - sheet = workbook.createSheet("Users"); - XSSFRow row = sheet.createRow(0); - - XSSFCellStyle cellStyle = workbook.createCellStyle(); - XSSFFont font = workbook.createFont(); - font.setBold(true); - font.setFontHeight(16); - cellStyle.setFont(font); - - createCell(row, 0, "User Id", cellStyle); - createCell(row, 1, "E-mail", cellStyle); - createCell(row, 2, "First Name", cellStyle); - createCell(row, 3, "Last Name", cellStyle); - createCell(row, 4, "Roles", cellStyle); - createCell(row, 5, "Enabled", cellStyle); - - } - - private void createCell(XSSFRow row, int columnIndex, Object value, CellStyle style) { - XSSFCell cell = row.createCell(columnIndex); - sheet.autoSizeColumn(columnIndex); - - if (value instanceof Integer) { - cell.setCellValue((Integer) value); - } else if (value instanceof Boolean) { - cell.setCellValue((Boolean) value); - } else { - cell.setCellValue((String) value); - } - - cell.setCellStyle(style); - } - - public void export(List listUsers, HttpServletResponse response) throws IOException { - super.setResponseHeader(response, "application/octet-stream", ".xlsx", "users_"); - - writeHeaderLine(); - writeDataLines(listUsers); - - ServletOutputStream outputStream = response.getOutputStream(); - workbook.write(outputStream); - workbook.close(); - outputStream.close(); - - - } - - private void writeDataLines(List listUsers) { - int rowIndex = 1; - - XSSFCellStyle cellStyle = workbook.createCellStyle(); - XSSFFont font = workbook.createFont(); - font.setFontHeight(14); - cellStyle.setFont(font); - - for (User user : listUsers) { - XSSFRow row = sheet.createRow(rowIndex++); - int columnIndex = 0; - - createCell(row, columnIndex++, user.getId(), cellStyle); - createCell(row, columnIndex++, user.getEmail(), cellStyle); - createCell(row, columnIndex++, user.getFirstName(), cellStyle); - createCell(row, columnIndex++, user.getLastName(), cellStyle); - createCell(row, columnIndex++, user.getRoles().toString(), cellStyle); - createCell(row, columnIndex++, user.isEnabled(), cellStyle); - } - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/10893fbf32b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/c8/10893fbf32b4001d1d079a924effdc9e deleted file mode 100644 index 104f2230..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/10893fbf32b4001d1d079a924effdc9e +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- - -
-

you have been logged out

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b0d8891350b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b0d8891350b3001d1e75aa5ef0815903 deleted file mode 100644 index 26457903..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b0d8891350b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,172 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword="; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/5097760b8fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/5097760b8fb3001d19bbb001c1a81c20 deleted file mode 100644 index 63bba920..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/5097760b8fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,33 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/906ec83b09b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/906ec83b09b4001d128fb79045552177 deleted file mode 100644 index 5fd8c0f0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/906ec83b09b4001d128fb79045552177 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assests in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c9/a02b182f0db9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/a02b182f0db9001d11addcb4256c67f9 new file mode 100644 index 00000000..52608403 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c9/a02b182f0db9001d11addcb4256c67f9 @@ -0,0 +1,206 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]] + + [[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/102755e41eb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/102755e41eb3001d1e75aa5ef0815903 deleted file mode 100644 index 423fd5f7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/102755e41eb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,43 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.stereotype.Repository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/604b29758bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ca/604b29758bb3001d19bbb001c1a81c20 deleted file mode 100644 index 19166f23..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ca/604b29758bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,152 +0,0 @@ -package com.shopme.common.entity; - -import java.util.HashSet; -import java.util.Set; - -import org.hibernate.grammars.hql.HqlParser.NthSideClauseContext; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.Table; -import jakarta.persistence.Transient; - -@Entity -@Table(name = "users") -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(length = 128, nullable = false, unique = true) - private String email; - - @Column(length = 64, nullable = false) - private String password; - - @Column(name = "first_name", length = 45, nullable = false) - private String firstName; - - @Column(name = "last_name", length = 45, nullable = false) - private String lastName; - - @Column(length = 64) - private String photos; - - private boolean enabled; - - // intermediate table - - @ManyToMany - @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) - private Set roles = new HashSet<>(); - - public User() { - - } - - public User(String email, String password, String firstName, String lastName) { - this.email = email; - this.password = password; - this.firstName = firstName; - this.lastName = lastName; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getPhotos() { - return photos; - } - - public void setPhotos(String photos) { - this.photos = photos; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public Set getRoles() { - return roles; - } - - public void setRoles(Set roles) { - this.roles = roles; - } - - public void addRoles(Role role) { - this.roles.add(role); - } - - @Override - public String toString() { - return "User [id=" + id + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName - + ", roles=" + roles + "]"; - } - - // Transient annotation to indicate this getter method is not mapped to any - // field in database - @Transient - public String getPhotosImagePath() { - - if(id == null || photos == null) return "/images/default-user.png"; - - return "/user-photos/" + this.id + "/" + this.photos; - - } - - @Transient - public String getFullName() { - - return firstName + lastName; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cb/d072480590b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/cb/d072480590b3001d19bbb001c1a81c20 deleted file mode 100644 index bc55b891..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cb/d072480590b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/0016730230b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/cc/0016730230b4001d1d079a924effdc9e deleted file mode 100644 index c6c708ec..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/0016730230b4001d1d079a924effdc9e +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/60803d1f95b6001d1567bacd2f52a0b7 b/.metadata/.plugins/org.eclipse.core.resources/.history/cc/60803d1f95b6001d1567bacd2f52a0b7 deleted file mode 100644 index c854eacc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/60803d1f95b6001d1567bacd2f52a0b7 +++ /dev/null @@ -1,6 +0,0 @@ -package com.shopme.common.entity; - -public class Category { - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e05739b68fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e05739b68fb3001d19bbb001c1a81c20 deleted file mode 100644 index 486fe671..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e05739b68fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/a0236b5915b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/a0236b5915b4001d128fb79045552177 deleted file mode 100644 index 638a04fb..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/a0236b5915b4001d128fb79045552177 +++ /dev/null @@ -1,30 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cf/00f9645b2fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/cf/00f9645b2fb4001d1d079a924effdc9e deleted file mode 100644 index 88616c1a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cf/00f9645b2fb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d/60f7769746b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/d/60f7769746b4001d1d079a924effdc9e deleted file mode 100644 index aff46f43..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d/60f7769746b4001d1d079a924effdc9e +++ /dev/null @@ -1,13 +0,0 @@ -$(document).ready(function(){ - $("#logoutLink").on("click", function(e){ - e.preventDefault(); /* stop the hyperlink default behaviour */ - - - /* use the form to log out and navigate to the url path /logout - - NOTE: spring security requires a POST request form to logout in order to obtain the csrf token, - the csrf token is a hidden property in the form - */ - document.logoutForm.submit(); - }); - }); \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d0/60a431662ab8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/d0/60a431662ab8001d1d97982e354adf88 deleted file mode 100644 index 4192c9b1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d0/60a431662ab8001d1d97982e354adf88 +++ /dev/null @@ -1,67 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category(category.getName())); - - category.getChildren().forEach(subCategory -> { - String name = "--" + subCategory.getName(); - - categoriesUsedInForm.add(new Category(name)); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - String name = ""; - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/8058478c8db3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/8058478c8db3001d19bbb001c1a81c20 deleted file mode 100644 index 441bbd53..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/8058478c8db3001d19bbb001c1a81c20 +++ /dev/null @@ -1,30 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} - div.less-details{ display: none;} -} - - -@media screen and (min-width: 1024px) { - /* large screen */ - - div.less-details{ display: none;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/b0a66ec86fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/b0a66ec86fb3001d19bbb001c1a81c20 deleted file mode 100644 index e71c5b2e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/b0a66ec86fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,183 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - - // NOTE: these are the default values for path variable and URL parameters - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if (endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - - // after user is saved display the user instead of the entire user list - // email is a unique field to identify each user. - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - - @GetMapping("/users/export/csv") - public void exportToCSV(HttpServletResponse response) { - - List listUsers = service.listAll(); - UserCsvExporter exporter = new UserCsvExporter(); - exporter.export(listUsers, response); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/50/20b47da458b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/c01df74389b9001d14fea12e82c90085 similarity index 100% rename from .metadata/.plugins/org.eclipse.core.resources/.history/50/20b47da458b7001d19ef99be8d31e273 rename to .metadata/.plugins/org.eclipse.core.resources/.history/d1/c01df74389b9001d14fea12e82c90085 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/f004ae5018b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/d1/f004ae5018b4001d128fb79045552177 deleted file mode 100644 index 770efa14..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d1/f004ae5018b4001d128fb79045552177 +++ /dev/null @@ -1,74 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/10b58f2b13b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/d2/10b58f2b13b4001d128fb79045552177 deleted file mode 100644 index d106392d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/10b58f2b13b4001d128fb79045552177 +++ /dev/null @@ -1,75 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - - - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/e04f181f4ab4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/d2/e04f181f4ab4001d1d079a924effdc9e deleted file mode 100644 index f3444e49..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d2/e04f181f4ab4001d1d079a924effdc9e +++ /dev/null @@ -1,80 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe(); - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20f8735279b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20f8735279b3001d19bbb001c1a81c20 deleted file mode 100644 index c202012b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20f8735279b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d4/20ed746a0bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/d4/20ed746a0bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..fd7737c4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d4/20ed746a0bb9001d11addcb4256c67f9 @@ -0,0 +1,49 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + Path userPhotoDir = Paths.get(dirName); + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDirName = "../category-images"; + Path categoryImagesDir = Paths.get(categoryImagesDirName); + String categoryImagesPath = categoryImagesDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/" + categoryImagesDirName + "/**") + .addResourceLocations("file:/" + categoryImagesPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d6/0043d24058b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/d6/0043d24058b7001d19ef99be8d31e273 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d6/103199e777b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/d6/103199e777b3001d19bbb001c1a81c20 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d6/708b80b158b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/d6/708b80b158b7001d19ef99be8d31e273 deleted file mode 100644 index 77b4d7c5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d6/708b80b158b7001d19ef99be8d31e273 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.admin.category; - -public class CategoryController { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d6/b0e4102362b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/d6/b0e4102362b3001d19bbb001c1a81c20 deleted file mode 100644 index 18e9ec8a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d6/b0e4102362b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - - - ShopmeBackEnd - - ShopmeBackEnd - Shopme Admin project - - 15 - - - - - org.springframework.boot - spring-boot-devtools - - - - net.sf.supercsv - super-csv - 2.4.0 - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/504869938bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/d7/504869938bb3001d19bbb001c1a81c20 deleted file mode 100644 index 68b336b9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/504869938bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,152 +0,0 @@ -package com.shopme.common.entity; - -import java.util.HashSet; -import java.util.Set; - -import org.hibernate.grammars.hql.HqlParser.NthSideClauseContext; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.Table; -import jakarta.persistence.Transient; - -@Entity -@Table(name = "users") -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(length = 128, nullable = false, unique = true) - private String email; - - @Column(length = 64, nullable = false) - private String password; - - @Column(name = "first_name", length = 45, nullable = false) - private String firstName; - - @Column(name = "last_name", length = 45, nullable = false) - private String lastName; - - @Column(length = 64) - private String photos; - - private boolean enabled; - - // intermediate table - - @ManyToMany - @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) - private Set roles = new HashSet<>(); - - public User() { - - } - - public User(String email, String password, String firstName, String lastName) { - this.email = email; - this.password = password; - this.firstName = firstName; - this.lastName = lastName; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getPhotos() { - return photos; - } - - public void setPhotos(String photos) { - this.photos = photos; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public Set getRoles() { - return roles; - } - - public void setRoles(Set roles) { - this.roles = roles; - } - - public void addRoles(Role role) { - this.roles.add(role); - } - - @Override - public String toString() { - return "User [id=" + id + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName - + ", roles=" + roles + "]"; - } - - // Transient annotation to indicate this getter method is not mapped to any - // field in database - @Transient - public String getPhotosImagePath() { - - if(id == null || photos == null) return "/images/default-user.png"; - - return "/user-photos/" + this.id + "/" + this.photos; - - } - - @Transient - public String getFullName() { - - return firstName + " " + lastName; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/80e75d1919b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/d7/80e75d1919b4001d128fb79045552177 deleted file mode 100644 index f2d85bc5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/80e75d1919b4001d128fb79045552177 +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/e02bee562ab8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/d7/e02bee562ab8001d1d97982e354adf88 deleted file mode 100644 index ddb4cb84..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/d7/e02bee562ab8001d1d97982e354adf88 +++ /dev/null @@ -1,66 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category(category.getName())); - - category.getChildren().forEach(subCategory -> { - String name = "--" + subCategory.getName(); - - categoriesUsedInForm.add(new Category(name)); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/dc/105183183cb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/dc/105183183cb4001d1d079a924effdc9e deleted file mode 100644 index dd31d49c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/dc/105183183cb4001d1d079a924effdc9e +++ /dev/null @@ -1,33 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/dc/109984ba32b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/dc/109984ba32b4001d1d079a924effdc9e deleted file mode 100644 index ef039d72..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/dc/109984ba32b4001d1d079a924effdc9e +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- -
-

you have been logged out

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/600d53ca8bb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/de/600d53ca8bb3001d19bbb001c1a81c20 deleted file mode 100644 index 021c2d66..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/de/600d53ca8bb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
- -
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/706bf4e217b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/de/706bf4e217b4001d128fb79045552177 deleted file mode 100644 index 4c593801..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/de/706bf4e217b4001d128fb79045552177 +++ /dev/null @@ -1,33 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -/* - * This class will be called by spring security when performing authentication - * - * */ - -public class ShopmeUserDetailsService implements UserDetailsService { - - @Autowired - private UserRepository userRepo; - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - if (user != null) { - return new ShopmeUserDetails(user); - } - - throw new UsernameNotFoundException("could not find user with the email: " + email); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/a08ccb6607b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/de/a08ccb6607b4001d128fb79045552177 deleted file mode 100644 index 3b9f292f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/de/a08ccb6607b4001d128fb79045552177 +++ /dev/null @@ -1,40 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/de/a0aa74c108b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/de/a0aa74c108b4001d128fb79045552177 deleted file mode 100644 index 7077ed09..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/de/a0aa74c108b4001d128fb79045552177 +++ /dev/null @@ -1,45 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix-websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - //custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated() - .and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - return (web) -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/10e4e6a80ab4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/10e4e6a80ab4001d128fb79045552177 deleted file mode 100644 index aa6713c0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/df/10e4e6a80ab4001d128fb79045552177 +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- -
-

Access to Shopme Control Panel

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/f0ed6f8589b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/f0ed6f8589b3001d19bbb001c1a81c20 deleted file mode 100644 index 7da64b30..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/df/f0ed6f8589b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,29 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} - div.less-details{ display: block;} - -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} - div.less-details{ display: none;} -} - - -@media screen and (min-width: 1024px) { - /* large screen */ - - div.less-details{ display: none;} - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e/60441aee22b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/e/60441aee22b4001d1216d7fff398b3d6 deleted file mode 100644 index f5a2b676..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e/60441aee22b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,83 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - - public String getFullname() { - - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/00b75c4a27b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/00b75c4a27b3001d1e75aa5ef0815903 deleted file mode 100644 index f7921cc0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/00b75c4a27b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,46 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - @Query("SELECT u FROM User u WHERE u.firstName OR u.lastName LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/40cb9cc822b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/40cb9cc822b4001d1216d7fff398b3d6 deleted file mode 100644 index d137072f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/40cb9cc822b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,78 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/807ac24248b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/807ac24248b4001d1d079a924effdc9e deleted file mode 100644 index 2916b7a5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/807ac24248b4001d1d079a924effdc9e +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- - -
-

you have been logged out

-
- -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/d06f43cf8cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/d06f43cf8cb3001d19bbb001c1a81c20 deleted file mode 100644 index 098e7e9b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/d06f43cf8cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,260 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e2/50718c6c30b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/e2/50718c6c30b7001d19ef99be8d31e273 deleted file mode 100644 index 424960dc..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e2/50718c6c30b7001d19ef99be8d31e273 +++ /dev/null @@ -1,52 +0,0 @@ -package com.shopme.admin.category; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Category; - -/* - * Unit Test for CategoryRepository - * - * objective: - * 1. test the methods in repository - * 2. populate the database with records - * -*/ - -@DataJpaTest -@AutoConfigureTestDatabase(replace = Replace.NONE) -@Rollback(false) -public class CategoryRepositoryTests { - - @Autowired - private CategoryRepository repo; - - @Test - public void testCreateRootCategory() { -// Category category = new Category("Computers"); - Category category = new Category("Electronics"); - Category savedCategory = repo.save(category); - - assertThat(savedCategory.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateSubCategory() { - - // ID for root category "Computer" is 1 - Category parent = new Category(1); - - - - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e2/80ee15b446b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/e2/80ee15b446b4001d1d079a924effdc9e deleted file mode 100644 index fcdadd3d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e2/80ee15b446b4001d1d079a924effdc9e +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
- - -
- -
-

Shopme Control Panel

-
- - -
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/70c888e529b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/e3/70c888e529b8001d1d97982e354adf88 deleted file mode 100644 index 618cc9ba..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/70c888e529b8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category()); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/80e252f114b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/e3/80e252f114b4001d128fb79045552177 deleted file mode 100644 index 06f1b45a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e3/80e252f114b4001d128fb79045552177 +++ /dev/null @@ -1,15 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -public class ShopmeUserDetailsService implements UserDetailsService { - - @Override - public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/0070c4df4db3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/e4/0070c4df4db3001d1e75aa5ef0815903 deleted file mode 100644 index 73028453..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/0070c4df4db3001d1e75aa5ef0815903 +++ /dev/null @@ -1,34 +0,0 @@ - - - - -Insert title here - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/3097e08a7ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/e4/3097e08a7ab3001d19bbb001c1a81c20 deleted file mode 100644 index 34cbe8f4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/3097e08a7ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,25 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import jakarta.servlet.http.HttpServletResponse; - -public class AbstractExporter { - - public void setResponseHeader(HttpServletResponse response, String contentType, - String extension, String prefix) throws IOException { - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timestamp = dateFormatter.format(new Date()); - String fileName = prefix + timestamp + extension; - - response.setContentType(contentType); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e5/202235c515b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/e5/202235c515b4001d128fb79045552177 deleted file mode 100644 index 3f86f8f9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e5/202235c515b4001d128fb79045552177 +++ /dev/null @@ -1,30 +0,0 @@ -package com.shopme.admin.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; - -import com.shopme.admin.user.UserRepository; -import com.shopme.common.entity.User; - -public class ShopmeUserDetailsService implements UserDetailsService { - - - @Autowired - private UserRepository userRepo; - - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - - User user = userRepo.getUserByEmail(email); - - if( user != null) { - return new ShopmeUserDetails(user); - } - - return null; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e5/70248e9346b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/e5/70248e9346b4001d1d079a924effdc9e deleted file mode 100644 index f2f1df2e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e5/70248e9346b4001d1d079a924effdc9e +++ /dev/null @@ -1,3 +0,0 @@ -/** - * - */ \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e5/904253ae32b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/e5/904253ae32b4001d1d079a924effdc9e deleted file mode 100644 index 2e5c843c..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e5/904253ae32b4001d1d079a924effdc9e +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
- - -
-

[[${session.SPRING_SECURITY_LAST_EXCEPTION.message}]]

-
- -
-

you have been logged out

-
- - -
-

Access to Shopme Control Panel

- -

- -

- -

- -

- -

- -

-
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e6/e04f667f23b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/e6/e04f667f23b4001d1216d7fff398b3d6 deleted file mode 100644 index 5d8efaad..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e6/e04f667f23b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/10eb047e58b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/e7/10eb047e58b7001d19ef99be8d31e273 deleted file mode 100644 index a936067f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/10eb047e58b7001d19ef99be8d31e273 +++ /dev/null @@ -1,19 +0,0 @@ -package com.shopme.admin.category; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/80b1ab606fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/e7/80b1ab606fb3001d19bbb001c1a81c20 deleted file mode 100644 index 6903d834..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/80b1ab606fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,35 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) throws IOException { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/f0faa33e2fb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/e7/f0faa33e2fb4001d1d079a924effdc9e deleted file mode 100644 index e59de66a..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/f0faa33e2fb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e8/b01b4c432eb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/e8/b01b4c432eb4001d1d079a924effdc9e deleted file mode 100644 index 4fc4af2b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e8/b01b4c432eb4001d1d079a924effdc9e +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/405628396fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/405628396fb3001d19bbb001c1a81c20 deleted file mode 100644 index 26788f6e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/405628396fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,30 +0,0 @@ -package com.shopme.admin.user; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter { - - public void export(List user, HttpServletResponse response) { - - DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - String timeStamp = dateFormatter.format(new Date()); - String fileName = "users_" + timeStamp + ".csv"; - - response.setContentType("text/csv"); - - String headerKey = "Content-Disposition"; - String headerValue = "attachment; filename=" + fileName; - response.setHeader(headerKey, headerValue); - - - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/9077d2f64fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/9077d2f64fb3001d1e75aa5ef0815903 deleted file mode 100644 index 18c1a1fd..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/9077d2f64fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,170 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/a0fd2c5579b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/a0fd2c5579b3001d19bbb001c1a81c20 deleted file mode 100644 index 16222dac..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/a0fd2c5579b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,37 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.supercsv.io.CsvBeanWriter; -import org.supercsv.io.ICsvBeanWriter; -import org.supercsv.prefs.CsvPreference; - -import com.shopme.common.entity.User; - -import jakarta.servlet.http.HttpServletResponse; - -public class UserCsvExporter extends AbstractExporter { - - public void export(List listUsers, HttpServletResponse response) throws IOException { - - super.setResponseHeader(response, ".csv" , "text/csv"); - - ICsvBeanWriter csvWriter = new CsvBeanWriter(response.getWriter(), CsvPreference.STANDARD_PREFERENCE); - - String[] csvHeader = {"User ID", "E-mail", "First Name", "Last Name", "Roles", "Enabled"}; - String[] fieldMapping = {"id", "email", "firstName", "lastName", "roles", "enabled"}; - - csvWriter.writeHeader(csvHeader); - - for (User user : listUsers) { - csvWriter.write(user, fieldMapping); - } - - csvWriter.close(); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/c02c4d5f8cb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/e9/c02c4d5f8cb3001d19bbb001c1a81c20 deleted file mode 100644 index d1668cb6..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e9/c02c4d5f8cb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
-
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/30b639fd8ab3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/30b639fd8ab3001d19bbb001c1a81c20 deleted file mode 100644 index a767d4d3..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/30b639fd8ab3001d19bbb001c1a81c20 +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/60ec048909b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/60ec048909b4001d128fb79045552177 deleted file mode 100644 index 73a9cbc2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/60ec048909b4001d128fb79045552177 +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - Login - Shopme Admin - - - - -
- -
- -
- -
-

Shopme Control Panel - Copyright © Shopme

-
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/90ac8fe513b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/90ac8fe513b4001d128fb79045552177 deleted file mode 100644 index 821edba9..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/90ac8fe513b4001d128fb79045552177 +++ /dev/null @@ -1,77 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/b0a69c3d77b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/b0a69c3d77b3001d19bbb001c1a81c20 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/10ae64c54bb4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/10ae64c54bb4001d1d079a924effdc9e deleted file mode 100644 index c46239ed..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/10ae64c54bb4001d1d079a924effdc9e +++ /dev/null @@ -1,88 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - - /* This bean will be called by spring security when performing authentication*/ - @Bean - public UserDetailsService userDetailsService() { - return new ShopmeUserDetailsService(); - } - - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } - - - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - - authProvider.setUserDetailsService(userDetailsService()); - authProvider.setPasswordEncoder(passwordEncoder()); - - return authProvider; - } - - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .usernameParameter("email") - .permitAll() - .and().logout().permitAll() - .and().rememberMe().key("AbcDefgHijKlmnOpqrs_1234567890") - .tokenValiditySeconds(7 * 24 * 60 * 60); // cookie is valid for one week - - /* - * set a fix key used for the md5 hash algorithm to encrypt cookie content each - * time the application is restarted, a new key will be generated; this key will - * be used to encrypt the cookie content so, in order for the cookie to be - * permanent; a fix key is needed. - */ - - http.authenticationProvider(authenticationProvider()); - - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/90c1dee550b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/ec/90c1dee550b3001d1e75aa5ef0815903 deleted file mode 100644 index b273ec64..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/90c1dee550b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,176 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - - return getRedirectURLtoAffectedUser(user); - } - - private String getRedirectURLtoAffectedUser(User user) { - String firstPartOfEmail = user.getEmail().split("@")[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword=" + firstPartOfEmail; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/90c634d727b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/ec/90c634d727b3001d1e75aa5ef0815903 deleted file mode 100644 index e73086f5..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/90c634d727b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,135 +0,0 @@ -package com.shopme.admin.user; - -import java.util.List; -import java.util.NoSuchElementException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.transaction.Transactional; - -@Service -@Transactional -public class UserService { - - public static final int USERS_PER_PAGE = 4; - - @Autowired - private UserRepository userRepo; - - @Autowired - private RoleRepository roleRepo; - - @Autowired - private PasswordEncoder passwordEncoder; - - public List listAll() { - - return (List) userRepo.findAll(); - } - - - public Page listByPage(int pageNum, String sortField, String sortDir, String keyword) { - - Sort sort = Sort.by(sortField); - - sort = sortDir.equals("asc") ? sort.ascending() : sort.descending(); - - //page number start with 0 for pageable, so need to minus 1. - Pageable pageable = PageRequest.of(pageNum - 1, USERS_PER_PAGE, sort); - - return userRepo.findAll(pageable); - } - - - public List listRoles() { - - return (List) roleRepo.findAll(); - } - - public User save(User user) { - - boolean isUpdatingUser = (user.getId() != null); - - if (isUpdatingUser) { - - User existingUser = userRepo.findById(user.getId()).get(); - - if (user.getPassword().isEmpty()) { - /* - * if we do not set the user password to existing user password, password field - * will be an empty string. When the user object is saved to database, the empty - * string will replace the encoded password. - */ - user.setPassword(existingUser.getPassword()); - } else { - encodePassword(user); - } - - } else { - encodePassword(user); - } - - return userRepo.save(user); - } - - private void encodePassword(User user) { - - String encodedPassword = passwordEncoder.encode(user.getPassword()); - user.setPassword(encodedPassword); - } - - public boolean isEmailUnique(Integer id, String email) { - User userByEmail = userRepo.getUserByEmail(email); - - if (userByEmail == null) - return true; - - boolean isCreatingNew = (id == null); - - if (isCreatingNew) { - if (userByEmail != null) - return false; - } else { - if (userByEmail.getId() != id) { - return false; - } - } - - return true; - } - - public User get(Integer id) throws UserNotFoundException { - try { - return userRepo.findById(id).get(); - } catch (NoSuchElementException ex) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - } - - public void delete(Integer id) throws UserNotFoundException { - - Long countById = userRepo.countById(id); - - if (countById == null || countById == 0) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - - userRepo.deleteById(id); - } - - public void updateUserEnabledStatus(Integer id, boolean enabled) { - - userRepo.updateEnabledStatus(id, enabled); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/e0885ba629b8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/ec/e0885ba629b8001d1d97982e354adf88 deleted file mode 100644 index f48db5e4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ec/e0885ba629b8001d1d97982e354adf88 +++ /dev/null @@ -1,65 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - System.out.println(category.getName()); - - category.getChildren().forEach(subCategory -> { - - System.out.println("--" + subCategory.getName()); - printChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/20e1d36f30b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ed/20e1d36f30b4001d1d079a924effdc9e deleted file mode 100644 index 9a9ce2fe..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/20e1d36f30b4001d1d079a924effdc9e +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
-
- -
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/702b1e3144b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ed/702b1e3144b4001d1d079a924effdc9e deleted file mode 100644 index c9ef4bdf..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/702b1e3144b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - [[${title}]] - - - - - - - - - - - - - - - - - - [[${columnLabel}]] - - - - - - - [[${label}]] - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/f0208a5d45b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ed/f0208a5d45b4001d1d079a924effdc9e deleted file mode 100644 index 0bedde0d..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ed/f0208a5d45b4001d1d079a924effdc9e +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - -
- - - -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/a06dadaf2db4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/a06dadaf2db4001d1d079a924effdc9e deleted file mode 100644 index 18d0dc5b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/a06dadaf2db4001d1d079a924effdc9e +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - Home - Shopme Admin - - - - - - - - - - -
-
- -
- -
-

Shopme Control Panel

-
- -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/d0b0ce3c52b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/d0b0ce3c52b4001d1d079a924effdc9e deleted file mode 100644 index b956e340..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/d0b0ce3c52b4001d1d079a924effdc9e +++ /dev/null @@ -1,80 +0,0 @@ - - - - - -
- - -
- -
- -
- - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/f09a572513b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/ef/f09a572513b4001d128fb79045552177 deleted file mode 100644 index 751d0516..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ef/f09a572513b4001d128fb79045552177 +++ /dev/null @@ -1,72 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.User; - - -/* - * Think of it as a wrapper class for Type User - * - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - return null; - } - - @Override - public String getPassword() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getUsername() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAccountNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f/b06ee8221eb4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/f/b06ee8221eb4001d1216d7fff398b3d6 deleted file mode 100644 index 405ed235..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f/b06ee8221eb4001d1216d7fff398b3d6 +++ /dev/null @@ -1,201 +0,0 @@ -package com.shopme.admin.user; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.hibernate.internal.build.AllowSysOut; -import org.hibernate.query.sqm.mutation.internal.TableKeyExpressionCollector; -import org.junit.jupiter.api.Test; -import org.springframework.aot.nativex.NativeConfigurationWriter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.test.annotation.Rollback; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@DataJpaTest(showSql = false) -//configure to run on real database(MySQL) instead of a test database -@AutoConfigureTestDatabase(replace = Replace.NONE) -/* - * Datajpatest will rollback the transaction after executing the test method - * everytime, so that the transaction will not be committed. if we want to - * commit the transaction(aka "save the record"), we can disable rollback by - * setting it to false. Now, all transactions will be committed - */ -@Rollback(false) -public class UserRepositoryTests { - - @Autowired - private UserRepository repo; - - @Autowired - private TestEntityManager entityManager; - - // On the very first execution of testCreateUser() method; hibernate will create - // the users table & users_roles table - @Test - public void testCreateUserWithOneRole() { - - Role roleAdmin = entityManager.find(Role.class, 1); - User userChow = new User("chow@gmail.com", "password", "chow", "seng fung"); - userChow.addRoles(roleAdmin); - User savedUser = repo.save(userChow); - assertThat(savedUser.getId()).isGreaterThan(0); - - } - - @Test - public void testCreateUserWithTwoRole() { - - User userRavi = new User("ravi@gmail.com", "ravipass", "ravi", "kumar"); - Role roleEditor = new Role(3); - Role roleAssistant = new Role(5); - - userRavi.addRoles(roleEditor); - userRavi.addRoles(roleAssistant); - - User savedUser = repo.save(userRavi); - assertThat(savedUser.getId()).isGreaterThan(0); - } - - @Test - public void testListAllUsers() { - Iterable listUsers = repo.findAll(); - - // use method reference instead of lambda expression here - listUsers.forEach(System.out::println); - - } - - @Test - public void testGetUserById() { - - User userChow = repo.findById(1).get(); - System.out.println(userChow); - // use method reference instead of lambda expression here - assertThat(userChow).isNotNull(); - } - - @Test - public void testUpdateUserDetails() { - - User userChow = repo.findById(1).get(); - userChow.setEnabled(true); - userChow.setEmail("chow22@gmail.com"); - - repo.save(userChow); - } - - @Test - public void testUpdateUserRoles() { - - User userRavi = repo.findById(4).get(); - Role roleEditor = new Role(3); - Role roleSalesperson= new Role(2); - - //change role from editor to salesperson - - /* take note of overriding/implementing the hashcode and equals method in roles - * class. need to override those two methods for remove() to work. - * The remove() method removes an element "e" such that Objects.equals(o, e), - * this will invoke the overwritten equals() method in Role Class. - * */ - userRavi.getRoles().remove(roleEditor); - userRavi.addRoles(roleSalesperson); - - repo.save(userRavi); - } - - @Test - public void testDeleteUser() { - - Integer userId = 4; - repo.deleteById(userId); - } - - - @Test - public void testGetUserByEmail() { - String email = "ravi@gmail.com"; - User user = repo.getUserByEmail(email); - - assertThat(user).isNotNull(); - } - - /* - * count the number of records in database with a particular id. - * return value should be 1, - * because id is unique. - * - * use countById() method to test whether a user exists. - */ - @Test - public void testCountById() { - - Integer userId = 1; - Long countById = repo.countById(userId); - - assertThat(countById).isNotNull().isGreaterThan(0).isEqualTo(1); - } - - @Test - public void testDisableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, false); - } - - @Test - public void testEnableUser() { - Integer userId = 1; - - repo.updateEnabledStatus(userId, true); - } - - @Test - public void testListFirstPage() { - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isEqualTo(pageSize); - } - - - @Test - public void testSearchUsers() { - - String keyword = "bruce"; - - - int pageNumber = 0; // the first page number always start with 0, change pageNumber to 1 to get the second page, 2 for thid page and so forth - int pageSize = 4; // no of elements - - Pageable pageable = PageRequest.of(pageNumber, pageSize); - Page page = repo.findAll(keyword, pageable); - - List listUsers = page.getContent(); - - listUsers.forEach(System.out::println); - - assertThat(listUsers.size()).isGreaterThan(0); - - } - - -} - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f/d06a80f74fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/f/d06a80f74fb3001d1e75aa5ef0815903 deleted file mode 100644 index 51e08620..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f/d06a80f74fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,172 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - //get first part of email - String firstPartOfEmail = user.getEmail().split('@')[0] - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword="; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/00008b1c23b4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/00008b1c23b4001d1216d7fff398b3d6 deleted file mode 100644 index f5d8e598..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/00008b1c23b4001d1216d7fff398b3d6 +++ /dev/null @@ -1,86 +0,0 @@ -package com.shopme.admin.security; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -/* - * Think of it as a wrapper class for Type User - * - * ShopmeUserDetailsService will use this dao class - * - * this is for spring security - * */ -public class ShopmeUserDetails implements UserDetails { - - private User user; - - public ShopmeUserDetails(User user) { - this.user = user; - } - - /* get a list of assigned roles to user */ - @Override - public Collection getAuthorities() { - - Set roles = user.getRoles(); - - List authorities = new ArrayList<>(); - - for (Role role : roles) { - authorities.add(new SimpleGrantedAuthority(role.getName())); - } - - return authorities; - } - - @Override - public String getPassword() { - return user.getPassword(); - } - - @Override - public String getUsername() { - return user.getEmail(); - } - - // "true" means account not expired - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean isEnabled() { - // TODO Auto-generated method stub - return user.isEnabled(); - } - - public String getFullname() { - - return this.user.getFirstName() + " " + this.user.getLastName(); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/b09f042d40b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/b09f042d40b3001d1e75aa5ef0815903 deleted file mode 100644 index 7f2245b4..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/b09f042d40b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,54 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh". - * - * Instead we should concatenate the fields separated by space as the query below - */ - @Query("SELECT u FROM User u WHERE CONCAT(u.id, ' ', u.email, ' ', u.firstName, ' ', u.lastName) LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/c0855db0f9b8001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/c0855db0f9b8001d11addcb4256c67f9 new file mode 100644 index 00000000..c7fff7fd --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/c0855db0f9b8001d11addcb4256c67f9 @@ -0,0 +1,44 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the resources are not locoated in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/d049481d55b4001d1d079a924effdc9e b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/d049481d55b4001d1d079a924effdc9e deleted file mode 100644 index e572aaae..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/d049481d55b4001d1d079a924effdc9e +++ /dev/null @@ -1,140 +0,0 @@ -package com.shopme.admin.user; - -import java.util.List; -import java.util.NoSuchElementException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.transaction.Transactional; - -@Service -@Transactional -public class UserService { - - public static final int USERS_PER_PAGE = 4; - - @Autowired - private UserRepository userRepo; - - @Autowired - private RoleRepository roleRepo; - - @Autowired - private PasswordEncoder passwordEncoder; - - public List listAll() { - - return (List) userRepo.findAll(Sort.by("firstName").ascending()); - } - - - public Page listByPage(int pageNum, String sortField, String sortDir, String keyword) { - - Sort sort = Sort.by(sortField); - - sort = sortDir.equals("asc") ? sort.ascending() : sort.descending(); - - //page number start with 0 for pageable, so need to minus 1. - Pageable pageable = PageRequest.of(pageNum - 1, USERS_PER_PAGE, sort); - - //keyword for filtering users - if(keyword != null) { - return userRepo.findAll(keyword, pageable); - } - - return userRepo.findAll(pageable); - } - - - public List listRoles() { - - return (List) roleRepo.findAll(); - } - - public User save(User user) { - - boolean isUpdatingUser = (user.getId() != null); - - if (isUpdatingUser) { - - User existingUser = userRepo.findById(user.getId()).get(); - - if (user.getPassword().isEmpty()) { - /* - * if we do not set the user password to existing user password, password field - * will be an empty string. When the user object is saved to database, the empty - * string will replace the encoded password. - */ - user.setPassword(existingUser.getPassword()); - } else { - encodePassword(user); - } - - } else { - encodePassword(user); - } - - return userRepo.save(user); - } - - private void encodePassword(User user) { - - String encodedPassword = passwordEncoder.encode(user.getPassword()); - user.setPassword(encodedPassword); - } - - public boolean isEmailUnique(Integer id, String email) { - User userByEmail = userRepo.getUserByEmail(email); - - if (userByEmail == null) - return true; - - boolean isCreatingNew = (id == null); - - if (isCreatingNew) { - if (userByEmail != null) - return false; - } else { - if (userByEmail.getId() != id) { - return false; - } - } - - return true; - } - - public User get(Integer id) throws UserNotFoundException { - try { - return userRepo.findById(id).get(); - } catch (NoSuchElementException ex) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - } - - public void delete(Integer id) throws UserNotFoundException { - - Long countById = userRepo.countById(id); - - if (countById == null || countById == 0) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - - userRepo.deleteById(id); - } - - public void updateUserEnabledStatus(Integer id, boolean enabled) { - - userRepo.updateEnabledStatus(id, enabled); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/7021e99d8fb3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/7021e99d8fb3001d19bbb001c1a81c20 deleted file mode 100644 index 1985e883..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/7021e99d8fb3001d19bbb001c1a81c20 +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - -Manage Users - - - - - - - - - - -
-
- -
- -
-

Manage Users

- - - -
- - - - -
- [[${message}]] -
- -
-
- - - - Filter:  - -    - -    - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - -
- Photos - - - Roles -
[[${user.id}]] - - - [[${user.email}]][[${user.firstName}]][[${user.lastName}]][[${user.roles}]] - - - - - -   - -
-
- - - -
- -
- -
- - - -
- -
-
[[${user.fullName}]]
-
[[${user.roles}]]
-
- - - - -   - -   - -
-
-
 
-
-
- - - -
- Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] -
- - -
- No users found -
- - -
- -
- - - - - - -
-

Shopme Control Panel - Copyright © Shopme

-
- - -
- - - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/908378240bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/908378240bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..f291266f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/908378240bb9001d11addcb4256c67f9 @@ -0,0 +1,57 @@ +package com.shopme.admin; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + + /* + * In short, we can tell Spring MVC to map a given URL (e.g. "/user-photos") + * to any directory (e.g. D:/ShopmeProject/ShopmeBackend/user-photos) + * and expose the resources (images, js, css...) in this directory to + * the web clients (browsers) - that's the primary purpose + * of using resource handlers in Spring MVC. + * + * Because the assets are not located in the src/main/resources/static folder + * */ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + + String dirName = "user-photos"; + + Path userPhotoDir = Paths.get(dirName); + + String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + + String categoryImagesDirName = "category-images"; + + Path categoryImagesDir = Paths.get(categoryImagesDirName); + + String categoryImagesPath = categoryImagesDir.toFile().getAbsolutePath(); + + + // add /** to allow all files under this directory to be available to client + + registry.addResourceHandler("/" + dirName + "/**") + .addResourceLocations("file:/" + userPhotosPath + "/"); + + } + + + + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/a0f4b03622b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/a0f4b03622b3001d1e75aa5ef0815903 deleted file mode 100644 index 8f1839e2..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/a0f4b03622b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - - public Page findAll(String keyword, Pageable pageable); - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/f0dcbe471fb4001d1216d7fff398b3d6 b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/f0dcbe471fb4001d1216d7fff398b3d6 deleted file mode 100644 index afedf5ac..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/f0dcbe471fb4001d1216d7fff398b3d6 +++ /dev/null @@ -1,76 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.2 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - ShopmeWebParent - pom - parent spring web project - - 15 - - - ShopmeBackEnd - ShopmeFrontEnd - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.thymeleaf.extras - thymeleaf-extras-springsecurity5 - - - mysql - mysql-connector-java - runtime - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - test - - - org.webjars - bootstrap - 4.3.1 - - - org.webjars - jquery - 3.4.1 - - - - org.webjars - webjars-locator-core - - - com.shopme - ShopmeCommon - 0.0.1-SNAPSHOT - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/005325560bb4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/005325560bb4001d128fb79045552177 deleted file mode 100644 index 2c9a38b0..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/005325560bb4001d128fb79045552177 +++ /dev/null @@ -1,47 +0,0 @@ -package com.shopme.admin.security; - -import org.aspectj.weaver.ast.And; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig { - - /* - * refer to this link: https://www.codejava.net/frameworks/spring-boot/fix- - * websecurityconfigureradapter-deprecated - * - */ - - @Bean - public PasswordEncoder PasswordEncoder() { - return new BCryptPasswordEncoder(); - } - - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - - // any request need to be authenticated (require login) - // custom login page at "/login" - handler method in MainController class - http.authorizeHttpRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll(); - - return http.build(); - } - - //NOTE: antMatchers() changed to requestMatchers() - //stack: https://stackoverflow.com/questions/74907533/the-method-antmatchersstring-is-undefined-for-the-type - @Bean - public WebSecurityCustomizer webSecurityCustomizer() { - //permit access to the assets in the following directories - return (web) -> web.ignoring().requestMatchers("/images/**", "/js/**", "/webjars/**"); - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/10c1b4964fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/f6/10c1b4964fb3001d1e75aa5ef0815903 deleted file mode 100644 index bfd1578f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f6/10c1b4964fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,169 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //email is unique field - - return "redirect:/users"; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f7/a069a6d41eb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/f7/a069a6d41eb3001d1e75aa5ef0815903 deleted file mode 100644 index 8dee822e..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f7/a069a6d41eb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,43 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.stereotype.Repository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - - - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f7/b0482e6205b4001d128fb79045552177 b/.metadata/.plugins/org.eclipse.core.resources/.history/f7/b0482e6205b4001d128fb79045552177 deleted file mode 100644 index 805b6244..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f7/b0482e6205b4001d128fb79045552177 +++ /dev/null @@ -1,22 +0,0 @@ -package com.shopme.admin; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class MainController { - - @GetMapping("") - public String viewHomePage() { - return "index"; - } - - - @GetMapping("/login") - public String viewHomePage() { - return "login"; - } - - - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f7/f002f60395b6001d1567bacd2f52a0b7 b/.metadata/.plugins/org.eclipse.core.resources/.history/f7/f002f60395b6001d1567bacd2f52a0b7 deleted file mode 100644 index e69de29b..00000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f8/702e38b788b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/f8/702e38b788b3001d19bbb001c1a81c20 deleted file mode 100644 index b58c9d5b..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f8/702e38b788b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,24 +0,0 @@ -*.icon-white{color: white} -*.icon-silver{color: silver} -*.icon-green{color: green} -*.icon-dark{color: gray} -*.icon-red{color: red} - - -@media screen and (max-width: 768px) { - /* small screen */ - - div.full-details{ display: none;} -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - /* medium screen */ - - div.full-details{ display: block;} -} - - -@media screen and (mini-width: 1024px) { - /* large screen */ - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/206591a677b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/fb/206591a677b3001d19bbb001c1a81c20 deleted file mode 100644 index cddcf6c1..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/206591a677b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,5 +0,0 @@ -package com.shopme.admin.user; - -public class UserExcelExporter { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/5005f1a93fb3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/fb/5005f1a93fb3001d1e75aa5ef0815903 deleted file mode 100644 index 396906ae..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fb/5005f1a93fb3001d1e75aa5ef0815903 +++ /dev/null @@ -1,55 +0,0 @@ -package com.shopme.admin.user; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import com.shopme.common.entity.User; - -@Repository -public interface UserRepository extends CrudRepository, PagingAndSortingRepository { - - /* - * JPQL statement. It should be noted that as compared to native SQL, JPQL does - * not interact with database tables, records, and fields - but with Java - * classes and instances. - * - * JPA kicks in as the mediator and transpiles JPQL queries to SQL queries for execution. - * - * If your database can change or varies from development to production, as long as - * they're both relational - JPQL works wonders and you can - * write JPQL queries to create generic logic that can be used over and over again. - */ - @Query("SELECT u FROM User u WHERE u.email = :email") - public User getUserByEmail(@Param("email") String email); - - // countById() declaration follows the JPA specification - //to check the existence of a user - public Long countById(Integer id); - - - //for filtering users by keyword - /* - * @Query("SELECT u FROM User u WHERE u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - * + " OR u.email LIKE %?1%") - * - * the above query does not work when we search for user with keyword "nam ha minh". - * - * Instead we should concatenate the fields separated by space as the query below - */ - @Query("SELECT u FROM User u WHERE CONCAT(u.id, ' ', u.firstName LIKE %?1% OR u.lastName LIKE %?1%" - + " u.email) LIKE %?1%") - public Page findAll(String keyword, Pageable pageable); - - - //change user enabled status - //need @Modifying annotation for update/delete operation - @Query("UPDATE User u SET u.enabled = ?2 WHERE u.id = ?1") - @Modifying - public void updateEnabledStatus(Integer id, boolean enabled); -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fc/60f4622f59b7001d19ef99be8d31e273 b/.metadata/.plugins/org.eclipse.core.resources/.history/fc/60f4622f59b7001d19ef99be8d31e273 deleted file mode 100644 index a6042913..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fc/60f4622f59b7001d19ef99be8d31e273 +++ /dev/null @@ -1,21 +0,0 @@ -package com.shopme.admin.category; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class CategoryController { - - @Autowired - private CategoryService service; - - @GetMapping("/categories") - public String listAll(Model model) { - - - - return "categories/categories"; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fd/60b12c109ab9001d10d0f9513979f945 b/.metadata/.plugins/org.eclipse.core.resources/.history/fd/60b12c109ab9001d10d0f9513979f945 new file mode 100644 index 00000000..5683c984 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/fd/60b12c109ab9001d10d0f9513979f945 @@ -0,0 +1,79 @@ +package com.shopme.admin.category; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.support.SimpleTriggerContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.shopme.admin.FileUploadUtil; +import com.shopme.common.entity.Category; + +@Controller +public class CategoryController { + + @Autowired + private CategoryService service; + + @GetMapping("/categories") + public String listAll(Model model) { + + List listCategories = service.listAll(); + model.addAttribute("listCategories", listCategories); + + return "categories/categories"; + } + + + @GetMapping("/categories/new") + public String newCategory(Model model) { + + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", new Category()); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Create New Category"); + + return "categories/category_form"; + + } + + @PostMapping("/categories/save") + public String saveCategory(@ModelAttribute("category") Category category, + RedirectAttributes redirectAttributes, + @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { + + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + + + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); + + + return "redirect:/categories"; + } + + + @GetMapping("/categories/edit/{id}") + public String editCategory(@Pa) + + + +} + + + + diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/fd/a0484b0150b3001d1e75aa5ef0815903 b/.metadata/.plugins/org.eclipse.core.resources/.history/fd/a0484b0150b3001d1e75aa5ef0815903 deleted file mode 100644 index 98f70453..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/fd/a0484b0150b3001d1e75aa5ef0815903 +++ /dev/null @@ -1,172 +0,0 @@ -package com.shopme.admin.user; - -import java.io.IOException; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.support.RedirectAttributes; - -import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator; -import com.shopme.admin.FileUploadUtil; -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -@Controller -public class UserController { - - @Autowired - private UserService service; - - @GetMapping("/users") - public String listFirstPage(Model model) { - return listByPage(1, model, "firstName", "asc", null); - } - - @GetMapping("/users/page/{pageNum}") - public String listByPage(@PathVariable(name = "pageNum") int pageNum, Model model, - @Param("sortField") String sortField, @Param("sortDir") String sortDir, - @Param("keyword") String keyword) { - - System.out.println("sort field: " + sortField); - System.out.println("sort order: " + sortDir); - - Page page = service.listByPage(pageNum, sortField, sortDir, keyword); - List listUsers = page.getContent(); - - - long startCount = (pageNum - 1) * UserService.USERS_PER_PAGE + 1; - long endCount = startCount + UserService.USERS_PER_PAGE - 1; - if(endCount > page.getTotalElements()) { - endCount = page.getTotalElements(); - } - - String reverseSortDir = sortDir.equals("asc") ? "desc" : "asc"; - - model.addAttribute("currentPage", pageNum); - model.addAttribute("totalPages", page.getTotalPages()); - model.addAttribute("startCount", startCount); - model.addAttribute("endCount", endCount); - model.addAttribute("totalItems", page.getTotalElements()); - model.addAttribute("listUsers", listUsers); - model.addAttribute("sortField", sortField); - model.addAttribute("sortDir", sortDir); - model.addAttribute("reverseSortDir", reverseSortDir); - model.addAttribute("keyword", keyword); - - - return "users"; - - } - - @GetMapping("/users/new") - public String newUser(Model model) { - - List listRoles = service.listRoles(); - - User user = new User(); - user.setEnabled(true); - - model.addAttribute("user", user); - model.addAttribute("listRoles", listRoles); - model.addAttribute("pageTitle", "Create New User"); - - return "user_form"; - - } - - // using @RequestParam, we can get the image file input, the input has the - // property name="image" - @PostMapping("/users/save") - public String saveUser(@ModelAttribute("user") User user, RedirectAttributes redirectAttributes, - @RequestParam("image") MultipartFile multipartFile) throws IOException { - - if (!multipartFile.isEmpty()) { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - user.setPhotos(fileName); - - User savedUser = service.save(user); - - String uploadDir = "user-photos/" + savedUser.getId(); - - FileUploadUtil.cleanDir(uploadDir); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - } else { - - // set photo to null for getPhotosImagePath() method's conditional statement in - // User class - if (user.getPhotos().isEmpty()) - user.setPhotos(null); - service.save(user); - } - - redirectAttributes.addFlashAttribute("message", "the user has been saved successfully"); - - // POST/REDIRECT/GET web design - - //after user is saved display the user instead of the entire user list - //email is a unique field to identify each user. - - //get first part of email - String firstPartOfEmail = user.getEmail().split('@')[0]; - return "redirect:/users/page/1?sortField=id&sortDir=asc&keyword="; - } - - @GetMapping("/users/edit/{id}") - public String editUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, Model model) { - try { - User user = service.get(id); - List listRoles = service.listRoles(); - - model.addAttribute("user", user); - model.addAttribute("pageTitle", "Edit User (ID: " + id + ")"); - model.addAttribute("listRoles", listRoles); - - return "user_form"; - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - return "redirect:/users"; - } - - } - - @GetMapping("/users/delete/{id}") - public String deleteUser(@PathVariable(name = "id") Integer id, RedirectAttributes redirectAttributes, - Model model) { - try { - service.delete(id); - redirectAttributes.addFlashAttribute("message", "The user ID " + id + " has been deleted successfully."); - - } catch (UserNotFoundException ex) { - redirectAttributes.addFlashAttribute("message", ex.getMessage()); - - } - - return "redirect:/users"; - } - - @GetMapping("/users/{id}/enabled/{status}") - public String updateUserEnabledStatus(@PathVariable(name = "id") Integer id, - @PathVariable(name = "status") boolean enabled, RedirectAttributes redirectAttributes) { - - service.updateUserEnabledStatus(id, enabled); - String status = enabled ? "enabled" : "disabled"; - String message = "The user id " + id + " has been " + status; - redirectAttributes.addFlashAttribute("message", message); - - return "redirect:/users"; - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/60fd0a2f2ab8001d1d97982e354adf88 b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/60fd0a2f2ab8001d1d97982e354adf88 deleted file mode 100644 index c9573d0f..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/60fd0a2f2ab8001d1d97982e354adf88 +++ /dev/null @@ -1,66 +0,0 @@ -package com.shopme.admin.category; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Category; - -@Service -public class CategoryService { - - @Autowired - private CategoryRepository repo; - - public List listAll(){ - return (List) repo.findAll(); - } - - public List listCategoriesUsedInForm(){ - - List categoriesUsedInForm = new ArrayList<>(); - - Iterable categoriesInDB = repo.findAll(); - - for (Category category : categoriesInDB) { - - // root category - if (category.getParent() == null) { - categoriesUsedInForm.add(new Category(category.getName())); - - category.getChildren().forEach(subCategory -> { - String name = "--" + subCategory.getName(); - - System.out.println("--" + subCategory.getName()); - listChildren(subCategory, 1); - }); - } - - } - - - return categoriesUsedInForm; - } - - private void listChildren(Category parent, int subLevel) { - - int newSubLevel = subLevel + 1; - Set children = parent.getChildren(); - - for (Category subCategory : children) { - - for (int i = 0; i < newSubLevel; i++) { - System.out.print("--"); - } - - System.out.println(subCategory.getName()); - - printChildren(subCategory, newSubLevel); - } - - } - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/90534f2672b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/90534f2672b3001d19bbb001c1a81c20 deleted file mode 100644 index c02445e7..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/90534f2672b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,140 +0,0 @@ -package com.shopme.admin.user; - -import java.util.List; -import java.util.NoSuchElementException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import com.shopme.common.entity.Role; -import com.shopme.common.entity.User; - -import jakarta.transaction.Transactional; - -@Service -@Transactional -public class UserService { - - public static final int USERS_PER_PAGE = 4; - - @Autowired - private UserRepository userRepo; - - @Autowired - private RoleRepository roleRepo; - - @Autowired - private PasswordEncoder passwordEncoder; - - public List listAll() { - - return (List) userRepo.findAll(); - } - - - public Page listByPage(int pageNum, String sortField, String sortDir, String keyword) { - - Sort sort = Sort.by(sortField); - - sort = sortDir.equals("asc") ? sort.ascending() : sort.descending(); - - //page number start with 0 for pageable, so need to minus 1. - Pageable pageable = PageRequest.of(pageNum - 1, USERS_PER_PAGE, sort); - - //keyword for filtering users - if(keyword != null) { - return userRepo.findAll(keyword, pageable); - } - - return userRepo.findAll(pageable); - } - - - public List listRoles() { - - return (List) roleRepo.findAll(); - } - - public User save(User user) { - - boolean isUpdatingUser = (user.getId() != null); - - if (isUpdatingUser) { - - User existingUser = userRepo.findById(user.getId()).get(); - - if (user.getPassword().isEmpty()) { - /* - * if we do not set the user password to existing user password, password field - * will be an empty string. When the user object is saved to database, the empty - * string will replace the encoded password. - */ - user.setPassword(existingUser.getPassword()); - } else { - encodePassword(user); - } - - } else { - encodePassword(user); - } - - return userRepo.save(user); - } - - private void encodePassword(User user) { - - String encodedPassword = passwordEncoder.encode(user.getPassword()); - user.setPassword(encodedPassword); - } - - public boolean isEmailUnique(Integer id, String email) { - User userByEmail = userRepo.getUserByEmail(email); - - if (userByEmail == null) - return true; - - boolean isCreatingNew = (id == null); - - if (isCreatingNew) { - if (userByEmail != null) - return false; - } else { - if (userByEmail.getId() != id) { - return false; - } - } - - return true; - } - - public User get(Integer id) throws UserNotFoundException { - try { - return userRepo.findById(id).get(); - } catch (NoSuchElementException ex) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - } - - public void delete(Integer id) throws UserNotFoundException { - - Long countById = userRepo.countById(id); - - if (countById == null || countById == 0) { - throw new UserNotFoundException("could not find any user with id: " + id); - } - - userRepo.deleteById(id); - } - - public void updateUserEnabledStatus(Integer id, boolean enabled) { - - userRepo.updateEnabledStatus(id, enabled); - } - - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/b03e3cf80bb9001d11addcb4256c67f9 b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/b03e3cf80bb9001d11addcb4256c67f9 new file mode 100644 index 00000000..a6a3a54d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/b03e3cf80bb9001d11addcb4256c67f9 @@ -0,0 +1,204 @@ + + + + + + +
+ + +
+ +
+

Manage Categories

+ + + +
+ + +
+ [[${message}]] +
+ + +
+
+ + Filter:  + +    + +    + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
IDCategory ImageCategory NameAliasEnabled
[[${cat.id}]][[${cat.name}]][[${cat.alias}]] +
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ +
+
[[${user.fullName}]]
+
[[${user.roles}]]
+
+ + + + +   + +   + +
+
+
 
+
+
+ + + +
+ Showing Users # [[${startCount}]] to [[${endCount}]] of [[${totalItems}]] +
+ + +
+ No users found +
+ + +
+ +
+ + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f0fd38de61b3001d19bbb001c1a81c20 b/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f0fd38de61b3001d19bbb001c1a81c20 deleted file mode 100644 index f2202bba..00000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ff/f0fd38de61b3001d19bbb001c1a81c20 +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - - - com.shopme - ShopmeWebParent - 0.0.1-SNAPSHOT - - - ShopmeBackEnd - - ShopmeBackEnd - Shopme Admin project - - 15 - - - - - - - - - - - - org.springframework.boot - spring-boot-devtools - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.markers.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.syncinfo.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/cb/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/cb/history.index index bc01cb91..b1c39a65 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/cb/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/cb/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/fe/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/fe/history.index index 9f260361..a6fff6fe 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/fe/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/92/22/81/f2/4f/fe/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/40/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/40/history.index index 93f2ef77..07c95887 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/40/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/40/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/4c/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/4c/history.index deleted file mode 100644 index e70d604d..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/4c/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/9c/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/9c/history.index index 003d9f7c..c7df06b3 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/9c/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/9c/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/history.index index 833d8d98..5635e6ef 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/cb/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/fe/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/fe/history.index index 26fa6bed..0a3ef37b 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/fe/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/fe/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/history.index index 13755961..bcb7b3f1 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/22/81/f2/4f/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/1c/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/1c/history.index index c64886b5..2489cc35 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/1c/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/1c/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/8/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/8/history.index index 8d1db367..6dcde96d 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/8/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/8/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/history.index index 391c83d5..66040e68 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/39/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/49/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/49/history.index index 4fb870bd..e23986bd 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/49/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/49/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/history.index deleted file mode 100644 index 75e7e711..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/e4/b9/db/92/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/history.index deleted file mode 100644 index 7937a12b..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.indexes/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers index f1343ece..3842eae6 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers.snap deleted file mode 100644 index 61f6d940..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.syncinfo.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/org.eclipse.jdt.core/state.dat new file mode 100644 index 00000000..ff210426 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeBackEnd/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.indexes/e4/b9/22/81/f2/15/1d/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.indexes/e4/b9/22/81/f2/15/1d/history.index index 0b6a0bec..bb6636a8 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.indexes/e4/b9/22/81/f2/15/1d/history.index and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.indexes/e4/b9/22/81/f2/15/1d/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.markers.snap deleted file mode 100644 index 72e9d9b2..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.syncinfo.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/org.eclipse.jdt.core/state.dat new file mode 100644 index 00000000..2bcff084 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeCommon/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/.markers.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/.syncinfo.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/org.eclipse.jdt.core/state.dat new file mode 100644 index 00000000..49e90f59 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeFrontEnd/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeProject/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeProject/.markers.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeProject/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeProject/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeProject/.syncinfo.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeProject/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.indexes/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.indexes/history.index deleted file mode 100644 index df3029a8..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.indexes/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.markers.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.syncinfo.snap deleted file mode 100644 index ed1969ba..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/ShopmeWebParent/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap deleted file mode 100644 index 811c8b39..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/45.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/48.tree similarity index 54% rename from .metadata/.plugins/org.eclipse.core.resources/.root/45.tree rename to .metadata/.plugins/org.eclipse.core.resources/.root/48.tree index 81c5bc7f..46d69eda 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/45.tree and b/.metadata/.plugins/org.eclipse.core.resources/.root/48.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources index 6f84be33..9495f12c 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/45.snap b/.metadata/.plugins/org.eclipse.core.resources/45.snap deleted file mode 100644 index 7d530d30..00000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/45.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.genuitec.eclipse.theming.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.genuitec.eclipse.theming.ui.prefs index f855fd21..7fbc20d3 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.genuitec.eclipse.theming.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.genuitec.eclipse.theming.ui.prefs @@ -5,7 +5,7 @@ eclipse.preferences.version=1 iconcolormode=primary iconreplacement=true includeThemingInOomph=false -last.download.attempt.time=1677664103725 -lastConfiguration=1677723961542 +last.download.attempt.time=1677829935538 +lastConfiguration=1677829870684 newinstall=true workbench.theme=Dark Gray diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs index 87935f9b..3489e73d 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs @@ -1,15 +1,5 @@ Console.highWaterMark=88000 eclipse.preferences.version=1 -org.eclipse.debug.ui.Color=218,29,67 -org.eclipse.debug.ui.MemoryHistoryKnownColor=233,235,237 -org.eclipse.debug.ui.MemoryHistoryUnknownColor=168,177,184 -org.eclipse.debug.ui.PREF_CHANGED_VALUE_BACKGROUND=145,77,111 org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n -org.eclipse.debug.ui.changedDebugElement=255,128,128 -org.eclipse.debug.ui.consoleBackground=25,29,31 -org.eclipse.debug.ui.errorColor=204,223,50 -org.eclipse.debug.ui.inColor=216,216,216 -org.eclipse.debug.ui.outColor=216,216,216 -overriddenByCSS=,org.eclipse.debug.ui.Color,org.eclipse.debug.ui.MemoryHistoryKnownColor,org.eclipse.debug.ui.MemoryHistoryUnknownColor,org.eclipse.debug.ui.PREF_CHANGED_VALUE_BACKGROUND,org.eclipse.debug.ui.changedDebugElement,org.eclipse.debug.ui.consoleBackground,org.eclipse.debug.ui.errorColor,org.eclipse.debug.ui.inColor,org.eclipse.debug.ui.outColor, pref_state_memento.org.eclipse.debug.ui.DebugVieworg.eclipse.debug.ui.DebugView=\r\n preferredTargets=default,org.eclipse.lsp4e.debug.toggleBreakpointTarget\:default|org.eclipse.lsp4e.debug.toggleBreakpointTarget\:org.eclipse.lsp4e.debug.toggleBreakpointTarget| diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs index fd7ca134..cf4a63e4 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -1,160 +1,10 @@ content_assist_autoactivation_triggers_java=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._@ content_assist_category_order=org.eclipse.jdt.ui.templateProposalCategory\:0\u0000org.eclipse.jdt.ui.swtProposalCategory\:1\u0000org.eclipse.jdt.ui.javaNoTypeProposalCategory\:2\u0000org.eclipse.jdt.ui.javaChainProposalCategory\:3\u0000org.eclipse.jdt.ui.javaTypeProposalCategory\:4\u0000org.eclipse.jdt.ui.textProposalCategory\:5\u0000org.eclipse.jdt.ui.javaAllProposalCategory\:6\u0000org.eclipse.jdt.ui.javaPostfixProposalCategory\:65542\u0000org.eclipse.pde.api.tools.ui.apitools_proposal_category\:8\u0000org.eclipse.lsp4e.jdt.ls-based-java-completion-computer\:9\u0000 -content_assist_completion_replacement_background=200,200,0 -content_assist_completion_replacement_foreground=194,0,0 content_assist_disabled_computers=org.eclipse.jdt.ui.textProposalCategory\u0000org.eclipse.jdt.ui.javaPostfixProposalCategory\u0000org.eclipse.jdt.ui.javaNoTypeProposalCategory\u0000org.eclipse.jdt.ui.javaTypeProposalCategory\u0000org.eclipse.jdt.ui.javaChainProposalCategory\u0000 -content_assist_lru_history= +content_assist_lru_history= content_assist_number_of_computers=15 -content_assist_parameters_background=48,54,59 -content_assist_parameters_foreground=235,237,239 -content_assist_proposals_background=48,54,59 -content_assist_proposals_foreground=235,237,239 eclipse.preferences.version=1 -java_bracket=216,216,216 -java_comment_task_tag=204,223,50 -java_default=216,216,216 -java_doc_default=98,151,85 -java_doc_keyword=132,185,119 -java_doc_link=132,185,119 -java_doc_tag=132,185,119 -java_keyword=204,120,50 -java_keyword_bold=false -java_keyword_return=204,120,50 -java_keyword_return_bold=false -java_multi_line_comment=98,151,85 -java_operator=216,216,216 -java_single_line_comment=128,128,128 -java_string=165,194,92 -matchingBracketsColor=244,245,246 org.eclipse.jdt.ui.formatterprofiles.version=22 -overriddenByCSS=,content_assist_completion_replacement_background,content_assist_completion_replacement_foreground,content_assist_parameters_background,content_assist_parameters_foreground,content_assist_proposals_background,content_assist_proposals_foreground,java_bracket,java_comment_task_tag,java_default,java_doc_default,java_doc_keyword,java_doc_link,java_doc_tag,java_keyword,java_keyword_bold,java_keyword_return,java_keyword_return_bold,java_multi_line_comment,java_operator,java_single_line_comment,java_string,matchingBracketsColor,pf_coloring_argument,pf_coloring_assignment,pf_coloring_comment,pf_coloring_key,pf_coloring_value,semanticHighlighting.abstractClass.color,semanticHighlighting.abstractClass.enabled,semanticHighlighting.abstractMethodInvocation.bold,semanticHighlighting.abstractMethodInvocation.color,semanticHighlighting.abstractMethodInvocation.enabled,semanticHighlighting.abstractMethodInvocation.italic,semanticHighlighting.abstractMethodInvocation.strikethrough,semanticHighlighting.abstractMethodInvocation.underline,semanticHighlighting.annotation.bold,semanticHighlighting.annotation.color,semanticHighlighting.annotation.enabled,semanticHighlighting.annotation.italic,semanticHighlighting.annotation.strikethrough,semanticHighlighting.annotation.underline,semanticHighlighting.annotationElementReference.color,semanticHighlighting.annotationElementReference.enabled,semanticHighlighting.class.bold,semanticHighlighting.class.color,semanticHighlighting.class.enabled,semanticHighlighting.class.italic,semanticHighlighting.class.strikethrough,semanticHighlighting.class.underline,semanticHighlighting.deprecatedMember.bold,semanticHighlighting.deprecatedMember.color,semanticHighlighting.deprecatedMember.enabled,semanticHighlighting.deprecatedMember.italic,semanticHighlighting.deprecatedMember.strikethrough,semanticHighlighting.deprecatedMember.underline,semanticHighlighting.enum.bold,semanticHighlighting.enum.color,semanticHighlighting.enum.enabled,semanticHighlighting.enum.italic,semanticHighlighting.enum.strikethrough,semanticHighlighting.enum.underline,semanticHighlighting.field.bold,semanticHighlighting.field.color,semanticHighlighting.field.enabled,semanticHighlighting.field.italic,semanticHighlighting.field.strikethrough,semanticHighlighting.field.underline,semanticHighlighting.inheritedField.color,semanticHighlighting.inheritedMethodInvocation.bold,semanticHighlighting.inheritedMethodInvocation.color,semanticHighlighting.inheritedMethodInvocation.enabled,semanticHighlighting.inheritedMethodInvocation.italic,semanticHighlighting.inheritedMethodInvocation.strikethrough,semanticHighlighting.inheritedMethodInvocation.underline,semanticHighlighting.interface.bold,semanticHighlighting.interface.color,semanticHighlighting.interface.enabled,semanticHighlighting.interface.italic,semanticHighlighting.interface.strikethrough,semanticHighlighting.interface.underline,semanticHighlighting.localVariable.bold,semanticHighlighting.localVariable.color,semanticHighlighting.localVariable.enabled,semanticHighlighting.localVariable.italic,semanticHighlighting.localVariable.strikethrough,semanticHighlighting.localVariable.underline,semanticHighlighting.localVariableDeclaration.bold,semanticHighlighting.localVariableDeclaration.color,semanticHighlighting.localVariableDeclaration.enabled,semanticHighlighting.localVariableDeclaration.italic,semanticHighlighting.localVariableDeclaration.strikethrough,semanticHighlighting.localVariableDeclaration.underline,semanticHighlighting.method.bold,semanticHighlighting.method.color,semanticHighlighting.method.enabled,semanticHighlighting.method.italic,semanticHighlighting.method.strikethrough,semanticHighlighting.method.underline,semanticHighlighting.methodDeclarationName.bold,semanticHighlighting.methodDeclarationName.color,semanticHighlighting.methodDeclarationName.enabled,semanticHighlighting.methodDeclarationName.italic,semanticHighlighting.methodDeclarationName.strikethrough,semanticHighlighting.methodDeclarationName.underline,semanticHighlighting.number.bold,semanticHighlighting.number.color,semanticHighlighting.number.enabled,semanticHighlighting.number.italic,semanticHighlighting.number.strikethrough,semanticHighlighting.number.underline,semanticHighlighting.parameterVariable.bold,semanticHighlighting.parameterVariable.color,semanticHighlighting.parameterVariable.enabled,semanticHighlighting.parameterVariable.italic,semanticHighlighting.parameterVariable.strikethrough,semanticHighlighting.parameterVariable.underline,semanticHighlighting.restrictedKeywords.bold,semanticHighlighting.restrictedKeywords.color,semanticHighlighting.staticField.bold,semanticHighlighting.staticField.color,semanticHighlighting.staticField.enabled,semanticHighlighting.staticField.italic,semanticHighlighting.staticField.strikethrough,semanticHighlighting.staticField.underline,semanticHighlighting.staticFinalField.bold,semanticHighlighting.staticFinalField.color,semanticHighlighting.staticFinalField.enabled,semanticHighlighting.staticFinalField.italic,semanticHighlighting.staticFinalField.strikethrough,semanticHighlighting.staticFinalField.underline,semanticHighlighting.staticMethodInvocation.bold,semanticHighlighting.staticMethodInvocation.color,semanticHighlighting.staticMethodInvocation.enabled,semanticHighlighting.staticMethodInvocation.italic,semanticHighlighting.staticMethodInvocation.strikethrough,semanticHighlighting.staticMethodInvocation.underline,semanticHighlighting.typeArgument.bold,semanticHighlighting.typeArgument.color,semanticHighlighting.typeArgument.enabled,semanticHighlighting.typeArgument.italic,semanticHighlighting.typeArgument.strikethrough,semanticHighlighting.typeArgument.underline,semanticHighlighting.typeParameter.bold,semanticHighlighting.typeParameter.color,semanticHighlighting.typeParameter.enabled,semanticHighlighting.typeParameter.italic,semanticHighlighting.typeParameter.strikethrough,semanticHighlighting.typeParameter.underline,sourceHoverBackgroundColor, -pf_coloring_argument=204,120,50 -pf_coloring_assignment=216,216,216 -pf_coloring_comment=128,128,128 -pf_coloring_key=216,216,216 -pf_coloring_value=165,194,92 -semanticHighlighting.abstractClass.color=62,171,230 -semanticHighlighting.abstractClass.enabled=true -semanticHighlighting.abstractMethodInvocation.bold=false -semanticHighlighting.abstractMethodInvocation.color=190,214,255 -semanticHighlighting.abstractMethodInvocation.enabled=true -semanticHighlighting.abstractMethodInvocation.italic=false -semanticHighlighting.abstractMethodInvocation.strikethrough=false -semanticHighlighting.abstractMethodInvocation.underline=false -semanticHighlighting.annotation.bold=false -semanticHighlighting.annotation.color=187,181,41 -semanticHighlighting.annotation.enabled=true -semanticHighlighting.annotation.italic=false -semanticHighlighting.annotation.strikethrough=false -semanticHighlighting.annotation.underline=false -semanticHighlighting.annotationElementReference.color=235,75,100 -semanticHighlighting.annotationElementReference.enabled=true -semanticHighlighting.class.bold=false -semanticHighlighting.class.color=169,183,198 -semanticHighlighting.class.enabled=true -semanticHighlighting.class.italic=false -semanticHighlighting.class.strikethrough=false -semanticHighlighting.class.underline=false -semanticHighlighting.deprecatedMember.bold=false -semanticHighlighting.deprecatedMember.color=210,82,82 -semanticHighlighting.deprecatedMember.enabled=true -semanticHighlighting.deprecatedMember.italic=false -semanticHighlighting.deprecatedMember.strikethrough=true -semanticHighlighting.deprecatedMember.underline=false -semanticHighlighting.enum.bold=false -semanticHighlighting.enum.color=127,179,71 -semanticHighlighting.enum.enabled=true -semanticHighlighting.enum.italic=false -semanticHighlighting.enum.strikethrough=false -semanticHighlighting.enum.underline=false -semanticHighlighting.field.bold=false -semanticHighlighting.field.color=190,214,255 -semanticHighlighting.field.enabled=true -semanticHighlighting.field.italic=false -semanticHighlighting.field.strikethrough=false -semanticHighlighting.field.underline=false -semanticHighlighting.inheritedField.color=143,143,191 -semanticHighlighting.inheritedMethodInvocation.bold=false -semanticHighlighting.inheritedMethodInvocation.color=190,214,255 -semanticHighlighting.inheritedMethodInvocation.enabled=true -semanticHighlighting.inheritedMethodInvocation.italic=false -semanticHighlighting.inheritedMethodInvocation.strikethrough=false -semanticHighlighting.inheritedMethodInvocation.underline=false -semanticHighlighting.interface.bold=false -semanticHighlighting.interface.color=152,118,170 -semanticHighlighting.interface.enabled=true -semanticHighlighting.interface.italic=false -semanticHighlighting.interface.strikethrough=false -semanticHighlighting.interface.underline=false -semanticHighlighting.localVariable.bold=false -semanticHighlighting.localVariable.color=121,171,255 -semanticHighlighting.localVariable.enabled=true -semanticHighlighting.localVariable.italic=false -semanticHighlighting.localVariable.strikethrough=false -semanticHighlighting.localVariable.underline=false -semanticHighlighting.localVariableDeclaration.bold=false -semanticHighlighting.localVariableDeclaration.color=190,214,255 -semanticHighlighting.localVariableDeclaration.enabled=true -semanticHighlighting.localVariableDeclaration.italic=false -semanticHighlighting.localVariableDeclaration.strikethrough=false -semanticHighlighting.localVariableDeclaration.underline=false -semanticHighlighting.method.bold=false -semanticHighlighting.method.color=169,183,198 -semanticHighlighting.method.enabled=true -semanticHighlighting.method.italic=false -semanticHighlighting.method.strikethrough=false -semanticHighlighting.method.underline=false -semanticHighlighting.methodDeclarationName.bold=false -semanticHighlighting.methodDeclarationName.color=255,198,109 -semanticHighlighting.methodDeclarationName.enabled=true -semanticHighlighting.methodDeclarationName.italic=false -semanticHighlighting.methodDeclarationName.strikethrough=false -semanticHighlighting.methodDeclarationName.underline=false -semanticHighlighting.number.bold=false -semanticHighlighting.number.color=104,151,187 -semanticHighlighting.number.enabled=true -semanticHighlighting.number.italic=false -semanticHighlighting.number.strikethrough=false -semanticHighlighting.number.underline=false -semanticHighlighting.parameterVariable.bold=false -semanticHighlighting.parameterVariable.color=121,171,255 -semanticHighlighting.parameterVariable.enabled=true -semanticHighlighting.parameterVariable.italic=false -semanticHighlighting.parameterVariable.strikethrough=false -semanticHighlighting.parameterVariable.underline=false -semanticHighlighting.restrictedKeywords.bold=false -semanticHighlighting.restrictedKeywords.color=197,104,28 -semanticHighlighting.staticField.bold=false -semanticHighlighting.staticField.color=239,192,144 -semanticHighlighting.staticField.enabled=true -semanticHighlighting.staticField.italic=false -semanticHighlighting.staticField.strikethrough=false -semanticHighlighting.staticField.underline=false -semanticHighlighting.staticFinalField.bold=false -semanticHighlighting.staticFinalField.color=152,118,170 -semanticHighlighting.staticFinalField.enabled=true -semanticHighlighting.staticFinalField.italic=false -semanticHighlighting.staticFinalField.strikethrough=false -semanticHighlighting.staticFinalField.underline=false -semanticHighlighting.staticMethodInvocation.bold=false -semanticHighlighting.staticMethodInvocation.color=190,214,255 -semanticHighlighting.staticMethodInvocation.enabled=true -semanticHighlighting.staticMethodInvocation.italic=false -semanticHighlighting.staticMethodInvocation.strikethrough=false -semanticHighlighting.staticMethodInvocation.underline=false -semanticHighlighting.typeArgument.bold=false -semanticHighlighting.typeArgument.color=191,164,164 -semanticHighlighting.typeArgument.enabled=true -semanticHighlighting.typeArgument.italic=false -semanticHighlighting.typeArgument.strikethrough=false -semanticHighlighting.typeArgument.underline=false -semanticHighlighting.typeParameter.bold=false -semanticHighlighting.typeParameter.color=191,164,164 -semanticHighlighting.typeParameter.enabled=true -semanticHighlighting.typeParameter.italic=false -semanticHighlighting.typeParameter.strikethrough=false -semanticHighlighting.typeParameter.underline=false -sourceHoverBackgroundColor=66,68,69 spelling_locale_initialized=true typefilter_migrated_2=true useAnnotationsPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.pde.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.pde.ui.prefs deleted file mode 100644 index 715e4bd5..00000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.pde.ui.prefs +++ /dev/null @@ -1,20 +0,0 @@ -eclipse.preferences.version=1 -editor.color.default=216,216,216 -editor.color.externalized_string=165,194,92 -editor.color.externalized_string_italic=true -editor.color.header_assignment=216,216,216 -editor.color.header_assignment_bold=true -editor.color.header_attributes=121,171,255 -editor.color.header_key=204,120,50 -editor.color.header_key_bold=true -editor.color.header_osgi=204,120,50 -editor.color.header_value=165,194,92 -editor.color.header_value_italic=true -editor.color.instr=169,183,198 -editor.color.instr_bold=true -editor.color.string=165,194,92 -editor.color.string_italic=true -editor.color.tag=121,171,255 -editor.color.tag_bold=true -editor.color.xml_comment=98,151,85 -overriddenByCSS=,editor.color.default,editor.color.externalized_string,editor.color.externalized_string_italic,editor.color.header_assignment,editor.color.header_assignment_bold,editor.color.header_attributes,editor.color.header_key,editor.color.header_key_bold,editor.color.header_osgi,editor.color.header_value,editor.color.header_value_italic,editor.color.instr,editor.color.instr_bold,editor.color.string,editor.color.string_italic,editor.color.tag,editor.color.tag_bold,editor.color.xml_comment, diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs index 4911532b..cf8bb60f 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs @@ -1,47 +1,6 @@ AbstractTextEditor.Color.Background=28,31,34 AbstractTextEditor.Color.Background.SystemDefault=false -AbstractTextEditor.Color.FindScope=66,68,69 -AbstractTextEditor.Color.Foreground=216,216,216 -AbstractTextEditor.Color.Foreground.SystemDefault=false -AbstractTextEditor.Color.SelectionBackground=26,95,140 AbstractTextEditor.Color.SelectionBackground.SystemDefault=false -AbstractTextEditor.Color.SelectionForeground=146,157,165 AbstractTextEditor.Color.SelectionForeground.SystemDefault=false -LSP4EReadOccurrenceIndicationColor=26,95,140 -LSP4ETextOccurrenceIndicationColor=26,95,140 -LSP4EWriteOccurrenceIndicationColor=26,95,140 -PHPReadOccurrenceIndicationColor=65,65,4 -PHPWriteOccurrenceIndicationColor=65,65,4 STS4BootMarkerIndicationColor=54,81,25 -TM4EMatchingPairColor=26,95,140 -TextOccurrenceIndicationColor=27, 98, 145 -asOccurencesIndicationColor=65,65,4 -breakpointIndicationColor=49,115,187 -currentIPColor=50,50,50 -currentLineColor=50,57,62 -deletionIndicationColor=210,82,82 eclipse.preferences.version=1 -filteredSearchResultIndicationColor=26,95,140 -findBlockColor=255,165,0 -findIndicationColor=47,58,119 -hyperlinkColor=111,197,238 -hyperlinkColor.SystemDefault=false -infoIndicationColor=86,194,170 -javaScriptOccurrenceIndicationColor=65,65,4 -lineNumberColor=208,208,208 -linked.slave.color=66,156,255 -matchingTagIndicationColor=65,65,4 -occurrenceIndicationColor=65,65,4 -org.eclipse.cdt.ui.occurrenceIndicationColor=65,65,4 -org.eclipse.cdt.ui.writeOccurrenceIndicationColor=65,65,4 -overriddenByCSS=,AbstractTextEditor.Color.FindScope,AbstractTextEditor.Color.Foreground,AbstractTextEditor.Color.Foreground.SystemDefault,AbstractTextEditor.Color.SelectionBackground,AbstractTextEditor.Color.SelectionForeground,LSP4EReadOccurrenceIndicationColor,LSP4ETextOccurrenceIndicationColor,LSP4EWriteOccurrenceIndicationColor,PHPReadOccurrenceIndicationColor,PHPWriteOccurrenceIndicationColor,TM4EMatchingPairColor,TextOccurrenceIndicationColor,asOccurencesIndicationColor,breakpointIndicationColor,currentIPColor,currentLineColor,deletionIndicationColor,filteredSearchResultIndicationColor,findBlockColor,findIndicationColor,hyperlinkColor,hyperlinkColor.SystemDefault,infoIndicationColor,javaScriptOccurrenceIndicationColor,lineNumberColor,linked.slave.color,matchingTagIndicationColor,occurrenceIndicationColor,org.eclipse.cdt.ui.occurrenceIndicationColor,org.eclipse.cdt.ui.writeOccurrenceIndicationColor,overrideIndicatorColor,printMarginColor,pydevOccurrenceIndicationColor,searchResultHighlighting,searchResultIndication,searchResultIndicationColor,searchResultTextStyle,secondaryIPColor,spellingIndicationColor,writeOccurrenceIndicationColor, -overrideIndicatorColor=75,116,113 -printMarginColor=208,208,208 -pydevOccurrenceIndicationColor=65,65,4 -searchResultHighlighting=false -searchResultIndication=true -searchResultIndicationColor=66,68,69 -searchResultTextStyle=BOX -secondaryIPColor=50,50,50 -spellingIndicationColor=253,170,211 -writeOccurrenceIndicationColor=65,65,4 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.genericeditor.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.genericeditor.prefs deleted file mode 100644 index 417e71e7..00000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.genericeditor.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -matchingBracketsColor=244,245,246 -overriddenByCSS=,matchingBracketsColor, diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs index 102f7ca0..98e0ba1b 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -1,39 +1,7 @@ //org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false -ACTIVE_HYPERLINK_COLOR=255,200,0 -ATMARK_RULE=89,179,179 -ATTRIBUTE_DELIM=89,179,179 -ATTRIBUTE_NAME=89,179,179 -ATTRIBUTE_OPERATOR=89,179,179 -ATTRIBUTE_VALUE=89,179,179 -CLASS=89,179,179 -COMBINATOR=89,179,179 -COMMENT=75,113,227 -CONFLICTING_COLOR=232,14,64 -CONTENT_ASSIST_BACKGROUND_COLOR=46,52,56 -CONTENT_ASSIST_FOREGROUND_COLOR=233,235,237 -COUNTER_COLOR=0,208,255 ColorsAndFontsPreferencePage.expandedCategories=Torg.eclipse.ui.presentation.default ColorsAndFontsPreferencePage.selectedElement=Forg.eclipse.ui.workbench.TAB_TEXT_FONT -DECORATIONS_COLOR=181,152,86 -ERROR=255,96,96 -ERROR_COLOR=247,68,117 -HYPERLINK_COLOR=111,197,238 -ID=89,179,179 -INCOMING_COLOR=31,179,235 -MEDIA=242,0,255 -OUTGOING_COLOR=235,237,239 PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; -PROPERTY_NAME=255,0,255 -PROPERTY_VALUE=242,0,255 -PSEUDO=89,179,179 -RESOLVED_COLOR=104,203,16 -SCRIPT_AREA_BORDER=227,113,75 -SELECTOR=89,179,179 -STRING=242,0,255 -UNIVERSAL=89,179,179 -URI=242,0,255 -cdataBorder=0,254,254 -cdataText=255,255,255 com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=44,49,53 com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=37,41,45 com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_SELECTED_TEXT_COLOR=199,205,209 @@ -56,196 +24,37 @@ com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.INACTIVE_TAB_UNSELECTE com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.INACTIVE_UNSELECTED_TABS_COLOR_END=60,67,73 com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.INACTIVE_UNSELECTED_TABS_COLOR_START=44,49,53 com.genuitec.eclipse.themes.dark.org.eclipse.ui.workbench.LINK_COLOR=111,197,238 -commentBorder=75,113,227 -commentText=75,113,227 -content_assist_parameters_background=46,52,56 -content_assist_parameters_foreground=233,235,237 -content_assist_proposals_background=46,52,56 -content_assist_proposals_foreground=233,235,237 -declBoder=0,254,254 -doctypeExternalId=110,124,135 -doctypeExternalPubref=0,254,254 -doctypeExtrenalSysref=106,213,160 -doctypeName=0,254,254 -dtdComment=115,130,140 -dtdData=186,92,92 -dtdDefault=255,255,255 -dtdKeyword=255,191,191 -dtdString=89,224,134 -dtdSymbol=255,191,191 -dtdTag=96,96,255 -dtdTagName=96,96,255 eclipse.preferences.version=1 editors=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n -entityReference=212,0,255 org.eclipse.compare.contentmergeviewer.TextMergeViewer=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.debug.ui.DetailPaneFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.debug.ui.MemoryViewTableFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.debug.ui.console.background=0,0,0 -org.eclipse.debug.ui.console.stream.err=255,127,127 -org.eclipse.debug.ui.console.stream.in=0,255,184 -org.eclipse.debug.ui.console.stream.out=255,255,255 org.eclipse.debug.ui.consoleFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.egit.ui.CommitGraphHighlightFont=1|Segoe UI|18.0|0|WINDOWS|1|-36|0|0|0|400|0|0|0|0|3|2|1|34|Segoe UI; org.eclipse.egit.ui.CommitGraphNormalFont=1|Segoe UI|18.0|0|WINDOWS|1|-36|0|0|0|400|0|0|0|0|3|2|1|34|Segoe UI; -org.eclipse.egit.ui.CommitMessageCommentColor=115,130,140 org.eclipse.egit.ui.CommitMessageEditorFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.egit.ui.CommitMessageFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.egit.ui.DiffAddBackgroundColor=51,81,30 -org.eclipse.egit.ui.DiffAddForegroundColor=235,237,239 -org.eclipse.egit.ui.DiffHeadlineBackgroundColor=25,29,31 org.eclipse.egit.ui.DiffHeadlineFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.egit.ui.DiffHeadlineForegroundColor=238,240,241 -org.eclipse.egit.ui.DiffHunkBackgroundColor=25,29,31 -org.eclipse.egit.ui.DiffHunkForegroundColor=241,242,244 -org.eclipse.egit.ui.DiffRemoveBackgroundColor=97,45,45 -org.eclipse.egit.ui.DiffRemoveForegroundColor=238,240,241 -org.eclipse.egit.ui.IgnoredResourceForegroundColor=157,167,175 -org.eclipse.egit.ui.UncommittedChangeBackgroundColor=25,29,31 -org.eclipse.egit.ui.UncommittedChangeForegroundColor=216,220,223 org.eclipse.jdt.internal.ui.compare.JavaMergeViewer=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.jdt.internal.ui.compare.PropertiesFileMergeViewer=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.jdt.ui.ColoredLabels.inherited=143,143,191 org.eclipse.jdt.ui.ColoredLabels.match_highlight=206,204,247 -org.eclipse.jdt.ui.ColoredLabels.writeaccess_highlight=255,128,128 -org.eclipse.jdt.ui.Javadoc.backgroundColor=48,54,59 -org.eclipse.jdt.ui.Javadoc.foregroundColor=235,237,239 org.eclipse.jdt.ui.PropertiesFileEditor.textfont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.jdt.ui.abstractMethodInvocationHighlighting=255,255,255 -org.eclipse.jdt.ui.annotationElementReferenceHighlighting=255,255,255 -org.eclipse.jdt.ui.annotationHighlighting=143,155,163 -org.eclipse.jdt.ui.autoboxingHighlighting=255,255,0 -org.eclipse.jdt.ui.classHighlighting=0,255,255 -org.eclipse.jdt.ui.content_assist_completion_replacement_background=123,123,0 -org.eclipse.jdt.ui.content_assist_completion_replacement_foreground=255,127,127 -org.eclipse.jdt.ui.content_assist_parameters_background=0,0,0 -org.eclipse.jdt.ui.content_assist_parameters_foreground=255,255,255 -org.eclipse.jdt.ui.deprecatedMemberHighlighting=255,255,255 org.eclipse.jdt.ui.editors.textfont=1|Consolas|22.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.jdt.ui.enumHighlighting=247,173,123 -org.eclipse.jdt.ui.fieldHighlighting=159,159,255 -org.eclipse.jdt.ui.inheritedMethodInvocationHighlighting=255,255,255 -org.eclipse.jdt.ui.interfaceHighlighting=125,158,255 -org.eclipse.jdt.ui.java_bracket=255,255,255 -org.eclipse.jdt.ui.java_comment_task_tag=73,93,111 -org.eclipse.jdt.ui.java_default=255,255,255 -org.eclipse.jdt.ui.java_doc_default=75,113,227 -org.eclipse.jdt.ui.java_doc_keyword=73,93,111 -org.eclipse.jdt.ui.java_doc_link=96,96,255 -org.eclipse.jdt.ui.java_doc_tag=104,104,130 -org.eclipse.jdt.ui.java_keyword=255,0,255 -org.eclipse.jdt.ui.java_keyword_return=255,0,255 -org.eclipse.jdt.ui.java_multi_line_comment=106,213,160 -org.eclipse.jdt.ui.java_operator=255,255,255 -org.eclipse.jdt.ui.java_single_line_comment=106,213,160 -org.eclipse.jdt.ui.java_string=212,0,255 org.eclipse.jdt.ui.javadocfont=1|Segoe UI|18.0|0|WINDOWS|1|-36|0|0|0|400|0|0|0|0|3|2|1|34|Segoe UI; -org.eclipse.jdt.ui.localVariableDeclarationHighlighting=246,144,144 -org.eclipse.jdt.ui.localVariableHighlighting=246,144,144 -org.eclipse.jdt.ui.matchingBracketsColor=255,0,255 -org.eclipse.jdt.ui.methodDeclarationHighlighting=255,255,255 -org.eclipse.jdt.ui.methodDeclarationNameHighlighting=255,255,255 -org.eclipse.jdt.ui.methodHighlighting=255,255,255 -org.eclipse.jdt.ui.numberHighlighting=212,0,255 -org.eclipse.jdt.ui.parameterVariableHighlighting=246,144,144 -org.eclipse.jdt.ui.pf_coloring_argument=255,0,255 -org.eclipse.jdt.ui.pf_coloring_assignment=255,255,255 -org.eclipse.jdt.ui.pf_coloring_comment=106,213,160 -org.eclipse.jdt.ui.pf_coloring_key=255,255,255 -org.eclipse.jdt.ui.pf_coloring_value=212,0,255 -org.eclipse.jdt.ui.staticFieldHighlighting=159,159,255 -org.eclipse.jdt.ui.staticFinalFieldHighlighting=159,159,255 -org.eclipse.jdt.ui.staticMethodInvocationHighlighting=255,255,255 -org.eclipse.jdt.ui.typeArgumentHighlighting=255,255,0 -org.eclipse.jdt.ui.typeParameterHighlighting=247,173,123 -org.eclipse.jdt.ui.typeVariableDeclarationHighlighting=247,173,123 -org.eclipse.jface.REVISION_NEWEST_COLOR=185,124,52 -org.eclipse.jface.REVISION_OLDEST_COLOR=25,29,31 org.eclipse.jface.bannerfont=1|Segoe UI|18.0|1|WINDOWS|1|-36|0|0|0|700|0|0|0|0|3|2|1|34|Segoe UI; org.eclipse.jface.dialogfont=1|Segoe UI|18.0|0|WINDOWS|1|-36|0|0|0|400|0|0|0|0|3|2|1|34|Segoe UI; org.eclipse.jface.headerfont=1|Segoe UI|18.0|1|WINDOWS|1|-36|0|0|0|700|0|0|0|0|3|2|1|34|Segoe UI; org.eclipse.jface.textfont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.mylyn.wikitext.ui.presentation.textFont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.pde.genericeditor.extension.editor.color.attribute=196,138,114 -org.eclipse.pde.genericeditor.extension.editor.color.comment=93,134,75 -org.eclipse.pde.genericeditor.extension.editor.color.header=115,130,140 -org.eclipse.pde.genericeditor.extension.editor.color.quote=118,200,244 -org.eclipse.pde.genericeditor.extension.editor.color.tag=86,156,214 -org.eclipse.pde.genericeditor.extension.editor.color.text=207,212,216 org.eclipse.pde.internal.ui.compare.ManifestContentMergeViewer=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; org.eclipse.pde.internal.ui.compare.PluginContentMergeViewer=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.eclipse.search.ui.match.highlight=73,83,90 org.eclipse.ui.commands=\r\n -org.eclipse.ui.editors.backgroundColor=0,0,0 -org.eclipse.ui.editors.currentLineColor=7,8,8 -org.eclipse.ui.editors.findScope=62,70,76 -org.eclipse.ui.editors.foregroundColor=255,255,255 -org.eclipse.ui.editors.lineNumberRulerColor=120,135,145 -org.eclipse.ui.editors.printMarginColor=62,70,76 -org.eclipse.ui.showkeys.backgroundColor=182,190,195 org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=37,41,45 org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=37,41,45 org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=53,60,65 org.eclipse.ui.workbench.TAB_TEXT_FONT=1|Segoe UI|16.0|0|WINDOWS|1|-32|0|0|0|400|0|0|0|0|3|2|1|34|Segoe UI; org.eclipse.ui.workbench.TREE_TABLE_FONT=1|Segoe UI|16.0|0|WINDOWS|1|-32|0|0|0|400|0|0|0|0|3|2|1|34|Segoe UI; org.eclipse.ui.workbench.texteditor.blockSelectionModeFont=1|Consolas|14.0|0|WINDOWS|1|-28|0|0|0|400|0|0|0|0|3|2|1|49|Consolas; -org.eclipse.wst.jsdt.ui.abstractMethodInvocationHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.annotationElementReferenceHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.annotationHighlighting=143,155,163 -org.eclipse.wst.jsdt.ui.autoboxingHighlighting=255,255,0 -org.eclipse.wst.jsdt.ui.classHighlighting=0,255,255 -org.eclipse.wst.jsdt.ui.content_assist_completion_replacement_background=123,123,0 -org.eclipse.wst.jsdt.ui.content_assist_completion_replacement_foreground=255,127,127 -org.eclipse.wst.jsdt.ui.content_assist_parameters_background=0,0,0 -org.eclipse.wst.jsdt.ui.content_assist_parameters_foreground=255,255,255 -org.eclipse.wst.jsdt.ui.content_assist_proposals_background=0,0,0 -org.eclipse.wst.jsdt.ui.content_assist_proposals_foreground=255,255,255 -org.eclipse.wst.jsdt.ui.deprecatedMemberHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.enumHighlighting=247,173,123 -org.eclipse.wst.jsdt.ui.fieldHighlighting=159,159,255 -org.eclipse.wst.jsdt.ui.inheritedMethodInvocationHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.interfaceHighlighting=125,158,255 -org.eclipse.wst.jsdt.ui.java_bracket=255,255,255 -org.eclipse.wst.jsdt.ui.java_comment_task_tag=73,93,111 -org.eclipse.wst.jsdt.ui.java_default=255,255,255 -org.eclipse.wst.jsdt.ui.java_doc_default=75,113,227 -org.eclipse.wst.jsdt.ui.java_doc_keyword=73,93,111 -org.eclipse.wst.jsdt.ui.java_doc_link=96,96,255 -org.eclipse.wst.jsdt.ui.java_doc_tag=104,104,130 -org.eclipse.wst.jsdt.ui.java_keyword=255,0,255 -org.eclipse.wst.jsdt.ui.java_keyword_return=255,0,255 -org.eclipse.wst.jsdt.ui.java_multi_line_comment=106,213,160 -org.eclipse.wst.jsdt.ui.java_operator=255,255,255 -org.eclipse.wst.jsdt.ui.java_single_line_comment=106,213,160 -org.eclipse.wst.jsdt.ui.java_string=212,0,255 -org.eclipse.wst.jsdt.ui.localVariableDeclarationHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.localVariableHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.matchingBracketsColor=53,60,65 -org.eclipse.wst.jsdt.ui.methodDeclarationHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.methodDeclarationNameHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.methodHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.parameterVariableHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.pf_coloring_argument=255,0,255 -org.eclipse.wst.jsdt.ui.pf_coloring_assignment=255,255,255 -org.eclipse.wst.jsdt.ui.pf_coloring_comment=106,213,160 -org.eclipse.wst.jsdt.ui.pf_coloring_key=255,255,255 -org.eclipse.wst.jsdt.ui.pf_coloring_value=212,0,255 -org.eclipse.wst.jsdt.ui.staticFieldHighlighting=159,159,255 -org.eclipse.wst.jsdt.ui.staticFinalFieldHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.staticMethodInvocationHighlighting=255,255,255 -org.eclipse.wst.jsdt.ui.typeArgumentHighlighting=255,255,0 -org.eclipse.wst.jsdt.ui.typeParameterHighlighting=247,173,123 -org.eclipse.wst.jsdt.ui.typeVariableDeclarationHighlighting=247,173,123 org.eclipse.wst.sse.ui.textfont=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; -org.springframework.ide.eclipse.boot.dash.AltTextDecorColor=173,216,230 -org.springframework.ide.eclipse.boot.dash.MutedTextDecorColor=205,210,214 -org.springframework.ide.eclipse.boot.dash.TextDecorColor=144,238,144 -org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor=54,81,25 -overriddenByCSS=,ACTIVE_HYPERLINK_COLOR,ATMARK_RULE,ATTRIBUTE_DELIM,ATTRIBUTE_NAME,ATTRIBUTE_OPERATOR,ATTRIBUTE_VALUE,CLASS,COMBINATOR,COMMENT,CONFLICTING_COLOR,CONTENT_ASSIST_BACKGROUND_COLOR,CONTENT_ASSIST_FOREGROUND_COLOR,COUNTER_COLOR,DECORATIONS_COLOR,ERROR,ERROR_COLOR,HYPERLINK_COLOR,ID,INCOMING_COLOR,MEDIA,OUTGOING_COLOR,PROPERTY_NAME,PROPERTY_VALUE,PSEUDO,RESOLVED_COLOR,SCRIPT_AREA_BORDER,SELECTOR,STRING,UNIVERSAL,URI,cdataBorder,cdataText,commentBorder,commentText,content_assist_parameters_background,content_assist_parameters_foreground,content_assist_proposals_background,content_assist_proposals_foreground,declBoder,doctypeExternalId,doctypeExternalPubref,doctypeExtrenalSysref,doctypeName,dtdComment,dtdData,dtdDefault,dtdKeyword,dtdString,dtdSymbol,dtdTag,dtdTagName,entityReference,org.eclipse.debug.ui.console.background,org.eclipse.debug.ui.console.stream.err,org.eclipse.debug.ui.console.stream.in,org.eclipse.debug.ui.console.stream.out,org.eclipse.egit.ui.CommitMessageCommentColor,org.eclipse.egit.ui.DiffAddBackgroundColor,org.eclipse.egit.ui.DiffAddForegroundColor,org.eclipse.egit.ui.DiffHeadlineBackgroundColor,org.eclipse.egit.ui.DiffHeadlineForegroundColor,org.eclipse.egit.ui.DiffHunkBackgroundColor,org.eclipse.egit.ui.DiffHunkForegroundColor,org.eclipse.egit.ui.DiffRemoveBackgroundColor,org.eclipse.egit.ui.DiffRemoveForegroundColor,org.eclipse.egit.ui.IgnoredResourceForegroundColor,org.eclipse.egit.ui.UncommittedChangeBackgroundColor,org.eclipse.egit.ui.UncommittedChangeForegroundColor,org.eclipse.jdt.ui.ColoredLabels.inherited,org.eclipse.jdt.ui.ColoredLabels.writeaccess_highlight,org.eclipse.jdt.ui.Javadoc.backgroundColor,org.eclipse.jdt.ui.Javadoc.foregroundColor,org.eclipse.jdt.ui.abstractMethodInvocationHighlighting,org.eclipse.jdt.ui.annotationElementReferenceHighlighting,org.eclipse.jdt.ui.annotationHighlighting,org.eclipse.jdt.ui.autoboxingHighlighting,org.eclipse.jdt.ui.classHighlighting,org.eclipse.jdt.ui.content_assist_completion_replacement_background,org.eclipse.jdt.ui.content_assist_completion_replacement_foreground,org.eclipse.jdt.ui.content_assist_parameters_background,org.eclipse.jdt.ui.content_assist_parameters_foreground,org.eclipse.jdt.ui.deprecatedMemberHighlighting,org.eclipse.jdt.ui.enumHighlighting,org.eclipse.jdt.ui.fieldHighlighting,org.eclipse.jdt.ui.inheritedMethodInvocationHighlighting,org.eclipse.jdt.ui.interfaceHighlighting,org.eclipse.jdt.ui.java_bracket,org.eclipse.jdt.ui.java_comment_task_tag,org.eclipse.jdt.ui.java_default,org.eclipse.jdt.ui.java_doc_default,org.eclipse.jdt.ui.java_doc_keyword,org.eclipse.jdt.ui.java_doc_link,org.eclipse.jdt.ui.java_doc_tag,org.eclipse.jdt.ui.java_keyword,org.eclipse.jdt.ui.java_keyword_return,org.eclipse.jdt.ui.java_multi_line_comment,org.eclipse.jdt.ui.java_operator,org.eclipse.jdt.ui.java_single_line_comment,org.eclipse.jdt.ui.java_string,org.eclipse.jdt.ui.localVariableDeclarationHighlighting,org.eclipse.jdt.ui.localVariableHighlighting,org.eclipse.jdt.ui.matchingBracketsColor,org.eclipse.jdt.ui.methodDeclarationHighlighting,org.eclipse.jdt.ui.methodDeclarationNameHighlighting,org.eclipse.jdt.ui.methodHighlighting,org.eclipse.jdt.ui.numberHighlighting,org.eclipse.jdt.ui.parameterVariableHighlighting,org.eclipse.jdt.ui.pf_coloring_argument,org.eclipse.jdt.ui.pf_coloring_assignment,org.eclipse.jdt.ui.pf_coloring_comment,org.eclipse.jdt.ui.pf_coloring_key,org.eclipse.jdt.ui.pf_coloring_value,org.eclipse.jdt.ui.staticFieldHighlighting,org.eclipse.jdt.ui.staticFinalFieldHighlighting,org.eclipse.jdt.ui.staticMethodInvocationHighlighting,org.eclipse.jdt.ui.typeArgumentHighlighting,org.eclipse.jdt.ui.typeParameterHighlighting,org.eclipse.jdt.ui.typeVariableDeclarationHighlighting,org.eclipse.jface.REVISION_NEWEST_COLOR,org.eclipse.jface.REVISION_OLDEST_COLOR,org.eclipse.pde.genericeditor.extension.editor.color.attribute,org.eclipse.pde.genericeditor.extension.editor.color.comment,org.eclipse.pde.genericeditor.extension.editor.color.header,org.eclipse.pde.genericeditor.extension.editor.color.quote,org.eclipse.pde.genericeditor.extension.editor.color.tag,org.eclipse.pde.genericeditor.extension.editor.color.text,org.eclipse.search.ui.match.highlight,org.eclipse.ui.editors.backgroundColor,org.eclipse.ui.editors.currentLineColor,org.eclipse.ui.editors.findScope,org.eclipse.ui.editors.foregroundColor,org.eclipse.ui.editors.lineNumberRulerColor,org.eclipse.ui.editors.printMarginColor,org.eclipse.ui.showkeys.backgroundColor,org.eclipse.wst.jsdt.ui.abstractMethodInvocationHighlighting,org.eclipse.wst.jsdt.ui.annotationElementReferenceHighlighting,org.eclipse.wst.jsdt.ui.annotationHighlighting,org.eclipse.wst.jsdt.ui.autoboxingHighlighting,org.eclipse.wst.jsdt.ui.classHighlighting,org.eclipse.wst.jsdt.ui.content_assist_completion_replacement_background,org.eclipse.wst.jsdt.ui.content_assist_completion_replacement_foreground,org.eclipse.wst.jsdt.ui.content_assist_parameters_background,org.eclipse.wst.jsdt.ui.content_assist_parameters_foreground,org.eclipse.wst.jsdt.ui.content_assist_proposals_background,org.eclipse.wst.jsdt.ui.content_assist_proposals_foreground,org.eclipse.wst.jsdt.ui.deprecatedMemberHighlighting,org.eclipse.wst.jsdt.ui.enumHighlighting,org.eclipse.wst.jsdt.ui.fieldHighlighting,org.eclipse.wst.jsdt.ui.inheritedMethodInvocationHighlighting,org.eclipse.wst.jsdt.ui.interfaceHighlighting,org.eclipse.wst.jsdt.ui.java_bracket,org.eclipse.wst.jsdt.ui.java_comment_task_tag,org.eclipse.wst.jsdt.ui.java_default,org.eclipse.wst.jsdt.ui.java_doc_default,org.eclipse.wst.jsdt.ui.java_doc_keyword,org.eclipse.wst.jsdt.ui.java_doc_link,org.eclipse.wst.jsdt.ui.java_doc_tag,org.eclipse.wst.jsdt.ui.java_keyword,org.eclipse.wst.jsdt.ui.java_keyword_return,org.eclipse.wst.jsdt.ui.java_multi_line_comment,org.eclipse.wst.jsdt.ui.java_operator,org.eclipse.wst.jsdt.ui.java_single_line_comment,org.eclipse.wst.jsdt.ui.java_string,org.eclipse.wst.jsdt.ui.localVariableDeclarationHighlighting,org.eclipse.wst.jsdt.ui.localVariableHighlighting,org.eclipse.wst.jsdt.ui.matchingBracketsColor,org.eclipse.wst.jsdt.ui.methodDeclarationHighlighting,org.eclipse.wst.jsdt.ui.methodDeclarationNameHighlighting,org.eclipse.wst.jsdt.ui.methodHighlighting,org.eclipse.wst.jsdt.ui.parameterVariableHighlighting,org.eclipse.wst.jsdt.ui.pf_coloring_argument,org.eclipse.wst.jsdt.ui.pf_coloring_assignment,org.eclipse.wst.jsdt.ui.pf_coloring_comment,org.eclipse.wst.jsdt.ui.pf_coloring_key,org.eclipse.wst.jsdt.ui.pf_coloring_value,org.eclipse.wst.jsdt.ui.staticFieldHighlighting,org.eclipse.wst.jsdt.ui.staticFinalFieldHighlighting,org.eclipse.wst.jsdt.ui.staticMethodInvocationHighlighting,org.eclipse.wst.jsdt.ui.typeArgumentHighlighting,org.eclipse.wst.jsdt.ui.typeParameterHighlighting,org.eclipse.wst.jsdt.ui.typeVariableDeclarationHighlighting,org.springframework.ide.eclipse.boot.dash.AltTextDecorColor,org.springframework.ide.eclipse.boot.dash.MutedTextDecorColor,org.springframework.ide.eclipse.boot.dash.TextDecorColor,org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor,piBorder,tagAttributeName,tagAttributeValue,tagBorder,tagName, -piBorder=0,254,254 resourcetypes=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n -tagAttributeName=255,0,255 -tagAttributeValue=212,0,255 -tagBorder=0,254,254 -tagName=89,179,179 terminal.views.view.font.definition=1|Consolas|18.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.css.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.css.ui.prefs index 0adaa824..b8ed20dd 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.css.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.css.ui.prefs @@ -1,24 +1,2 @@ -ATMARK_RULE=\#A9B7C6 | null | null | null | null | null -ATTRIBUTE_DELIM=\#A9B7C6 | null | null | null | null | null -ATTRIBUTE_NAME=\#A9B7C6 | null | null | null | null | null -ATTRIBUTE_OPERATOR=\#A9B7C6 | null | null | null | null | null -ATTRIBUTE_VALUE=\#A9B7C6 | null | null | null | null | null -CLASS=\#A9B7C6 | null | null | null | null | null -COLON=\#D8D8D8 | null | null | null | null | null -COMBINATOR=\#A9B7C6 | null | null | null | null | null -COMMENT=\#629755 | null | null | false | null | null -CURLY_BRACE=\#D8D8D8 | null | null | null | null | null -ID=\#A9B7C6 | null | null | null | null | null -MEDIA=\#CC7832 | null | false | null | null | null -NORMAL=\#D8D8D8 | null | null | null | null | null -PROPERTY_NAME=\#BED6FF | null | null | null | null | null -PROPERTY_VALUE=\#A5C25C | null | null | null | null | null -PSEUDO=\#A9B7C6 | null | null | null | null | null -SELECTOR=\#A9B7C6 | null | null | null | null | null -SEMI_COLON=\#D8D8D8 | null | null | null | null | null -STRING=\#A5C25C | null | null | null | null | null -UNIVERSAL=\#A9B7C6 | null | null | null | null | null -URI=\#A5C25C | null | null | null | null | null eclipse.preferences.version=1 newFileTemplateName=New CSS File -overriddenByCSS=,ATMARK_RULE,ATTRIBUTE_DELIM,ATTRIBUTE_NAME,ATTRIBUTE_OPERATOR,ATTRIBUTE_VALUE,CLASS,COLON,COMBINATOR,COMMENT,CURLY_BRACE,ID,MEDIA,NORMAL,PROPERTY_NAME,PROPERTY_VALUE,PSEUDO,SELECTOR,SEMI_COLON,STRING,UNIVERSAL,URI, diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.dtd.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.dtd.ui.prefs deleted file mode 100644 index 093af652..00000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.dtd.ui.prefs +++ /dev/null @@ -1,10 +0,0 @@ -dtdComment=\#629755 | null | null | false | null | null -dtdData=\#D8D8D8 | null | null | null | null | null -dtdDefault=\#D8D8D8 | null | null | null | null | null -dtdKeyword=\#CC7832 | null | false | null | null | null -dtdString=\#A5C25C | null | null | null | null | null -dtdSymbol=\#BED6FF | null | null | null | null | null -dtdTag=\#BED6FF | null | null | null | null | null -dtdTagName=\#BED6FF | null | null | null | null | null -eclipse.preferences.version=1 -overriddenByCSS=,dtdKeyword,dtdTag,dtdString,dtdTagName,dtdDefault,dtdData,dtdSymbol,dtdComment, diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.html.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.html.ui.prefs index faffac4e..5421dd22 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.html.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.html.ui.prefs @@ -1,17 +1,2 @@ -commentBorder=\#629755 | null | null | false | null | null -commentText=\#629755 | null | null | false | null | null -declBoder=\#A9B7C6 | null | null | null | null | null -doctypeExternalId=\#A9B7C6 | null | null | null | null | null -doctypeExternalPubref=\#A9B7C6 | null | null | null | null | null -doctypeExtrenalSysref=\#A9B7C6 | null | null | null | null | null -doctypeName=\#A9B7C6 | null | null | null | null | null eclipse.preferences.version=1 -entityReference=\#CC7832 | null | false | null | null | null newFileTemplateName=New HTML File (5) -overriddenByCSS=,commentBorder,commentText,declBoder,doctypeExternalId,doctypeExternalPubref,doctypeExtrenalSysref,doctypeName,entityReference,tagAttributeEquals,tagAttributeName,tagAttributeValue,tagBorder,tagName,xmlContent, -tagAttributeEquals=\#D8D8D8 | null | null | null | null | null -tagAttributeName=\#BED6FF | null | null | null | null | null -tagAttributeValue=\#A5C25C | null | null | null | null | null -tagBorder=\#79ABFF | null | null | null | null | null -tagName=\#BED6FF | null | null | null | null | null -xmlContent=\#D8D8D8 | null | null | null | null | null diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs index 7efca663..0c7f140e 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs @@ -1,50 +1,11 @@ -CONTENT_ASSIST_BACKGROUND_COLOR=46,52,56 -CONTENT_ASSIST_FOREGROUND_COLOR=233,235,237 -content_assist_parameters_background=46,52,56 -content_assist_parameters_foreground=233,235,237 -content_assist_proposals_background=46,52,56 -content_assist_proposals_foreground=233,235,237 eclipse.preferences.version=1 fontPropagated=true -java_bracket=216,216,216 -java_comment_task_tag=204,223,50 -java_default=216,216,216 -java_doc_default=98,151,85 -java_doc_keyword=132,185,119 -java_doc_link=132,185,119 -java_doc_tag=132,185,119 -java_keyword=204,120,50 -java_keyword_return=204,120,50 -java_multi_line_comment=98,151,85 -java_operator=216,216,216 -java_single_line_comment=128,128,128 -java_string=165,194,92 org.eclipse.wst.jsdt.ui.editor.tab.width= org.eclipse.wst.jsdt.ui.formatterprofiles.version=11 org.eclipse.wst.jsdt.ui.javadoclocations.migrated=true org.eclipse.wst.jsdt.ui.text.code_templates_migrated=true org.eclipse.wst.jsdt.ui.text.custom_code_templates= -overriddenByCSS=,CONTENT_ASSIST_BACKGROUND_COLOR,CONTENT_ASSIST_FOREGROUND_COLOR,content_assist_parameters_background,content_assist_parameters_foreground,content_assist_proposals_background,content_assist_proposals_foreground,java_bracket,java_comment_task_tag,java_default,java_doc_default,java_doc_keyword,java_doc_link,java_doc_tag,java_keyword,java_keyword_return,java_multi_line_comment,java_operator,java_single_line_comment,java_string,semanticHighlighting.localVariable.bold,semanticHighlighting.localVariable.color,semanticHighlighting.localVariable.enabled,semanticHighlighting.localVariable.italic,semanticHighlighting.localVariable.strikethrough,semanticHighlighting.localVariable.underline,semanticHighlighting.localVariableDeclaration.bold,semanticHighlighting.localVariableDeclaration.color,semanticHighlighting.localVariableDeclaration.enabled,semanticHighlighting.localVariableDeclaration.italic,semanticHighlighting.localVariableDeclaration.strikethrough,semanticHighlighting.localVariableDeclaration.underline,semanticHighlighting.methodDeclarationName.bold,semanticHighlighting.methodDeclarationName.color,semanticHighlighting.methodDeclarationName.enabled,semanticHighlighting.methodDeclarationName.italic,semanticHighlighting.methodDeclarationName.strikethrough,semanticHighlighting.methodDeclarationName.underline,tagName, proposalOrderMigrated=true -semanticHighlighting.localVariable.bold=false -semanticHighlighting.localVariable.color=121,171,255 -semanticHighlighting.localVariable.enabled=true -semanticHighlighting.localVariable.italic=false -semanticHighlighting.localVariable.strikethrough=false -semanticHighlighting.localVariable.underline=false -semanticHighlighting.localVariableDeclaration.bold=false -semanticHighlighting.localVariableDeclaration.color=190,214,255 -semanticHighlighting.localVariableDeclaration.enabled=true -semanticHighlighting.localVariableDeclaration.italic=false -semanticHighlighting.localVariableDeclaration.strikethrough=false -semanticHighlighting.localVariableDeclaration.underline=false -semanticHighlighting.methodDeclarationName.bold=false -semanticHighlighting.methodDeclarationName.color=255,198,109 -semanticHighlighting.methodDeclarationName.enabled=true -semanticHighlighting.methodDeclarationName.italic=false -semanticHighlighting.methodDeclarationName.strikethrough=false -semanticHighlighting.methodDeclarationName.underline=false tabWidthPropagated=true -tagName=169,183,198 useAnnotationsPrefPage=true useQuickDiffPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.json.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.json.ui.prefs deleted file mode 100644 index d9391aa1..00000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.json.ui.prefs +++ /dev/null @@ -1,10 +0,0 @@ -COLON=\#ffffff | null | false | false | false | false -COMMA=\#ffffff | null | false | false | false | false -CURLY_BRACE=\#ffffff | null | false | false | false | false -OBJECT_KEY=\#bed6ff | null | false | false | false | false -VALUE_BOOLEAN=\#03a8d8 | null | false | false | false | false -VALUE_NULL=\#89969f | null | false | false | false | false -VALUE_NUMBER=\#cb4f40 | null | false | false | false | false -VALUE_STRING=\#ffc600 | null | true | true | false | false -eclipse.preferences.version=1 -overriddenByCSS=,COLON,COMMA,CURLY_BRACE,OBJECT_KEY,VALUE_BOOLEAN,VALUE_NULL,VALUE_NUMBER,VALUE_STRING, diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.sse.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.sse.ui.prefs index 216d3170..13319dc0 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.sse.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.sse.ui.prefs @@ -1,12 +1,5 @@ -content_assist_completion_replacement_background=200,200,0 -content_assist_completion_replacement_foreground=194,0,0 content_assist_number_of_computers=17 -content_assist_parameters_background=48,54,59 -content_assist_parameters_foreground=235,237,239 -content_assist_proposals_background=48,54,59 -content_assist_proposals_foreground=235,237,239 eclipse.preferences.version=1 hoverModifiers=combinationHover|true|0;problemHover|false|0;documentationHover|false|0;annotationHover|true|Shift; -overriddenByCSS=,content_assist_completion_replacement_background,content_assist_completion_replacement_foreground,content_assist_parameters_background,content_assist_parameters_foreground,content_assist_proposals_background,content_assist_proposals_foreground, useAnnotationsPrefPage=true useQuickDiffPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.ui.prefs deleted file mode 100644 index 1985d12d..00000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.ui.prefs +++ /dev/null @@ -1,21 +0,0 @@ -cdataBorder=\#A9B7C6 | null | null | null | null | null -cdataText=\#D8D8D8 | null | null | null | null | null -commentBorder=\#629755 | null | null | false | null | null -commentText=\#629755 | null | null | false | null | null -declBoder=\#A9B7C6 | null | null | null | null | null -declBorder=\#A9B7C6 | null | null | null | null | null -doctypeExternalId=\#A9B7C6 | null | null | null | null | null -doctypeExternalPubref=\#A9B7C6 | null | null | null | null | null -doctypeExtrenalSysref=\#A9B7C6 | null | null | null | null | null -doctypeName=\#A9B7C6 | null | null | null | null | null -eclipse.preferences.version=1 -entityReference=\#CC7832 | null | false | null | null | null -overriddenByCSS=,cdataBorder,cdataText,commentBorder,commentText,declBoder,declBorder,doctypeExternalId,doctypeExternalPubref,doctypeExtrenalSysref,doctypeName,entityReference,piBorder,piContent,tagAttributeEquals,tagAttributeName,tagAttributeValue,tagBorder,tagName,xmlContent, -piBorder=\#A9B7C6 | null | null | null | null | null -piContent=\#D8D8D8 | null | null | null | null | null -tagAttributeEquals=\#D8D8D8 | null | null | null | null | null -tagAttributeName=\#BED6FF | null | null | null | null | null -tagAttributeValue=\#A5C25C | null | null | null | null | null -tagBorder=\#79ABFF | null | null | null | null | null -tagName=\#BED6FF | null | null | null | null | null -xmlContent=\#D8D8D8 | null | null | null | null | null diff --git a/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml index 1cb33417..a007491b 100644 --- a/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml @@ -2,8 +2,8 @@ - + @@ -25,8 +25,8 @@ - + diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi index b0d954df..735e4f2b 100644 --- a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -1,8 +1,8 @@ - - + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - + @@ -11,9 +11,9 @@ topLevel shellMaximized - - - + + + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet persp.actionSet:org.eclipse.search.searchActionSet @@ -73,106 +73,106 @@ persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView persp.viewSC:org.eclipse.ant.ui.views.AntView persp.actionSet:org.eclipse.debug.ui.debugActionSet - - - - + + + + org.eclipse.e4.primaryNavigationStack - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:Java - - + + View categoryTag:Other - - + + View categoryTag:Git - - - - + + + + org.eclipse.e4.secondaryDataStack Debug General - + View categoryTag:General - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Terminal - + View categoryTag:Debug - + View categoryTag:General - + org.eclipse.e4.secondaryNavigationStack - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Ant @@ -180,7 +180,7 @@ - + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet persp.actionSet:org.eclipse.search.searchActionSet @@ -205,41 +205,41 @@ persp.newWizSC:org.eclipse.egit.ui.CreateRepositoryWizard persp.actionSet:org.eclipse.debug.ui.launchActionSet persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView - - - - + + + + View categoryTag:Git - - + + View categoryTag:Java - - - - + + + + View categoryTag:Version Control (Team) - + View categoryTag:Version Control (Team) - + View categoryTag:Git - + View categoryTag:Git - + View categoryTag:General @@ -247,7 +247,7 @@ - + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet persp.actionSet:org.eclipse.search.searchActionSet @@ -281,73 +281,73 @@ persp.viewSC:org.eclipse.ui.views.minimap.MinimapView persp.perspSC:org.eclipse.jdt.ui.JavaPerspective persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView - - - + + + View categoryTag:General - + View categoryTag:General - - - - - + + + + + View categoryTag:General - + View categoryTag:Server - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Terminal - - + + View categoryTag:General - + View categoryTag:General - + View categoryTag:General @@ -356,2740 +356,2740 @@ - - + + View categoryTag:Help - + View categoryTag:General - + View categoryTag:Help - + View categoryTag:Help - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:Help - - + + org.eclipse.e4.primaryDataStack EditorStack active - noFocus - - + + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor - + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor - - + + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor active + activeOnClose - - + + Editor removeOnHide - org.eclipse.wst.html.core.htmlsource.source + org.eclipse.jdt.ui.CompilationUnitEditor - - + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + + + Editor removeOnHide org.eclipse.wst.html.core.htmlsource.source - - + + Editor removeOnHide - org.eclipse.jdt.ui.CompilationUnitEditor + org.eclipse.wst.html.core.htmlsource.source - - + + Editor removeOnHide - org.eclipse.jdt.ui.CompilationUnitEditor + org.eclipse.wst.html.core.htmlsource.source - + View categoryTag:Java - + ViewMenu menuContribution:menu - + - + View categoryTag:Java - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Java - + ViewMenu menuContribution:menu - + - + View categoryTag:Git - + ViewMenu menuContribution:menu - + - + View categoryTag:Other - + ViewMenu menuContribution:menu - + - + View categoryTag:Terminal - + View categoryTag:Ant - + View categoryTag:Debug - + ViewMenu menuContribution:menu - + - + View categoryTag:Version Control (Team) - + ViewMenu menuContribution:menu - + - + View categoryTag:Version Control (Team) - + View categoryTag:Git - + View categoryTag:Git - + View categoryTag:General - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:Server - + ViewMenu menuContribution:menu - + - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + ViewMenu menuContribution:menu - + - - + + toolbarSeparator Draggable - + Draggable - + - + toolbarSeparator - + - + Draggable - + toolbarSeparator - + - + Draggable - + Draggable - + Draggable - + Draggable - + Draggable - + Draggable - + toolbarSeparator - - - - Draggable - - - - Draggable + - + Draggable + - + toolbarSeparator - + - + toolbarSeparator - + - + Draggable - + toolbarSeparator - + - + stretch SHOW_RESTORE_MENU - + Draggable HIDEABLE SHOW_RESTORE_MENU - + breadcrumb_visible_tag - - + + stretch - + Draggable - + Draggable - - + + TrimStack Draggable - + TrimStack Draggable - - + + TrimStack Draggable - + TrimStack Draggable - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + platform:win32 - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - + + - - - - - - - + + + + + + + deleted - - + + - - - + + + - - - + + + - - - - - + + + + + - - + + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - + + + + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + - - - - - + + + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - - + + + + + + - - - + + + - - - + + + - - - - - - + + + + + + - - + + - - - - - - - - + + + + + + + + - - - + + + platform:win32 - - - - + + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - + - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Spy - - - - + + + + - - - + + + - + - - + + - + - + Spy - + Spy - + Spy - + Spy - + Spy - + Spy - + Editor removeOnHide - + View categoryTag:Ant - + View categoryTag:Gradle - + View categoryTag:Gradle - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Debug - + View categoryTag:Git - + View categoryTag:Git - + View categoryTag:Git - + View categoryTag:Git NoRestore - + View categoryTag:Git - + View categoryTag:Help - + View categoryTag:Debug - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Java Browsing - + View categoryTag:Java Browsing - + View categoryTag:Java Browsing - + View categoryTag:Java Browsing - + View categoryTag:Java - + View categoryTag:General - + View categoryTag:Java - + View categoryTag:Java - + View categoryTag:Docker - + View categoryTag:Docker - + View categoryTag:Docker - + View categoryTag:Docker - + View categoryTag:Maven - + View categoryTag:Maven - + View categoryTag:Maven - + View categoryTag:API Tools - + View categoryTag:Plug-in Development - + View categoryTag:Plug-in Development - + View categoryTag:Plug-in Development - + View categoryTag:Plug-in Development - + View categoryTag:Plug-in Development - + View categoryTag:Plug-in Development - + View categoryTag:General - + View categoryTag:Version Control (Team) - + View categoryTag:Version Control (Team) - + View categoryTag:Help - + View categoryTag:Terminal - + View categoryTag:Other - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Help - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Debug - + View categoryTag:Server - + View categoryTag:Other - + View categoryTag:Other - + View categoryTag:DevStyle - + View categoryTag:General - + View categoryTag:General - + View categoryTag:Other - + View categoryTag:Other - + View categoryTag:Other - + View categoryTag:XML - + View categoryTag:XML - - + + glue move_after:PerspectiveSpacer SHOW_RESTORE_MENU - + move_after:Spacer Glue HIDEABLE SHOW_RESTORE_MENU - + glue move_after:SearchField SHOW_RESTORE_MENU - - - - - + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index index 1c6f5068..d0016cc3 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index and b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/2740986887.index b/.metadata/.plugins/org.eclipse.jdt.core/2740986887.index index 246891d4..c6e35107 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/2740986887.index and b/.metadata/.plugins/org.eclipse.jdt.core/2740986887.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/740010317.index b/.metadata/.plugins/org.eclipse.jdt.core/740010317.index index 4339c61c..4ddccfe2 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/740010317.index and b/.metadata/.plugins/org.eclipse.jdt.core/740010317.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml index 9b54cb9f..001a8e92 100644 --- a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -1,16 +1,5 @@ - - - - - - - - - - - @@ -24,13 +13,10 @@ - - - @@ -45,19 +31,33 @@ - - - - + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml index ff5d19b8..025e0458 100644 --- a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -181,4 +181,6 @@
+
+
diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png deleted file mode 100644 index 1f627fae..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png deleted file mode 100644 index 697278b8..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/10.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/10.png deleted file mode 100644 index c1e0d7d6..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/10.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/11.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/11.png deleted file mode 100644 index ffc18f4c..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/11.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/12.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/12.png deleted file mode 100644 index bc9ec45f..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/12.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png deleted file mode 100644 index 4d0a2c0e..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png deleted file mode 100644 index c1e0d7d6..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/3.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png deleted file mode 100644 index a2afc02b..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/4.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png deleted file mode 100644 index 2a4f1a7f..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/5.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/6.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/6.png deleted file mode 100644 index 57dd43cb..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/6.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/7.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/7.png deleted file mode 100644 index fd754724..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/7.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/8.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/8.png deleted file mode 100644 index 0cdcd102..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/8.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/9.png b/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/9.png deleted file mode 100644 index fbcb1225..00000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/9.png and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.m2e.logback/0.log b/.metadata/.plugins/org.eclipse.m2e.logback/0.log index 64c6e3c7..cc0df358 100644 --- a/.metadata/.plugins/org.eclipse.m2e.logback/0.log +++ b/.metadata/.plugins/org.eclipse.m2e.logback/0.log @@ -8713,3 +8713,167 @@ org.eclipse.core.runtime.CoreException: Could not resolve artifact org.apache.po 2023-03-02 18:21:47,141 [Worker-110: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource 2023-03-02 18:21:47,152 [Worker-110: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources 2023-03-02 18:21:47,165 [Worker-110: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 20:56:42,149 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 20:56:42,190 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 20:56:42,204 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 20:56:47,160 [Worker-119: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 20:56:47,183 [Worker-119: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 20:56:47,196 [Worker-119: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 20:56:51,942 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 20:56:51,971 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 20:56:51,985 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 20:56:55,232 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 20:56:55,254 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 20:56:55,270 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 22:59:50,784 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 22:59:50,849 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 22:59:50,863 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:00:01,440 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:00:01,469 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:00:01,484 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:00:22,528 [Worker-126: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:00:22,555 [Worker-126: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:00:22,568 [Worker-126: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:00:43,385 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:00:43,457 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:00:43,471 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:01:16,357 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:01:16,382 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:01:16,396 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:01:43,382 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:01:43,393 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:01:43,411 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:02:06,100 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:02:06,114 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:02:06,128 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:02:17,398 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:02:17,408 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:02:17,423 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:02:46,114 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:02:46,125 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:02:46,142 [Worker-122: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:03:40,404 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:03:40,416 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-02 23:03:40,434 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:06:02,647 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:06:02,654 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:06:02,656 [Worker-121: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeCommon\src\test\resources +2023-03-02 23:07:38,093 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:07:38,093 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:07:38,097 [Worker-128: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:08:06,187 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:08:06,187 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:08:06,191 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:08:22,181 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:08:22,182 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:08:22,186 [Worker-127: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:16:03,567 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:16:03,567 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:16:03,573 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:16:14,581 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:16:14,581 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:16:14,586 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:16:19,756 [Worker-134: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:16:19,757 [Worker-134: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:16:19,761 [Worker-134: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:16:27,589 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:16:27,589 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:16:27,593 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:16:53,850 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:16:53,851 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:16:53,855 [Worker-129: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:17:45,014 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:17:45,014 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:17:45,018 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-02 23:17:57,355 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-02 23:17:57,356 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-02 23:17:57,359 [Worker-133: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 12:12:44,521 [Worker-10: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2023-03-03 14:04:41,213 [Worker-41: Building] WARN o.e.m.c.i.embedder.EclipseLogger - The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. +2023-03-03 14:04:41,285 [Worker-41: Building] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier to /ShopmeCommon/target/classes +2023-03-03 14:04:41,953 [Worker-41: Building] WARN o.e.m.c.i.embedder.EclipseLogger - The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. +2023-03-03 14:04:41,975 [Worker-41: Building] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier to /ShopmeCommon/target/classes +2023-03-03 14:04:44,217 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 14:04:44,249 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 14:04:44,862 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 14:04:46,791 [Worker-41: Building] WARN o.e.m.c.i.embedder.EclipseLogger - The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. +2023-03-03 14:04:46,815 [Worker-41: Building] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier to /ShopmeCommon/target/classes +2023-03-03 14:05:16,473 [Worker-40: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 14:05:16,487 [Worker-40: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 14:05:16,506 [Worker-40: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 14:07:46,924 [Worker-42: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 14:07:46,942 [Worker-42: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 14:07:46,971 [Worker-42: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 14:07:49,099 [Worker-42: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 14:07:49,108 [Worker-42: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 14:07:49,122 [Worker-42: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 14:42:37,826 [Worker-54: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 14:42:37,859 [Worker-54: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 14:42:37,885 [Worker-54: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 15:52:16,424 [Worker-10: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. +2023-03-03 15:59:05,993 [Worker-11: Building] WARN o.e.m.c.i.embedder.EclipseLogger - The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. +2023-03-03 15:59:06,069 [Worker-11: Building] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier to /ShopmeCommon/target/classes +2023-03-03 15:59:06,660 [Worker-11: Building] WARN o.e.m.c.i.embedder.EclipseLogger - The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. +2023-03-03 15:59:06,695 [Worker-11: Building] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier to /ShopmeCommon/target/classes +2023-03-03 15:59:08,846 [Worker-11: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 15:59:08,894 [Worker-11: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 15:59:09,514 [Worker-11: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 15:59:11,964 [Worker-11: Building] WARN o.e.m.c.i.embedder.EclipseLogger - The artifact mysql:mysql-connector-java:jar:8.0.32 has been relocated to com.mysql:mysql-connector-j:jar:8.0.32: MySQL Connector/J artifacts moved to reverse-DNS compliant Maven 2+ coordinates. +2023-03-03 15:59:11,988 [Worker-11: Building] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier to /ShopmeCommon/target/classes +2023-03-03 15:59:23,673 [Worker-23: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 15:59:23,690 [Worker-23: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 15:59:23,710 [Worker-23: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:04:46,860 [Worker-30: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:04:46,880 [Worker-30: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:04:46,912 [Worker-30: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:05:02,318 [Worker-6: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:05:02,335 [Worker-6: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:05:02,361 [Worker-6: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:16:01,426 [Worker-28: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 16:16:01,427 [Worker-28: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:16:01,436 [Worker-28: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:17:17,673 [Worker-35: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 16:17:17,674 [Worker-35: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:17:17,680 [Worker-35: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:17:24,692 [Worker-32: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 16:17:24,692 [Worker-32: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:17:24,697 [Worker-32: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:19:14,847 [Worker-35: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:19:14,988 [Worker-35: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 16:19:14,997 [Worker-35: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeCommon\src\test\resources +2023-03-03 16:19:24,035 [Worker-39: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:19:24,045 [Worker-39: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 16:19:24,051 [Worker-39: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeCommon\src\test\resources +2023-03-03 16:23:19,129 [Worker-38: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:23:19,143 [Worker-38: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:23:19,166 [Worker-38: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:23:48,515 [Worker-38: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:23:48,525 [Worker-38: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:23:48,538 [Worker-38: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:23:57,559 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:23:57,570 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:23:57,584 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:24:26,050 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:24:26,061 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:24:26,077 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 16:24:32,241 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 16:24:32,254 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 16:24:32,272 [Worker-41: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 20:36:33,602 [Worker-45: Launching ShopmeBackEnd - ShopmeBackEndApplication] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier null to /ShopmeCommon/target/classes +2023-03-03 20:36:33,817 [Worker-45: Launching ShopmeBackEnd - ShopmeBackEndApplication] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier null to /ShopmeCommon/target/classes +2023-03-03 20:36:34,061 [Worker-45: Launching ShopmeBackEnd - ShopmeBackEndApplication] INFO o.e.m.c.i.p.WorkspaceClassifierResolverManager - Resolving P/ShopmeCommon: com.shopme:ShopmeCommon:0.0.1-SNAPSHOT with classifier null to /ShopmeCommon/target/classes +2023-03-03 21:10:07,983 [Worker-63: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 21:10:07,984 [Worker-63: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 21:10:07,989 [Worker-63: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 21:10:16,129 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 21:10:16,130 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 21:10:16,134 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 21:11:35,579 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 21:11:35,580 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 21:11:35,584 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 21:11:55,229 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 0 resource +2023-03-03 21:11:55,229 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 21:11:55,234 [Worker-64: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources +2023-03-03 22:25:30,460 [Worker-68: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 1 resource +2023-03-03 22:25:30,514 [Worker-68: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - Copying 29 resources +2023-03-03 22:25:30,528 [Worker-68: Building] INFO o.a.m.s.f.DefaultMavenResourcesFiltering - skip non existing resourceDirectory C:\Users\User\Desktop\ShopmeEcommerce\ShopmeProject\ShopmeWebParent\ShopmeBackEnd\src\test\resources diff --git a/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties b/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties index 3040c6a2..f453200f 100644 --- a/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties +++ b/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties @@ -1,2 +1,2 @@ #Cached timestamps -#Wed Mar 01 20:52:09 SGT 2023 +#Fri Mar 03 22:53:49 SGT 2023 diff --git a/.metadata/version.ini b/.metadata/version.ini index 7cfba620..d17a25c3 100644 --- a/.metadata/version.ini +++ b/.metadata/version.ini @@ -1,3 +1,3 @@ -#Thu Mar 02 10:25:50 SGT 2023 +#Fri Mar 03 15:51:05 SGT 2023 org.eclipse.core.runtime=2 org.eclipse.platform=4.26.0.v20221123-1800 diff --git a/ShopmeProject/ShopmeCommon/src/main/java/com/shopme/common/entity/Category.java b/ShopmeProject/ShopmeCommon/src/main/java/com/shopme/common/entity/Category.java index 5ba9b5cf..ebbcbbcd 100644 --- a/ShopmeProject/ShopmeCommon/src/main/java/com/shopme/common/entity/Category.java +++ b/ShopmeProject/ShopmeCommon/src/main/java/com/shopme/common/entity/Category.java @@ -12,6 +12,7 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; +import jakarta.persistence.Transient; @Entity @Table(name = "categories") @@ -158,4 +159,12 @@ public void setChildren(Set children) { this.children = children; } + @Transient + public String getImagePath() { + + if(this.id == null) return "/images/image-thumbnail.png"; + + return "/category-images/" + this.id + "/" + this.image; + } + } diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/MvcConfig.java b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/MvcConfig.java index a0dae396..556d4bc6 100644 --- a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/MvcConfig.java +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/MvcConfig.java @@ -18,23 +18,29 @@ public class MvcConfig implements WebMvcConfigurer { * the web clients (browsers) - that's the primary purpose * of using resource handlers in Spring MVC. * + * Because the assets are not located in the src/main/resources/static folder * */ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { String dirName = "user-photos"; - Path userPhotoDir = Paths.get(dirName); - String userPhotosPath = userPhotoDir.toFile().getAbsolutePath(); - // add /** to allow all files under this directory to be available to client - registry.addResourceHandler("/" + dirName + "/**") .addResourceLocations("file:/" + userPhotosPath + "/"); + + String categoryImagesDirName = "../category-images"; + Path categoryImagesDir = Paths.get(categoryImagesDirName); + String categoryImagesPath = categoryImagesDir.toFile().getAbsolutePath(); + + // add /** to allow all files under this directory to be available to client + registry.addResourceHandler("/category-images/**") + .addResourceLocations("file:/" + categoryImagesPath + "/"); + } diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryController.java b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryController.java index 6f9eea2e..f7c82387 100644 --- a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryController.java +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryController.java @@ -10,6 +10,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @@ -20,54 +21,68 @@ @Controller public class CategoryController { - + @Autowired private CategoryService service; - + @GetMapping("/categories") public String listAll(Model model) { - + List listCategories = service.listAll(); model.addAttribute("listCategories", listCategories); - + return "categories/categories"; } - - + @GetMapping("/categories/new") public String newCategory(Model model) { - + List listCategories = service.listCategoriesUsedInForm(); - + model.addAttribute("category", new Category()); model.addAttribute("listCategories", listCategories); model.addAttribute("pageTitle", "Create New Category"); - + return "categories/category_form"; - + } - + @PostMapping("/categories/save") - public String saveCategory(@ModelAttribute("category") Category category, - RedirectAttributes redirectAttributes, + public String saveCategory(@ModelAttribute("category") Category category, RedirectAttributes redirectAttributes, @RequestParam("fileImage") MultipartFile multipartFile) throws IOException { - - String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); - category.setImage(fileName); - - Category savedCategory = service.save(category); - String uploadDir = "../category-images/" + savedCategory.getId(); - FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); - - + + if (!multipartFile.isEmpty()) { + String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename()); + category.setImage(fileName); + + Category savedCategory = service.save(category); + String uploadDir = "../category-images/" + savedCategory.getId(); + + FileUploadUtil.cleanDir(uploadDir); + FileUploadUtil.saveFile(uploadDir, fileName, multipartFile); + } else { + service.save(category); + } + redirectAttributes.addFlashAttribute("message", "the category have been saved successfully"); - - return "redirect:/categories"; } - -} - + @GetMapping("/categories/edit/{id}") + public String editCategory(@PathVariable(name = "id") Integer id, Model model, RedirectAttributes ra) { + try { + Category category = service.get(id); + List listCategories = service.listCategoriesUsedInForm(); + + model.addAttribute("category", category); + model.addAttribute("listCategories", listCategories); + model.addAttribute("pageTitle", "Edit Category (ID: " + id + ")"); + return "categories/category_form"; + } catch (CategoryNotFoundException ex) { + ra.addFlashAttribute("message", ex.getMessage()); + return "redirect:/categories"; + } + } +} diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryNotFoundException.java b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryNotFoundException.java new file mode 100644 index 00000000..f425c50a --- /dev/null +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryNotFoundException.java @@ -0,0 +1,10 @@ +package com.shopme.admin.category; + +public class CategoryNotFoundException extends Exception { + + public CategoryNotFoundException(String message) { + super(message); + } + + +} diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryService.java b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryService.java index 8fde603c..af3fe72c 100644 --- a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryService.java +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/java/com/shopme/admin/category/CategoryService.java @@ -2,9 +2,11 @@ import java.util.ArrayList; import java.util.List; +import java.util.NoSuchElementException; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.support.Repositories; import org.springframework.stereotype.Service; import com.shopme.common.entity.Category; @@ -34,7 +36,7 @@ private List listHierarchicalCategories(List rootCategories) for (Category subCategory : children) { String name = "--" + subCategory.getName(); hierarchicalCategories.add(Category.copyFull(subCategory, name)); - + listHierarchicalCategories(hierarchicalCategories, subCategory, 1); } } @@ -106,7 +108,6 @@ private void listSubCategoriesUsedInForm(List categoriesUsedInForm, Ca for (int i = 0; i < newSubLevel; i++) { name += "--"; } - name += subCategory.getName(); categoriesUsedInForm.add(Category.copyIdAndName(subCategory.getId(), name)); @@ -115,4 +116,16 @@ private void listSubCategoriesUsedInForm(List categoriesUsedInForm, Ca } + public Category get(Integer id) throws CategoryNotFoundException { + + try { + return repo.findById(id).get(); + + } catch (NoSuchElementException ex) { + + throw new CategoryNotFoundException("could not find any category with the ID: " + id); + } + + } + } diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/categories.html b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/categories.html index a6a3a54d..0a41de2e 100644 --- a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/categories.html +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/categories.html @@ -55,14 +55,16 @@

Manage Categories

[[${cat.id}]] - + + + [[${cat.name}]] [[${cat.alias}]]
-
+
diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/category_form.html b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/category_form.html index 4dd231f4..ad710d66 100644 --- a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/category_form.html +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/categories/category_form.html @@ -50,10 +50,10 @@

Manage Categories | [[${pageTitle}]]

+ th:required="${category.imagePath == null}" required class="mb-2" />
- Image preview
diff --git a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/fragments.html b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/fragments.html index 0dc26190..0c854e1a 100644 --- a/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/fragments.html +++ b/ShopmeProject/ShopmeWebParent/ShopmeBackEnd/src/main/resources/templates/fragments.html @@ -58,9 +58,9 @@ title="Enable this category">
-
+
-