Revision 6c0d81f1 src/com/rackspace/cloud/servers/api/client/ImageManager.java
b/src/com/rackspace/cloud/servers/api/client/ImageManager.java | ||
---|---|---|
32 | 32 |
public class ImageManager extends EntityManager { |
33 | 33 |
|
34 | 34 |
public ArrayList<Image> createList(boolean detail, Context context) { |
35 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
|
36 |
HttpGet get = new HttpGet(Account.getAccount().getServerUrl() + "/images/detail.xml?now=cache_time2"); |
|
37 |
ArrayList<Image> images = new ArrayList<Image>(); |
|
38 | 35 |
|
39 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
|
40 |
|
|
41 |
try { |
|
42 |
HttpResponse resp = httpclient.execute(get); |
|
43 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
44 |
String body = responseHandler.handleResponse(resp); |
|
45 |
|
|
46 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 203) { |
|
47 |
|
|
48 |
ImagesXMLParser imagesXMLParser = new ImagesXMLParser(); |
|
49 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
50 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
51 |
xmlReader.setContentHandler(imagesXMLParser); |
|
52 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
53 |
images = imagesXMLParser.getImages(); |
|
54 |
} |
|
55 |
} catch (ClientProtocolException cpe) { |
|
56 |
// we'll end up with an empty list; that's good enough |
|
57 |
} catch (IOException e) { |
|
58 |
// we'll end up with an empty list; that's good enough |
|
59 |
} catch (ParserConfigurationException e) { |
|
60 |
// we'll end up with an empty list; that's good enough |
|
61 |
} catch (SAXException e) { |
|
62 |
// we'll end up with an empty list; that's good enough |
|
63 |
} catch (FactoryConfigurationError e) { |
|
64 |
// we'll end up with an empty list; that's good enough |
|
36 |
ArrayList<Image> images = new ArrayList<Image>(); |
|
37 |
if(Account.getAccount().getServerUrl()!=null){ |
|
38 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
|
39 |
HttpGet get = new HttpGet(Account.getAccount().getServerUrl() + "/images/detail.xml?now=cache_time2"); |
|
40 |
get.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
|
41 |
|
|
42 |
try { |
|
43 |
HttpResponse resp = httpclient.execute(get); |
|
44 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
45 |
String body = responseHandler.handleResponse(resp); |
|
46 |
|
|
47 |
if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 203) { |
|
48 |
|
|
49 |
ImagesXMLParser imagesXMLParser = new ImagesXMLParser(); |
|
50 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
51 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
52 |
xmlReader.setContentHandler(imagesXMLParser); |
|
53 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
54 |
images = imagesXMLParser.getImages(); |
|
55 |
} |
|
56 |
} catch (ClientProtocolException cpe) { |
|
57 |
// we'll end up with an empty list; that's good enough |
|
58 |
} catch (IOException e) { |
|
59 |
// we'll end up with an empty list; that's good enough |
|
60 |
} catch (ParserConfigurationException e) { |
|
61 |
// we'll end up with an empty list; that's good enough |
|
62 |
} catch (SAXException e) { |
|
63 |
// we'll end up with an empty list; that's good enough |
|
64 |
} catch (FactoryConfigurationError e) { |
|
65 |
// we'll end up with an empty list; that's good enough |
|
66 |
} |
|
65 | 67 |
} |
66 | 68 |
|
67 | 69 |
return images; |
Also available in: Unified diff