public class AjaxRestWebsocketListener extends org.eclipse.jetty.websocket.servlet.WebSocketServlet
Constructor and Description |
---|
AjaxRestWebsocketListener() |
Modifier and Type | Method and Description |
---|---|
private String |
checkForAjaxRequest(HttpServletRequest req)
Checks if this Request is an AJAX request and prepares the response in XML format.
|
private String |
checkForRestRequest(HttpServletRequest req)
Parses the REST command string and prepares the response in XML format.
|
void |
configure(org.eclipse.jetty.websocket.servlet.WebSocketServletFactory factory) |
void |
destroy()
Override to close Things
|
void |
doGet(HttpServletRequest req,
HttpServletResponse res)
This method handles the "GET" submission - it is used for Ajax calls to set webApp parameters using JQuery.
|
void |
doPost(HttpServletRequest req,
HttpServletResponse res)
This method handles the "POST" submissions.
|
boolean |
getDebugOut()
Returns the value of debugOut_.
|
String |
getServletInfo()
Gets the ServletInfo attribute of the AjaxRestWebsocketListener object
|
int |
getViewPortHeight()
Returns the value of viewPortHeight_.
|
int |
getViewPortWidth()
Returns the value of viewPortWidth_.
|
boolean |
getXmlResponse()
Get Method for class field 'xmlResponse'.
|
void |
init()
The one time servlet init stuff goes here.
|
private boolean |
loginLastFM()
Logs into the last.fm session with the already provided user/pass.
|
private void |
parseParams(HttpServletRequest req)
Parses any defined servlet params into the defined class vars.
|
private String |
parseRestRequest(String restPath)
Parses the REST command string and prepares the response in XML format.
|
private void |
sendServletAdminPage(HttpServletRequest req,
HttpServletResponse res)
Prepares and returns basic info page about the server.
|
void |
setDebugOut(boolean debugOut)
Sets the value of debugOut_.
|
void |
setViewPortHeight(int viewPortHeight)
Sets the value of viewPortHeight_.
|
void |
setViewPortWidth(int viewPortWidth)
Sets the value of viewPortWidth_.
|
void |
setXmlResponse(boolean xmlResponse)
Set Method for class field 'xmlResponse' that controls if teh rest response is in XML (true) or JSON (false).
|
private void |
streamZIP(OutputStream servletOut,
String[] dataNames,
InputStream[] dataStreams)
streams to a zipped out stream (without creating a file).
|
private void |
streamZIP(OutputStream servletOut,
String dataName,
InputStream dataStream)
streams to a zipped out stream (without creating a file).
|
private String |
xmlToJson(String xml)
Convert a well-formed (but not necessarily valid) XML string into a JSON String.
|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
protected static final String className_
private static final String SYSTEM_FILE_SEPERATOR
private static final String SERVLET_VERSION
public static final String CLIENT_SETTING_NAME_VIEWPORTWIDTH
public static final String CLIENT_SETTING_NAME_VIEWPORTHEIGHT
public static final String CLIENT_SETTING_NAME_BROWSER_NAME
public static final String CLIENT_SETTING_NAME_BROWSER_VERSION
public static final String CLIENT_SETTING_NAME_DEVICE_TYPE
public static final String CLIENT_SETTING_NAME_LASTFM_SESSION_KEY
public static final String CLIENT_SETTING_NAME_LASTFM_USERID
public static final String CLIENT_SETTING_NAME_LASTFM_USER_RECENT
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_TRACK_NUM
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_TRACK
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_ALBUM
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_ARTIST
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_ALBUM_ARTIST
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_TIME
public static final String CLIENT_SETTING_NAME_LASTFM_PLAY_DURATION
public static final String CLIENT_SETTING_NAME_LASTFM_SCROBBLE_TRACK
public static final String CLIENT_SETTING_NAME_LASTFM_SCROBBLE_ARTIST
public static final String CLIENT_SETTING_NAME_LASTFM_SCROBBLE_ALBUM
public static final String CLIENT_SETTING_NAME_LASTFM_SCROBBLE_ALBUM_ARTIST
public static final String CLIENT_SETTING_NAME_LASTFM_LOVE_TRACK
public static final String CLIENT_SETTING_NAME_LASTFM_LIST_LOVE_TRACK
protected static final String LASTFM_DEFAULT_USERNAME
protected static final String LASTFM_DEFAULT_PASSWORD
private static final String BUILD_TAG
private static String webServerHostName_
private boolean debugOut_
private int viewPortWidth_
private int viewPortHeight_
private String someParamYouWannaSet_
private boolean xmlResponse_
private int viewPortWidth
private int viewPortHeight
private String browserName
private String browserVersion
private String lastFmSessionKey
private String lastFmPlayTrack
private String lastFmPlayArtist
private String lastFmScrobbleTrack
private String lastFmScrobbleArtist
private String lastFmScrobbleAlbum
private String lastFmLoveTrack
private boolean xmlResponse
private TunesHelper tunesHelper
private String lastFmUserID_
private String lastFmPassword_
private boolean lastFMInit_
public AjaxRestWebsocketListener()
public String getServletInfo()
getServletInfo
in interface Servlet
getServletInfo
in class GenericServlet
public void init()
init
in class org.eclipse.jetty.websocket.servlet.WebSocketServlet
public void destroy()
public void configure(org.eclipse.jetty.websocket.servlet.WebSocketServletFactory factory)
configure
in class org.eclipse.jetty.websocket.servlet.WebSocketServlet
public int getViewPortWidth()
public void setViewPortWidth(int viewPortWidth)
viewPortWidth
- The value to assign viewPortWidth_.public int getViewPortHeight()
public void setViewPortHeight(int viewPortHeight)
viewPortWidth
- The value to assign viewPortWidth_.public boolean getDebugOut()
public void setDebugOut(boolean debugOut)
debugOut
- The value to assign debugOut_.public boolean getXmlResponse()
public void setXmlResponse(boolean xmlResponse)
xmlResponse
- is the value to set this class field to XML (true) or JSON (false).private void streamZIP(OutputStream servletOut, String dataName, InputStream dataStream)
servletOutput
- is the stream to zip intodataName
- are the pseudo fileName that will get created in the zip (pseudo file) streamdataStream
- the data to zipprivate void streamZIP(OutputStream servletOut, String[] dataNames, InputStream[] dataStreams)
servletOutput
- is the stream to zip intodataNames
- are the pseudo fileNames that will get created in the zip (pseudo file) streamdataStreams
- the data to zipprivate String parseRestRequest(String restPath)
restPath
- is the rest command part of the rest URLprivate void parseParams(HttpServletRequest req)
private String xmlToJson(String xml)
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
doGet
in class HttpServlet
req
- Description of the Parameterres
- Description of the ParameterServletException
- Description of the ExceptionIOException
- Description of the Exceptionpublic void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
doPost
in class HttpServlet
req
- Description of Parameterres
- Description of ParameterServletException
- Description of ExceptionIOException
- Description of Exceptionprivate String checkForRestRequest(HttpServletRequest req) throws ServletException, IOException
restPath
- is the rest command part of the rest URLServletException
IOException
private String checkForAjaxRequest(HttpServletRequest req) throws ServletException, IOException
req
- the servlet requestServletException
IOException
private boolean loginLastFM()
private void sendServletAdminPage(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
ServletException
IOException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses