Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 1092 additions and 0 deletions
package com.adaapa.ojekservice.handlers;
import com.adaapa.bean.DriverBean;
import com.adaapa.bean.PreferredLocationBean;
import com.adaapa.bean.UserBean;
import com.adaapa.bean.WebServiceBean;
import com.adaapa.ojekservice.models.DriverModel;
import com.adaapa.ojekservice.models.UserModel;
import com.adaapa.ojekservice.services.TokenVerificationService;
import com.google.gson.Gson;
import java.sql.ResultSet;
import java.util.ArrayList;
public class DriverHandler {
public static String doGetPreferredLocation(String access_token) {
try {
WebServiceBean response = new WebServiceBean();
UserModel userModel = new UserModel();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser != null) {
DriverModel driverModel = new DriverModel();
ArrayList<PreferredLocationBean> preferredLocationArray = driverModel.findPreferredLocation(validUser.getUsername());
response.setStatus(WebServiceBean.STATUS_VALID);
response.setBody(new Gson().toJson(preferredLocationArray));
} else {
response.setStatus(WebServiceBean.STATUS_INVALID);
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doGetDriverProfile(String access_token) {
try {
WebServiceBean response = new WebServiceBean();
UserModel userModel = new UserModel();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser != null) {
DriverModel driverModel = new DriverModel();
DriverBean driverBean = new DriverBean();
driverBean.setVote(driverModel.countVote(validUser.username));
driverBean.setName(validUser.getName());
driverBean.setRating(driverModel.calculateRating(validUser.username));
response.setStatus(WebServiceBean.STATUS_VALID);
response.setBody(new Gson().toJson(driverBean));
} else {
response.setStatus(WebServiceBean.STATUS_INVALID);
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doAddPreferredLocation(String access_token, String location) {
try {
WebServiceBean response = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
response.setStatus(WebServiceBean.STATUS_INVALID);
} else {
response.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
DriverModel driverModel = new DriverModel();
UserBean wsUser = userModel.findUserByUsername(validUser.username);
ResultSet rs = driverModel.query(String.format("SELECT MAX(position) as max FROM preferred_locations WHERE id= %d", wsUser.getId()));
int curr = rs.next() ? rs.getInt("max") + 1 : 1;
driverModel.queryUpdate(
String.format("INSERT INTO preferred_locations VALUES (%d,%d,'%s')",
wsUser.getId(), curr, location));
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String doDeletePreferredLocation(String access_token, Integer position) {
try {
WebServiceBean response = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
response.setStatus(WebServiceBean.STATUS_INVALID);
} else {
response.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
DriverModel driverModel = new DriverModel();
UserBean wsUser = userModel.findUserByUsername(validUser.getUsername());
ResultSet rs = driverModel.queryUpdate(String.format(
"DELETE FROM preferred_locations WHERE id=%d and position=%d",
wsUser.getId(), position
));
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String doUpdatePreferredLocation(String access_token, Integer position, String location) {
try {
WebServiceBean response = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
response.setStatus(WebServiceBean.STATUS_INVALID);
} else {
response.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
DriverModel driverModel = new DriverModel();
UserBean wsUser = userModel.findUserByUsername(validUser.getUsername());
ResultSet rs = driverModel.queryUpdate(String.format(
"UPDATE preferred_locations SET location = '%s' WHERE id=%d AND position=%d",
location, wsUser.getId(), position
));
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String doFindDriverByUsername(String access_token, String username) {
try {
UserBean validUser = TokenVerificationService.verifyToken(access_token);
Gson gson = new Gson();
WebServiceBean response = new WebServiceBean();
if (validUser != null) {
response.setStatus(WebServiceBean.STATUS_VALID);
response.setBody(gson.toJson(new UserModel().findUserByUsername(username)));
} else {
response.setStatus(WebServiceBean.STATUS_INVALID);
}
return gson.toJson(response);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
package com.adaapa.ojekservice.handlers;
import com.adaapa.bean.DriverBean;
import com.adaapa.bean.OrderBean;
import com.adaapa.bean.UserBean;
import com.adaapa.bean.WebServiceBean;
import com.adaapa.ojekservice.models.DriverModel;
import com.adaapa.ojekservice.models.UserModel;
import com.adaapa.ojekservice.services.TokenVerificationService;
import com.google.gson.Gson;
import java.util.ArrayList;
/**
* Created by ireneedriadr on 11/5/17.
*/
public class OrderHandler {
public static String doGetUserHistory(String access_token) {
try {
WebServiceBean response = new WebServiceBean();
UserModel userModel = new UserModel();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser != null) {
ArrayList<OrderBean> userHistoryArray = userModel.findPrevOrder(userModel.findUserByUsername(validUser.getUsername()));
response.setStatus(WebServiceBean.STATUS_VALID);
response.setBody(new Gson().toJson(userHistoryArray));
} else {
response.setStatus(WebServiceBean.STATUS_INVALID);
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doFindDriver(String access_token, String driver_name) {
try {
Gson gson = new Gson();
WebServiceBean webServiceBean = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
return gson.toJson(webServiceBean);
} else {
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
DriverModel driverModel = new DriverModel();
ArrayList<DriverBean> driverBeans = driverModel.findDriverByName(validUser.getUsername(), driver_name);
webServiceBean.setBody(gson.toJson(driverBeans));
return gson.toJson(webServiceBean);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doGetDriverHistory(String access_token) {
try {
WebServiceBean response = new WebServiceBean();
UserModel userModel = new UserModel();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser != null) {
ArrayList<OrderBean> userHistoryArray = userModel.findPrevDriverOrder(userModel.findUserByUsername(validUser.getUsername()));
response.setStatus(WebServiceBean.STATUS_VALID);
response.setBody(new Gson().toJson(userHistoryArray));
} else {
response.setStatus(WebServiceBean.STATUS_INVALID);
}
return new Gson().toJson(response);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doFindDriverByPreferredLocation(String access_token, String pickup, String destination) {
try {
Gson gson = new Gson();
WebServiceBean webServiceBean = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
return gson.toJson(webServiceBean);
} else {
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
DriverModel driverModel = new DriverModel();
ArrayList<DriverBean> driverBeans = driverModel.findDriverByPreferredLocation(validUser.getUsername(), pickup, destination);
webServiceBean.setBody(gson.toJson(driverBeans));
return gson.toJson(webServiceBean);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doCompleteOrder(String access_token, String order) {
try {
Gson gson = new Gson();
WebServiceBean webServiceBean = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
} else {
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
UserBean wsUser = userModel.findUserByUsername(validUser.getUsername());
OrderBean orderBean = gson.fromJson(order, OrderBean.class);
DriverModel driverModel = new DriverModel();
driverModel.queryUpdate(String.format(
"INSERT INTO orders (user_id,driver_id,pickup,destination,rating,comment) VALUES"
+ "(%d,%d,'%s','%s','%d','%s')",
wsUser.getId(), orderBean.getDriverId(), orderBean.getPickup(), orderBean.getDestination(),
orderBean.getRating().intValue(), orderBean.getComment()
));
}
return gson.toJson(webServiceBean);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doUserHideHistory(String access_token, Integer orderId) {
try {
Gson gson = new Gson();
WebServiceBean webServiceBean = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
} else {
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
userModel.queryUpdate(String.format("UPDATE orders SET user_hidden=1 WHERE id=%d", orderId));
}
return gson.toJson(webServiceBean);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doDriverHideHistory(String access_token, Integer orderId) {
try {
Gson gson = new Gson();
WebServiceBean webServiceBean = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
} else {
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
userModel.queryUpdate(String.format("UPDATE orders SET driver_hidden=1 WHERE id=%d", orderId));
}
return gson.toJson(webServiceBean);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
package com.adaapa.ojekservice.handlers;
import com.adaapa.bean.UserBean;
import com.adaapa.bean.WebServiceBean;
import com.adaapa.ojekservice.models.UserModel;
import com.adaapa.ojekservice.services.TokenVerificationService;
import com.google.gson.Gson;
public class ProfileHandler {
static Gson gson = new Gson();
public static String doGetProfile(String access_token) {
try {
WebServiceBean webServiceBean = new WebServiceBean();
UserBean resUser = TokenVerificationService.verifyToken(access_token);
if (resUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
return gson.toJson(webServiceBean);
} else {
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
UserModel userModel = new UserModel();
UserBean user = userModel.findUserByUsername(resUser.getUsername());
if (user == null) {
resUser.isDriver = false;
userModel.saveUser(resUser);
webServiceBean.setBody(gson.toJson(resUser));
} else {
webServiceBean.setBody(gson.toJson(user));
}
return gson.toJson(webServiceBean);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doEditProfile(String access_token, String user) {
try {
WebServiceBean webServiceBean = new WebServiceBean();
UserBean resUser = TokenVerificationService.verifyToken(access_token);
if (resUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
} else {
UserBean userBean = gson.fromJson(user, UserBean.class);
userBean.username = resUser.username;
UserModel userModel = new UserModel();
userModel.updateUser(userBean);
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
}
return gson.toJson(webServiceBean);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String doAddUser(String access_token, String user) {
try {
WebServiceBean webServiceBean = new WebServiceBean();
UserBean validUser = TokenVerificationService.verifyToken(access_token);
if (validUser == null) {
webServiceBean.setStatus(WebServiceBean.STATUS_INVALID);
} else {
UserBean userBean = gson.fromJson(user, UserBean.class);
UserModel userModel = new UserModel();
userModel.saveUser(userBean);
webServiceBean.setStatus(WebServiceBean.STATUS_VALID);
}
return gson.toJson(webServiceBean);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
package com.adaapa.ojekservice.models;
import com.adaapa.bean.DriverBean;
import com.adaapa.bean.PreferredLocationBean;
import com.adaapa.models.BaseModel;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Base64;
public class DriverModel extends BaseModel {
public static String ORDER_TABLE = "orders";
public static String USER_TABLE = "users";
public static String PREFERRED_TABLE = "preferred_locations";
public DriverModel() {
super("users", "id");
}
public Integer countVote(String username) {
try {
ResultSet rs = query(String.format(
"SELECT COUNT(rating) as vote FROM %s inner join %s on (%s.driver_id = %s.id) where users.username = '%s'",
ORDER_TABLE, USER_TABLE, ORDER_TABLE, USER_TABLE, username));
if (rs.next()) {
return rs.getInt("vote");
} else {
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public DriverBean parseDriverBean(ResultSet resultSet) throws SQLException {
String username = resultSet.getString("username");
DriverBean driverBean = new DriverBean();
driverBean.setRating(calculateRating(username));
driverBean.setName(resultSet.getString("name"));
driverBean.setVote(countVote(username));
driverBean.setId(resultSet.getInt("id"));
driverBean.setUsername(username);
try {
driverBean.setImage("data:image/jpeg;charset=utf-8;base64," + Base64.getEncoder().encodeToString(resultSet.getBytes("image")));
} catch (Exception e) {
System.out.println("User has no profile image");
}
return driverBean;
}
public Double calculateRating(String username) {
try {
ResultSet rs = query(String.format(
"SELECT AVG(rating) as rating FROM %s inner join %s on (%s.driver_id = %s.id) where users.username = '%s'",
ORDER_TABLE, USER_TABLE, ORDER_TABLE, USER_TABLE, username));
if (rs.next()) {
return rs.getDouble("rating");
} else {
return 0.0;
}
} catch (Exception e) {
e.printStackTrace();
return 0.0;
}
}
public ArrayList<PreferredLocationBean> findPreferredLocation(String username) {
ArrayList<PreferredLocationBean> preferredLocationBeanArray = new ArrayList<>();
try {
ResultSet rs = query(String.format(
"SELECT position,location FROM %s NATURAL JOIN %s WHERE users.username = '%s'",
PREFERRED_TABLE, USER_TABLE, username
));
while (rs.next()) {
PreferredLocationBean preferredLocationBean = new PreferredLocationBean();
preferredLocationBean.setLocation(rs.getString("location"));
preferredLocationBean.setPosition(rs.getInt("position"));
preferredLocationBeanArray.add(preferredLocationBean);
}
return preferredLocationBeanArray;
} catch (Exception e) {
e.printStackTrace();
return preferredLocationBeanArray;
}
}
public ArrayList<DriverBean> findDriverByName(String username, String name) {
ResultSet resultSet = null;
ArrayList<DriverBean> driverBeans = new ArrayList<>();
int i = 0;
try {
resultSet = query("SELECT * FROM users WHERE username != '" + username + "' AND name LIKE '%" + name + "%' and is_driver=1");
while (resultSet.next()) {
driverBeans.add(parseDriverBean(resultSet));
}
} catch (Exception e) {
e.printStackTrace();
}
return driverBeans;
}
public ArrayList<DriverBean> findDriverByPreferredLocation(String username, String pickup, String destination) {
ResultSet resultSet = null;
ArrayList<DriverBean> driverBeans = new ArrayList<>();
int i = 0;
try {
resultSet = query(String.format(
"SELECT DISTINCT users.name, users.username, users.id, users.image "
+ "FROM users NATURAL JOIN preferred_locations WHERE username!= '%s' and (location='%s' or location='%s')",
username, pickup, destination
));
while (resultSet.next()) {
driverBeans.add(parseDriverBean(resultSet));
}
} catch (Exception e) {
e.printStackTrace();
}
return driverBeans;
}
}
package com.adaapa.ojekservice.models;
import com.adaapa.bean.OrderBean;
import com.adaapa.bean.UserBean;
import com.adaapa.models.BaseModel;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Base64;
public class UserModel extends BaseModel {
public UserModel() {
super("users", "id");
}
public UserBean parseUserBean(ResultSet resultSet) throws SQLException {
UserBean ubean = new UserBean();
ubean.id = resultSet.getInt("id");
ubean.email = resultSet.getString("email");
ubean.phoneNumber = resultSet.getString("phone");
ubean.name = resultSet.getString("name");
ubean.isDriver = resultSet.getBoolean("is_driver");
ubean.username = resultSet.getString("username");
try {
ubean.image = "data:image/jpeg;charset=utf-8;base64," + Base64.getEncoder().encodeToString(resultSet.getBytes("image"));
} catch (Exception e) {
System.out.println("User has no image");
}
return ubean;
}
public OrderBean parseUserOrder(ResultSet resultSet) throws SQLException {
OrderBean obean = new OrderBean();
obean.setId(resultSet.getInt("id"));
obean.setUserId(resultSet.getInt("user_id"));
obean.setDriverId(resultSet.getInt("driver_id"));
obean.setPickup(resultSet.getString("pickup"));
obean.setDestination(resultSet.getString("destination"));
obean.setRating(resultSet.getDouble("rating"));
obean.setComment(resultSet.getString("comment"));
obean.setName(resultSet.getString("name"));
obean.setTimestamp(resultSet.getTimestamp("timestamp"));
try {
obean.setImage("data:image/jpeg;charset=utf-8;base64," + Base64.getEncoder().encodeToString(resultSet.getBytes("image")));
} catch (Exception e) {
System.out.println("User has no image");
}
return obean;
}
public UserBean findUserByUsername(String username) {
UserBean userBean = null;
ResultSet resultSet = null;
try {
resultSet = query(String.format("SELECT * FROM %s WHERE username='%s'", tableName, username));
if (resultSet.next()) {
userBean = parseUserBean(resultSet);
}
} catch (Exception e) {
e.printStackTrace();
}
return userBean;
}
public OrderBean findOrderByUsername(String username) {
OrderBean orderBean = null;
ResultSet resultSet = null;
try {
resultSet = query(String.format(
"SELECT * FROM orders JOIN users ON users.id = orders.driver_id WHERE username='%s'",
username));
if (resultSet.next()) {
orderBean = parseUserOrder(resultSet);
}
} catch (Exception e) {
e.printStackTrace();
}
return orderBean;
}
public Boolean saveUser(UserBean userBean) {
ResultSet resultSet = null;
try {
resultSet = queryUpdate(String.format(
"INSERT INTO %s (name,email,phone,username,is_driver)"
+ "VALUES ('%s','%s','%s','%s','%d')",
tableName, userBean.name, userBean.email, userBean.phoneNumber, userBean.username, userBean.isDriver ? 1 : 0
));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public void updateImage(String username, String image) throws SQLException {
PreparedStatement statement = db
.prepareStatement("UPDATE users SET image=? WHERE username = ?");
statement.setBytes(1, Base64.getDecoder().decode(image));
statement.setString(2, username);
statement.executeUpdate();
}
public void updateUser(UserBean updatedUser) {
try {
PreparedStatement statement = db
.prepareStatement("UPDATE users SET name=?, phone=?,is_driver=? WHERE username = ?");
statement.setString(1, updatedUser.getName());
statement.setString(2, updatedUser.phoneNumber);
statement.setBoolean(3, updatedUser.isDriver);
statement.setString(4, updatedUser.getUsername());
statement.executeUpdate();
if (updatedUser.getImage() != null) {
updateImage(updatedUser.username, updatedUser.image);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public ArrayList<OrderBean> findPrevOrder(UserBean driver) {
ArrayList<OrderBean> res = new ArrayList<>();
try {
ResultSet rs = query(String.format("SELECT * FROM orders JOIN users ON users.id = orders.driver_id WHERE user_id = '%s' and not user_hidden ORDER BY timestamp desc", driver.getId()));
while (rs.next()) {
res.add(parseUserOrder(rs));
}
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
public ArrayList<OrderBean> findPrevDriverOrder(UserBean driver) {
ArrayList<OrderBean> res = new ArrayList<>();
try {
ResultSet rs = query(String.format("SELECT * FROM orders JOIN users ON users.id = orders.user_id WHERE driver_id = '%s' and not driver_hidden ORDER BY timestamp desc", driver.getId()));
while (rs.next()) {
res.add(parseUserOrder(rs));
}
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
}
package com.adaapa.ojekservice.services;
import java.io.InputStream;
import java.util.Properties;
public class DomainConfig {
public static String IS_DOMAIN;
private final String file_name = "/config/domain.properties";
public DomainConfig() {
try {
Properties prop = new Properties();
InputStream inp = this.getClass().getResourceAsStream(file_name);
prop.load(inp);
IS_DOMAIN = prop.getProperty("IDSERVICE_DOMAIN");
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getISDomain() {
if (IS_DOMAIN == null) {
new DomainConfig();
}
return IS_DOMAIN;
}
}
package com.adaapa.ojekservice.services;
import com.adaapa.bean.TokenVerificationResponse;
import com.adaapa.bean.UserBean;
import com.adaapa.bean.WebServiceBean;
import com.adaapa.tokenverifier.TokenVerifier;
import com.google.gson.Gson;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;
public class TokenVerificationService {
private static TokenVerifier serviceClass;
private final String TOKEN_VERIFIER_PATH = "/verifytoken";
private final String WSDL_PATH = "?wsdl";
TokenVerificationService() throws MalformedURLException {
URL url = new URL(DomainConfig.getISDomain() + TOKEN_VERIFIER_PATH + WSDL_PATH);
QName qname = new QName("tokenverifier.adaapa.com", "TokenVerifierService");
Service service = Service.create(url, qname);
serviceClass = service.getPort(TokenVerifier.class);
}
public static UserBean verifyToken(String access_token) throws MalformedURLException {
if (serviceClass == null) {
new TokenVerificationService();
}
String result = serviceClass.verifyToken(access_token);
TokenVerificationResponse resultObj = new Gson().fromJson(result, TokenVerificationResponse.class);
WebServiceBean response = new WebServiceBean();
if (resultObj.getStatus().equals(TokenVerificationResponse.TOKEN_VALID)) {
return resultObj.getUser();
} else {
return null;
}
}
}
package com.adaapa.tokenverifier;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.adaapa.tokenverifier package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _VerifyToken_QNAME = new QName("tokenverifier.adaapa.com", "verifyToken");
private final static QName _VerifyTokenResponse_QNAME = new QName("tokenverifier.adaapa.com", "verifyTokenResponse");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.adaapa.tokenverifier
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link VerifyToken }
*/
public VerifyToken createVerifyToken() {
return new VerifyToken();
}
/**
* Create an instance of {@link VerifyTokenResponse }
*/
public VerifyTokenResponse createVerifyTokenResponse() {
return new VerifyTokenResponse();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link VerifyToken }{@code >}}
*/
@XmlElementDecl(namespace = "tokenverifier.adaapa.com", name = "verifyToken")
public JAXBElement<VerifyToken> createVerifyToken(VerifyToken value) {
return new JAXBElement<VerifyToken>(_VerifyToken_QNAME, VerifyToken.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link VerifyTokenResponse }{@code >}}
*/
@XmlElementDecl(namespace = "tokenverifier.adaapa.com", name = "verifyTokenResponse")
public JAXBElement<VerifyTokenResponse> createVerifyTokenResponse(VerifyTokenResponse value) {
return new JAXBElement<VerifyTokenResponse>(_VerifyTokenResponse_QNAME, VerifyTokenResponse.class, null, value);
}
}
package com.adaapa.tokenverifier;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*/
@WebService(name = "TokenVerifier", targetNamespace = "tokenverifier.adaapa.com")
@XmlSeeAlso({
ObjectFactory.class
})
public interface TokenVerifier {
/**
* @param accessToken
* @return returns java.lang.String
*/
@WebMethod
@WebResult(name = "userObjectInJSON", targetNamespace = "")
@RequestWrapper(localName = "verifyToken", targetNamespace = "tokenverifier.adaapa.com", className = "com.adaapa.tokenverifier.VerifyToken")
@ResponseWrapper(localName = "verifyTokenResponse", targetNamespace = "tokenverifier.adaapa.com", className = "com.adaapa.tokenverifier.VerifyTokenResponse")
@Action(input = "tokenverifier.adaapa.com/TokenVerifier/verifyTokenRequest", output = "tokenverifier.adaapa.com/TokenVerifier/verifyTokenResponse")
public String verifyToken(
@WebParam(name = "access_token", targetNamespace = "")
String accessToken);
}
package com.adaapa.tokenverifier;
import javax.xml.namespace.QName;
import javax.xml.ws.*;
import java.net.MalformedURLException;
import java.net.URL;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*/
@WebServiceClient(name = "TokenVerifierService", targetNamespace = "tokenverifier.adaapa.com", wsdlLocation = "http://localhost:8001/verifytoken?wsdl")
public class TokenVerifierService
extends Service {
private final static URL TOKENVERIFIERSERVICE_WSDL_LOCATION;
private final static WebServiceException TOKENVERIFIERSERVICE_EXCEPTION;
private final static QName TOKENVERIFIERSERVICE_QNAME = new QName("tokenverifier.adaapa.com", "TokenVerifierService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://localhost:8001/verifytoken?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
TOKENVERIFIERSERVICE_WSDL_LOCATION = url;
TOKENVERIFIERSERVICE_EXCEPTION = e;
}
public TokenVerifierService() {
super(__getWsdlLocation(), TOKENVERIFIERSERVICE_QNAME);
}
public TokenVerifierService(WebServiceFeature... features) {
super(__getWsdlLocation(), TOKENVERIFIERSERVICE_QNAME, features);
}
public TokenVerifierService(URL wsdlLocation) {
super(wsdlLocation, TOKENVERIFIERSERVICE_QNAME);
}
public TokenVerifierService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, TOKENVERIFIERSERVICE_QNAME, features);
}
public TokenVerifierService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public TokenVerifierService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
private static URL __getWsdlLocation() {
if (TOKENVERIFIERSERVICE_EXCEPTION != null) {
throw TOKENVERIFIERSERVICE_EXCEPTION;
}
return TOKENVERIFIERSERVICE_WSDL_LOCATION;
}
/**
* @return returns TokenVerifier
*/
@WebEndpoint(name = "TokenVerifierPort")
public TokenVerifier getTokenVerifierPort() {
return super.getPort(new QName("tokenverifier.adaapa.com", "TokenVerifierPort"), TokenVerifier.class);
}
/**
* @param features A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return returns TokenVerifier
*/
@WebEndpoint(name = "TokenVerifierPort")
public TokenVerifier getTokenVerifierPort(WebServiceFeature... features) {
return super.getPort(new QName("tokenverifier.adaapa.com", "TokenVerifierPort"), TokenVerifier.class, features);
}
}
package com.adaapa.tokenverifier;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for verifyToken complex type.
* <p>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;complexType name="verifyToken">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="access_token" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "verifyToken", propOrder = {
"accessToken"
})
public class VerifyToken {
@XmlElement(name = "access_token")
protected String accessToken;
/**
* Gets the value of the accessToken property.
*
* @return possible object is
* {@link String }
*/
public String getAccessToken() {
return accessToken;
}
/**
* Sets the value of the accessToken property.
*
* @param value allowed object is
* {@link String }
*/
public void setAccessToken(String value) {
this.accessToken = value;
}
}
package com.adaapa.tokenverifier;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for verifyTokenResponse complex type.
* <p>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;complexType name="verifyTokenResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="userObjectInJSON" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "verifyTokenResponse", propOrder = {
"userObjectInJSON"
})
public class VerifyTokenResponse {
protected String userObjectInJSON;
/**
* Gets the value of the userObjectInJSON property.
*
* @return possible object is
* {@link String }
*/
public String getUserObjectInJSON() {
return userObjectInJSON;
}
/**
* Sets the value of the userObjectInJSON property.
*
* @param value allowed object is
* {@link String }
*/
public void setUserObjectInJSON(String value) {
this.userObjectInJSON = value;
}
}
@javax.xml.bind.annotation.XmlSchema(namespace = "tokenverifier.adaapa.com")
package com.adaapa.tokenverifier;
DB_HOST = localhost
DB_USER = test
DB_PASS = test
DB_NAME = test_wbd3_web
IDSERVICE_DOMAIN = http://localhost:8080/IdentityService
<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="OjekOnline"
implementation="com.adaapa.ojekservice.OjekOnline"
url-pattern="/ojekonline"/>
</endpoints>
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>web-jaxws</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>web-jaxws</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
plugins {
id 'org.akhikhl.gretty' version '2.0.0'
}
dependencies {
// https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-ri
gretty 'com.sun.xml.ws:jaxws-ri:2.3.0'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
gretty 'mysql:mysql-connector-java:5.1.44'
}
allprojects {
repositories {
jcenter()
maven {
url 'http://download.eclipse.org/rt/eclipselink/maven.repo'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
File added
#Tue Nov 07 15:12:14 ICT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip