public class TunesAjaxRestListener extends HttpServlet
Constructor and Description |
---|
TunesAjaxRestListener() |
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 |
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 TunesAjaxRestListener 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 Vector<String> |
sendPiSocketMessage(String msg) |
private Vector<String> |
sendPiSocketMessage(String msg,
String cmdParm) |
private void |
sendServletAdminPage(HttpServletRequest req,
HttpServletResponse res)
Prepares and returns basic info page about the servlet and 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 static Calendar |
toCalendar(Date date) |
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, 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
public static final String PIWEBSOCKET_DEFAULT_SERVER
public static final int PIWEBSOCKET_DEFAULT_PORT
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 lastFmUserRecent
private String lastFmPlayTrack
private int lastFmPlayTrackNum
private String lastFmPlayAlbum
private String lastFmPlayArtist
private String lastFmPlayAlbumArtist
private int lastFmPlayTime
private int lastFmPlayDuration
private String lastFmScrobbleTrack
private String lastFmPreviousScrobbleTrack
private String lastFmScrobbleArtist
private String lastFmScrobbleAlbum
private String lastFmScrobbleAlbumArtist
private String lastFmLoveTrack
private String lastFmListLovedTracks
private boolean xmlResponse
private TunesHelper tunesHelper
private String lastFmLogin
private String lastFmUserID_
private String lastFmPassword_
private boolean lastFMInit_
private Vector<Track> lastFmRecentTracks_
private String[] ajaxCommands_
private String[] restCommands_
private boolean piWebSocketAccess_
private String piWebSocketServer_
private int piWebSocketPort_
private org.eclipse.jetty.websocket.client.WebSocketClient piWebSocket_
private boolean piSocketAccess_
private String piTunesTCPSocketServer_
private int piTunesTCPSocket_
public TunesAjaxRestListener()
public String getServletInfo()
getServletInfo
in interface Servlet
getServletInfo
in class GenericServlet
public void init()
init
in class GenericServlet
public void destroy()
destroy
in interface Servlet
destroy
in class GenericServlet
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 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 static Calendar toCalendar(Date date)
private Vector<String> sendPiSocketMessage(String msg)
private Vector<String> sendPiSocketMessage(String msg, String cmdParm)
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