Skip to content

Commit 7c311ef

Browse files
Merge pull request #43 from contentstack/next
Next: Check Issue Fixed
2 parents c5517b9 + cad6a7b commit 7c311ef

File tree

11 files changed

+170
-60
lines changed

11 files changed

+170
-60
lines changed

.github/workflows/codeql-analysis.yml

+27-27
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,36 @@ jobs:
3333
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3434

3535
steps:
36-
- name: Checkout repository
37-
uses: actions/checkout@v3
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
3838

39-
# Initializes the CodeQL tools for scanning.
40-
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@v2
42-
with:
43-
languages: ${{ matrix.language }}
44-
# If you wish to specify custom queries, you can do so here or in a config file.
45-
# By default, queries listed here will override any specified in a config file.
46-
# Prefix the list here with "+" to use these queries and those in the config file.
47-
48-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
49-
# queries: security-extended,security-and-quality
39+
# Initializes the CodeQL tools for scanning.
40+
- name: Initialize CodeQL
41+
uses: github/codeql-action/init@v2
42+
with:
43+
languages: ${{ matrix.language }}
44+
# If you wish to specify custom queries, you can do so here or in a config file.
45+
# By default, queries listed here will override any specified in a config file.
46+
# Prefix the list here with "+" to use these queries and those in the config file.
5047

51-
52-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
53-
# If this step fails, then you should remove it and run the build manually (see below)
54-
- name: Autobuild
55-
uses: github/codeql-action/autobuild@v2
48+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
49+
# queries: security-extended,security-and-quality
5650

57-
# ℹ️ Command-line programs to run using the OS shell.
58-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
5951

60-
# If the Autobuild fails above, remove it and uncomment the following three lines.
61-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
52+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
53+
# If this step fails, then you should remove it and run the build manually (see below)
54+
- name: Autobuild
55+
uses: github/codeql-action/autobuild@v2
6256

63-
# - run: |
64-
# echo "Run, Build Application using script"
65-
# ./location_of_script_within_repo/buildscript.sh
57+
# ℹ️ Command-line programs to run using the OS shell.
58+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6659

67-
- name: Perform CodeQL Analysis
68-
uses: github/codeql-action/analyze@v2
60+
# If the Autobuild fails above, remove it and uncomment the following three lines.
61+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
62+
63+
# - run: |
64+
# echo "Run, Build Application using script"
65+
# ./location_of_script_within_repo/buildscript.sh
66+
67+
- name: Perform CodeQL Analysis
68+
uses: github/codeql-action/analyze@v2

.github/workflows/sast-scan.yml

-11
This file was deleted.

.github/workflows/sca-scan.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Source Composition Analysis Scan
22
on:
33
pull_request:
4-
types: [opened, synchronize, reopened]
4+
types: [ opened, synchronize, reopened ]
55
jobs:
66
security:
77
runs-on: ubuntu-latest

.github/workflows/secrets-scan.yml

-11
This file was deleted.
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.net.*;
17+
import java.io.*;
18+
import java.nio.channels.*;
19+
import java.util.Properties;
20+
21+
public class MavenWrapperDownloader {
22+
23+
private static final String WRAPPER_VERSION = "0.5.6";
24+
/**
25+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26+
*/
27+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29+
30+
/**
31+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32+
* use instead of the default one.
33+
*/
34+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35+
".mvn/wrapper/maven-wrapper.properties";
36+
37+
/**
38+
* Path where the maven-wrapper.jar will be saved to.
39+
*/
40+
private static final String MAVEN_WRAPPER_JAR_PATH =
41+
".mvn/wrapper/maven-wrapper.jar";
42+
43+
/**
44+
* Name of the property which should be used to override the default download url for the wrapper.
45+
*/
46+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47+
48+
public static void main(String args[]) {
49+
System.out.println("- Downloader started");
50+
File baseDirectory = new File(args[0]);
51+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52+
53+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
54+
// wrapperUrl parameter.
55+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56+
String url = DEFAULT_DOWNLOAD_URL;
57+
if(mavenWrapperPropertyFile.exists()) {
58+
FileInputStream mavenWrapperPropertyFileInputStream = null;
59+
try {
60+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61+
Properties mavenWrapperProperties = new Properties();
62+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64+
} catch (IOException e) {
65+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66+
} finally {
67+
try {
68+
if(mavenWrapperPropertyFileInputStream != null) {
69+
mavenWrapperPropertyFileInputStream.close();
70+
}
71+
} catch (IOException e) {
72+
// Ignore ...
73+
}
74+
}
75+
}
76+
System.out.println("- Downloading from: " + url);
77+
78+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79+
if(!outputFile.getParentFile().exists()) {
80+
if(!outputFile.getParentFile().mkdirs()) {
81+
System.out.println(
82+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83+
}
84+
}
85+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86+
try {
87+
downloadFileFromURL(url, outputFile);
88+
System.out.println("Done");
89+
System.exit(0);
90+
} catch (Throwable e) {
91+
System.out.println("- Error downloading");
92+
e.printStackTrace();
93+
System.exit(1);
94+
}
95+
}
96+
97+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99+
String username = System.getenv("MVNW_USERNAME");
100+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101+
Authenticator.setDefault(new Authenticator() {
102+
@Override
103+
protected PasswordAuthentication getPasswordAuthentication() {
104+
return new PasswordAuthentication(username, password);
105+
}
106+
});
107+
}
108+
URL website = new URL(urlString);
109+
ReadableByteChannel rbc;
110+
rbc = Channels.newChannel(website.openStream());
111+
FileOutputStream fos = new FileOutputStream(destination);
112+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113+
fos.close();
114+
rbc.close();
115+
}
116+
117+
}

