20
20
*/
21
21
package com .silverpeas .gallery .socialNetwork ;
22
22
23
+ import org .apache .commons .lang .builder .HashCodeBuilder ;
24
+
23
25
import com .silverpeas .gallery .model .InternalMedia ;
24
26
import com .silverpeas .gallery .model .MediaWithStatus ;
25
- import com .silverpeas .socialnetwork .model .SocialInformation ;
27
+ import com .silverpeas .socialnetwork .model .AbstractSocialInformation ;
26
28
import com .silverpeas .socialnetwork .model .SocialInformationType ;
27
29
import com .silverpeas .util .StringUtil ;
28
30
29
- import java .util .Date ;
30
-
31
- import org .apache .commons .lang .builder .HashCodeBuilder ;
32
-
33
- public class SocialInformationGallery implements SocialInformation {
34
-
35
- private final SocialInformationType type = SocialInformationType .MEDIA ;
36
- private String title ;
37
- private String description ;
38
- private boolean socialInformationWasupdated = false ;
39
- private String author ;
40
- private long dateTime ;
41
- private String url ;
42
- private String icon ;
31
+ public class SocialInformationGallery extends AbstractSocialInformation {
43
32
44
33
public SocialInformationGallery (MediaWithStatus picture ) {
45
34
46
- this .title = picture .getMedia ().getTitle ();
47
-
48
- this .socialInformationWasupdated = picture .isUpdate ();
49
-
50
- this .description = picture .getMedia ().getDescription ();
35
+ setTitle (picture .getMedia ().getTitle ());
36
+ setUpdated (picture .isUpdate ());
37
+
38
+ String description = picture .getMedia ().getDescription ();
51
39
if (!StringUtil .isDefined (description )) {
52
40
description = "" ;
53
41
}
54
- if (socialInformationWasupdated ) {
55
- this .author = picture .getMedia ().getLastUpdatedBy ();
56
- this .dateTime = picture .getMedia ().getLastUpdateDate ().getTime ();
42
+ setDescription (description );
43
+
44
+ if (isUpdated ()) {
45
+ setAuthor (picture .getMedia ().getLastUpdatedBy ());
46
+ setDate (picture .getMedia ().getLastUpdateDate ());
57
47
} else {
58
- this . author = picture .getMedia ().getCreatorId ();
59
- dateTime = picture .getMedia ().getCreationDate (). getTime ( );
48
+ setAuthor ( picture .getMedia ().getCreatorId () );
49
+ setDate ( picture .getMedia ().getCreationDate ());
60
50
}
61
- this .url =
62
- "/Rgallery/" + picture .getMedia ().getInstanceId () + "/" + picture .getMedia ().getURL ();
51
+ setUrl ("/Rgallery/" + picture .getMedia ().getInstanceId () + "/" + picture .getMedia ().getURL ());
63
52
String id = picture .getMedia ().getId ();
64
53
String mimeType = "streaming" ;
65
54
if (picture .getMedia () instanceof InternalMedia ) {
66
55
mimeType = ((InternalMedia ) picture .getMedia ()).getFileMimeType ().getMimeType ();
67
56
}
68
- this . icon =
57
+ String icon =
69
58
"/FileServer/" + id + "_preview.jpg?ComponentId=" + picture .getMedia ().getInstanceId () +
70
59
"&SourceFile=" + id + "_preview.jpg&MimeType=" + mimeType + "&Directory=image" + id ;
71
- }
72
-
73
- /**
74
- * return the Title of this SocialInformation
75
- * @return String
76
- */
77
- @ Override
78
- public String getTitle () {
79
- return title ;
80
- }
81
-
82
- /**
83
- * return the Description of this SocialInformation
84
- * @return String
85
- */
86
- @ Override
87
- public String getDescription () {
88
- return description ;
89
- }
90
-
91
- /**
92
- * return the Author of this SocialInfo
93
- * @return String
94
- */
95
- @ Override
96
- public String getAuthor () {
97
- return author ;
98
- }
99
-
100
- /**
101
- * return the Url of this SocialInfo
102
- * @return String
103
- */
104
- @ Override
105
- public String getUrl () {
106
- return url ;
107
- }
108
-
109
- /**
110
- * return the Date of this SocialInfo
111
- * @return
112
- */
113
- @ Override
114
- public Date getDate () {
115
- return new Date (dateTime );
116
- }
117
-
118
- /**
119
- * return the icon of this SocialInformation
120
- * @return String
121
- */
122
- @ Override
123
- public String getIcon () {
124
- return icon ;
125
- }
126
-
127
- /**
128
- * return the type of this SocialInformation
129
- * @return String
130
- */
131
- @ Override
132
- public String getType () {
133
- return type .toString ();
134
- }
135
-
136
- /**
137
- * return if this socialInfo was updtated or not
138
- * @return boolean
139
- */
140
- @ Override
141
- public boolean isUpdeted () {
142
- return socialInformationWasupdated ;
60
+ setIcon (icon );
61
+ setType (SocialInformationType .MEDIA .toString ());
143
62
}
144
63
145
64
/*
@@ -175,8 +94,4 @@ public int hashCode() {
175
94
.toHashCode ();
176
95
}
177
96
178
- @ Override
179
- public int compareTo (SocialInformation o ) {
180
- return o .getDate ().compareTo (getDate ());
181
- }
182
- }
97
+ }
0 commit comments