Skip to content

Commit

Permalink
Merge pull request #33 from hpcc-systems/eda
Browse files Browse the repository at this point in the history
Eda
  • Loading branch information
jchambers-ln committed Jul 31, 2014
2 parents 1fea00c + 8b7da09 commit a2fa57f
Show file tree
Hide file tree
Showing 3 changed files with 504 additions and 0 deletions.
128 changes: 128 additions & 0 deletions src/main/java/org/hpccsystems/javaecl/FileInfoSoap.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,134 @@ public String[] fetchFiles(){
return new String[0];
}

public String getFileType(String fileName){
errors=new ArrayList<String>();
String type = null;
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body>"
+ "<DFUInfo xmlns=\"urn:hpccsystems:ws:wsdfu\">"
+ "<Name>" + fileName + "</Name>"
+ "<Cluster></Cluster>"
+ "<UpdateDescription></UpdateDescription>"
+ "<FileName></FileName>"
+ "<FileDesc></FileDesc>"
+ "</DFUInfo>"
+ "</soap:Body>"
+ "</soap:Envelope>";

soap = new ECLSoap();

soap.setHostname(serverHost);
soap.setAllowInvalidCerts(allowInvalidCerts);
soap.setPort(this.serverPort);
soap.setUser(user);
soap.setPass(pass);
soap.setHttps(isHttps);

String path = "/WsDfu/DFUInfo?ver_=1.22";

InputStream is=null;
try {
is = soap.doSoap(xml, path);
} catch (Exception e)
{
errors.add("Error making soap request to HPCC web service " + path + ":" + e.getMessage() + " soap data:" + xml);
return type;
}

try{
if(soap.isLogonFail){
isLogonFail = soap.isLogonFail;
System.out.println("Authentication Failed, or you don't have permissions to read this file");
errors.add("Authentication Failed, or you don't have permissions to read this file");
}else{
if(is != null){
type = processFileInfoForType(is);
}
}
}catch(Exception e){
System.out.println(e);
errors.add(e.getMessage());
e.printStackTrace();
}
return type;
}

public String processFileInfoForType(InputStream is) throws Exception{
String type = "";
ArrayList<String[]> results = new ArrayList<String[]>();
String xml = "";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();

Document dom = db.parse(is);

Element docElement = dom.getDocumentElement();
System.out.println(dom.getTextContent());
NodeList dfuResponse = docElement.getElementsByTagName("DFUInfoResponse");

if (dfuResponse != null && dfuResponse.getLength() > 0) {
for (int i = 0; i < dfuResponse.getLength(); i++) {
System.out.println("Node:" + dfuResponse.item(i).getNodeName());
Element ds = (Element) dfuResponse.item(i);
System.out.println(ds.getFirstChild().getNodeName());
NodeList FileDetail = ds.getElementsByTagName("FileDetail");
NodeList errorList = ds.getElementsByTagName("Exceptions");
System.out.println("Node:" + FileDetail.getLength());
if (FileDetail != null && FileDetail.getLength() > 0) {
System.out.println("Node:" + FileDetail.getLength());
for (int j = 0; j < FileDetail.getLength(); j++) {
NodeList format = ((Element)FileDetail.item(j)).getElementsByTagName("Format");

for(int k=0; k< format.getLength(); k++){
String fm = format.item(k).getTextContent();
System.out.println("Type: " + fm);
type = fm;
}
}
}

if (errorList != null && errorList.getLength() > 0) {
System.out.println("Has ERROR");
for (int j = 0; j < errorList.getLength(); j++) {
System.out.println("Looping error");
Element row = (Element) errorList.item(j);
NodeList messages = row.getElementsByTagName("Code");
if (messages != null && messages.getLength() > 0) {
System.out.println("Found Code");
for (int k = 0; k < messages.getLength(); k++) {
Element messageRow = (Element) messages.item(j);
String code = messageRow.getTextContent();
//errors.add("HPCC Error " + code);
System.out.println("code: " + code);
if(code.equals("3")){
isLogonFail = true;
errors.add("Authentication Failed, or you don't have permissions to read this file");
}
}
}
NodeList messages2 = row.getElementsByTagName("Message");
if (messages2 != null && messages2.getLength() > 0) {
for (int k = 0; k < messages2.getLength(); k++) {
Element messageRow = (Element) messages2.item(j);
String messagestr = "HPCC error:" + messageRow.getTextContent();
errors.add(messagestr);
}
}
}
}

}
}
System.out.println("XML: " + xml);
if(!xml.equals("")){
results = parseRecordXML(xml);
}
// Iterator iterator = results.iterator();
return type;
}

public ArrayList<String[]> fetchFileMeta(String fileName){
errors=new ArrayList<String>();
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/hpccsystems/javaecl/HPCCServerInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@ public ArrayList<String[]> fetchFileDetails(String fileName){
isLogonFail = c.isLogonFail;
return file;
}

public String fetchXML(String fileName){
FileInfoSoap c = new FileInfoSoap(serverHost,serverPort,user,pass);
String xml = c.recordXML(fileName);
return xml;
}

}
Loading

0 comments on commit a2fa57f

Please sign in to comment.