import gr.ebs.gss.client.exceptions.RpcException;
import gr.ebs.gss.server.domain.User;
import gr.ebs.gss.server.domain.dto.UserDTO;
-import gr.ebs.gss.server.ejb.ExternalAPI;
import gr.ebs.gss.server.ejb.TransactionHelper;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import java.util.concurrent.Callable;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.rmi.PortableRemoteObject;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
*
* @author past
*/
-public class Registration extends HttpServlet {
+public class Registration extends BaseServlet {
/**
* The request parameter name for the acceptance flag.
*/
*/
private static Log logger = LogFactory.getLog(Registration.class);
- /**
- * A helper method that retrieves a reference to the ExternalAPI bean and
- * stores it for future use.
- *
- * @return an ExternalAPI instance
- * @throws RpcException in case an error occurs
- */
- protected ExternalAPI getService() throws RpcException {
- try {
- final Context ctx = new InitialContext();
- final Object ref = ctx.lookup(getConfiguration().getString("externalApiPath"));
- return (ExternalAPI) PortableRemoteObject.narrow(ref, ExternalAPI.class);
- } catch (final NamingException e) {
- logger.error("Unable to retrieve the ExternalAPI EJB", e);
- throw new RpcException("An error occurred while contacting the naming service");
- }
- }
-
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (getConfiguration().getBoolean("onlyRegisterWithCode"))
errorUrl += "&email=" + (email == null? "": encode(email));
response.sendRedirect(errorUrl);
return;
+ } else if (username.indexOf(' ') != -1) {
+ String error = encode("Spaces in username are not allowed");
+ String errorUrl = "register.jsp?username=&error=" + error;
+ errorUrl += "&firstname=" + (firstname == null? "": encode(firstname));
+ errorUrl += "&lastname=" + (lastname == null? "": encode(lastname));
+ errorUrl += "&email=" + (email == null? "": encode(email));
+ response.sendRedirect(errorUrl);
+ return;
} else if (firstname == null || firstname.isEmpty()) {
String error = encode("No firstname was specified");
String errorUrl = "register.jsp?firstname=&error=" + error;
String errorUrl = "register.jsp?username=&firstname=&lastname=&email=&error=" + encode(error);
response.sendRedirect(errorUrl);
}
-
- protected String encode(String parameter) throws UnsupportedEncodingException {
- return URLEncoder.encode(parameter, "UTF-8");
- }
}