TSK-1693: automatic reformatting

This commit is contained in:
Mustapha Zorgati 2021-08-05 21:46:59 +02:00
parent a4ab94bb04
commit 698808e9d3
9 changed files with 110 additions and 112 deletions

View File

@ -20,98 +20,99 @@ 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";
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 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";
/** 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";
/**
* 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());
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());
// 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 {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
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();
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();
}
}

View File

@ -1,7 +1,7 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>taskana-common-logging</artifactId>
@ -9,8 +9,8 @@
<description>The global trace logging implementation</description>
<parent>
<artifactId>taskana-common-parent</artifactId>
<groupId>pro.taskana</groupId>
<artifactId>taskana-common-parent</artifactId>
<version>4.8.1-SNAPSHOT</version>
</parent>

View File

@ -115,8 +115,8 @@ public interface TimeIntervalReportBuilder<
* Excludes the values of a certain {@linkplain TaskCustomField} to the builder.
*
* <p>The created report contains only tasks with a {@linkplain
* Task#getCustomAttribute(TaskCustomField) custom attribute} value not matching one of the
* items in the list.
* Task#getCustomAttribute(TaskCustomField) custom attribute} value not matching one of the items
* in the list.
*
* @param customField the specified {@linkplain TaskCustomField}
* @param strings the values the specified {@linkplain Task#getCustomAttribute(TaskCustomField)

View File

@ -48,7 +48,9 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("report") TimeIntervalReportBuilder<?, ?, ?> report);
@SelectProvider(type = MonitorMapperSqlProvider.class, method = "getTaskCountOfDetailedClassifications")
@SelectProvider(
type = MonitorMapperSqlProvider.class,
method = "getTaskCountOfDetailedClassifications")
@Result(column = "TASK_CLASSIFICATION_KEY", property = "key")
@Result(column = "ATTACHMENT_CLASSIFICATION_KEY", property = "attachmentKey")
@Result(column = "AGE_IN_DAYS", property = "ageInDays")
@ -58,7 +60,9 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("report") TimeIntervalReportBuilder<?, ?, ?> report);
@SelectProvider(type = MonitorMapperSqlProvider.class, method = "getTaskCountOfTaskCustomFieldValues")
@SelectProvider(
type = MonitorMapperSqlProvider.class,
method = "getTaskCountOfTaskCustomFieldValues")
@Result(column = "CUSTOM_FIELD", property = "key")
@Result(column = "AGE_IN_DAYS", property = "ageInDays")
@Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")
@ -67,9 +71,7 @@ public interface MonitorMapper {
@Param("timestamp") TaskTimestamp timestamp,
@Param("report") TimeIntervalReportBuilder<?, ?, ?> report);
@SelectProvider(
type = MonitorMapperSqlProvider.class,
method = "getTaskIdsForSelectedItems")
@SelectProvider(type = MonitorMapperSqlProvider.class, method = "getTaskIdsForSelectedItems")
List<String> getTaskIdsForSelectedItems(
@Param("now") Instant now,
@Param("report") TimeIntervalReportBuilder<?, ?, ?> report,

View File

@ -47,6 +47,7 @@ abstract class TimeIntervalReportBuilderImpl<
protected List<String> domains;
protected List<String> classificationIds;
protected List<String> excludedClassificationIds;
protected WorkingDaysToDaysConverter converter;
private String[] custom1In;
private String[] custom1NotIn;
private String[] custom1Like;
@ -95,7 +96,6 @@ abstract class TimeIntervalReportBuilderImpl<
private String[] custom16In;
private String[] custom16NotIn;
private String[] custom16Like;
protected WorkingDaysToDaysConverter converter;
TimeIntervalReportBuilderImpl(InternalTaskanaEngine taskanaEngine, MonitorMapper monitorMapper) {
this.taskanaEngine = taskanaEngine;
@ -386,9 +386,7 @@ abstract class TimeIntervalReportBuilderImpl<
try {
this.taskanaEngine.openConnection();
return monitorMapper.getCustomAttributeValuesForReport(
this,
getCombinedClassificationFilter(),
taskCustomField);
this, getCombinedClassificationFilter(), taskCustomField);
} finally {
this.taskanaEngine.returnConnection();
}

View File

@ -23,6 +23,9 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
"pro.taskana.workbasket.internal.WorkbasketQueryMapper.countQueryWorkbasketAccessItems";
private static final String LINK_TO_VALUEMAPPER =
"pro.taskana.workbasket.internal.WorkbasketQueryMapper.queryWorkbasketAccessItemColumnValues";
private final InternalTaskanaEngine taskanaEngine;
private final List<String> orderBy;
private final List<String> orderColumns;
private AccessItemQueryColumnName columnName;
private String[] accessIdIn;
private String[] accessIdLike;
@ -31,10 +34,6 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
private String[] workbasketKeyLike;
private String[] idIn;
private final InternalTaskanaEngine taskanaEngine;
private final List<String> orderBy;
private final List<String> orderColumns;
WorkbasketAccessItemQueryImpl(InternalTaskanaEngine taskanaEngine) {
this.taskanaEngine = taskanaEngine;
orderBy = new ArrayList<>();

View File

@ -324,8 +324,7 @@ class ProvideClassificationCategoryReportAccTest extends AbstractReportAccTest {
@WithAccessId(user = "monitor")
@Test
void should_ReturnItemsOfCategoryReport_When_FilteringWithCustomAttributeIn()
throws Exception {
void should_ReturnItemsOfCategoryReport_When_FilteringWithCustomAttributeIn() throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationCategoryReport report =

14
pom.xml
View File

@ -152,6 +152,13 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${version.aspectj-maven-plugin}</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${version.aspectj}</version>
</dependency>
</dependencies>
<configuration>
<complianceLevel>${java.version}</complianceLevel>
<source>11</source>
@ -173,13 +180,6 @@
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${version.aspectj}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

View File

@ -231,8 +231,7 @@ class WorkbasketControllerIntTest {
RestEndpoints.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000004");
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("businessadmin"));
ThrowingCallable call =
() -> TEMPLATE.exchange(url, HttpMethod.DELETE, auth, Void.class);
ThrowingCallable call = () -> TEMPLATE.exchange(url, HttpMethod.DELETE, auth, Void.class);
assertThatThrownBy(call)
.isInstanceOf(HttpStatusCodeException.class)