Skip to content

Commit

Permalink
fixed code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Dec 31, 2024
1 parent 4031bd2 commit 83d7e91
Show file tree
Hide file tree
Showing 68 changed files with 617 additions and 302 deletions.
26 changes: 18 additions & 8 deletions logicaldoc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
<artifactId>commons-el</artifactId>
<scope>provided</scope>
</dependency>
<!-- dependency> <groupId>commons-discovery</groupId> <artifactId>commons-discovery</artifactId>
<!-- dependency> <groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<scope>provided</scope> </dependency -->
<dependency>
<groupId>commons-lang</groupId>
Expand Down Expand Up @@ -144,7 +145,8 @@
<artifactId>sqltool</artifactId>
<scope>provided</scope>
</dependency>
<!-- dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId>
<!-- dependency> <groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<scope>provided</scope> <exclusions> <exclusion> <groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId> </exclusion> </exclusions> </dependency -->
<dependency>
Expand Down Expand Up @@ -280,10 +282,12 @@
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-tools</artifactId>
</dependency>
<!-- Extracting text in languages whose text goes from right to left (such
<!-- Extracting text in languages whose text goes from right to left
(such
as Arabic and Hebrew) in PDF files can result in text that is backwards.
PDFBox can normalize and reverse the text if the ICU4J jar file has been
placed on the classpath (it is an optional dependency). http://pdfbox.apache.org/userguide/text_extraction.html -->
placed on the classpath (it is an optional dependency).
http://pdfbox.apache.org/userguide/text_extraction.html -->
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
Expand Down Expand Up @@ -566,7 +570,12 @@
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -654,8 +663,8 @@
<exclude name="commons-math*" />
<exclude name="xz-*" />
<exclude name="*smime*" />
<exclude name="java-libpst*" />
<exclude name="*commonmark*" />
<exclude name="java-libpst*" />
<exclude name="*commonmark*" />
</delete>
<delete dir="target/plugin/WEB-INF/lib">
<include name="opencv-*-android-*" />
Expand Down Expand Up @@ -708,7 +717,8 @@
<reportSet>
<reports>
<report>dependencies</report>
<!-- <report>project-team</report> <report>mailing-list</report> <report>cim</report>
<!-- <report>project-team</report>
<report>mailing-list</report> <report>cim</report>
<report>issue-tracking</report> <report>license</report> <report>scm</report> -->
</reports>
</reportSet>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.logicaldoc.core.automation;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -23,8 +20,7 @@ public class LogTool {
* @param message the message to print
*/
public void print(String message) {
SimpleDateFormat df = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]");
System.out.println(df.format(new Date()) + " " + message);
LoggerFactory.getLogger("console").info(message);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.Serializable;
import java.util.Date;

import javax.annotation.Nullable;

import com.logicaldoc.core.document.Document;
import com.logicaldoc.core.folder.Folder;
import com.logicaldoc.core.security.user.User;
Expand Down Expand Up @@ -157,7 +159,8 @@ public Date getDateValue() {
public void setDateValue(Date dateValue) {
this.dateValue = dateValue;
}


@Nullable
public Boolean getBooleanValue() {
if (intValue != null)
return intValue.intValue() == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,29 @@ private int getLastPosition() {

return position;
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((templateId == null) ? 0 : templateId.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ExtensibleObject other = (ExtensibleObject) obj;
if (templateId == null) {
if (other.templateId != null)
return false;
} else if (!templateId.equals(other.templateId))
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,29 @@ public LDAuthenticationDetails(HttpServletRequest request) {
else
secretKey = request.getParameter("key");
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((secretKey == null) ? 0 : secretKey.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
LDAuthenticationDetails other = (LDAuthenticationDetails) obj;
if (secretKey == null) {
if (other.secretKey != null)
return false;
} else if (!secretKey.equals(other.secretKey))
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LDAuthenticationToken extends UsernamePasswordAuthenticationToken {

private String sid;

private boolean anonymous=false;
private boolean anonymous = false;

/**
* Constructor for the anonymous login
Expand Down Expand Up @@ -62,4 +62,29 @@ public String toString() {
return super.toString();
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((sid == null) ? 0 : sid.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
LDAuthenticationToken other = (LDAuthenticationToken) obj;
if (sid == null) {
if (other.sid != null)
return false;
} else if (!sid.equals(other.sid))
return false;
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public static List<File> print(File srcPdf, File dst, Integer page) {
* http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
*/
protected static class StreamGobbler extends Thread {

InputStream is;

StreamGobbler(InputStream is) {
Expand All @@ -150,7 +149,7 @@ public void run() {
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
LoggerFactory.getLogger("console").info(line);
}
} catch (IOException ioe) {
log.error(ioe.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ServerValidationException extends ServerException {
/**
* Array of errors
*/
private ServerValidationError[] errors;
private final ServerValidationError[] errors;

public ServerValidationException() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.Date;
import java.util.List;

import javax.annotation.Nullable;

/**
* This class defines the value of an attribute associated to an extensible
* object. For each value, is possible to define the type and if it is mandatory
Expand Down Expand Up @@ -337,6 +339,7 @@ public void setOptions(List<String> options) {
this.options = options;
}

@Nullable
public Boolean getBooleanValue() {
return booleanValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,35 @@ public boolean hasPermission(String permission) {
return true;
return false;
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((automation == null) ? 0 : automation.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
GUIAutomationRoutine other = (GUIAutomationRoutine) obj;
if (automation == null) {
if (other.automation != null)
return false;
} else if (!automation.equals(other.automation))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public class GUIDocument extends GUIExtensibleObject implements Serializable {

public static final int DOC_UNLOCKED = 0;

private long tenantId;

private Long docRef;

private String docRefType;
Expand Down Expand Up @@ -110,7 +108,7 @@ public class GUIDocument extends GUIExtensibleObject implements Serializable {
private Long formId = null;

// Users to be notified of the upload
private List<Long> notifyUsers=new ArrayList<>();
private List<Long> notifyUsers = new ArrayList<>();

// Optional message to send to users
private String notifyMessage;
Expand Down Expand Up @@ -603,14 +601,6 @@ public void setBulkUpdate(boolean bulkUpdate) {
this.bulkUpdate = bulkUpdate;
}

public long getTenantId() {
return tenantId;
}

public void setTenantId(long tenantId) {
this.tenantId = tenantId;
}

public int getDocAttrs() {
if (docAttrs == 0 && getAttributes().isEmpty())
for (GUIAttribute att : getAttributes())
Expand All @@ -634,19 +624,19 @@ public void setAllowedPermissions(GUIAccessControlEntry permissions) {
public boolean isCustomid() {
return allowedPermissions.isCustomid();
}

public boolean isRead() {
return allowedPermissions.isRead();
}

public boolean isWrite() {
return allowedPermissions.isWrite();
}

public boolean isPreview() {
return allowedPermissions.isPreview();
}

public boolean isDownload() {
return allowedPermissions.isDownload();
}
Expand Down Expand Up @@ -674,4 +664,47 @@ public List<GUIAccessControlEntry> getAccessControlList() {
public void setAccessControlList(List<GUIAccessControlEntry> accessControlList) {
this.accessControlList = accessControlList;
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((fileName == null) ? 0 : fileName.hashCode());
result = prime * result + ((fileVersion == null) ? 0 : fileVersion.hashCode());
result = prime * result + ((folder == null) ? 0 : folder.hashCode());
result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
GUIDocument other = (GUIDocument) obj;
if (fileName == null) {
if (other.fileName != null)
return false;
} else if (!fileName.equals(other.fileName))
return false;
if (fileVersion == null) {
if (other.fileVersion != null)
return false;
} else if (!fileVersion.equals(other.fileVersion))
return false;
if (folder == null) {
if (other.folder != null)
return false;
} else if (!folder.equals(other.folder))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
}
}
Loading

0 comments on commit 83d7e91

Please sign in to comment.