fixed bug allowing users to post while generating file/url previews, fixed bug allowing users to mention theirselves

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@91547 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-02-13 15:35:43 +00:00
parent 31a482eba5
commit 497f7793e0
3 changed files with 47 additions and 5 deletions

14
pom.xml
View File

@ -102,6 +102,18 @@
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.swinglabs</groupId> <groupId>org.swinglabs</groupId>
<artifactId>pdf-renderer</artifactId> <artifactId>pdf-renderer</artifactId>
@ -139,7 +151,7 @@
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId> <artifactId>home-library-jcr</artifactId>
<scope>provided</scope> <scope>provided</scope>

View File

@ -22,8 +22,10 @@ import org.jsonmaker.gwt.client.Jsonizer;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.VerticalAlign;
import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory; import com.google.gwt.uibinder.client.UiFactory;
@ -37,6 +39,8 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FileUpload; import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -341,16 +345,19 @@ public class ShareUpdateForm extends Composite {
for( String item : parts ) { for( String item : parts ) {
if (item.startsWith("http")) { if (item.startsWith("http")) {
preview.add(new LinkLoader()); preview.add(new LinkLoader());
submitButton.setEnabled(false);
//GWT.log("It's http link:" + linkToCheck); //GWT.log("It's http link:" + linkToCheck);
shareupdateService.checkLink(textToCheck, new AsyncCallback<LinkPreview>() { shareupdateService.checkLink(textToCheck, new AsyncCallback<LinkPreview>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
preview.clear(); preview.clear();
submitButton.setEnabled(true);
} }
public void onSuccess(LinkPreview result) { public void onSuccess(LinkPreview result) {
preview.clear(); preview.clear();
if (result != null) if (result != null)
addPreview(result, false); addPreview(result, false);
submitButton.setEnabled(true);
} }
}); });
break; break;
@ -369,11 +376,31 @@ public class ShareUpdateForm extends Composite {
*/ */
protected void checkFile(final String fileName, final String absolutePathOnServer) { protected void checkFile(final String fileName, final String absolutePathOnServer) {
preview.add(new LinkLoader()); preview.add(new LinkLoader());
submitButton.setEnabled(false);
shareupdateService.checkUploadedFile(fileName, absolutePathOnServer, new AsyncCallback<LinkPreview>() { shareupdateService.checkUploadedFile(fileName, absolutePathOnServer, new AsyncCallback<LinkPreview>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
GWT.log("Failed");
uploadProgress.showRegisteringResult(false); uploadProgress.showRegisteringResult(false);
preview.clear(); preview.clear();
attachButton.getElement().getStyle().setVisibility(Visibility.VISIBLE); //beacuse otherwise it looses the other properties setting attachButton.getElement().getStyle().setVisibility(Visibility.VISIBLE); //beacuse otherwise it looses the other properties setting
submitButton.setEnabled(true);
final HorizontalPanel hp = new HorizontalPanel();
final Button close = new Button("Try Again");
final HTML reportIssue = new HTML("<a href=\"https://support.d4science.research-infrastructures.eu\" target=\"_blank\">"
+ "<span>Report the issue</span></a>");
close.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
uploadProgress.setVisible(false);
preview.remove(hp);
}
});
hp.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
hp.add(close);
hp.add(reportIssue);
preview.add(hp);
} }
public void onSuccess(LinkPreview result) { public void onSuccess(LinkPreview result) {
@ -384,6 +411,8 @@ public class ShareUpdateForm extends Composite {
attachButton.getElement().getStyle().setVisibility(Visibility.HIDDEN); //beacuse otherwise it looses the other properties setting attachButton.getElement().getStyle().setVisibility(Visibility.HIDDEN); //beacuse otherwise it looses the other properties setting
uploadedFilePathOnServer = absolutePathOnServer; uploadedFilePathOnServer = absolutePathOnServer;
uploadedFileNameOnServer = fileName; uploadedFileNameOnServer = fileName;
submitButton.setEnabled(true);
} }
}); });
} }

View File

@ -133,8 +133,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
if (user == null) { if (user == null) {
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL"); _log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
user = "test.user"; user = "test.user";
// user = "massimiliano.assante"; user = "massimiliano.assante";
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE"); SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
withinPortal = false; withinPortal = false;
} }
else { else {
@ -811,13 +811,14 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
@Override @Override
public ArrayList<PickingUser> getPortalUsers() { public ArrayList<PickingUser> getPortalUsers() {
ArrayList<PickingUser> portalUsers = new ArrayList<PickingUser>(); ArrayList<PickingUser> portalUsers = new ArrayList<PickingUser>();
String currUser = getASLSession().getUsername();
try { try {
if (withinPortal) { if (withinPortal) {
UserManager um = new LiferayUserManager(); UserManager um = new LiferayUserManager();
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();
List<UserModel> users = um.listUsersByGroup(gm.getRootVO().getGroupId()); List<UserModel> users = um.listUsersByGroup(gm.getRootVO().getGroupId());
for (UserModel user : users) { for (UserModel user : users) {
if (user.getScreenName().compareTo("test.user") != 0) { //skip test.user if (user.getScreenName().compareTo("test.user") != 0 && user.getScreenName().compareTo(currUser) != 0) { //skip test.user & current user
String thumbnailURL = ""; String thumbnailURL = "";
com.liferay.portal.model.UserModel lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getScreenName()); com.liferay.portal.model.UserModel lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getScreenName());
thumbnailURL = "/image/user_male_portrait?img_id="+lifeUser.getPortraitId(); thumbnailURL = "/image/user_male_portrait?img_id="+lifeUser.getPortraitId();