Converting RESTful webservice client written with javax.ws.rs.* and javax.xml.bind.* to work

128
July 10, 2019, at 04:30 AM

I wrote this restful webservice client to consume a JAX-RS webservice. I would like to use it on android but android does not support the javax.ws or javax.xml.bind libraries. is there a simple way to convert the code to work on android without having to do a complete overhaul? if not, what is a simple android restful webservice API that I can use?

package databaseAccess;
import databaseAccess.Recipe.recipeType;
import databaseAccess.UserProfile.skillLevel;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
public class DatabaseService {
private static final String BASE_URI = 
"http://localhost:8080/RecipeAppDatabaseService/webresources";
private Client client;
public DatabaseService() {            
    client = ClientBuilder.newClient();
}
/**
 * validate if correct password (on sign-in)
 * @return if correct - the user's profile. if incorrect username or 
    password - returns null
 */
public UserProfile validateSignIn(String email, String password) {
    WebTarget webTarget = 
    client.target(BASE_URI).path("userProfile/signIn/" + email + "/" + 
                                 password);
    return webTarget.request().get(UserProfile.class);
}
/**
 * add a new user to the database (on first sign-up)
 */
public Response addUser(UserProfile user, String password) {
    WebTarget webTarget = client.target(BASE_URI).path("userProfile/add/" 
                          + password);
    Response response = 
 webTarget.request().post(Entity.entity(user,MediaType.APPLICATION_XML));
    return response;
}
/**
 * delete account
 */
public Response deleteUser(String email) {
    WebTarget webTarget = client.target(BASE_URI).path("userProfile/" + 
    email);
    Response response = webTarget.request().delete();
    return response;
}
/**
 * get User profile based on a given email
 * @return user profile
 */
public UserProfile getUser(String email) {
    WebTarget webTarget = client.target(BASE_URI).path("userProfile/" + 
    email);
    return webTarget.request().get(UserProfile.class);
}
/**
 * add a follower to a user
 */
public Response addFollower(String userEmail, String followerEmail) {
    WebTarget webTarget = client.target(BASE_URI).path("userProfile/" + userEmail + "/" + followerEmail);
    Response response = webTarget.request().get();
    return response;
}
/**
 * add a follower to a user
 */
public Response deleteFollower(String userEmail, String followerEmail) {
    WebTarget webTarget = client.target(BASE_URI).path("userProfile/" + 
    userEmail + "/" + followerEmail);
    Response response = webTarget.request().delete();
    return response;        
}

...

package databaseAccess;
import java.io.Serializable;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class UserProfile implements Serializable {
public enum skillLevel{BEGINNER, INTERMEDIATE, PRO}
private String email;
private String firstName;
private String lastName;
private skillLevel cookingSkills;
@XmlElement
private ArrayList<String> cuisines;
private String country;
@XmlElement
private ArrayList<String> followers; // emails of followers
@XmlElement
private ArrayList<String> followerOf; // emails of people the user 
 follows
public UserProfile() {
    followers = new ArrayList<>();
    followerOf = new ArrayList<>();
    cuisines = new ArrayList<>();
}
 ...
Rent Charter Buses Company
READ ALSO
Change architecture of module to correctly handle transactions

Change architecture of module to correctly handle transactions

I have application with modular architectureEach module in this application communicate between each other though RPC protocol

132
How to filter variables by its value in a dump file?

How to filter variables by its value in a dump file?

As you see from the picture, I've dumped a binary file from a java process and use VisualVM to analyze itAnd I believe there is something wrong with a key called "rn64832", but I can't filter the ConcurrentHashMap with the problem key and there're too many entries...

162
&ldquo;Error: package system.threading.tasks does not exist&rdquo;

“Error: package system.threading.tasks does not exist”

I am trying to convert aNet dll to java jar using jni

236
JDBC server side driver support to save mandarin characters into we8iso8859p1 characterset DB

JDBC server side driver support to save mandarin characters into we8iso8859p1 characterset DB

Im trying to save Mandarin characters into Oracle instance database 11gField datatype - NVARCHAR2 ; NLS_CHARACTERSET - WE8ISO8859P1 ; NLS_NCHAR_CHARACTERSET - AL16UTF16 I prefer not to change the CharacterSet as it has huge data

113