Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fh.at.ooe.mc10;
- import java.rmi.RemoteException;
- import java.sql.SQLException;
- import javax.jws.*;
- import javax.jws.soap.SOAPBinding;
- import fh.at.ooe.mc10.DBHandle;
- @WebService
- @SOAPBinding(style = SOAPBinding.Style.RPC)
- public class JaxWebService {
- private DBHandle dbhandle;
- public JaxWebService() {
- dbhandle = new DBHandle();
- }
- /**
- * @param groupname
- * @param password
- * @return 0: No error -1: Group already exists -2: Connection problem
- * @throws Exception
- */
- @WebMethod
- public int registerGroup(String groupname, String password)
- throws RemoteException {
- if (dbhandle.existsGroup(groupname)) {
- return -1;
- } else {
- try {
- if (dbhandle.createGroup(groupname, password)) {
- return 0;
- } else {
- return -2;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- return -2;
- }
- }
- }
- /**
- * @param name
- * @return 0: No error -1: Group already exists -2: Connection problem
- */
- @WebMethod
- public int registerUser(String name) throws RemoteException {
- if (dbhandle.existsUser(name)) {
- return -1;
- } else {
- try {
- if (dbhandle.createUser(name)) {
- return 0;
- } else {
- return -2;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- return -2;
- }
- }
- }
- /**
- * @param groupname
- * @param password
- * @return 0: No error -1: Group already exists -2: Connection problem
- */
- @WebMethod
- public int joinGroup(String groupname, String password)
- throws RemoteException {
- if (dbhandle.existsGroup(groupname)) {
- return -1;
- } else {
- if (dbhandle.joinGroup(groupname, password)) {
- return 0;
- } else {
- return -2;
- }
- }
- }
- @WebMethod
- public boolean setNewUserHighscore(String name, int newHighscore)
- throws RemoteException {
- return dbhandle.setNewUserHighscore(name, newHighscore);
- }
- @WebMethod
- public User[] getUsers() throws RemoteException {
- return dbhandle.getUsers();
- }
- }
Add Comment
Please, Sign In to add comment