Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import java.sql.Timestamp;
import java.time.ZonedDateTime;

import org.osgi.annotation.versioning.ProviderType;

Expand All @@ -24,23 +25,45 @@
@ProviderType
public final class HistoryEntry {

private Timestamp timestamp;
private ZonedDateTime date;
private String message;
private long index;

/**
* Creates a new history entry. Calls {@link #HistoryEntry(long, ZonedDateTime, String)} internally with a converted timestamp using the current time zone.
* @param index
* @param timestamp
* @param message
* @deprecated Use {@link #HistoryEntry(long, ZonedDateTime, String)} instead.
*/
@Deprecated

Check warning on line 39 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add 'since' and/or 'forRemoval' arguments to the @Deprecated annotation.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM5&open=AZzC378GyXmjOTWOgVM5&pullRequest=868
public HistoryEntry(long index, Timestamp timestamp, String message) {

Check warning on line 40 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM6&open=AZzC378GyXmjOTWOgVM6&pullRequest=868
this(index, timestamp.toInstant().atZone(ZonedDateTime.now().getZone()), message);
}

public HistoryEntry(long index, ZonedDateTime date, String message) {
super();
this.index = index;
this.timestamp = timestamp;
this.date = date;
this.message = message;
}

@Deprecated

Check warning on line 51 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add 'since' and/or 'forRemoval' arguments to the @Deprecated annotation.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM7&open=AZzC378GyXmjOTWOgVM7&pullRequest=868
public Timestamp getTimestamp() {

Check warning on line 52 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add the missing @deprecated Javadoc tag.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM9&open=AZzC378GyXmjOTWOgVM9&pullRequest=868

Check warning on line 52 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM8&open=AZzC378GyXmjOTWOgVM8&pullRequest=868
return timestamp;
return Timestamp.from(date.toInstant());
}

@Deprecated

Check warning on line 56 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add 'since' and/or 'forRemoval' arguments to the @Deprecated annotation.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM-&open=AZzC378GyXmjOTWOgVM-&pullRequest=868
public void setTimestamp(Timestamp timestamp) {

Check warning on line 57 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add the missing @deprecated Javadoc tag.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVNA&open=AZzC378GyXmjOTWOgVNA&pullRequest=868

Check warning on line 57 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/api/HistoryEntry.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC378GyXmjOTWOgVM_&open=AZzC378GyXmjOTWOgVM_&pullRequest=868
this.timestamp = timestamp;
setDate(timestamp.toInstant().atZone(ZonedDateTime.now().getZone()));
}

public ZonedDateTime getDate() {
return date;
}

public void setDate(ZonedDateTime date) {
this.date = date;
}

public String getMessage() {
Expand All @@ -61,7 +84,7 @@

@Override
public String toString() {
return "HistoryEntry [timestamp=" + timestamp + ", message=" + message
return "HistoryEntry [date=" + date + ", message=" + message
+ ", index=" + index + "]";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Version("3.3.0")
@Version("3.4.0")
package biz.netcentric.cq.tools.actool.api;

/*-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Timestamp;

Check warning on line 21 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/history/impl/PersistableInstallationLogger.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.sql.Timestamp'.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC377uyXmjOTWOgVM4&open=AZzC377uyXmjOTWOgVM4&pullRequest=868
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.time.ZonedDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -141,8 +142,7 @@
}

protected void addWarning(String warning) {
warnings.add(new HistoryEntry(msgIndex, new Timestamp(
new Date().getTime()), MSG_IDENTIFIER_WARNING + warning));
warnings.add(new HistoryEntry(msgIndex, ZonedDateTime.now(), MSG_IDENTIFIER_WARNING + warning));
listeners.forEach(l -> l.accept(InstallationLogLevel.WARNING, warning));
msgIndex++;
}
Expand All @@ -154,8 +154,7 @@
}

protected void addMessage(String message) {
messages.add(new HistoryEntry(msgIndex, new Timestamp(new Date()
.getTime()), " " + message));
messages.add(new HistoryEntry(msgIndex, ZonedDateTime.now(), " " + message));
listeners.forEach(l -> l.accept(InstallationLogLevel.INFO, message));
msgIndex++;
}
Expand All @@ -175,8 +174,7 @@
if (e != null) {
fullErrorValue += " / e=" + e;
}
errors.add(new HistoryEntry(msgIndex, new Timestamp(
new Date().getTime()), MSG_IDENTIFIER_ERROR + fullErrorValue));
errors.add(new HistoryEntry(msgIndex, ZonedDateTime.now(), MSG_IDENTIFIER_ERROR + fullErrorValue));
listeners.forEach(l -> l.accept(InstallationLogLevel.ERROR, error));
success = false;
msgIndex++;
Expand All @@ -195,8 +193,7 @@
}

protected void addVerboseMessage(String message) {
verboseMessages.add(new HistoryEntry(msgIndex, new Timestamp(
new Date().getTime()), " " + message));
verboseMessages.add(new HistoryEntry(msgIndex, ZonedDateTime.now(), " " + message));
listeners.forEach(l -> l.accept(InstallationLogLevel.TRACE, message));
msgIndex++;
}
Expand Down Expand Up @@ -268,8 +265,8 @@
StringBuilder sb = new StringBuilder();
if (!messageHistorySet.isEmpty()) {
for (HistoryEntry entry : messageHistorySet) {
sb.append(EOL + timestampFormat.format(entry.getTimestamp()) + ": "
sb.append(EOL + timestampFormat.format(entry.getDate()) + ": "
+ entry.getMessage());

Check warning on line 269 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/history/impl/PersistableInstallationLogger.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use multiple calls to "append" instead of string concatenation.

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AZzC377uyXmjOTWOgVM3&open=AZzC377uyXmjOTWOgVM3&pullRequest=868
}
}
return sb.toString();
Expand Down