diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..aa63bb7 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..eedc03e --- /dev/null +++ b/.project @@ -0,0 +1,59 @@ + + + social-profile + social-profile project + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + com.google.gdt.eclipse.core.webAppProjectValidator + + + + + com.google.gwt.eclipse.core.gwtProjectValidator + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + com.google.gwt.eclipse.core.gwtNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..ba3c245 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/.settings/com.google.appengine.eclipse.core.prefs b/.settings/com.google.appengine.eclipse.core.prefs new file mode 100644 index 0000000..e4ac63a --- /dev/null +++ b/.settings/com.google.appengine.eclipse.core.prefs @@ -0,0 +1,3 @@ +#Mon Jan 21 12:20:12 CET 2013 +eclipse.preferences.version=1 +filesCopiedToWebInfLib= diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs new file mode 100644 index 0000000..caa65d7 --- /dev/null +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -0,0 +1,6 @@ +#Mon Jan 21 12:24:20 CET 2013 +eclipse.preferences.version=1 +jarsExcludedFromWebInfLib= +lastWarOutDir=/Users/massi/Documents/workspace/social-profile/target/social-profile-0.1.0-SNAPSHOT +warSrcDir=src/main/webapp +warSrcDirIsOutput=false diff --git a/.settings/com.google.gwt.eclipse.core.prefs b/.settings/com.google.gwt.eclipse.core.prefs new file mode 100644 index 0000000..c803c44 --- /dev/null +++ b/.settings/com.google.gwt.eclipse.core.prefs @@ -0,0 +1,5 @@ +#Thu Jun 16 11:14:17 CEST 2011 +eclipse.preferences.version=1 +entryPointModules= +filesCopiedToWebInfLib=gwt-servlet.jar +gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgc3JjL21haW4vd2ViYXBwXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLmNvbXBhbnkuU29tZU1vZHVsZTwvZW50cnktcG9pbnQtbW9kdWxlPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+ diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..5d8b3cc --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +#Mon Jan 21 12:20:12 CET 2013 +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ad26666 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +#Thu Sep 02 10:42:20 CEST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..a22402a --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Mon Jan 21 12:20:12 CET 2013 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..737c457 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..18c1b9a --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000..c74c58e --- /dev/null +++ b/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Thu Sep 02 10:42:12 CEST 2010 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/SocialProfileTest-dev.launch b/SocialProfileTest-dev.launch new file mode 100644 index 0000000..3b2a700 --- /dev/null +++ b/SocialProfileTest-dev.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/SocialProfileTest-prod.launch b/SocialProfileTest-prod.launch new file mode 100644 index 0000000..01943c8 --- /dev/null +++ b/SocialProfileTest-prod.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d64e7cf --- /dev/null +++ b/pom.xml @@ -0,0 +1,187 @@ + + + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + + + org.gcube.portlets.user + social-profile + war + 0.1.0-SNAPSHOT + gCube Social Profile Portlet + + + + 2.4.0 + distro + + 1.6 + 1.6 + ${project.build.directory}/${project.build.finalName} + + UTF-8 + UTF-8 + + + + + + xerces + xercesImpl + 2.9.1 + provided + + + com.google.gwt + gwt-user + ${gwtVersion} + provided + + + com.google.gwt + gwt-servlet + ${gwtVersion} + provided + + + org.gcube.core + gcf + [1.4.0,1.5.0] + provided + + + org.gcube.portal + custom-portal-handler + 1.2.0-SNAPSHOT + provided + + + org.gcube.applicationsupportlayer + aslcore + 3.2.0-2.12.0 + provided + + + com.liferay.portal + portal-service + 6.0.6 + provided + + + javax.portlet + portlet-api + 2.0 + provided + + + org.gcube.portal + social-networking-library + 1.0.0-SNAPSHOT + provided + + + junit + junit + 4.7 + test + + + javax.validation + validation-api + 1.0.0.GA + test + + + javax.validation + validation-api + 1.0.0.GA + sources + test + + + + + + ${webappDirectory}/WEB-INF/classes + + + + + + org.codehaus.mojo + gwt-maven-plugin + 2.4.0 + + + + compile + + + + + + + Notifications.html + ${webappDirectory} + org.gcube.portlets.user.notifications.client.Messages + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + compile + + exploded + + + + + ${webappDirectory} + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${distroDirectory}/descriptor.xml + + + + + servicearchive + install + + single + + + + + + + + diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingService.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingService.java new file mode 100644 index 0000000..a77537b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingService.java @@ -0,0 +1,12 @@ +package org.gcube.portlets.user.socialprofile.client; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +/** + * The client side stub for the RPC service. + */ +@RemoteServiceRelativePath("greet") +public interface GreetingService extends RemoteService { + String greetServer(String name) throws IllegalArgumentException; +} diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingServiceAsync.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingServiceAsync.java new file mode 100644 index 0000000..3af119f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingServiceAsync.java @@ -0,0 +1,9 @@ +package org.gcube.portlets.user.socialprofile.client; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +public interface GreetingServiceAsync { + + void greetServer(String name, AsyncCallback callback); + +} diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java new file mode 100644 index 0000000..a854890 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java @@ -0,0 +1,148 @@ +package org.gcube.portlets.user.socialprofile.client; + +import org.gcube.portlets.user.socialprofile.shared.FieldVerifier; +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyUpEvent; +import com.google.gwt.event.dom.client.KeyUpHandler; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.VerticalPanel; + +/** + * Entry point classes define onModuleLoad(). + */ +public class SocialProfile implements EntryPoint { + /** + * The message displayed to the user when the server cannot be reached or + * returns an error. + */ + private static final String SERVER_ERROR = "An error occurred while " + + "attempting to contact the server. Please check your network " + + "connection and try again."; + + /** + * Create a remote service proxy to talk to the server-side Greeting service. + */ + private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class); + + + /** + * This is the entry point method. + */ + public void onModuleLoad() { + final Button sendButton = new Button( "" ); + final TextBox nameField = new TextBox(); + nameField.setText( "" ); + final Label errorLabel = new Label(); + + // We can add style names to widgets + sendButton.addStyleName("sendButton"); + + // Add the nameField and sendButton to the RootPanel + // Use RootPanel.get() to get the entire body element + RootPanel.get("nameFieldContainer").add(nameField); + RootPanel.get("sendButtonContainer").add(sendButton); + RootPanel.get("errorLabelContainer").add(errorLabel); + + // Focus the cursor on the name field when the app loads + nameField.setFocus(true); + nameField.selectAll(); + + // Create the popup dialog box + final DialogBox dialogBox = new DialogBox(); + dialogBox.setText("Remote Procedure Call"); + dialogBox.setAnimationEnabled(true); + final Button closeButton = new Button("Close"); + // We can set the id of a widget by accessing its Element + closeButton.getElement().setId("closeButton"); + final Label textToServerLabel = new Label(); + final HTML serverResponseLabel = new HTML(); + VerticalPanel dialogVPanel = new VerticalPanel(); + dialogVPanel.addStyleName("dialogVPanel"); + dialogVPanel.add(new HTML("Sending name to the server:")); + dialogVPanel.add(textToServerLabel); + dialogVPanel.add(new HTML("
Server replies:")); + dialogVPanel.add(serverResponseLabel); + dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); + dialogVPanel.add(closeButton); + dialogBox.setWidget(dialogVPanel); + + // Add a handler to close the DialogBox + closeButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + dialogBox.hide(); + sendButton.setEnabled(true); + sendButton.setFocus(true); + } + }); + + // Create a handler for the sendButton and nameField + class MyHandler implements ClickHandler, KeyUpHandler { + /** + * Fired when the user clicks on the sendButton. + */ + public void onClick(ClickEvent event) { + sendNameToServer(); + } + + /** + * Fired when the user types in the nameField. + */ + public void onKeyUp(KeyUpEvent event) { + if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { + sendNameToServer(); + } + } + + /** + * Send the name from the nameField to the server and wait for a response. + */ + private void sendNameToServer() { + // First, we validate the input. + errorLabel.setText(""); + String textToServer = nameField.getText(); + if (!FieldVerifier.isValidName(textToServer)) { + errorLabel.setText("Please enter at least four characters"); + return; + } + + // Then, we send the input to the server. + sendButton.setEnabled(false); + textToServerLabel.setText(textToServer); + serverResponseLabel.setText(""); + greetingService.greetServer(textToServer, new AsyncCallback() { + public void onFailure(Throwable caught) { + // Show the RPC error message to the user + dialogBox.setText("Remote Procedure Call - Failure"); + serverResponseLabel.addStyleName("serverResponseLabelError"); + serverResponseLabel.setHTML(SERVER_ERROR); + dialogBox.center(); + closeButton.setFocus(true); + } + + public void onSuccess(String result) { + dialogBox.setText("Remote Procedure Call"); + serverResponseLabel.removeStyleName("serverResponseLabelError"); + serverResponseLabel.setHTML(result); + dialogBox.center(); + closeButton.setFocus(true); + } + }); + } + } + + // Add a handler to send the name to the server + MyHandler handler = new MyHandler(); + sendButton.addClickHandler(handler); + nameField.addKeyUpHandler(handler); + } +} diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java b/src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java new file mode 100644 index 0000000..ecf57a1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java @@ -0,0 +1,48 @@ +package org.gcube.portlets.user.socialprofile.server; + +import org.gcube.portlets.user.socialprofile.client.GreetingService; +import org.gcube.portlets.user.socialprofile.shared.FieldVerifier; +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +/** + * The server side implementation of the RPC service. + */ +@SuppressWarnings("serial") +public class GreetingServiceImpl extends RemoteServiceServlet implements + GreetingService { + + public String greetServer(String input) throws IllegalArgumentException { + // Verify that the input is valid. + if (!FieldVerifier.isValidName(input)) { + // If the input is not valid, throw an IllegalArgumentException back to + // the client. + throw new IllegalArgumentException( + "Name must be at least 4 characters long"); + } + + String serverInfo = getServletContext().getServerInfo(); + String userAgent = getThreadLocalRequest().getHeader("User-Agent"); + + // Escape data from the client to avoid cross-site script vulnerabilities. + input = escapeHtml(input); + userAgent = escapeHtml(userAgent); + + return "Hello, " + input + "!

