| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package net.sf.arestc.core; |
| 20 |
|
|
| 21 |
|
import java.util.HashMap; |
| 22 |
|
import java.util.Map; |
| 23 |
|
|
| 24 |
|
import net.sf.arestc.core.bodytransformations.ReturnTransformationTypes; |
| 25 |
|
|
| 26 |
|
import org.apache.commons.configuration.ConfigurationException; |
| 27 |
|
import org.apache.log4j.Logger; |
| 28 |
|
import org.w3c.dom.Document; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@author |
| 35 |
|
|
|
|
|
| 84% |
Uncovered Elements: 4 (25) |
Complexity: 5 |
Complexity Density: 0.25 |
|
| 36 |
|
public class Ticketer { |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
private static final Logger LOGGER = Logger.getLogger(Ticketer.class |
| 40 |
|
.getName()); |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
@param |
| 47 |
|
|
| 48 |
|
@param |
| 49 |
|
|
| 50 |
|
@param |
| 51 |
|
|
| 52 |
|
@return |
| 53 |
|
|
|
|
|
| 83.3% |
Uncovered Elements: 4 (24) |
Complexity: 5 |
Complexity Density: 0.25 |
|
| 54 |
1
|
public String getTicket(final ConnectorContext context,... |
| 55 |
|
final String username, final String password) { |
| 56 |
1
|
final Map<String, Object> myParams = new HashMap<String, Object>(); |
| 57 |
1
|
myParams.put("u", username); |
| 58 |
1
|
myParams.put("pw", password); |
| 59 |
1
|
ARESTConnector connector = null; |
| 60 |
1
|
Document doc = null; |
| 61 |
|
|
| 62 |
1
|
String ret = "NOTICKET"; |
| 63 |
1
|
try { |
| 64 |
1
|
connector = new ARESTConnector(ConnectorTypes.STANDARD); |
| 65 |
|
|
| 66 |
1
|
connector.setClient(context.getClient()); |
| 67 |
1
|
final ConnectorRequest request = new StandardConnectorRequest( |
| 68 |
|
"login", myParams, ReturnTransformationTypes.DOM, "UTF-8"); |
| 69 |
|
|
| 70 |
1
|
final ConnectorResponse resp = connector.serve(request); |
| 71 |
1
|
doc = (Document) resp.getResponseBody(); |
| 72 |
1
|
if (doc != null) { |
| 73 |
1
|
doc.getDocumentElement().normalize(); |
| 74 |
1
|
ret = doc.getDocumentElement().getChildNodes().item(0) |
| 75 |
|
.getNodeValue(); |
| 76 |
|
} |
| 77 |
|
} catch (final ConfigurationException e) { |
| 78 |
0
|
LOGGER.error( |
| 79 |
|
"This should never occur, configuration should be fine by now", |
| 80 |
|
e); |
| 81 |
|
} catch (final CommandException e) { |
| 82 |
0
|
LOGGER.error( |
| 83 |
|
"This should never occur, configuration should be fine by now", |
| 84 |
|
e); |
| 85 |
|
} finally { |
| 86 |
1
|
if (null != connector) { |
| 87 |
1
|
connector.shutdown(); |
| 88 |
|
} |
| 89 |
|
} |
| 90 |
1
|
return ret; |
| 91 |
|
} |
| 92 |
|
} |