Skip to content

Commit ab5d5cc

Browse files
committed
updated classes, resolved compilation errors
1 parent 97aff8c commit ab5d5cc

File tree

13 files changed

+295
-96
lines changed

13 files changed

+295
-96
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/EventCollector.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,25 @@ public void newEvent(History history) {
9696
if (!rememberHistory(history))
9797
return;
9898

99-
if (history.getDocId() != null && history.getDocument() == null) {
100-
DocumentDAO docDao = com.logicaldoc.util.Context.get(DocumentDAO.class);
101-
try {
102-
history.setDocument(docDao.findById(history.getDocId()));
103-
} catch (PersistenceException e) {
104-
log.error(e.getMessage(), e);
99+
if (history instanceof AbstractDocumentHistory adh) {
100+
if (adh.getDocId() != null && adh.getDocument() == null) {
101+
DocumentDAO docDao = com.logicaldoc.util.Context.get(DocumentDAO.class);
102+
try {
103+
adh.setDocument(docDao.findById(adh.getDocId()));
104+
} catch (PersistenceException e) {
105+
log.error(e.getMessage(), e);
106+
}
107+
} else if (adh.getDocument() != null && adh.getDocument() instanceof Document doc) {
108+
/*
109+
* Do not use the original document because to avoid
110+
* interactions with Hibernate session.
111+
*/
112+
Document clone = new Document(doc);
113+
// Restore some attributes skipped by the clone method
114+
clone.setCustomId(adh.getDocument().getCustomId());
115+
clone.setStatus(adh.getDocument().getStatus());
116+
adh.setDocument(clone);
105117
}
106-
} else if (history.getDocument() != null && history.getDocument() instanceof Document doc) {
107-
/*
108-
* Do not use the original document because to avoid interactions
109-
* with Hibernate session.
110-
*/
111-
Document clone = new Document(doc);
112-
// Restore some attributes skipped by the clone method
113-
clone.setCustomId(history.getDocument().getCustomId());
114-
clone.setStatus(history.getDocument().getStatus());
115-
history.setDocument(clone);
116118
}
117119

118120
ThreadPools pools = Context.get(ThreadPools.class);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.logicaldoc.core.document;
22

33
import javax.persistence.Cacheable;
4+
import javax.persistence.Column;
45
import javax.persistence.Entity;
56
import javax.persistence.Table;
67

@@ -23,12 +24,24 @@
2324
public class DocumentHistory extends AbstractDocumentHistory {
2425
private static final long serialVersionUID = 1L;
2526

27+
@Column(name = "ld_color", length = 255)
28+
protected String color;
29+
30+
public String getColor() {
31+
return color;
32+
}
33+
34+
public void setColor(String color) {
35+
this.color = color;
36+
}
37+
2638
public DocumentHistory() {
2739
super();
2840
}
2941

3042
public DocumentHistory(DocumentHistory source) {
3143
copyAttributesFrom(source);
44+
this.color=source.color;
3245
}
3346

3447
@Override

logicaldoc-core/src/main/java/com/logicaldoc/core/folder/FolderHistory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.logicaldoc.core.folder;
22

33
import javax.persistence.Cacheable;
4+
import javax.persistence.Column;
45
import javax.persistence.Entity;
56
import javax.persistence.Table;
67

@@ -23,11 +24,23 @@ public class FolderHistory extends AbstractDocumentHistory {
2324

2425
private static final long serialVersionUID = 1L;
2526

27+
@Column(name = "ld_color", length = 255)
28+
protected String color;
29+
30+
public String getColor() {
31+
return color;
32+
}
33+
34+
public void setColor(String color) {
35+
this.color = color;
36+
}
37+
2638
public FolderHistory() {
2739
super();
2840
}
2941

3042
public FolderHistory(FolderHistory source) {
3143
copyAttributesFrom(source);
44+
this.color = source.color;
3245
}
3346
}

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

Lines changed: 111 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import javax.persistence.Column;
44
import javax.persistence.MappedSuperclass;
5+
import javax.persistence.Transient;
56

67
import com.logicaldoc.core.document.AbstractDocument;
8+
import com.logicaldoc.core.document.Document;
9+
import com.logicaldoc.core.document.Version;
10+
import com.logicaldoc.core.folder.Folder;
711

812
/**
913
* A superclass for those histories tightly related to documents
@@ -16,9 +20,6 @@ public abstract class AbstractDocumentHistory extends History {
1620

1721
private static final long serialVersionUID = 1L;
1822

19-
@Column(name = "ld_color", length = 255)
20-
protected String color;
21-
2223
@Column(name = "ld_version", length = 10)
2324
protected String version = null;
2425

@@ -30,17 +31,71 @@ public abstract class AbstractDocumentHistory extends History {
3031

3132
@Column(name = "ld_filenameold", length = 255)
3233
protected String filenameOld = null;
34+
35+
@Column(name = "ld_docid")
36+
private Long docId;
37+
38+
@Column(name = "ld_folderid")
39+
private Long folderId;
40+
41+
@Column(name = "ld_filename", length = 255)
42+
private String filename = null;
43+
44+
@Column(name = "ld_filesize")
45+
private Long fileSize = null;
46+
47+
@Column(name = "ld_new")
48+
private int isNew = 1;
49+
50+
/**
51+
* Something to better qualify the event
52+
*/
53+
@Column(name = "ld_reason")
54+
private String reason = null;
55+
56+
// Not persistent
57+
@Transient
58+
private AbstractDocument document;
59+
60+
// Not persistent
61+
@Transient
62+
private Folder folder;
63+
3364

3465
public AbstractDocumentHistory() {
3566
super();
3667
}
68+
69+
public Long getDocId() {
70+
return docId;
71+
}
72+
73+
public void setDocId(Long docId) {
74+
this.docId = docId;
75+
}
76+
77+
public Long getFolderId() {
78+
return folderId;
79+
}
80+
81+
public void setFolderId(Long folderId) {
82+
this.folderId = folderId;
83+
}
84+
85+
public String getFilename() {
86+
return filename;
87+
}
3788

38-
public String getColor() {
39-
return color;
89+
public void setFilename(String filename) {
90+
this.filename = filename;
4091
}
4192

42-
public void setColor(String color) {
43-
this.color = color;
93+
public Long getFileSize() {
94+
return fileSize;
95+
}
96+
97+
public void setFileSize(Long fileSize) {
98+
this.fileSize = fileSize;
4499
}
45100

46101
public String getVersion() {
@@ -74,23 +129,66 @@ public String getFilenameOld() {
74129
public void setFilenameOld(String filenameOld) {
75130
this.filenameOld = filenameOld;
76131
}
132+
133+
public int getIsNew() {
134+
return isNew;
135+
}
136+
137+
public void setIsNew(int isNew) {
138+
this.isNew = isNew;
139+
}
140+
141+
public String getReason() {
142+
return reason;
143+
}
144+
145+
public void setReason(String reason) {
146+
this.reason = reason;
147+
}
148+
149+
public Folder getFolder() {
150+
return folder;
151+
}
152+
153+
public void setFolder(Folder folder) {
154+
this.folder = folder;
155+
}
156+
157+
public AbstractDocument getDocument() {
158+
return document;
159+
}
77160

78-
@Override
79161
public void setDocument(AbstractDocument document) {
80-
super.setDocument(document);
162+
this.document = document;
81163
if (document != null) {
82-
this.setVersion(document.getVersion());
83-
this.setFileVersion(document.getFileVersion());
84-
this.setColor(document.getColor());
164+
this.setTenantId(document.getTenantId());
165+
if (document instanceof Version ver)
166+
this.setDocId(ver.getDocId());
167+
else
168+
this.setDocId(document.getId());
169+
170+
this.setFilename(document.getFileName());
171+
this.setFileSize(document.getFileSize());
172+
173+
if (document instanceof Version ver)
174+
this.setFolderId(ver.getFolderId());
175+
else if (document instanceof Document doc)
176+
this.setFolderId(doc.getFolder().getId());
85177
}
86178
}
87179

180+
88181
protected void copyAttributesFrom(AbstractDocumentHistory source) {
89182
super.copyAttributesFrom(source);
90-
setColor(source.getColor());
91183
setVersion(source.getVersion());
92184
setFileVersion(source.getFileVersion());
93185
setPathOld(source.getPathOld());
94186
setFilenameOld(source.getFilenameOld());
187+
setDocId(source.getDocId());
188+
setFolderId(source.getFolderId());
189+
setReason(source.getReason());
190+
setIsNew(source.getIsNew());
191+
setFilename(source.getFilename());
192+
setFileSize(source.getFileSize());
95193
}
96194
}

logicaldoc-core/src/main/java/com/logicaldoc/core/security/user/UserHistory.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ public class UserHistory extends History {
2828
@Column(name = "ld_author", length = 255)
2929
private String author;
3030

31+
@Column(name = "ld_filename", length = 255)
32+
private String filename = null;
33+
34+
@Column(name = "ld_filesize")
35+
private Long fileSize = null;
36+
37+
@Column(name = "ld_docid")
38+
private Long docId;
39+
40+
@Column(name = "ld_folderid")
41+
private Long folderId;
42+
3143
public UserHistory() {
3244
super();
3345
}
@@ -39,7 +51,19 @@ public UserHistory(Session session) {
3951

4052
public UserHistory(UserHistory source) {
4153
copyAttributesFrom(source);
42-
setAuthor(source.getAuthor());
54+
this.author = source.author;
55+
this.filename = source.filename;
56+
this.fileSize = source.fileSize;
57+
this.folderId = source.folderId;
58+
this.docId = source.docId;
59+
}
60+
61+
public Long getFolderId() {
62+
return folderId;
63+
}
64+
65+
public void setFolderId(Long folderId) {
66+
this.folderId = folderId;
4367
}
4468

4569
public String getAuthor() {
@@ -50,6 +74,30 @@ public void setAuthor(String author) {
5074
this.author = author;
5175
}
5276

77+
public String getFilename() {
78+
return filename;
79+
}
80+
81+
public void setFilename(String filename) {
82+
this.filename = filename;
83+
}
84+
85+
public Long getFileSize() {
86+
return fileSize;
87+
}
88+
89+
public void setFileSize(Long fileSize) {
90+
this.fileSize = fileSize;
91+
}
92+
93+
public Long getDocId() {
94+
return docId;
95+
}
96+
97+
public void setDocId(Long docId) {
98+
this.docId = docId;
99+
}
100+
53101
@Override
54102
public int hashCode() {
55103
final int prime = 31;

logicaldoc-core/src/main/resources/mappings/UserHistory.hbm.skip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,27 @@
1616
<property name="creation" type="timestamp" column="ld_creation" not-null="true" />
1717
<property name="deleted" type="int" column="ld_deleted" not-null="true" />
1818
<property name="tenantId" type="long" column="ld_tenantid" not-null="true" />
19+
1920
<property name="docId" type="long" column="ld_docid"/>
2021
<property name="folderId" type="long" column="ld_folderid" />
22+
2123
<property name="userId" type="long" column="ld_userid" />
2224
<property name="date" type="timestamp" column="ld_date" />
2325
<property name="username" type="string" column="ld_username" length="255" />
2426
<property name="userLogin" type="string" column="ld_userlogin" length="255" />
2527
<property name="event" type="string" column="ld_event" length="255" />
2628
<property name="comment" type="string" column="ld_comment" length="4000" />
29+
2730
<property name="reason" type="string" column="ld_reason" length="4000" />
31+
2832
<property name="notified" type="int" column="ld_notified" not-null="true" />
2933
<property name="sessionId" type="string" column="ld_sessionid" length="255" />
3034
<property name="keyLabel" type="string" column="ld_keylabel" length="255" />
3135
<property name="isNew" type="int" column="ld_new" />
36+
3237
<property name="filename" type="string" column="ld_filename" length="255" />
3338
<property name="fileSize" type="long" column="ld_filesize"/>
39+
3440
<property name="ip" type="string" column="ld_ip" length="255" />
3541
<property name="author" type="string" column="ld_author" length="255" />
3642
<property name="geolocation" type="string" column="ld_geolocation" length="255" />

logicaldoc-webapp/src/main/java/com/logicaldoc/web/service/DocumentServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
import com.logicaldoc.core.metadata.TemplateDAO;
8686
import com.logicaldoc.core.metadata.validation.Validator;
8787
import com.logicaldoc.core.parser.ParsingException;
88-
import com.logicaldoc.core.security.AccessControlEntry;
8988
import com.logicaldoc.core.security.Permission;
9089
import com.logicaldoc.core.security.Session;
9190
import com.logicaldoc.core.security.authorization.PermissionException;

0 commit comments

Comments
 (0)