Commit d119a25f authored by Ghitha Dinan's avatar Ghitha Dinan

Initial commit

parents
Pipeline #375 failed with stages
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
FROM openjdk:17-jdk-alpine
ADD target/inovasi-daerah-master-0.0.1-SNAPSHOT.jar /inovasi-daerah-master-0.0.1-SNAPSHOT.jar
EXPOSE 8080
CMD ["java", "-jar", "/inovasi-daerah-master-0.0.1-SNAPSHOT.jar"]
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>id.co.sangkuriang</groupId>
<artifactId>inovasi-daerah-master</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>inovasi-daerah-master</name>
<description>Master Pusat Jejaring Inovasi Daerah</description>
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.5.30</kotlin.version>
<start-class>id.co.sangkuriang.inovasi.daerah.master.InovasiDaerahMasterApplicationKt</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.7</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.18.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- send email -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>${start-class}</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<jvmTarget>1.8</jvmTarget>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
package id.co.sangkuriang.inovasi.daerah.master
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class InovasiDaerahMasterApplication
fun main(args: Array<String>) {
runApplication<InovasiDaerahMasterApplication>(*args)
}
package id.co.sangkuriang.inovasi.daerah.master.config
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
@Configuration
class SecurityConfig : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http.httpBasic()?.disable()
http.cors()?.and()?.csrf()?.disable()
}
}
package id.co.sangkuriang.inovasi.daerah.master.config
import id.co.sangkuriang.inovasi.daerah.master.constant.TOKEN_FILTER_PATTERNS
import id.co.sangkuriang.inovasi.daerah.master.interceptor.TokenInterceptor
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
class SpringWebConfig : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedMethods("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "PUT", "TRACE")
.allowedOrigins("*")
.allowedHeaders("*")
.maxAge(60000)
}
@Bean
fun tokenFilter(): FilterRegistrationBean<TokenInterceptor>? {
val registrationBean: FilterRegistrationBean<TokenInterceptor> =
FilterRegistrationBean<TokenInterceptor>()
TOKEN_FILTER_PATTERNS.forEach {
registrationBean.addUrlPatterns("/$it/*")
}
registrationBean.filter = TokenInterceptor()
registrationBean.order = 1
return registrationBean
}
}
package id.co.sangkuriang.inovasi.daerah.master.constant
import java.io.File
const val ROOT_DIR = "C:\\Users\\ghith\\Desktop\\inovasi_daerah_master\\"
//const val ROOT_DIR = "/home/inovasi_daerah_master/data/"
val UPLOAD_DIR = "${ROOT_DIR}uploads${File.separator}"
val UPLOAD_USER_DIR = "${UPLOAD_DIR}users"
val UPLOAD_APPLICATION_DIR = "${UPLOAD_DIR}application"
val UPLOAD_BANNER_APPLICATION_DIR = "$UPLOAD_APPLICATION_DIR${File.separator}video"
val UPLOAD_IMAGE_APPLICATION_QR_DIR = "$UPLOAD_APPLICATION_DIR${File.separator}qr"
val UPLOAD_IMAGE_APPLICATION_DETAIL_DIR = "$UPLOAD_APPLICATION_DIR${File.separator}detail"
val UPLOAD_ICON_APPLICATION_CATEGORY_DIR = "${UPLOAD_DIR}apllication_category/icon"
val UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR = "${UPLOAD_DIR}apllication_category/image"
package id.co.sangkuriang.inovasi.daerah.master.constant
const val ROLE_ADMIN_LITBANG_ID = "8c41a810-105d-11ec-b287-bfa9c35a8733"
const val ROLE_USER_ID = "8653d626-105d-11ec-b286-a7eede28118f"
const val ROLE_ADMIN_PEMERINTAH_KOTA_BANDUNG = "01a0a300-105d-11ec-920d-6bb50f1bde1a"
const val ROLE_ADMIN_PEMERINTAH_PROVINSI_JAWA_BARAT = "efff3828-105c-11ec-920c-dbd208503209"
package id.co.sangkuriang.inovasi.daerah.master.constant
const val SECRET = "PUJA-INDAH"
const val TOKEN_PREFIX = "Bearer "
const val HEADER_STRING = "Authorization"
val TOKEN_FILTER_PATTERNS =
listOf(
"tag"
)
package id.co.sangkuriang.inovasi.daerah.master.constant
const val VALIDATOR_MSG_REQUIRED = "harus di isi"
const val VALIDATOR_MSG_NOT_VALID = "tidak valid"
const val VALIDATOR_MSG_HAS_USED = "sudah di pakai"
const val VALIDATOR_MSG_NOT_FOUND = "tidak di temukan"
const val VALIDATOR_MSG_DUPLICATE = "Data sudah ada di database"
package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import javax.servlet.http.HttpServletRequest
import javax.validation.Valid
@RestController
@RequestMapping(path = ["application-category"])
class ApplicationCategoryController {
@Autowired
private lateinit var service: ApplicationCategoryService
@GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return service.getAll(page)
}
@GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? {
return service.getDetail(id)
}
@PostMapping(value = [""], produces = ["application/json"])
fun saveData(
@Valid @ModelAttribute request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest
): ResponseEntity<*>? {
return service.saveData(request, httpServletRequest)
}
@PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(
@PathVariable id: String,
@Valid @ModelAttribute request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest
): ResponseEntity<*>? {
return service.updateData(id, request, httpServletRequest)
}
@DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest): ResponseEntity<*>? {
return service.deleteData(request)
}
}
package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import javax.validation.Valid
@RestController
@RequestMapping(path = ["province"])
class ProvinceController {
@Autowired
private lateinit var service: ProvinceService
@GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return service.getAll(page)
}
@PostMapping(value = ["datatable"], produces = ["application/json"])
fun datatable(@RequestBody req: Pagination2Request): ResponseEntity<*>? {
return service.datatable(req)
}
@GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? {
return service.getDetail(id)
}
@PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Province): ResponseEntity<*>? {
return service.saveData(request)
}
@PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(@PathVariable id: String, @Valid @RequestBody request: Province): ResponseEntity<*>? {
return service.updateData(id, request)
}
@DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest): ResponseEntity<*>? {
return service.deleteData(request)
}
}
package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import javax.validation.Valid
@RestController
@RequestMapping(path = ["regency"])
class RegencyController {
@Autowired
private lateinit var service: RegencyService
@GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return service.getAll(page)
}
@GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? {
return service.getDetail(id)
}
@PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Regency): ResponseEntity<*>? {
return service.saveData(request)
}
@PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(@PathVariable id: String, @Valid @RequestBody request: Regency): ResponseEntity<*>? {
return service.updateData(id, request)
}
@DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest): ResponseEntity<*>? {
return service.deleteData(request)
}
}
package id.co.sangkuriang.inovasi.daerah.master.controller
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag
import id.co.sangkuriang.inovasi.daerah.master.service.TagService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import javax.validation.Valid
@RestController
@RequestMapping(path = ["tag"])
class TagController {
@Autowired
private lateinit var service: TagService
@GetMapping(value = [""], produces = ["application/json"])
fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return service.getAll(page)
}
@GetMapping(value = ["{id}"], produces = ["application/json"])
fun getDetail(@PathVariable id: String): ResponseEntity<*>? {
return service.getDetail(id)
}
@PostMapping(value = [""], produces = ["application/json"])
fun saveData(@Valid @RequestBody request: Tag): ResponseEntity<*>? {
return service.saveData(request)
}
@PutMapping(value = ["{id}"], produces = ["application/json"])
fun updateData(@PathVariable id: String, @Valid @RequestBody request: Tag): ResponseEntity<*>? {
return service.updateData(id, request)
}
@DeleteMapping(value = [""], produces = ["application/json"])
fun deleteData(@Valid @RequestBody request: DeleteDataRequest): ResponseEntity<*>? {
return service.deleteData(request)
}
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
/**
*
* response status code indicates that the server cannot or will not process
* the request due to something that is perceived to be a client error
* (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
*/
class BadRequestException : BaseException {
constructor(message: String? = "Bad Request") {
this.code = "400"
this.message = message!!
this.status = HttpStatus.BAD_REQUEST
}
constructor(message: String? = "Bad Request", data: Any?) {
this.code = "400"
this.message = message!!
this.status = HttpStatus.BAD_REQUEST
this.data = data
}
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
open class BaseException : RuntimeException() {
var code = "500"
override var message = ""
var status = HttpStatus.INTERNAL_SERVER_ERROR
var data: Any? = null
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
/**
* The 409 (Conflict) status code indicates that the request could not
* be completed due to a conflict with the current state of the target
* resource. This code is used in situations where the user might be
* able to resolve the conflict and resubmit the request. The server
* SHOULD generate a payload that includes enough information for a user
* to recognize the source of the conflict.
*/
class ConflictException : BaseException {
constructor() {
this.code = "409"
this.message = "Conflict"
this.status = HttpStatus.CONFLICT
}
constructor(message: String?) {
this.code = "409"
this.message = message!!
this.status = HttpStatus.CONFLICT
}
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
/**
* The 500 (Internal Server Error) status code indicates that the server
* encountered an unexpected condition that prevented it from fulfilling
* the request.
*/
class InternalServerErrorException : BaseException {
constructor() {
this.code = "500"
this.message = "Internal Server Error"
this.status = HttpStatus.INTERNAL_SERVER_ERROR
}
constructor(message: String?) {
this.code = "500"
this.message = message!!
this.status = HttpStatus.INTERNAL_SERVER_ERROR
}
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
/**
* The 404 (Not Found) status code indicates that the origin server did
* not find a current representation for the target resource or is not
* willing to disclose that one exists. A 404 status code does not
* indicate whether this lack of representation is temporary or
* permanent.
*/
class NotFoundException : BaseException {
constructor() {
this.code = "404"
this.message = "Not Found"
this.status = HttpStatus.NOT_FOUND
}
constructor(message: String?) {
this.code = "404"
this.message = message!!
this.status = HttpStatus.NOT_FOUND
}
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
/**
* The server understands the content type of the request entity,
* and the syntax of the request entity is correct
* but was unable to process the contained instructions.
*/
class UnProcessableEntityException : BaseException {
constructor() {
this.code = "422"
this.message = "UnProcessable Entity"
this.status = HttpStatus.UNPROCESSABLE_ENTITY
}
constructor(message: String?) {
this.code = "422"
this.message = message!!
this.status = HttpStatus.UNPROCESSABLE_ENTITY
}
constructor(message: String? = null, data: Any? = null) {
this.code = "422"
this.message = message ?: "UnProcessable Entity"
this.status = HttpStatus.UNPROCESSABLE_ENTITY
this.data = data
}
}
package id.co.sangkuriang.inovasi.daerah.master.exception
import org.springframework.http.HttpStatus
/**
* The 415 (Unsupported Media Type) status code indicates that the
* origin server is refusing to service the request because the payload
* is in a format not supported by this method on the target resource.
* The format problem might be due to the request's indicated
* Content-Type or Content-Encoding, or as a result of inspecting the
* data directly.
*/
class UnsupportedMediaTypeException : BaseException {
constructor() {
this.code = "415"
this.message = "Unsupported Media Type"
this.status = HttpStatus.UNSUPPORTED_MEDIA_TYPE
}
constructor(message: String?) {
this.code = "415"
this.message = message!!
this.status = HttpStatus.UNSUPPORTED_MEDIA_TYPE
}
}
package id.co.sangkuriang.inovasi.daerah.master.helpers
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
fun responseSuccess(message: String = "Success", data: Any? = null): ResponseEntity<*> {
return ResponseEntity<Any?>(
ReturnData(
success = true,
message = message,
data = data
),
HttpStatus.OK
)
}
fun responseCreated(message: String = "Created", data: Any? = null): ResponseEntity<*> {
return ResponseEntity<Any?>(
ReturnData(
success = true,
message = message,
data = data
),
HttpStatus.CREATED
)
}
fun responseInternalServerError(message: String = "Internal Server Error", data: Any? = null): ResponseEntity<*> {
return ResponseEntity<Any?>(
ReturnData(
success = false,
message = message,
data = data
),
HttpStatus.INTERNAL_SERVER_ERROR
)
}
fun responseNotFound(message: String = "Not Found", data: Any? = null): ResponseEntity<*> {
return ResponseEntity<Any?>(
ReturnData(
success = false,
message = message,
data = data
),
HttpStatus.NOT_FOUND
)
}
fun responseUnprocessableEntity(message: String = "Unprocessable Entity", data: Any? = null): ResponseEntity<*> {
return ResponseEntity<Any?>(
ReturnData(
success = false,
message = message,
data = data
),
HttpStatus.UNPROCESSABLE_ENTITY
)
}
fun responseBadRequest(message: String = "Bad Request", data: Any? = null): ResponseEntity<*> {
return ResponseEntity<Any?>(
ReturnData(
success = false,
message = message,
data = data
),
HttpStatus.BAD_REQUEST
)
}
package id.co.sangkuriang.inovasi.daerah.master.interceptor
import com.fasterxml.jackson.databind.ObjectMapper
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.utility.getUsersLogin
import org.slf4j.LoggerFactory
import org.springframework.core.annotation.Order
import org.springframework.stereotype.Component
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.util.ContentCachingRequestWrapper
import org.springframework.web.util.ContentCachingResponseWrapper
import java.time.Duration
import java.time.Instant
import java.util.*
import javax.servlet.Filter
import javax.servlet.FilterChain
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
@Suppress("UNCHECKED_CAST")
@Component
@Order(2)
class LogInterceptor : Filter {
override fun doFilter(request: ServletRequest?, response: ServletResponse?, chain: FilterChain?) {
val time = Instant.now()
val req = ContentCachingRequestWrapper(request as HttpServletRequest)
val res = response as HttpServletResponse
val responseCacheWrapperObject = ContentCachingResponseWrapper(res)
chain?.doFilter(req, responseCacheWrapperObject)
val responseArray = responseCacheWrapperObject.contentAsByteArray.toString(Charsets.UTF_8)
responseCacheWrapperObject.copyBodyToResponse()
writeLog(req, responseArray, response, time)
}
private fun writeLog(
httpServletRequest: ContentCachingRequestWrapper,
responseArray: String,
httpServletResponse: HttpServletResponse,
startTime: Instant
) {
var requestUri = httpServletRequest.requestURI
val requestInfo: MutableMap<String, Any> = getRequestInfo(httpServletRequest, httpServletResponse)
try {
if (httpServletRequest.method == RequestMethod.GET.toString()) {
if (requestInfo["param"] != null) {
val paramMap: Map<String, Any> = requestInfo["param"] as Map<String, Any>
requestUri += "?"
var i = 0
paramMap.forEach {
if (i > 0) {
requestUri += "&"
}
requestUri += "$it"
i++
}
requestInfo.remove("param")
}
}
val returnData: ReturnData? = null
try {
ObjectMapper().readValue(responseArray, ReturnData::class.java)
} catch (e: Exception) {
}
try {
requestInfo["userData"] = getUsersLogin() as Any
} catch (e: Exception) {
}
var success = false
returnData?.let {
requestInfo["responseData"] = it
if (returnData.success!!) {
success = true
}
} ?: kotlin.run {
requestInfo["responseData"] = responseArray
}
requestInfo["responseCode"] = httpServletResponse.status
val now = Instant.now()
requestInfo["requestTime"] = Duration.between(startTime, now).toMillis().toDouble() / 1000
val res = ObjectMapper().writeValueAsString(requestInfo)
LoggerFactory.getLogger("access.log").info(
getLogDescription(success, requestUri, httpServletRequest.method),
res.replace("\\\"", "\"")
)
println("requestInfo => $res")
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun getRequestInfo(
httpRequest: ContentCachingRequestWrapper,
httpServletResponse: HttpServletResponse
): MutableMap<String, Any> {
val requestHeaderMap = mutableMapOf<String, Any>()
val requestParamMap = mutableMapOf<String, Any>()
val responseHeaderMap = mutableMapOf<String, Any>()
try {
val requestHeaderNames: Enumeration<*> = httpRequest.headerNames
while (requestHeaderNames.hasMoreElements()) {
val headerName = requestHeaderNames.nextElement() as String
requestHeaderMap[headerName] = httpRequest.getHeader(headerName)
}
val params: Enumeration<*> = httpRequest.parameterNames
while (params.hasMoreElements()) {
val paramName = params.nextElement() as String
requestParamMap[paramName] = httpRequest.getParameter(paramName)
}
val reqBody = extractRequestBody(httpRequest)
if (reqBody != "") {
val result: HashMap<*, *>? = ObjectMapper().readValue(
reqBody,
HashMap::class.java
)
if (!result.isNullOrEmpty()) {
requestParamMap.putAll(result as MutableMap<String, Any>)
}
}
httpServletResponse.headerNames.forEach {
responseHeaderMap[it] = httpServletResponse.getHeader(it)
}
} catch (e: Exception) {
e.printStackTrace()
}
return mutableMapOf(
"requestHeader" to requestHeaderMap,
"requestParam" to requestParamMap,
"responseHeader" to responseHeaderMap
)
}
private fun extractRequestBody(request: ContentCachingRequestWrapper): String {
if ("POST".equals(request.method, ignoreCase = true) || "PUT".equals(request.method, ignoreCase = true)) {
val content = request.contentAsByteArray
return String(content, Charsets.UTF_8)
}
return ""
}
private fun getLogDescription(success: Boolean, path: String, method: String): String {
var info = "INFO"
if (!success) {
info = "ERROR"
}
return "$info - $path - $method : {}"
}
}
package id.co.sangkuriang.inovasi.daerah.master.interceptor
import com.auth0.jwt.JWT
import com.auth0.jwt.algorithms.Algorithm
import com.auth0.jwt.exceptions.JWTCreationException
import com.auth0.jwt.exceptions.JWTDecodeException
import com.auth0.jwt.exceptions.JWTVerificationException
import com.fasterxml.jackson.databind.ObjectMapper
import id.co.sangkuriang.inovasi.daerah.master.constant.HEADER_STRING
import id.co.sangkuriang.inovasi.daerah.master.constant.SECRET
import id.co.sangkuriang.inovasi.daerah.master.constant.TOKEN_PREFIX
import id.co.sangkuriang.inovasi.daerah.master.model.response.ReturnData
import id.co.sangkuriang.inovasi.daerah.master.utility.getPathUrl
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.web.util.ContentCachingRequestWrapper
import javax.servlet.Filter
import javax.servlet.FilterChain
import javax.servlet.ServletRequest
import javax.servlet.ServletResponse
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
class TokenInterceptor : Filter {
override fun doFilter(request: ServletRequest?, response: ServletResponse?, chain: FilterChain?) {
val req = ContentCachingRequestWrapper(request as HttpServletRequest)
val res = response as HttpServletResponse
// Read the Authorization header, where the JWT token should be
val header = req.getHeader(HEADER_STRING)
// If header doesn't contain Bearer or is null will return nothing and exit
if (header == null || !header.startsWith(TOKEN_PREFIX)) {
responseException(res, "Sorry, your provided token information not exists")
return
}
var authentication: UsernamePasswordAuthenticationToken? = null
var successAuth = true
try {
authentication = getAuthentication(req)
} catch (e: JWTDecodeException) {
successAuth = false
responseException(res, e.message.toString())
} catch (e: JWTCreationException) {
successAuth = false
responseException(res, e.message.toString())
} catch (e: JWTVerificationException) {
successAuth = false
responseException(res, e.message.toString())
} catch (e: IllegalArgumentException) {
successAuth = false
responseException(res, e.message.toString())
}
SecurityContextHolder.getContext().authentication = authentication
if (successAuth) {
chain?.doFilter(request, response)
}
}
private fun responseException(response: HttpServletResponse, message: String) {
val json = ObjectMapper().writeValueAsString(
ReturnData(
message = message
)
)
response.contentType = "application/json"
response.status = HttpServletResponse.SC_UNAUTHORIZED
response.writer.write(json)
response.writer.flush()
response.writer.close()
}
@Throws(
JWTDecodeException::class,
JWTCreationException::class,
JWTVerificationException::class,
IllegalArgumentException::class
)
private fun getAuthentication(request: HttpServletRequest): UsernamePasswordAuthenticationToken? {
val token = request.getHeader(HEADER_STRING)
if (token != null) {
// parse jwt token from request and validate it internal authentication
val jwt =
JWT.require(Algorithm.HMAC512(SECRET.toByteArray())).build().verify(token.replace(TOKEN_PREFIX, ""))
return if (jwt.subject != null) { // return principal username
val pathUrl = getPathUrl(request)
val audience = jwt.audience?.get(0)
println("pathUrl => $audience - ${request.method} - $pathUrl")
if (audience == "user") {
val tokenParse = token + System.currentTimeMillis()
JWT.require(Algorithm.HMAC512(SECRET.toByteArray())).build()
.verify(tokenParse.replace(TOKEN_PREFIX, ""))
}
UsernamePasswordAuthenticationToken(
jwt.subject,
audience,
ArrayList<GrantedAuthority>()
)
} else {
null
}
}
return null
}
}
package id.co.sangkuriang.inovasi.daerah.master.model.request
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUIRED
import org.springframework.web.multipart.MultipartFile
import javax.validation.constraints.NotEmpty
data class ApplicationCategoryRequest(
@field:NotEmpty(message = "Nama $VALIDATOR_MSG_REQUIRED")
var name: String? = null,
var icon: MultipartFile? = null,
var image: MultipartFile? = null
)
package id.co.sangkuriang.inovasi.daerah.master.model.request
import javax.validation.constraints.NotEmpty
class DeleteDataRequest {
@field:NotEmpty
var id: String? = null
}
package id.co.sangkuriang.inovasi.daerah.master.model.request
class Pagination2Request(
var enablePage: Boolean? = true,
var page: Int? = 0,
var size: Int? = 10,
var sort: List<Sort>? = emptyList(),
var paramLike: List<ParamSearch>? = emptyList(),
var paramIs: List<ParamSearch>? = emptyList()
)
class Sort(
var field: String? = null,
var direction: String? = null
)
class ParamSearch(
var field: String? = null,
var dataType: String? = null,
var value: String? = null
)
package id.co.sangkuriang.inovasi.daerah.master.model.request
class PaginationRequest(
var enablePage: Int? = 1,
var page: Int? = 0,
var size: Int? = 10,
var sort: String? = "desc",
var sortBy: String? = "updatedAt",
var param: String? = ""
)
package id.co.sangkuriang.inovasi.daerah.master.model.response
data class ReturnData(
var success: Boolean? = false,
var data: Any? = null,
var message: String? = null
)
package id.co.sangkuriang.inovasi.daerah.master.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import java.util.*
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.validation.constraints.NotEmpty
@Entity
@Table(name = "application_category")
data class ApplicationCategory(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "name")
@field:NotEmpty
var name: String? = null,
@Column(name = "icon")
var icon: String? = null,
@Column(name = "image")
var image: String? = null,
@Column(name = "created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
package id.co.sangkuriang.inovasi.daerah.master.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUIRED
import java.util.*
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.validation.constraints.NotEmpty
@Entity
@Table(name = "province")
data class Province(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "name")
@field:NotEmpty(message = "Nama $VALIDATOR_MSG_REQUIRED")
var name: String? = null,
@Column(name = "created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
package id.co.sangkuriang.inovasi.daerah.master.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUIRED
import java.util.*
import javax.persistence.*
import javax.validation.constraints.NotEmpty
@Entity
@Table(name = "regency")
data class Regency(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "name")
@field:NotEmpty(message = "Nama $VALIDATOR_MSG_REQUIRED")
var name: String? = null,
@Column(name = "province_id")
@field:NotEmpty(message = "Provinsi $VALIDATOR_MSG_REQUIRED")
var provinceId: String? = null,
@ManyToOne
@JoinColumn(name = "province_id", insertable = false, updatable = false, nullable = true)
var province: Province? = null,
@Column(name = "created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
package id.co.sangkuriang.inovasi.daerah.master.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUIRED
import java.util.*
import javax.persistence.*
import javax.validation.constraints.NotEmpty
@Entity
@Table(name = "role")
data class Role(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "name")
@field:NotEmpty(message = "Nama $VALIDATOR_MSG_REQUIRED")
var name: String? = null,
@Column(name = "province_id")
var provinceId: String? = null,
@ManyToOne
@JoinColumn(name = "province_id", insertable = false, updatable = false, nullable = true)
var province: Province? = null,
@Column(name = "regency_id")
var regencyId: String? = null,
@ManyToOne
@JoinColumn(name = "regency_id", insertable = false, updatable = false, nullable = true)
var regency: Regency? = null,
@Column(name = "created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
package id.co.sangkuriang.inovasi.daerah.master.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_REQUIRED
import java.util.*
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.validation.constraints.NotEmpty
@Entity
@Table(name = "tag")
data class Tag(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "name")
@field:NotEmpty(message = "Nama $VALIDATOR_MSG_REQUIRED")
var name: String? = null,
@Column(name = "created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
package id.co.sangkuriang.inovasi.daerah.master.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import java.util.*
import javax.persistence.*
@Entity
@Table(name = "users")
data class Users(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "nik")
var nik: String? = null,
@Column(name = "password")
@JsonIgnore
var password: String? = null,
@Column(name = "full_name")
var fullName: String? = null,
@Column(name = "image")
var image: String? = null,
@Column(name = "phone_number")
var phoneNumber: String? = null,
@Column(name = "email")
var email: String? = null,
@Column(name = "role_id")
var roleId: String? = null,
@ManyToOne(cascade = [CascadeType.MERGE])
@JoinColumn(name = "role_id", insertable = false, updatable = false, nullable = true)
var role: Role? = null,
@Column(name = "confirmed")
@JsonIgnore
var confirmed: Boolean? = false,
@Column(name = "confirmed_date")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
@JsonIgnore
var confirmedDate: Date? = null,
@Column(name = "created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
package id.co.sangkuriang.inovasi.daerah.master.repository
import id.co.sangkuriang.inovasi.daerah.master.pojo.ApplicationCategory
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import java.util.*
interface ApplicationCategoryRepository : JpaRepository<ApplicationCategory, String> {
@Query(
"SELECT u FROM ApplicationCategory u " +
"WHERE u.active = true " +
"AND (LOWER(u.name) LIKE %:param%)"
)
fun getListPagination(@Param("param") param: String?, pageable: Pageable?): Page<ApplicationCategory?>?
fun findByIdAndActive(id: String?, active: Boolean = true): Optional<ApplicationCategory>
@Query("FROM ApplicationCategory WHERE LOWER(name) = LOWER(:name) AND active = true")
fun findByName(name: String?): Optional<ApplicationCategory>
}
package id.co.sangkuriang.inovasi.daerah.master.repository
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import java.util.*
interface ProvinceRepository : JpaRepository<Province, String> {
@Query(
"SELECT u FROM Province u " +
"WHERE u.active = true " +
"AND (LOWER(u.name) LIKE %:param%)"
)
fun getListPagination(@Param("param") param: String?, pageable: Pageable?): Page<Province?>?
fun findByIdAndActive(id: String?, active: Boolean = true): Optional<Province>
@Query("FROM Province WHERE LOWER(name) = LOWER(:name) AND active = true")
fun findByName(name: String?): Optional<Province>
}
package id.co.sangkuriang.inovasi.daerah.master.repository
import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import java.util.*
interface RegencyRepository : JpaRepository<Regency, String> {
@Query(
"SELECT u FROM Regency u " +
"WHERE u.active = true " +
"AND (LOWER(u.name) LIKE %:param%)"
)
fun getListPagination(@Param("param") param: String?, pageable: Pageable?): Page<Regency?>?
fun findByIdAndActive(id: String?, active: Boolean = true): Optional<Regency>
@Query("FROM Regency WHERE LOWER(name) = LOWER(:name) AND provinceId = :provinceId AND active = true")
fun findByNameProvinceId(name: String?, provinceId: String?): Optional<Regency>
}
package id.co.sangkuriang.inovasi.daerah.master.repository
import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import java.util.*
interface TagRepository : JpaRepository<Tag, String> {
@Query(
"SELECT t FROM Tag t " +
"WHERE t.active = true " +
"AND (LOWER(t.name) LIKE %:param%)"
)
fun getListPagination(@Param("param") param: String?, pageable: Pageable?): Page<Tag?>?
fun findByIdAndActive(id: String?, active: Boolean = true): Optional<Tag>
@Query("FROM Tag WHERE LOWER(name) = LOWER(:name) AND active = true")
fun findByName(name: String?): Optional<Tag>
}
package id.co.sangkuriang.inovasi.daerah.master.repository.native
import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request
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.support.PageableExecutionUtils
import javax.persistence.EntityManager
import javax.persistence.Query
@Suppress("UNCHECKED_CAST")
open class BaseRepositoryNative<T>(_class: Class<T>?) {
private val collection = _class?.simpleName
@Autowired
private lateinit var em: EntityManager
open fun getPage(req: Pagination2Request): Page<T>? {
try {
var queryStr = "SELECT s FROM $collection s WHERE s.active = true"
if (!req.paramLike.isNullOrEmpty()) {
queryStr += " AND ("
req.paramLike?.forEachIndexed { index, element ->
queryStr += "LOWER(s.${element.field}) LIKE LOWER(CONCAT('%',:${element.field},'%'))"
if ((index + 1) < req.paramLike!!.size) {
queryStr += " OR "
}
}
queryStr += ")"
}
if (!req.paramIs.isNullOrEmpty()) {
queryStr += " AND ("
req.paramIs?.forEachIndexed { index, element ->
queryStr += "s.${element.field} = :${element.field}"
if ((index + 1) < req.paramIs!!.size) {
queryStr += " AND "
}
}
queryStr += ")"
}
if (!req.sort.isNullOrEmpty()) {
queryStr += " ORDER BY "
req.sort?.forEachIndexed { index, element ->
queryStr += "s.${element.field} ${element.direction}"
if ((index + 1) < req.sort!!.size) {
queryStr += ", "
}
}
}
val query: Query = em.createQuery(queryStr, Any::class.java)
req.paramLike?.forEach {
query.setParameter(it.field, it.value)
}
req.paramIs?.forEach {
query.setParameter(it.field, it.value)
}
if (req.enablePage == true) {
query.firstResult = req.page!! * req.size!!
query.maxResults = req.size!!
}
val list: List<T> = query.resultList as List<T>
var pageable: Pageable = PageRequest.of(req.page!!, req.size!!)
if (req.enablePage == true) {
pageable = Pageable.unpaged()
}
return PageableExecutionUtils.getPage(
list,
pageable
) {
list.size.toLong()
}
} catch (e: Exception) {
throw e
}
}
}
package id.co.sangkuriang.inovasi.daerah.master.repository.native
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import org.springframework.stereotype.Repository
@Repository
class ProvinceRepositoryNative : BaseRepositoryNative<Province>(Province::class.java)
package id.co.sangkuriang.inovasi.daerah.master.repository.native.impl
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_HAS_USED
import id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag
import id.co.sangkuriang.inovasi.daerah.master.repository.TagRepository
import id.co.sangkuriang.inovasi.daerah.master.service.TagService
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.http.ResponseEntity
import org.springframework.stereotype.Service
import java.util.*
@Suppress("NAME_SHADOWING")
@Service
class TagServiceImpl : TagService {
@Autowired
private lateinit var repo: TagRepository
override fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return try {
val page: Page<Tag?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC
if (page.sort?.lowercase(Locale.getDefault()).equals("desc")) {
direction = Sort.Direction.DESC
}
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = PageRequest.of(page.page!!, page.size!!, Sort.by(direction, page.sortBy))
)
} else {
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = Pageable.unpaged()
)
}
responseSuccess(data = page)
} catch (e: Exception) {
throw e
}
}
override fun getDetail(id: String): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
return responseSuccess(data = data)
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun saveData(request: Tag): ResponseEntity<*>? {
return try {
validateRequest(request)
val save = Tag()
save.name = request.name
responseCreated(data = repo.save(save))
} catch (e: Exception) {
throw e
}
}
override fun updateData(id: String, request: Tag): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
validateRequest(request, id)
val update = data.get()
update.name = request.name
update.updatedAt = Date()
return responseSuccess(data = repo.save(update))
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun deleteData(request: DeleteDataRequest): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(request.id)
if (data.isPresent) {
val update = data.get()
update.active = false
update.updatedAt = Date()
repo.save(update)
return responseSuccess()
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
private fun validateRequest(request: Tag, id: String? = null) {
try {
val listMessage = mutableListOf<Map<String, String>>()
val checkName = repo.findByName(request.name)
if (checkName.isPresent) {
val msgCheckName = mapOf("name" to "Nama ${request.name} $VALIDATOR_MSG_HAS_USED")
if (id == null) {
listMessage.add(msgCheckName)
} else {
if (checkName.get().id != id) {
listMessage.add(msgCheckName)
}
}
}
if (listMessage.isNotEmpty()) {
throw BadRequestException(data = listMessage)
}
} catch (e: Exception) {
throw e
}
}
}
package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import org.springframework.http.ResponseEntity
import javax.servlet.http.HttpServletRequest
interface ApplicationCategoryService {
fun getAll(page: PaginationRequest): ResponseEntity<*>?
fun getDetail(id: String): ResponseEntity<*>?
fun saveData(request: ApplicationCategoryRequest, httpServletRequest: HttpServletRequest): ResponseEntity<*>?
fun updateData(
id: String,
request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest
): ResponseEntity<*>?
fun deleteData(request: DeleteDataRequest): ResponseEntity<*>?
}
package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import org.springframework.http.ResponseEntity
interface ProvinceService {
fun getAll(page: PaginationRequest): ResponseEntity<*>?
fun getDetail(id: String): ResponseEntity<*>?
fun saveData(request: Province): ResponseEntity<*>?
fun updateData(id: String, request: Province): ResponseEntity<*>?
fun deleteData(request: DeleteDataRequest): ResponseEntity<*>?
fun datatable(req: Pagination2Request): ResponseEntity<*>?
}
package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import org.springframework.http.ResponseEntity
interface RegencyService {
fun getAll(page: PaginationRequest): ResponseEntity<*>?
fun getDetail(id: String): ResponseEntity<*>?
fun saveData(request: Regency): ResponseEntity<*>?
fun updateData(id: String, request: Regency): ResponseEntity<*>?
fun deleteData(request: DeleteDataRequest): ResponseEntity<*>?
}
package id.co.sangkuriang.inovasi.daerah.master.service
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Tag
import org.springframework.http.ResponseEntity
interface TagService {
fun getAll(page: PaginationRequest): ResponseEntity<*>?
fun getDetail(id: String): ResponseEntity<*>?
fun saveData(request: Tag): ResponseEntity<*>?
fun updateData(id: String, request: Tag): ResponseEntity<*>?
fun deleteData(request: DeleteDataRequest): ResponseEntity<*>?
}
package id.co.sangkuriang.inovasi.daerah.master.service.impl
import id.co.sangkuriang.inovasi.daerah.master.constant.UPLOAD_ICON_APPLICATION_CATEGORY_DIR
import id.co.sangkuriang.inovasi.daerah.master.constant.UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_NOT_FOUND
import id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import id.co.sangkuriang.inovasi.daerah.master.model.request.ApplicationCategoryRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.ApplicationCategory
import id.co.sangkuriang.inovasi.daerah.master.repository.ApplicationCategoryRepository
import id.co.sangkuriang.inovasi.daerah.master.service.ApplicationCategoryService
import id.co.sangkuriang.inovasi.daerah.master.utility.deleteFile
import id.co.sangkuriang.inovasi.daerah.master.utility.uploadFile
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.http.ResponseEntity
import org.springframework.stereotype.Service
import java.util.*
import javax.servlet.http.HttpServletRequest
@Suppress("NAME_SHADOWING")
@Service
class ApplicationCategoryServiceImpl : ApplicationCategoryService {
@Autowired
private lateinit var repo: ApplicationCategoryRepository
override fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return try {
val page: Page<ApplicationCategory?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC
if (page.sort?.lowercase(Locale.getDefault()).equals("desc")) {
direction = Sort.Direction.DESC
}
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = PageRequest.of(page.page!!, page.size!!, Sort.by(direction, page.sortBy))
)
} else {
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = Pageable.unpaged()
)
}
responseSuccess(data = page)
} catch (e: Exception) {
throw e
}
}
override fun getDetail(id: String): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
return responseSuccess(data = data)
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun saveData(
request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest
): ResponseEntity<*>? {
return try {
validateRequest(request)
val save = ApplicationCategory()
save.name = request.name
if (request.icon != null) {
save.icon = uploadFile(request.icon!!, httpServletRequest, UPLOAD_ICON_APPLICATION_CATEGORY_DIR)
}
if (request.image != null) {
save.image = uploadFile(request.image!!, httpServletRequest, UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR)
}
responseCreated(data = repo.save(save))
} catch (e: Exception) {
throw e
}
}
override fun updateData(
id: String,
request: ApplicationCategoryRequest,
httpServletRequest: HttpServletRequest
): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
validateRequest(request, id)
val update = data.get()
update.name = request.name
if (request.icon != null) {
update.icon?.let { deleteFile(UPLOAD_ICON_APPLICATION_CATEGORY_DIR, it) }
update.icon = uploadFile(request.icon!!, httpServletRequest, UPLOAD_ICON_APPLICATION_CATEGORY_DIR)
}
if (request.image != null) {
update.image?.let { deleteFile(UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR, it) }
update.image =
uploadFile(request.image!!, httpServletRequest, UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR)
}
update.updatedAt = Date()
return responseSuccess(data = repo.save(update))
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun deleteData(request: DeleteDataRequest): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(request.id)
if (data.isPresent) {
val update = data.get()
update.updatedAt = Date()
update.active = false
repo.save(update)
return responseSuccess()
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
private fun validateRequest(request: ApplicationCategoryRequest, id: String? = null) {
try {
val listMessage = mutableListOf<Map<String, String>>()
val checkName = repo.findByName(request.name)
if (checkName.isPresent) {
val msgCheckName = mapOf("name" to "Nama ${request.name} $VALIDATOR_MSG_NOT_FOUND")
if (id == null) {
listMessage.add(msgCheckName)
} else {
if (checkName.get().id != id) {
listMessage.add(msgCheckName)
}
}
}
if (listMessage.isNotEmpty()) {
throw BadRequestException(data = listMessage)
}
} catch (e: Exception) {
throw e
}
}
}
package id.co.sangkuriang.inovasi.daerah.master.service.impl
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_HAS_USED
import id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.Pagination2Request
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Province
import id.co.sangkuriang.inovasi.daerah.master.repository.ProvinceRepository
import id.co.sangkuriang.inovasi.daerah.master.repository.native.ProvinceRepositoryNative
import id.co.sangkuriang.inovasi.daerah.master.service.ProvinceService
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.http.ResponseEntity
import org.springframework.stereotype.Service
import java.util.*
@Suppress("NAME_SHADOWING")
@Service
class ProvinceServiceImpl : ProvinceService {
@Autowired
private lateinit var repo: ProvinceRepository
@Autowired
private lateinit var repoNative: ProvinceRepositoryNative
override fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return try {
val page: Page<Province?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC
if (page.sort?.lowercase(Locale.getDefault()).equals("desc")) {
direction = Sort.Direction.DESC
}
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = PageRequest.of(page.page!!, page.size!!, Sort.by(direction, page.sortBy))
)
} else {
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = Pageable.unpaged()
)
}
responseSuccess(data = page)
} catch (e: Exception) {
throw e
}
}
override fun datatable(req: Pagination2Request): ResponseEntity<*>? {
return try {
responseSuccess(data = repoNative.getPage(req))
} catch (e: Exception) {
throw e
}
}
override fun getDetail(id: String): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
return responseSuccess(data = data)
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun saveData(request: Province): ResponseEntity<*>? {
return try {
validateRequest(request)
val save = Province()
save.name = request.name
responseCreated(data = repo.save(save))
} catch (e: Exception) {
throw e
}
}
override fun updateData(id: String, request: Province): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
validateRequest(request, id)
val update = data.get()
update.name = request.name
update.updatedAt = Date()
return responseSuccess(data = repo.save(update))
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun deleteData(request: DeleteDataRequest): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(request.id)
if (data.isPresent) {
val update = data.get()
update.active = false
update.updatedAt = Date()
repo.save(update)
return responseSuccess()
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
private fun validateRequest(request: Province, id: String? = null) {
try {
val listMessage = mutableListOf<Map<String, String>>()
val checkName = repo.findByName(request.name)
if (checkName.isPresent) {
val msgCheckName = mapOf("name" to "Nama ${request.name} $VALIDATOR_MSG_HAS_USED")
if (id == null) {
listMessage.add(msgCheckName)
} else {
if (checkName.get().id != id) {
listMessage.add(msgCheckName)
}
}
}
if (listMessage.isNotEmpty()) {
throw BadRequestException(data = listMessage)
}
} catch (e: Exception) {
throw e
}
}
}
package id.co.sangkuriang.inovasi.daerah.master.service.impl
import id.co.sangkuriang.inovasi.daerah.master.constant.VALIDATOR_MSG_HAS_USED
import id.co.sangkuriang.inovasi.daerah.master.exception.BadRequestException
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseCreated
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseNotFound
import id.co.sangkuriang.inovasi.daerah.master.helpers.responseSuccess
import id.co.sangkuriang.inovasi.daerah.master.model.request.DeleteDataRequest
import id.co.sangkuriang.inovasi.daerah.master.model.request.PaginationRequest
import id.co.sangkuriang.inovasi.daerah.master.pojo.Regency
import id.co.sangkuriang.inovasi.daerah.master.repository.RegencyRepository
import id.co.sangkuriang.inovasi.daerah.master.service.RegencyService
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.http.ResponseEntity
import org.springframework.stereotype.Service
import java.util.*
@Suppress("NAME_SHADOWING")
@Service
class RegencyServiceImpl : RegencyService {
@Autowired
private lateinit var repo: RegencyRepository
override fun getAll(page: PaginationRequest): ResponseEntity<*>? {
return try {
val page: Page<Regency?>? = if (page.enablePage!! == 1) {
var direction: Sort.Direction = Sort.Direction.ASC
if (page.sort?.lowercase(Locale.getDefault()).equals("desc")) {
direction = Sort.Direction.DESC
}
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = PageRequest.of(page.page!!, page.size!!, Sort.by(direction, page.sortBy))
)
} else {
repo.getListPagination(
param = page.param.toString().lowercase(Locale.getDefault()),
pageable = Pageable.unpaged()
)
}
responseSuccess(data = page)
} catch (e: Exception) {
throw e
}
}
override fun getDetail(id: String): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
return responseSuccess(data = data)
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun saveData(request: Regency): ResponseEntity<*>? {
return try {
validateRequest(request)
val save = Regency()
save.name = request.name
save.provinceId = request.provinceId
responseCreated(data = repo.save(save))
} catch (e: Exception) {
throw e
}
}
override fun updateData(id: String, request: Regency): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(id)
if (data.isPresent) {
validateRequest(request, id)
val update = data.get()
update.name = request.name
update.updatedAt = Date()
return responseSuccess(data = repo.save(update))
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
override fun deleteData(request: DeleteDataRequest): ResponseEntity<*>? {
try {
val data = repo.findByIdAndActive(request.id)
if (data.isPresent) {
val update = data.get()
update.active = false
update.updatedAt = Date()
repo.save(update)
return responseSuccess()
}
return responseNotFound()
} catch (e: Exception) {
throw e
}
}
private fun validateRequest(request: Regency, id: String? = null) {
try {
val listMessage = mutableListOf<Map<String, String>>()
val checkName = repo.findByNameProvinceId(request.name, request.provinceId)
if (checkName.isPresent) {
val msgCheckName = mapOf("name" to "Nama ${request.name} $VALIDATOR_MSG_HAS_USED")
if (id == null) {
listMessage.add(msgCheckName)
} else {
if (checkName.get().id != id) {
listMessage.add(msgCheckName)
}
}
}
if (listMessage.isNotEmpty()) {
throw BadRequestException(data = listMessage)
}
} catch (e: Exception) {
throw e
}
}
}
package id.co.sangkuriang.inovasi.daerah.master.utility
import com.fasterxml.jackson.databind.ObjectMapper
import id.co.sangkuriang.inovasi.daerah.master.constant.*
import id.co.sangkuriang.inovasi.daerah.master.pojo.Users
import org.apache.commons.io.FileUtils
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.web.multipart.MultipartFile
import java.io.File
import java.io.IOException
import java.net.MalformedURLException
import java.net.URL
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import javax.servlet.http.HttpServletRequest
fun getUsersLogin(): Users? {
return try {
val principal = SecurityContextHolder.getContext().authentication.principal as Any
ObjectMapper().readValue(principal.toString(), Users::class.java)
} catch (e: Exception) {
null
}
}
@Throws(MalformedURLException::class)
fun getBaseUrl(request: HttpServletRequest): String {
try {
val requestURL = URL(request.requestURL.toString())
val port = if (requestURL.port == -1) "" else ":" + requestURL.port
return requestURL.protocol + "://" + requestURL.host + port + request.contextPath + "/"
} catch (e: Exception) {
throw e
}
}
fun getFullUrl(request: HttpServletRequest): String {
val requestURL = StringBuilder(request.requestURL.toString())
val queryString = request.queryString
return if (queryString == null) {
requestURL.toString()
} else {
requestURL.append('?').append(queryString).toString()
}
}
fun getPathUrl(request: HttpServletRequest): String {
return getFullUrl(request).replace(getBaseUrl(request), "")
.replaceAfter("?", "")
.replace("?", "")
.replaceAfter("/", "")
.replace("/", "")
}
fun uploadFile(
file: MultipartFile,
httpServletRequest: HttpServletRequest,
path: String,
fileType: String? = "images"
): String {
try {
var dirType = ""
when (path) {
UPLOAD_USER_DIR -> {
dirType = "users"
}
UPLOAD_APPLICATION_DIR -> {
dirType = "application"
}
UPLOAD_ICON_APPLICATION_CATEGORY_DIR -> {
dirType = "application-category-icon"
}
UPLOAD_IMAGE_APPLICATION_CATEGORY_DIR -> {
dirType = "application-category-image"
}
UPLOAD_BANNER_APPLICATION_DIR -> {
dirType = "application-banner"
}
UPLOAD_IMAGE_APPLICATION_QR_DIR -> {
dirType = "application-qr"
}
UPLOAD_IMAGE_APPLICATION_DETAIL_DIR -> {
dirType = "application-detail"
}
}
val root: Path = Paths.get(path)
if (!Files.exists(root)) {
try {
Files.createDirectories(Paths.get(path))
} catch (e: IOException) {
throw RuntimeException("Could not create upload folder!")
}
}
val fileName =
System.currentTimeMillis().toString() + "-" + file.originalFilename?.trim()?.replace(" ", "-")
Files.copy(file.inputStream, root.resolve(fileName))
return getBaseUrl(httpServletRequest) + "file/$fileType?type=$dirType&fileName=" + fileName
} catch (e: Exception) {
throw RuntimeException("Could not store the file. Error: " + e.message)
}
}
fun deleteFile(fileDir: String, file: String) {
try {
val delete = File(fileDir + File.separator + file.substringAfterLast("fileName="))
if (delete.exists()) {
FileUtils.forceDelete(delete)
}
} catch (e: Exception) {
throw e
}
}
# SERVER CONFIG
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
spring.profiles.active=development
server.port=8080
# DATABASE CONFIG
spring.datasource.url=jdbc:postgresql://localhost:5432/inovasi_daerah_db
spring.datasource.username=postgres
spring.datasource.password=root
#spring.datasource.url=jdbc:postgresql://pgadmin.spbe.sangkuriang.co.id:5432/inovasi_daerah_db
#spring.datasource.username=u_inovasi_daerah
#spring.datasource.password=wV9Tnx6S8TmmUYXdgkmN4pzreSD3RE
spring.jpa.hibernate.ddl-auto=none
# JPA CONFIG
spring.jpa.generate-ddl=false
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.legacy_limit_handler=true
spring.jpa.properties.hibernate.format_sql=true
# UPLOAD CONFIG
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB
# MAIl CONFIG
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=dinanhafiza@gmail.com
spring.mail.password=sembalap1991
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
spring.mail.properties.mail.smtp.starttls.enable=true
<?xml version="1.0" encoding="UTF-8"?>
<!-- configuration file for LogBack (slf4J implementation)
See here for more details: http://gordondickens.com/wordpress/2013/03/27/sawing-through-the-java-loggers/ -->
<configuration scan="true" scanPeriod="30 seconds">
<property name="DEV_HOME" value="C:\\Users\\ghith\\Desktop\\inovasi_daerah_master\\log"/>
<!-- <property name="DEV_HOME" value="/home/inovasi_daerah_master/log"/>-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-5relative %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<appender name="DEBUG-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${DEV_HOME}/debug.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} %-5level - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${DEV_HOME}/archived/debug.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<appender name="ACCESS-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${DEV_HOME}/access.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${DEV_HOME}/archived/access.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<root level="debug">
<appender-ref ref="DEBUG-LOG"/>
<appender-ref ref="STDOUT"/>
</root>
<logger name="access.log" level="debug">
<appender-ref ref="ACCESS-LOG"/>
</logger>
</configuration>
package id.co.sangkuriang.inovasi.daerah.master
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
@SpringBootTest
class InovasiDaerahMasterApplicationTests {
@Test
fun contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment