Skip to content

Commit c707ecf

Browse files
integrating feature #5523
1 parent 4cd73ba commit c707ecf

File tree

2 files changed

+22
-107
lines changed

2 files changed

+22
-107
lines changed

gallery/gallery-ejb/src/main/java/com/silverpeas/gallery/socialNetwork/SocialInformationGallery.java

Lines changed: 20 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -20,126 +20,45 @@
2020
*/
2121
package com.silverpeas.gallery.socialNetwork;
2222

23+
import org.apache.commons.lang.builder.HashCodeBuilder;
24+
2325
import com.silverpeas.gallery.model.InternalMedia;
2426
import com.silverpeas.gallery.model.MediaWithStatus;
25-
import com.silverpeas.socialnetwork.model.SocialInformation;
27+
import com.silverpeas.socialnetwork.model.AbstractSocialInformation;
2628
import com.silverpeas.socialnetwork.model.SocialInformationType;
2729
import com.silverpeas.util.StringUtil;
2830

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 {
4332

4433
public SocialInformationGallery(MediaWithStatus picture) {
4534

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();
5139
if (!StringUtil.isDefined(description)) {
5240
description = "";
5341
}
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());
5747
} else {
58-
this.author = picture.getMedia().getCreatorId();
59-
dateTime = picture.getMedia().getCreationDate().getTime();
48+
setAuthor(picture.getMedia().getCreatorId());
49+
setDate(picture.getMedia().getCreationDate());
6050
}
61-
this.url =
62-
"/Rgallery/" + picture.getMedia().getInstanceId() + "/" + picture.getMedia().getURL();
51+
setUrl("/Rgallery/" + picture.getMedia().getInstanceId() + "/" + picture.getMedia().getURL());
6352
String id = picture.getMedia().getId();
6453
String mimeType = "streaming";
6554
if (picture.getMedia() instanceof InternalMedia) {
6655
mimeType = ((InternalMedia) picture.getMedia()).getFileMimeType().getMimeType();
6756
}
68-
this.icon =
57+
String icon =
6958
"/FileServer/" + id + "_preview.jpg?ComponentId=" + picture.getMedia().getInstanceId() +
7059
"&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());
14362
}
14463

14564
/*
@@ -175,8 +94,4 @@ public int hashCode() {
17594
.toHashCode();
17695
}
17796

178-
@Override
179-
public int compareTo(SocialInformation o) {
180-
return o.getDate().compareTo(getDate());
181-
}
182-
}
97+
}

gallery/gallery-ejb/src/test/java/com/silverpeas/gallery/dao/PhotoDaoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public void testGetAllPhotosIdByUserid() throws Exception {
8080
assertThat(photos, notNullValue());
8181
assertThat(photos, hasSize(4));
8282
assertThat(photos.get(0), equalTo(socialmer1));
83-
assertThat(photos.get(0).isUpdeted(), equalTo(true));
83+
assertThat(photos.get(0).isUpdated(), equalTo(true));
8484
assertThat(photos.get(1), equalTo(socialmer2));
85-
assertThat(photos.get(1).isUpdeted(), equalTo(false));
85+
assertThat(photos.get(1).isUpdated(), equalTo(false));
8686
assertThat(photos.get(2), equalTo(socialFleur));
8787
assertThat(photos.get(3), equalTo(socialCiel));
8888
} finally {

0 commit comments

Comments
 (0)