I am running " + serverInfo + + ".

It looks like you are using:
" + userAgent; + } + + /** + * 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/server/portlet/SocialProfilePortlet.java b/src/main/java/org/gcube/portlets/user/socialprofile/server/portlet/SocialProfilePortlet.java new file mode 100644 index 0000000..83d753c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/server/portlet/SocialProfilePortlet.java @@ -0,0 +1,32 @@ + +package org.gcube.portlets.user.socialprofile.server.portlet; + +import javax.portlet.GenericPortlet; +import javax.portlet.ActionRequest; +import javax.portlet.RenderRequest; +import javax.portlet.ActionResponse; +import javax.portlet.RenderResponse; +import javax.portlet.PortletException; +import java.io.IOException; +import javax.portlet.PortletRequestDispatcher; + +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; + +/** + * WfTemplatesPortlet Portlet Class + * + * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it + * @version May 2011 (0.1) + */ + public class SocialProfilePortlet extends GenericPortlet { + public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { + response.setContentType("text/html"); + ScopeHelper.setContext(request); + PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/SocialProfile_view.jsp"); + dispatcher.include(request, response); + } + + public void processAction(ActionRequest request, ActionResponse response) + throws PortletException, IOException { + } +} diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/shared/FieldVerifier.java b/src/main/java/org/gcube/portlets/user/socialprofile/shared/FieldVerifier.java new file mode 100644 index 0000000..a2ebb57 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/shared/FieldVerifier.java @@ -0,0 +1,42 @@ +package org.gcube.portlets.user.socialprofile.shared; + +/** + *

+ * FieldVerifier validates that the name the user enters is valid. + *

+ *

+ * This class is in the shared packing because we use it in both + * the client code and on the server. On the client, we verify that the name is + * valid before sending an RPC request so the user doesn't have to wait for a + * network round trip to get feedback. On the server, we verify that the name is + * correct to ensure that the input is correct regardless of where the RPC + * originates. + *

+ *

+ * When creating a class that is used on both the client and the server, be sure + * that all code is translatable and does not use native JavaScript. Code that + * is note translatable (such as code that interacts with a database or the file + * system) cannot be compiled into client side JavaScript. Code that uses native + * JavaScript (such as Widgets) cannot be run on the server. + *

+ */ +public class FieldVerifier { + + /** + * Verifies that the specified name is valid for our service. + * + * In this example, we only require that the name is at least four + * characters. In your application, you can use more complex checks to ensure + * that usernames, passwords, email addresses, URLs, and other fields have the + * proper syntax. + * + * @param name the name to validate + * @return true if valid, false if invalid + */ + public static boolean isValidName(String name) { + if (name == null) { + return false; + } + return name.length() > 3; + } +} 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 new file mode 100644 index 0000000..b4da3d5 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties b/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties new file mode 100644 index 0000000..c222555 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties @@ -0,0 +1,2 @@ +sendButton = Send +nameField = Enter your name \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties new file mode 100644 index 0000000..b4a7627 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties @@ -0,0 +1,2 @@ +sendButton = Envoyer +nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/webapp/SocialProfile.css b/src/main/webapp/SocialProfile.css new file mode 100644 index 0000000..7aca7ac --- /dev/null +++ b/src/main/webapp/SocialProfile.css @@ -0,0 +1,34 @@ +/** Add css rules here for your application. */ + + +/** Example rules used by the template application (remove for your app) */ +h1 { + font-size: 2em; + font-weight: bold; + color: #777777; + margin: 40px 0px 70px; + text-align: center; +} + +.sendButton { + display: block; + font-size: 16pt; +} + +/** Most GWT widgets already have a style name defined */ +.gwt-DialogBox { + width: 400px; +} + +.dialogVPanel { + margin: 5px; +} + +.serverResponseLabelError { + color: red; +} + +/** Set ids using widget.getElement().setId("idOfElement") */ +#closeButton { + margin: 15px 6px 6px; +} diff --git a/src/main/webapp/SocialProfile.html b/src/main/webapp/SocialProfile.html new file mode 100644 index 0000000..78eefdb --- /dev/null +++ b/src/main/webapp/SocialProfile.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + +

Web Application Starter Project

+ + + + + + + + + + + + +
Please enter your name:
+ + diff --git a/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp b/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp new file mode 100644 index 0000000..420df1e --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp @@ -0,0 +1,14 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + +<%-- Uncomment below lines to add portlet taglibs to jsp +<%@ page import="javax.portlet.*"%> +<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> + + +--%> + + +
+ +
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml new file mode 100644 index 0000000..445328e --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties new file mode 100644 index 0000000..2e1d3a9 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -0,0 +1,9 @@ +name=SocialProfile +module-group-id=liferay +module-incremental-version=1 +tags= +short-description= +change-log= +page-url=http://www.d4science.org +author=D4Science.org +licenses=EUPL \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml new file mode 100644 index 0000000..b301be5 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -0,0 +1,28 @@ + + + + + + SocialProfile + false + false + false + /SocialProfile.css + + + administrator + Administrator + + + guest + Guest + + + power-user + Power User + + + user + User + + diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml new file mode 100644 index 0000000..c58bb49 --- /dev/null +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -0,0 +1,30 @@ + + + + + SocialProfile + Social Profile + org.gcube.portlets.user.socialprofile.server.portlet.SocialProfilePortlet + + view-jsp + /view.jsp + + 0 + + text/html + + + Social Profile + Social Profile + Social Profile + + + administrator + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..61e288c --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + + + + + greetServlet + org.gcube.portlets.user.socialprofile.server.GreetingServiceImpl + + + + greetServlet + /SocialProfile/greet + + + + + SocialProfile.html + + + diff --git a/src/main/webapp/images/coming_soon.jpg b/src/main/webapp/images/coming_soon.jpg new file mode 100644 index 0000000..ab77aa3 Binary files /dev/null and b/src/main/webapp/images/coming_soon.jpg differ diff --git a/src/test/java/org/gcube/portlets/user/socialprofile/client/GwtTestSocialProfile.java b/src/test/java/org/gcube/portlets/user/socialprofile/client/GwtTestSocialProfile.java new file mode 100644 index 0000000..5c786a4 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/socialprofile/client/GwtTestSocialProfile.java @@ -0,0 +1,75 @@ +package org.gcube.portlets.user.socialprofile.client; + +import org.gcube.portlets.user.socialprofile.shared.FieldVerifier; +import com.google.gwt.core.client.GWT; +import com.google.gwt.junit.client.GWTTestCase; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; + +/** + * GWT JUnit integration tests must extend GWTTestCase. + * Using "GwtTest*" naming pattern exclude them from running with + * surefire during the test phase. + * + * If you run the tests using the Maven command line, you will have to + * navigate with your browser to a specific url given by Maven. + * See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html + * for details. + */ +public class GwtTestSocialProfile extends GWTTestCase { + + /** + * Must refer to a valid module that sources this class. + */ + public String getModuleName() { + return "org.gcube.portlets.user.socialprofile.SocialProfileJUnit"; + } + + /** + * Tests the FieldVerifier. + */ + public void testFieldVerifier() { + assertFalse(FieldVerifier.isValidName(null)); + assertFalse(FieldVerifier.isValidName("")); + assertFalse(FieldVerifier.isValidName("a")); + assertFalse(FieldVerifier.isValidName("ab")); + assertFalse(FieldVerifier.isValidName("abc")); + assertTrue(FieldVerifier.isValidName("abcd")); + } + + /** + * This test will send a request to the server using the greetServer method in + * GreetingService and verify the response. + */ + public void testGreetingService() { + // Create the service that we will test. + GreetingServiceAsync greetingService = GWT.create(GreetingService.class); + ServiceDefTarget target = (ServiceDefTarget) greetingService; + target.setServiceEntryPoint(GWT.getModuleBaseURL() + "SocialProfile/greet"); + + // Since RPC calls are asynchronous, we will need to wait for a response + // after this test method returns. This line tells the test runner to wait + // up to 10 seconds before timing out. + delayTestFinish(10000); + + // Send a request to the server. + greetingService.greetServer("GWT User", new AsyncCallback() { + public void onFailure(Throwable caught) { + // The request resulted in an unexpected error. + fail("Request failure: " + caught.getMessage()); + } + + public void onSuccess(String result) { + // Verify that the response is correct. + assertTrue(result.startsWith("Hello, GWT User!")); + + // Now that we have received a response, we need to tell the test runner + // that the test is complete. You must call finishTest() after an + // asynchronous test finishes successfully, or the test will time out. + finishTest(); + } + }); + } + + +} diff --git a/src/test/resources/org/gcube/portlets/user/socialprofile/SocialProfileJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/user/socialprofile/SocialProfileJUnit.gwt.xml new file mode 100644 index 0000000..17e37a7 --- /dev/null +++ b/src/test/resources/org/gcube/portlets/user/socialprofile/SocialProfileJUnit.gwt.xml @@ -0,0 +1,9 @@ + + + + + + + + +