Skip to content

Commit 0f589e8

Browse files
committed
code fixes
1 parent 8b9b031 commit 0f589e8

File tree

63 files changed

+778
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+778
-409
lines changed

logicaldoc-cmis/src/main/java/com/logicaldoc/cmis/LDRepository.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,10 +1870,10 @@ private void compileDocumentOrVersionProperties(AbstractDocument doc, ObjectInfo
18701870
addPropertyId(result, typeId, filter, PropertyIds.OBJECT_TYPE_ID, TypeManager.DOCUMENT_TYPE_ID);
18711871

18721872
// file properties
1873-
if (doc instanceof Document) {
1873+
if (doc instanceof Document document) {
18741874
addPropertyBoolean(result, typeId, filter, PropertyIds.IS_LATEST_VERSION, true);
18751875
addPropertyBoolean(result, typeId, filter, PropertyIds.IS_MAJOR_VERSION,
1876-
doc.getVersion() == null || doc.getVersion().endsWith(".0"));
1876+
document.getVersion() == null || document.getVersion().endsWith(".0"));
18771877
} else {
18781878
Version ver = (Version) doc;
18791879
AbstractDocument d = getDocument(ID_PREFIX_DOC + ver.getDocId());
@@ -1882,9 +1882,11 @@ private void compileDocumentOrVersionProperties(AbstractDocument doc, ObjectInfo
18821882
d.getVersion().equals(ver.getVersion()));
18831883
addPropertyBoolean(result, typeId, filter, PropertyIds.IS_MAJOR_VERSION, ver.getVersion().endsWith(".0"));
18841884
}
1885+
18851886
addPropertyString(result, typeId, filter, PropertyIds.VERSION_LABEL, doc.getVersion());
18861887
addPropertyId(result, typeId, filter, PropertyIds.VERSION_SERIES_ID, getId(doc));
1887-
if (doc.getStatus() != DocumentStatus.CHECKEDOUT) {
1888+
1889+
if (doc.getStatus().equals(DocumentStatus.CHECKEDOUT)) {
18881890
addPropertyBoolean(result, typeId, filter, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, false);
18891891
addPropertyString(result, typeId, filter, PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, null);
18901892
addPropertyString(result, typeId, filter, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, null);
@@ -1897,6 +1899,7 @@ private void compileDocumentOrVersionProperties(AbstractDocument doc, ObjectInfo
18971899
checkoutUser != null ? checkoutUser.getFullName() : null);
18981900
addPropertyString(result, typeId, filter, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, getId(doc));
18991901
}
1902+
19001903
addPropertyString(result, typeId, filter, PropertyIds.CHECKIN_COMMENT, doc.getComment());
19011904
addPropertyInteger(result, typeId, filter, PropertyIds.CONTENT_STREAM_LENGTH, doc.getFileSize());
19021905
objectInfo.setHasContent(true);
@@ -1931,12 +1934,7 @@ private void compileDocumentOrVersionProperties(AbstractDocument doc, ObjectInfo
19311934
addPropertyString(result, typeId, filter, TypeManager.PROP_FILEVERSION, doc.getFileVersion());
19321935
addPropertyString(result, typeId, filter, TypeManager.PROP_VERSION, doc.getVersion());
19331936
addPropertyString(result, typeId, filter, TypeManager.PROP_CUSTOMID, doc.getCustomId());
1934-
1935-
try {
1936-
addPropertyString(result, typeId, filter, TypeManager.PROP_TAGS, doc.getTgs());
1937-
} catch (Exception e) {
1938-
log.error(e.getMessage(), e);
1939-
}
1937+
addPropertyString(result, typeId, filter, TypeManager.PROP_TAGS, StringUtils.defaultString(doc.getTgs()));
19401938

19411939
compileDocumentOrVersionExtAttrsProperties(doc, typeId, result, filter);
19421940
}

logicaldoc-core/src/main/java/com/logicaldoc/core/CorePlugin.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
public class CorePlugin extends LogicalDOCPlugin {
2626

27+
protected static final String DEFAULT = "default";
28+
2729
private static final Logger log = LoggerFactory.getLogger(CorePlugin.class);
2830

2931
@Override
@@ -58,11 +60,11 @@ public void install() throws PluginException {
5860
pbean.setProperty("aspect." + aspect + "." + level.toString(), "true");
5961
}
6062

61-
pbean.setProperty("threadpool.Email.type", "default");
63+
pbean.setProperty("threadpool.Email.type", DEFAULT);
6264
pbean.setProperty("threadpool.EventCollector.max", "20");
63-
pbean.setProperty("threadpool.EventCollector.type", "default");
65+
pbean.setProperty("threadpool.EventCollector.type", DEFAULT);
6466
pbean.setProperty("threadpool."+IndexerTask.NAME+".max", "2");
65-
pbean.setProperty("threadpool."+IndexerTask.NAME+".type", "default");
67+
pbean.setProperty("threadpool."+IndexerTask.NAME+".type", DEFAULT);
6668

6769
pbean.write();
6870
} catch (IOException e) {

logicaldoc-core/src/main/java/com/logicaldoc/core/automation/Automation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ private Map<String, Object> prepareDictionary(Map<String, Object> clientDictiona
159159
Class<?> beanClass = Class.forName(beanClassName);
160160

161161
String key = beanClass.getSimpleName();
162-
AutomationDictionary annotation = (AutomationDictionary) beanClass
163-
.getAnnotation(AutomationDictionary.class);
162+
AutomationDictionary annotation = beanClass.getAnnotation(AutomationDictionary.class);
164163
if (annotation != null && StringUtils.isNotEmpty(annotation.key()))
165164
key = annotation.key();
166165

logicaldoc-core/src/main/java/com/logicaldoc/core/conversion/FormatConverterManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import javax.annotation.Resource;
1414

15+
import org.apache.commons.collections.CollectionUtils;
1516
import org.apache.commons.lang.StringUtils;
1617
import org.java.plugin.registry.Extension;
1718
import org.slf4j.Logger;
@@ -442,9 +443,9 @@ public FormatConverter getConverter(String inFileName, String outFileName) {
442443
String inOutkey = composeKey(inFileName, outFileName);
443444

444445
List<FormatConverter> formatConverters = getConverters().get(inOutkey);
445-
if (formatConverters == null || formatConverters.isEmpty())
446+
if (CollectionUtils.isEmpty(formatConverters))
446447
formatConverters = getConverters().get("*-pdf");
447-
if (formatConverters == null || formatConverters.isEmpty())
448+
if (CollectionUtils.isEmpty(formatConverters))
448449
log.warn("No format converter for file {}", inFileName);
449450

450451
// Get the first available and enabled converter

logicaldoc-core/src/main/java/com/logicaldoc/core/document/AbstractDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ public void setTagsFromWords(Set<String> tgs) {
939939
if (CollectionUtils.isEmpty(tgs)) {
940940
this.tgs = null;
941941
} else {
942-
tgs.stream().collect(Collectors.joining(","));
942+
this.tgs = tgs.stream().collect(Collectors.joining(","));
943943
}
944944
}
945945

logicaldoc-core/src/main/java/com/logicaldoc/core/document/AbstractDocumentHistory.java

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public abstract class AbstractDocumentHistory extends History {
2323

2424
@Column(name = "ld_folderid")
2525
private Long folderId;
26-
26+
2727
@Column(name = "ld_filesize")
2828
private Long fileSize = null;
29-
29+
3030
@Column(name = "ld_filename", length = 255)
3131
private String filename = null;
32-
32+
3333
/**
3434
* Something to better qualify the event
3535
*/
@@ -47,15 +47,15 @@ public abstract class AbstractDocumentHistory extends History {
4747

4848
@Column(name = "ld_filenameold", length = 255)
4949
private String filenameOld = null;
50-
50+
5151
@Transient
5252
private AbstractDocument document;
5353

5454
// Not persistent
5555
@Transient
5656
private Folder folder;
5757

58-
public AbstractDocumentHistory() {
58+
protected AbstractDocumentHistory() {
5959
super();
6060
}
6161

@@ -74,31 +74,31 @@ public Long getFolderId() {
7474
public void setFolderId(Long folderId) {
7575
this.folderId = folderId;
7676
}
77-
77+
7878
public Long getFileSize() {
7979
return fileSize;
8080
}
8181

8282
public void setFileSize(Long fileSize) {
8383
this.fileSize = fileSize;
8484
}
85-
85+
8686
public String getFilename() {
8787
return filename;
8888
}
8989

9090
public void setFilename(String filename) {
9191
this.filename = filename;
9292
}
93-
93+
9494
public String getReason() {
9595
return reason;
9696
}
9797

9898
public void setReason(String reason) {
9999
this.reason = reason;
100100
}
101-
101+
102102
public AbstractDocument getDocument() {
103103
return document;
104104
}
@@ -158,12 +158,12 @@ protected void copyAttributesFrom(AbstractDocumentHistory source) {
158158
}
159159

160160
public void setDocument(AbstractDocument document) {
161-
this.document = document;
162-
161+
this.document = document;
162+
163163
if (document != null) {
164164
this.setFileSize(document.getFileSize());
165165
this.setFilename(document.getFileName());
166-
166+
167167
if (document instanceof Version ver) {
168168
this.setDocId(ver.getDocId());
169169
this.setFolderId(ver.getFolderId());
@@ -173,4 +173,41 @@ public void setDocument(AbstractDocument document) {
173173
}
174174
}
175175
}
176+
177+
@Override
178+
public int hashCode() {
179+
final int prime = 31;
180+
int result = super.hashCode();
181+
result = prime * result + ((docId == null) ? 0 : docId.hashCode());
182+
result = prime * result + ((folderId == null) ? 0 : folderId.hashCode());
183+
result = prime * result + ((version == null) ? 0 : version.hashCode());
184+
return result;
185+
}
186+
187+
@Override
188+
public boolean equals(Object obj) {
189+
if (this == obj)
190+
return true;
191+
if (!super.equals(obj))
192+
return false;
193+
if (getClass() != obj.getClass())
194+
return false;
195+
AbstractDocumentHistory other = (AbstractDocumentHistory) obj;
196+
if (docId == null) {
197+
if (other.docId != null)
198+
return false;
199+
} else if (!docId.equals(other.docId))
200+
return false;
201+
if (folderId == null) {
202+
if (other.folderId != null)
203+
return false;
204+
} else if (!folderId.equals(other.folderId))
205+
return false;
206+
if (version == null) {
207+
if (other.version != null)
208+
return false;
209+
} else if (!version.equals(other.version))
210+
return false;
211+
return true;
212+
}
176213
}

logicaldoc-core/src/main/java/com/logicaldoc/core/document/Document.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,29 @@ public void addAccessControlEntry(DocumentAccessControlEntry ace) {
340340
getAccessControlList().add(ace);
341341
}
342342
}
343+
344+
@Override
345+
public int hashCode() {
346+
final int prime = 31;
347+
int result = super.hashCode();
348+
result = prime * result + ((docRef == null) ? 0 : docRef.hashCode());
349+
return result;
350+
}
351+
352+
@Override
353+
public boolean equals(Object obj) {
354+
if (this == obj)
355+
return true;
356+
if (!super.equals(obj))
357+
return false;
358+
if (getClass() != obj.getClass())
359+
return false;
360+
Document other = (Document) obj;
361+
if (docRef == null) {
362+
if (other.docRef != null)
363+
return false;
364+
} else if (!docRef.equals(other.docRef))
365+
return false;
366+
return true;
367+
}
343368
}

0 commit comments

Comments
 (0)