added initial UserResource
git-svn-id: svn://anubis/gvsu@268 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
903877828d
commit
bfbd7a4388
93
cs656/lab4/UserResource.java
Normal file
93
cs656/lab4/UserResource.java
Normal file
@ -0,0 +1,93 @@
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Filename: UserResource.java
|
||||
// Description:
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.restlet.Context;
|
||||
import org.restlet.data.Form;
|
||||
import org.restlet.data.MediaType;
|
||||
import org.restlet.data.Request;
|
||||
import org.restlet.data.Response;
|
||||
import org.restlet.data.Status;
|
||||
import org.restlet.resource.DomRepresentation;
|
||||
import org.restlet.resource.Representation;
|
||||
import org.restlet.resource.Variant;
|
||||
|
||||
|
||||
public class UserResource extends Resource
|
||||
{
|
||||
|
||||
public UserResource(Context context, Request request, Response response)
|
||||
{
|
||||
super(context, request, response);
|
||||
String id = (String) request.getAttributes().get("id");
|
||||
getVariants().add(new Variant(MediaType.TEXT_XML));
|
||||
}
|
||||
|
||||
/**
|
||||
* handle HTTP GET requests.
|
||||
*/
|
||||
@Override
|
||||
public Representation getRepresentation(Variant variant)
|
||||
{
|
||||
DomRepresentation rep = null;
|
||||
if (variant.getMediaType().equals(MediaType.TEXT_XML))
|
||||
{
|
||||
try
|
||||
{
|
||||
rep = new DomRepresentation(MediaType.TEXT_XML);
|
||||
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
|
||||
rep.getDocument().normalizeDocument();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return rep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowDelete()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete()
|
||||
{
|
||||
/*
|
||||
if (this.book != null)
|
||||
{
|
||||
getContainer().delete(this.book);
|
||||
getContainer().commit();
|
||||
getResponse().setStatus(Status.SUCCESS_OK);
|
||||
} else {
|
||||
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT is implemented.
|
||||
*/
|
||||
@Override
|
||||
public boolean allowPut()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a resource in response to an HTTP PUT call.
|
||||
*/
|
||||
@Override
|
||||
public void put(Representation entity)
|
||||
{
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user