() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Window.alert("Sorry, an error occurred");
+ cancelHeadline();
+ }
+
+ @Override
+ public void onSuccess(Boolean result) {
+ headline.removeStyleName("edit");
+ editHeadline.setVisible(true);
+ headline.getElement().getStyle().setOpacity(1.0);
+ }
+ });
+
+ }
+ }
+ });
+
+ cancelHead.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ cancelHeadline();
+ }
+ });
+ }
+
+ private void cancelHeadline() {
+ headline.removeStyleName("edit");
+ headline.setReadOnly(true);
+ editHeadline.setVisible(true);
+ saveHead.setVisible(false);
+ cancelHead.setVisible(false);
+ headline.setText(currHeadLine);
}
/**
* check if it has to show just one feed
@@ -71,4 +181,19 @@ public class DisplayProfile extends Composite {
private String getUserToShowId() {
return Window.Location.getParameter(GET_OID_PARAMETER);
}
+
+ /**
+ * Escape an html string. Escaping data received from the client helps to
+ * prevent cross-site script vulnerabilities.
+ *
+ * @param html the html string to escape
+ * @return the escaped string
+ */
+ private String escapeHtml(String html) {
+ if (html == null) {
+ return null;
+ }
+ return html.replaceAll("&", "&").replaceAll("<", "<")
+ .replaceAll(">", ">");
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml
index 1d3c1db..5de82e0 100644
--- a/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml
+++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml
@@ -11,11 +11,38 @@
-
+ |
-
-
+
+
+
+
+ |
+
+ Save
+ Cancel
+
+
+ |
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
|
diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java b/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java
index 77ef281..8362a1b 100644
--- a/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java
@@ -10,6 +10,11 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.socialprofile.client.SocialService;
import org.gcube.portlets.user.socialprofile.shared.UserContext;
+import org.gcube.vomanagement.usermanagement.UserManager;
+import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
+import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
+import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
+import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.exception.PortalException;
@@ -64,10 +69,40 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
else {
System.out.println("Reading Profile");
_log.info(userid + " Reading Profile");
- return new UserContext();
+ return getUserProfile(userid);
}
}
+ private UserContext getUserProfile(String username) {
+ ASLSession session = getASLSession();
+ String email = username+"@isti.cnr.it";
+ String fullName = username+" FULL";
+ String thumbnailURL = "images/Avatar_default.png";
+ if (withinPortal) {
+ try {
+ com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
+ thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
+ fullName = user.getFirstName() + " " + user.getLastName();
+ email = user.getEmailAddress();
+ HashMap vreNames = new HashMap();
+ UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), "", true, false, vreNames);
+ return new UserContext(userInfo, getHeadline(username), getInstitution(username), session.getScopeName(), true);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new UserContext();
+ }
+ } else {
+ _log.info("Returning test USER");
+ HashMap fakeVreNames = new HashMap();
+ fakeVreNames.put("/gcube/devsec/devVRE","devVRE");
+ //fakeVreNames.put("/gcube/devNext/NexNext","NexNext");
+
+ UserInfo user = new UserInfo(username, username+ "FULL", thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
+ return new UserContext(user, null, "Institution", session.getScopeName(), true);
+ }
+ }
+
private UserContext getOwnProfile() {
try {
ASLSession session = getASLSession();
@@ -96,7 +131,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
//fakeVreNames.put("/gcube/devNext/NexNext","NexNext");
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
- return new UserContext(user, "headline", "Institution", session.getScopeName(), true);
+ return new UserContext(user, "", "", session.getScopeName(), true);
}
} catch (Exception e) {
@@ -114,4 +149,47 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
User user = OrganizationsUtil.validateUser(userid);
return user.getComments();
}
+
+ @Override
+ public Boolean saveHeadline(String newHeadline) {
+ com.liferay.portal.model.User user;
+ try {
+ user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), getASLSession().getUsername());
+ user.setJobTitle(escapeHtml(newHeadline));
+ return (UserLocalServiceUtil.updateUser(user) != null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ }
+ @Override
+ public Boolean saveIsti(String institution) {
+ com.liferay.portal.model.User user;
+ try {
+ user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), getASLSession().getUsername());
+ user.setComments(escapeHtml(institution));
+ return (UserLocalServiceUtil.updateUser(user) != null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * Escape an html string. Escaping data received from the client helps to
+ * prevent cross-site script vulnerabilities.
+ *
+ * @param html the html string to escape
+ * @return the escaped string
+ */
+ private String escapeHtml(String html) {
+ if (html == null) {
+ return null;
+ }
+ return html.replaceAll("&", "&").replaceAll("<", "<")
+ .replaceAll(">", ">");
+ }
+
+
}
diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml
index 76292ac..d645b22 100644
--- a/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml
@@ -4,8 +4,6 @@
-
-
diff --git a/src/main/webapp/SocialProfile.css b/src/main/webapp/SocialProfile.css
index cdc22aa..fee903a 100644
--- a/src/main/webapp/SocialProfile.css
+++ b/src/main/webapp/SocialProfile.css
@@ -23,14 +23,42 @@
font-weight: bold;
}
+.edit {
+ border: 1px solid #999 !important;
+ cursor: text !important;
+ opacity: 1.0 !important;
+}
+
.headline {
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
color: #444444;
+ border: 0;
+ cursor: default;
+ width: 250px;
}
.institution {
font-family: Helvetica, Arial, sans-serif;
- font-size: 12px;
+ font-size: 16px;
color: #444444;
+ border: 0;
+ cursor: default;
+ width: 250px;
+}
+
+.editImage {
+ background: url(images/edit.png) 0px 0px no-repeat;
+ height: 15px;
+ width: 15px;
+}
+
+.editImage:hover {
+ background: url(images/edit.png) 0px -16px no-repeat;
+ cursor: pointer;
+ cursor: hand;
+}
+
+.editImage:active {
+ background: url(images/edit.png) 0px -32px no-repeat;
}
\ No newline at end of file
diff --git a/src/main/webapp/images/edit.png b/src/main/webapp/images/edit.png
new file mode 100644
index 0000000..03d88a1
Binary files /dev/null and b/src/main/webapp/images/edit.png differ
diff --git a/src/main/webapp/images/saving.gif b/src/main/webapp/images/saving.gif
new file mode 100644
index 0000000..b644918
Binary files /dev/null and b/src/main/webapp/images/saving.gif differ