Guest User

Untitled

a guest
May 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1. package fh.at.ooe.mc10;
  2.  
  3. import java.rmi.RemoteException;
  4. import java.sql.SQLException;
  5. import javax.jws.*;
  6. import javax.jws.soap.SOAPBinding;
  7. import fh.at.ooe.mc10.DBHandle;
  8.  
  9. @WebService
  10. @SOAPBinding(style = SOAPBinding.Style.RPC)
  11. public class JaxWebService {
  12.  
  13.     private DBHandle dbhandle;
  14.  
  15.     public JaxWebService() {
  16.         dbhandle = new DBHandle();
  17.        
  18.     }
  19.  
  20.     /**
  21.      * @param groupname
  22.      * @param password
  23.      * @return 0: No error -1: Group already exists -2: Connection problem
  24.      * @throws Exception
  25.      */
  26.     @WebMethod
  27.     public int registerGroup(String groupname, String password)
  28.             throws RemoteException {
  29.         if (dbhandle.existsGroup(groupname)) {
  30.             return -1;
  31.         } else {
  32.             try {
  33.                 if (dbhandle.createGroup(groupname, password)) {
  34.                     return 0;
  35.                 } else {
  36.                     return -2;
  37.                 }
  38.             } catch (SQLException e) {
  39.                 e.printStackTrace();
  40.                 return -2;
  41.             }
  42.         }
  43.     }
  44.  
  45.     /**
  46.      * @param name
  47.      * @return 0: No error -1: Group already exists -2: Connection problem
  48.      */
  49.     @WebMethod
  50.     public int registerUser(String name) throws RemoteException {
  51.         if (dbhandle.existsUser(name)) {
  52.             return -1;
  53.         } else {
  54.             try {
  55.                 if (dbhandle.createUser(name)) {
  56.                     return 0;
  57.                 } else {
  58.                     return -2;
  59.                 }
  60.             } catch (SQLException e) {
  61.                 e.printStackTrace();
  62.                 return -2;
  63.             }
  64.         }
  65.     }
  66.  
  67.     /**
  68.      * @param groupname
  69.      * @param password
  70.      * @return 0: No error -1: Group already exists -2: Connection problem
  71.      */
  72.     @WebMethod
  73.     public int joinGroup(String groupname, String password)
  74.             throws RemoteException {
  75.         if (dbhandle.existsGroup(groupname)) {
  76.             return -1;
  77.         } else {
  78.             if (dbhandle.joinGroup(groupname, password)) {
  79.                 return 0;
  80.             } else {
  81.                 return -2;
  82.             }
  83.         }
  84.     }
  85.  
  86.     @WebMethod
  87.     public boolean setNewUserHighscore(String name, int newHighscore)
  88.             throws RemoteException {
  89.         return dbhandle.setNewUserHighscore(name, newHighscore);
  90.     }
  91.  
  92.     @WebMethod
  93.     public User[] getUsers() throws RemoteException {
  94.         return dbhandle.getUsers();
  95.     }
  96.  
  97. }
Add Comment
Please, Sign In to add comment