.mvn/wrapper/maven-wrapper.jar

49.5 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

mvnw

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# "License"); you may not use this file except in compliance
99
# with the License. You may obtain a copy of the License at
1010
#
11-
# https://www.apache.org/licenses/LICENSE-2.0
11+
# http://www.apache.org/licenses/LICENSE-2.0
1212
#
1313
# Unless required by applicable law or agreed to in writing,
1414
# software distributed under the License is distributed on an

mvnw.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@REM "License"); you may not use this file except in compliance
88
@REM with the License. You may obtain a copy of the License at
99
@REM
10-
@REM https://www.apache.org/licenses/LICENSE-2.0
10+
@REM http://www.apache.org/licenses/LICENSE-2.0
1111
@REM
1212
@REM Unless required by applicable law or agreed to in writing,
1313
@REM software distributed under the License is distributed on an

pom.xml

+20-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>2.4.4</version>
9+
<version>3.1.4</version>
1010
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212
<groupId>com.contentstack</groupId>
@@ -16,56 +16,69 @@
1616
<description>Demo project for graphql-springboot-api-integration</description>
1717
<properties>
1818
<java.version>1.8</java.version>
19+
<spring-boot.version>3.1.4</spring-boot.version>
20+
<json-smart.version>5.2.2</json-smart.version>
1921
</properties>
2022

21-
2223
<dependencies>
2324
<dependency>
2425
<groupId>org.springframework.boot</groupId>
2526
<artifactId>spring-boot-starter-web</artifactId>
26-
<version>2.5.4</version>
27+
<version>${spring-boot.version}</version>
2728
</dependency>
2829
<dependency>
2930
<groupId>org.springframework.boot</groupId>
3031
<artifactId>spring-boot-starter-freemarker</artifactId>
32+
<version>${spring-boot.version}</version>
3133
</dependency>
3234
<dependency>
3335
<groupId>org.springframework.boot</groupId>
3436
<artifactId>spring-boot-starter-thymeleaf</artifactId>
37+
<version>${spring-boot.version}</version>
3538
</dependency>
3639
<dependency>
3740
<groupId>org.springframework.boot</groupId>
3841
<artifactId>spring-boot-starter</artifactId>
42+
<version>${spring-boot.version}</version>
3943
</dependency>
4044
<dependency>
4145
<groupId>io.github.cdimascio</groupId>
4246
<artifactId>java-dotenv</artifactId>
43-
<version>5.2.2</version>
47+
<version>${json-smart.version}</version>
4448
</dependency>
49+
50+
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
4551
<dependency>
4652
<groupId>org.projectlombok</groupId>
4753
<artifactId>lombok</artifactId>
48-
<optional>true</optional>
54+
<version>1.18.30</version>
55+
<scope>provided</scope>
4956
</dependency>
57+
58+
<!-- https://mvnrepository.com/artifact/net.minidev/json-smart -->
5059
<dependency>
5160
<groupId>net.minidev</groupId>
5261
<artifactId>json-smart</artifactId>
53-
<version>2.4.7</version>
62+
<version>2.5.0</version>
5463
</dependency>
64+
65+
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-test -->
5566
<dependency>
5667
<groupId>org.springframework.boot</groupId>
5768
<artifactId>spring-boot-test</artifactId>
58-
<version>2.5.1</version>
69+
<version>${spring-boot.version}</version>
5970
<scope>test</scope>
6071
</dependency>
6172

73+
6274
</dependencies>
6375

6476
<build>
6577
<plugins>
6678
<plugin>
6779
<groupId>org.springframework.boot</groupId>
6880
<artifactId>spring-boot-maven-plugin</artifactId>
81+
<version>3.1.4</version>
6982
</plugin>
7083
</plugins>
7184
</build>

src/main/java/com/contentstack/gqlspring/Util.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static String load(@NotNull String filename) {
1818
File resource = new ClassPathResource("graphql/" + filename).getFile();
1919
return new String(Files.readAllBytes(resource.toPath()));
2020
} catch (IOException e) {
21-
e.printStackTrace();
21+
System.out.println("Exception: " + e.getMessage());
2222
}
2323
return null;
2424
}

0 commit comments

Comments
 (0)