Example usage for org.w3c.dom Element getFirstChild

List of usage examples for org.w3c.dom Element getFirstChild

Introduction

In this page you can find the example usage for org.w3c.dom Element getFirstChild.

Prototype

public Node getFirstChild();

Source Link

Document

The first child of this node.

Usage

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

public Element getReturnStoredDocumentElement(ReturnStoredDocument returnStoredDocument) {

    Document newDocument = this.documentBuilder.newDocument();
    Element newElement = newDocument.createElement("newNode");
    try {/*from   w w w .  j  a  v  a2  s .c om*/
        this.artifactMarshaller.marshal(
                this.artifactObjectFactory.createReturnStoredDocument(returnStoredDocument), newElement);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }
    return (Element) newElement.getFirstChild();
}

From source file:com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.java

/**
 * @param linkText//from www.j a v a  2s . co m
 * @param domContext
 * @param link
 * @param tab
 * @param tabSet
 */
private void renderLinkText(String linkText, DOMContext domContext, Element link, PanelTab tab,
        PanelTabSet tabSet) {

    // create a new or update the old text node for the label
    if (linkText != null && linkText.length() != 0) {
        Text labelNode = (Text) link.getFirstChild();
        if (labelNode == null) {
            labelNode = domContext.createTextNode(linkText);
            tab.addHeaderText(domContext, link, labelNode, tabSet);
        } else {
            labelNode.setData(linkText);
        }
    }
}

From source file:com.fota.Link.sdpApi.java

public String CheckNumberPortabilityByPhoneNumber(String CTN)
        throws SAXException, IOException, ParserConfigurationException {
    String resultStr = null;//w  w w  .  j a v a 2s. co  m
    try {
        String endPointUrl = PropUtil.getPropValue("sdp.oif552.url");

        String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' "
                + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'"
                + " xmlns:sdp='http://kt.com/sdp'>" + "     <soapenv:Header>" + "         <oas:Security>"
                + "             <oas:UsernameToken>" + "                 <oas:Username>"
                + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + "                 <oas:Password>"
                + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + "             </oas:UsernameToken>"
                + "         </oas:Security>" + "     </soapenv:Header>"

                + "     <soapenv:Body>" + "         <sdp:checkNumberPortabilityByPhoneNumberRequest>"
                + "         <!--You may enterthe following 6 items in any order-->"
                + "             <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>"
                + "         </sdp:checkNumberPortabilityByPhoneNumberRequest>\n" + "     </soapenv:Body>\n"
                + "</soapenv:Envelope>";

        // phone_number + telco_code + party_name + birth_date + [gender +
        // foreigner](?)
        // + auth_code + random_no + action_type

        // connection
        URL url = new URL(endPointUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Content-type", "text/xml;charset=utf-8");
        // connection.setRequestProperty("Content-Length",
        // String.valueOf(strRequest.length()));
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.connect();

        // output
        OutputStream os = connection.getOutputStream();
        // os.write(strRequest.getBytes(), 0, strRequest.length());
        os.write(strRequest.getBytes("utf-8"));
        os.flush();
        os.close();

        // input
        InputStream is = connection.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8"));
        String line = null;
        String resValue = null;
        String parseStr = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            parseStr = line;

            //int nIndex = resultStr.indexOf("<sdp:ROUTING_DIGIT>");
            //resValue = resultStr.substring(nIndex,nIndex+1);

        }
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource temp = new InputSource();
        temp.setCharacterStream(new StringReader(parseStr));
        Document doc = builder.parse(temp); //xml?

        NodeList list = doc.getElementsByTagName("*");

        int i = 0;
        Element element;
        String contents;

        while (list.item(i) != null) {
            element = (Element) list.item(i);
            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            System.out.println(element.getNodeName());
            if (element.hasChildNodes()) {
                contents = element.getFirstChild().getNodeValue();
                System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                System.out.println(element.getNodeName());
                System.out.println(element.getFirstChild().getNodeName());
                if (element.getNodeName().equals("sdp:ROUTING_DIGIT")) {
                    //nero17 
                    //resultStr = element.getFirstChild().getNodeName();
                    resultStr = contents;
                }
                System.out.println(contents);
            }
            i++;
        }

        connection.disconnect();

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (resultStr.length() < 2) {
        resultStr = "";
    }
    return resultStr;
}

From source file:com.fota.Link.sdpApi.java

public String GetBasicUserInfoAndMarketInfo2(String CTN) throws JDOMException {
    String resultStr = null;/*from  w  w  w .  ja  va  2 s. c o m*/
    try {
        String endPointUrl = PropUtil.getPropValue("sdp.oif516.url");

        String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' "
                + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'"
                + " xmlns:sdp='http://kt.com/sdp'>" + "     <soapenv:Header>" + "         <oas:Security>"
                + "             <oas:UsernameToken>" + "                 <oas:Username>"
                + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + "                 <oas:Password>"
                + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + "             </oas:UsernameToken>"
                + "         </oas:Security>" + "     </soapenv:Header>"

                + "     <soapenv:Body>" + "         <sdp:getBasicUserInfoAndMarketInfoRequest>"
                + "         <!--You may enterthe following 6 items in any order-->"
                + "             <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>"
                + "         </sdp:getBasicUserInfoAndMarketInfoRequest>\n" + "     </soapenv:Body>\n"
                + "</soapenv:Envelope>";

        // connection
        URL url = new URL(endPointUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Content-type", "text/xml;charset=utf-8");
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.connect();

        // output
        OutputStream os = connection.getOutputStream();
        // os.write(strRequest.getBytes(), 0, strRequest.length());
        os.write(strRequest.getBytes("utf-8"));
        os.flush();
        os.close();

        // input
        InputStream is = connection.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8"));
        String line = null;
        String resValue = null;
        String parseStr = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            parseStr = line;

        }

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource temp = new InputSource();
        temp.setCharacterStream(new StringReader(parseStr));
        Document doc = builder.parse(temp); //xml?

        NodeList list = doc.getElementsByTagName("*");

        int i = 0;
        Element element;
        String contents;

        while (list.item(i) != null) {
            element = (Element) list.item(i);
            //            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //            System.out.println(element.getNodeName());
            if (element.hasChildNodes()) {
                contents = element.getFirstChild().getNodeValue();
                //            System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                //            System.out.println(element.getNodeName());
                //            System.out.println(element.getFirstChild().getNodeName());
                if (element.getNodeName().equals("sdp:CUSTOMER_LINK_NAME")) {
                    resultStr = element.getFirstChild().getNodeValue();
                }
                System.out.println(contents);
            }
            i++;
        }
        //resultStr = resValue;         
        resultStr = java.net.URLDecoder.decode(resultStr, "euc-kr");
        connection.disconnect();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return resultStr;
}

From source file:com.fota.Link.sdpApi.java

public String GetBasicUserInfoAndMarketInfo(String CTN) throws JDOMException {
    String resultStr = null;//from w  w w  . ja va  2 s .  co  m
    StringBuffer logSb = new StringBuffer();
    try {
        String endPointUrl = PropUtil.getPropValue("sdp.oif516.url");

        String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' "
                + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'"
                + " xmlns:sdp='http://kt.com/sdp'>" + "     <soapenv:Header>" + "         <oas:Security>"
                + "             <oas:UsernameToken>" + "                 <oas:Username>"
                + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + "                 <oas:Password>"
                + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + "             </oas:UsernameToken>"
                + "         </oas:Security>" + "     </soapenv:Header>"

                + "     <soapenv:Body>" + "         <sdp:getBasicUserInfoAndMarketInfoRequest>"
                + "         <!--You may enterthe following 6 items in any order-->"
                + "             <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>"
                + "         </sdp:getBasicUserInfoAndMarketInfoRequest>\n" + "     </soapenv:Body>\n"
                + "</soapenv:Envelope>";

        logSb.append("\r\n---------- GetBasicUserInfoAndMarketInfo(" + CTN + ") ----------");
        logSb.append("\r\nendPointUrl : " + endPointUrl);
        logSb.append("\r\nrequest msg : \r\n==============================\r\n" + strRequest
                + "\r\n===============================\r\n");

        logger.info(logSb.toString());
        logSb.setLength(0);

        // connection
        URL url = new URL(endPointUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Content-type", "text/xml;charset=utf-8");
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.connect();

        // output
        OutputStream os = connection.getOutputStream();
        // os.write(strRequest.getBytes(), 0, strRequest.length());
        os.write(strRequest.getBytes("utf-8"));
        os.flush();
        os.close();

        // input
        InputStream is = connection.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8"));
        String line = null;
        String resValue = null;
        String parseStr = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            parseStr = line;

        }

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource temp = new InputSource();
        temp.setCharacterStream(new StringReader(parseStr));
        Document doc = builder.parse(temp); //xml?

        NodeList list = doc.getElementsByTagName("*");

        int i = 0;
        Element element;
        String contents;

        while (list.item(i) != null) {
            element = (Element) list.item(i);
            //            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //            System.out.println(element.getNodeName());
            if (element.hasChildNodes()) {
                contents = element.getFirstChild().getNodeValue();
                //            System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                //            System.out.println(element.getNodeName());
                //            System.out.println(element.getFirstChild().getNodeName());
                if (element.getNodeName().equals("sdp:PREPAID")) {
                    resultStr = contents;
                }
                System.out.println(contents);
            }
            i++;
        }
        //resultStr = resValue;         

        connection.disconnect();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return resultStr;
}

From source file:com.fota.Link.sdpApi.java

public SDPInfoVO getSpecificSubscpnInfo(String CTN) {
    //String resultStr = null;
    SDPInfoVO resVO = new SDPInfoVO();
    String strIMEI = null;/*w  w  w .j  ava 2s  .co  m*/
    String Model_Name = null;
    String return_cd = null;
    try {
        String endPointUrl = PropUtil.getPropValue("sdp.oif114.url");

        String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' "
                + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'"
                + " xmlns:sdp='http://kt.com/sdp'>" + "     <soapenv:Header>" + "         <oas:Security>"
                + "             <oas:UsernameToken>" + "                 <oas:Username>"
                + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + "                 <oas:Password>"
                + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + "             </oas:UsernameToken>"
                + "         </oas:Security>" + "     </soapenv:Header>"

                + "     <soapenv:Body>" + "         <sdp:getSpecificSubscpnInfoRequest>"
                + "         <!--You may enterthe following 6 items in any order-->"

                // + "             <sdp:Credt_Id></sdp:Credt_Id>"
                + "             <sdp:User_Name>" + CTN + "</sdp:User_Name>" + "<sdp:Credt_Type_Cd>" + "05"

                + "</sdp:Credt_Type_Cd>"

                + "         </sdp:getSpecificSubscpnInfoRequest>\n" + "     </soapenv:Body>\n"
                + "</soapenv:Envelope>";

        // connection
        URL url = new URL(endPointUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Content-type", "text/xml;charset=utf-8");
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.connect();

        // output
        OutputStream os = connection.getOutputStream();
        // os.write(strRequest.getBytes(), 0, strRequest.length());
        os.write(strRequest.getBytes("utf-8"));
        os.flush();
        os.close();

        // input
        InputStream is = connection.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8"));
        String line = null;
        String parseStr = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            parseStr = line;
        }
        //resultStr = line;
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource temp = new InputSource();
        temp.setCharacterStream(new StringReader(parseStr));
        Document doc = builder.parse(temp); //xml?

        NodeList list = doc.getElementsByTagName("*");

        int i = 0;
        Element element;
        String contents;
        // sdp:returnCode
        while (list.item(i) != null) {
            element = (Element) list.item(i);
            //System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //System.out.println(element.getNodeName());
            if (element.hasChildNodes()) {
                contents = element.getFirstChild().getNodeValue();
                //System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                //System.out.println(element.getNodeName());
                //System.out.println(element.getFirstChild().getNodeName());
                if (element.getNodeName().equals("n1:Resource_Unique_Id")) {
                    if (element.getNextSibling().getFirstChild().getNodeValue().equals(("06"))) {
                        //System.out.println("%%%%%%%%%%%%%%%%% FINDFIND!!! %%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                        strIMEI = element.getFirstChild().getNodeValue();

                        //System.out.println("%%%%%%%%%%%%%%%%% FINDFIND!!!  " + strIMEI + "%%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                    }
                    //resultStr = element.getFirstChild().getNodeName();
                }
                if (element.getNodeName().equals("n1:Resource_Model_Name")) {
                    Model_Name = element.getFirstChild().getNodeValue();
                }
                if (element.getNodeName().equals("sdp:returnCode")) {
                    return_cd = element.getFirstChild().getNodeValue();
                }
                //n1:Resource_Model_Name
                System.out.println(contents);
            }
            i++;
        }
        connection.disconnect();

    } catch (Exception e) {
        e.printStackTrace();
    }

    resVO.setModem_model_nm(Model_Name);
    resVO.setImei(strIMEI);
    resVO.setReturn_cd(return_cd);
    return resVO;
}

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

private ResponseBaseType doVerification(byte[] documentData, String mimeType, boolean returnSignerIdentity,
        boolean returnVerificationReport, byte[] originalDocumentData) throws NotParseableXMLDocumentException {

    LOG.debug("verify");

    String requestId = "dss-verify-request-" + UUID.randomUUID().toString();
    VerifyRequest verifyRequest = this.dssObjectFactory.createVerifyRequest();
    verifyRequest.setRequestID(requestId);

    AnyType optionalInputs = this.dssObjectFactory.createAnyType();
    if (returnSignerIdentity) {
        JAXBElement<Object> returnSignerIdentityElement = this.dssObjectFactory
                .createReturnSignerIdentity(null);
        optionalInputs.getAny().add(returnSignerIdentityElement);
    }//from   w ww . j  av a2  s .  com
    if (returnVerificationReport) {
        ReturnVerificationReport jaxbReturnVerificationReport = this.vrObjectFactory
                .createReturnVerificationReport();
        /*
         * No need to do this, as we're using SSL.
         */
        jaxbReturnVerificationReport.setIncludeVerifier(false);
        jaxbReturnVerificationReport.setIncludeCertificateValues(true);
        jaxbReturnVerificationReport.setReportDetailLevel(
                "urn:oasis:names:tc:dss-x:1.0:profiles:verificationreport:reportdetail:noDetails");

        Document document = this.documentBuilder.newDocument();
        Element newElement = document.createElement("newNode");
        try {
            this.vrMarshaller.marshal(jaxbReturnVerificationReport, newElement);
        } catch (JAXBException e) {
            throw new RuntimeException("JAXB error: " + e.getMessage(), e);
        }
        Element returnVerificationReportElement = (Element) newElement.getFirstChild();
        optionalInputs.getAny().add(returnVerificationReportElement);
    }
    if (null != originalDocumentData) {
        OriginalDocumentType originalDocument = this.originalDocumentObjectFactory.createOriginalDocumentType();
        InputDocuments inputDocuments = this.vrDssObjectFactory.createInputDocuments();
        List<Object> documents = inputDocuments.getDocumentOrTransformedDataOrDocumentHash();
        be.fedict.eid.dss.ws.profile.vr.jaxb.dss.DocumentType document = this.vrDssObjectFactory
                .createDocumentType();
        if (null == mimeType || "text/xml".equals(mimeType)) {
            document.setBase64XML(originalDocumentData);
        } else {
            be.fedict.eid.dss.ws.profile.vr.jaxb.dss.Base64Data base64Data = this.vrDssObjectFactory
                    .createBase64Data();
            base64Data.setValue(originalDocumentData);
            base64Data.setMimeType(mimeType);
            document.setBase64Data(base64Data);
        }
        documents.add(document);
        originalDocument.setInputDocuments(inputDocuments);

        Document domDocument = this.documentBuilder.newDocument();
        Element newElement = domDocument.createElement("newElement");
        try {
            this.originalDocumentMarshaller.marshal(
                    this.originalDocumentObjectFactory.createOriginalDocument(originalDocument), newElement);
        } catch (JAXBException e) {
            throw new RuntimeException("JAXB error: " + e.getMessage(), e);
        }

        optionalInputs.getAny().add((Element) newElement.getFirstChild());
    }

    if (!optionalInputs.getAny().isEmpty()) {
        verifyRequest.setOptionalInputs(optionalInputs);
    }

    verifyRequest.setInputDocuments(getInputDocuments(documentData, mimeType));

    // operate
    ResponseBaseType response = port.verify(verifyRequest);

    // check response
    checkResponse(response, requestId);

    return response;
}

From source file:org.apache.manifoldcf.authorities.authorities.sharepoint.SPSProxyHelper.java

/**
* Get the access tokens for a user principal.
*///from ww  w . j a va  2  s. com
public List<String> getAccessTokens(String site, String userLoginName) throws ManifoldCFException {
    try {
        if (site.compareTo("/") == 0)
            site = ""; // root case

        userLoginName = mapToClaimSpace(userLoginName);

        UserGroupWS userService = new UserGroupWS(baseUrl + site, userName, password, configuration,
                httpClient);
        com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = userService
                .getUserGroupSoapHandler();

        com.microsoft.schemas.sharepoint.soap.directory.GetUserInfoResponseGetUserInfoResult userResp = userCall
                .getUserInfo(userLoginName);
        org.apache.axis.message.MessageElement[] usersList = userResp.get_any();

        /* Response looks like this:
            <GetUserInfo xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
               <User ID="4" Sid="S-1-5-21-2127521184-1604012920-1887927527-34577" Name="User1_Display_Name" 
        LoginName="DOMAIN\User1_Alias" Email="User1_E-mail" 
        Notes="Notes" IsSiteAdmin="False" IsDomainGroup="False" />
            </GetUserInfo>
          */

        if (usersList.length != 1)
            throw new ManifoldCFException("Bad response - expecting one outer 'GetUserInfo' node, saw "
                    + Integer.toString(usersList.length));

        if (Logging.authorityConnectors.isDebugEnabled()) {
            Logging.authorityConnectors
                    .debug("SharePoint authority: getUserInfo xml response: '" + usersList[0].toString() + "'");
        }

        MessageElement users = usersList[0];
        if (!users.getElementName().getLocalName().equals("GetUserInfo"))
            throw new ManifoldCFException("Bad response - outer node should have been 'GetUserInfo' node");

        String userID = null;
        String userName = null;

        Iterator userIter = users.getChildElements();
        while (userIter.hasNext()) {
            MessageElement child = (MessageElement) userIter.next();
            if (child.getElementName().getLocalName().equals("User")) {
                userID = child.getAttribute("ID");
                userName = child.getAttribute("LoginName");
            }
        }

        // If userID is null, no such user
        if (userID == null)
            return null;

        List<String> accessTokens = new ArrayList<String>();
        accessTokens.add("U" + userName);

        com.microsoft.schemas.sharepoint.soap.directory.GetGroupCollectionFromUserResponseGetGroupCollectionFromUserResult userGroupResp = userCall
                .getGroupCollectionFromUser(userLoginName);
        org.apache.axis.message.MessageElement[] groupsList = userGroupResp.get_any();

        /* Response looks like this:
            <GetGroupCollectionFromUser xmlns=
               "http://schemas.microsoft.com/sharepoint/soap/directory/">
               <Groups>
        <Group ID="3" Name="Group1" Description="Description" OwnerID="1" 
           OwnerIsUser="False" />
        <Group ID="15" Name="Group2" Description="Description" 
           OwnerID="12" OwnerIsUser="True" />
        <Group ID="16" Name="Group3" Description="Description" 
           OwnerID="7" OwnerIsUser="False" />
               </Groups>
            </GetGroupCollectionFromUser>
          */

        if (groupsList.length != 1)
            throw new ManifoldCFException(
                    "Bad response - expecting one outer 'GetGroupCollectionFromUser' node, saw "
                            + Integer.toString(groupsList.length));

        if (Logging.authorityConnectors.isDebugEnabled()) {
            Logging.authorityConnectors.debug("SharePoint authority: getGroupCollectionFromUser xml response: '"
                    + groupsList[0].toString() + "'");
        }

        MessageElement groups = groupsList[0];
        if (!groups.getElementName().getLocalName().equals("GetGroupCollectionFromUser"))
            throw new ManifoldCFException(
                    "Bad response - outer node should have been 'GetGroupCollectionFromUser' node");

        Iterator groupsIter = groups.getChildElements();
        while (groupsIter.hasNext()) {
            MessageElement child = (MessageElement) groupsIter.next();
            if (child.getElementName().getLocalName().equals("Groups")) {
                Iterator groupIter = child.getChildElements();
                while (groupIter.hasNext()) {
                    MessageElement group = (MessageElement) groupIter.next();
                    if (group.getElementName().getLocalName().equals("Group")) {
                        String groupID = group.getAttribute("ID");
                        String groupName = group.getAttribute("Name");
                        // Add to the access token list
                        accessTokens.add("G" + groupName);
                    }
                }
            }
        }

        // AxisFault is expected for case where user has no assigned roles
        try {
            com.microsoft.schemas.sharepoint.soap.directory.GetRoleCollectionFromUserResponseGetRoleCollectionFromUserResult userRoleResp = userCall
                    .getRoleCollectionFromUser(userLoginName);
            org.apache.axis.message.MessageElement[] rolesList = userRoleResp.get_any();

            if (rolesList.length != 1)
                throw new ManifoldCFException(
                        "Bad response - expecting one outer 'GetRoleCollectionFromUser' node, saw "
                                + Integer.toString(rolesList.length));

            if (Logging.authorityConnectors.isDebugEnabled()) {
                Logging.authorityConnectors
                        .debug("SharePoint authority: getRoleCollectionFromUser xml response: '"
                                + rolesList[0].toString() + "'");
            }

            // Not specified in doc and must be determined experimentally
            /*
            <ns1:GetRoleCollectionFromUser xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/directory/">
            <ns1:Roles>
            <ns1:Role ID="1073741825" Name="Limited Access" Description="Can view specific lists, document libraries, list items, folders, or documents when given permissions."
            Order="160" Hidden="True" Type="Guest" BasePermissions="ViewFormPages, Open, BrowseUserInfo, UseClientIntegration, UseRemoteAPIs"/>
            </ns1:Roles>
            </ns1:GetRoleCollectionFromUser>'
            */

            MessageElement roles = rolesList[0];
            if (!roles.getElementName().getLocalName().equals("GetRoleCollectionFromUser"))
                throw new ManifoldCFException(
                        "Bad response - outer node should have been 'GetRoleCollectionFromUser' node");

            Iterator rolesIter = roles.getChildElements();
            while (rolesIter.hasNext()) {
                MessageElement child = (MessageElement) rolesIter.next();
                if (child.getElementName().getLocalName().equals("Roles")) {
                    Iterator roleIter = child.getChildElements();
                    while (roleIter.hasNext()) {
                        MessageElement role = (MessageElement) roleIter.next();
                        if (role.getElementName().getLocalName().equals("Role")) {
                            String roleID = role.getAttribute("ID");
                            String roleName = role.getAttribute("Name");
                            // Add to the access token list
                            accessTokens.add("R" + roleName);
                        }
                    }
                }
            }
        } catch (org.apache.axis.AxisFault e) {
            if (e.getFaultCode().equals(
                    new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
                org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName(
                        "http://schemas.microsoft.com/sharepoint/soap/", "errorcode"));
                if (elem != null) {
                    elem.normalize();
                    String sharepointErrorCode = elem.getFirstChild().getNodeValue().trim();
                    if (!sharepointErrorCode.equals("0x80131600"))
                        throw e;
                }
            } else
                throw e;
        }

        return accessTokens;
    } catch (java.net.MalformedURLException e) {
        throw new ManifoldCFException("Bad SharePoint url: " + e.getMessage(), e);
    } catch (javax.xml.rpc.ServiceException e) {
        if (Logging.authorityConnectors.isDebugEnabled())
            Logging.authorityConnectors
                    .debug("SharePoint: Got a service exception getting the acls for site " + site, e);
        throw new ManifoldCFException("Service exception: " + e.getMessage(), e);
    } catch (org.apache.axis.AxisFault e) {
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(
                    new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
            if (elem != null) {
                elem.normalize();
                String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                if (httpErrorCode.equals("404")) {
                    // Page did not exist
                    if (Logging.authorityConnectors.isDebugEnabled())
                        Logging.authorityConnectors
                                .debug("SharePoint: The page at " + baseUrl + site + " did not exist");
                    throw new ManifoldCFException("The page at " + baseUrl + site + " did not exist");
                } else if (httpErrorCode.equals("401")) {
                    // User did not have permissions for this library to get the acls
                    if (Logging.authorityConnectors.isDebugEnabled())
                        Logging.authorityConnectors
                                .debug("SharePoint: The user did not have access to the usergroups service for "
                                        + baseUrl + site);
                    throw new ManifoldCFException(
                            "The user did not have access to the usergroups service at " + baseUrl + site);
                } else if (httpErrorCode.equals("403"))
                    throw new ManifoldCFException(
                            "Http error " + httpErrorCode + " while reading from " + baseUrl + site
                                    + " - check IIS and SharePoint security settings! " + e.getMessage(),
                            e);
                else
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode
                            + " accessing SharePoint at " + baseUrl + site + ": " + e.getMessage(), e);
            }
            throw new ManifoldCFException("Unknown http error occurred: " + e.getMessage(), e);
        } else if (e.getFaultCode()
                .equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName(
                    "http://schemas.microsoft.com/sharepoint/soap/", "errorcode"));
            if (elem != null) {
                elem.normalize();
                String sharepointErrorCode = elem.getFirstChild().getNodeValue().trim();
                if (sharepointErrorCode.equals("0x80131600")) {
                    // No such user
                    return null;
                }
                if (Logging.authorityConnectors.isDebugEnabled()) {
                    org.w3c.dom.Element elem2 = e.lookupFaultDetail(new javax.xml.namespace.QName(
                            "http://schemas.microsoft.com/sharepoint/soap/", "errorstring"));
                    String errorString = "";
                    if (elem != null)
                        errorString = elem2.getFirstChild().getNodeValue().trim();

                    Logging.authorityConnectors.debug("SharePoint: Getting usergroups in site " + site
                            + " failed with unexpected SharePoint error code " + sharepointErrorCode + ": "
                            + errorString, e);
                }
                throw new ManifoldCFException("SharePoint server error code: " + sharepointErrorCode);
            }
            if (Logging.authorityConnectors.isDebugEnabled())
                Logging.authorityConnectors
                        .debug("SharePoint: Unknown SharePoint server error getting usergroups for site " + site
                                + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = "
                                + e.getFaultString(), e);

            throw new ManifoldCFException("Unknown SharePoint server error: " + e.getMessage());
        }

        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/",
                "Server.userException"))) {
            String exceptionName = e.getFaultString();
            if (exceptionName.equals("java.lang.InterruptedException"))
                throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
        }

        if (Logging.authorityConnectors.isDebugEnabled())
            Logging.authorityConnectors
                    .debug("SharePoint: Got an unknown remote exception getting usergroups for " + site
                            + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = "
                            + e.getFaultString(), e);
        throw new ManifoldCFException("Remote procedure exception: " + e.getMessage(), e);
    } catch (java.rmi.RemoteException e) {
        // We expect the axis exception to be thrown, not this generic one!
        // So, fail hard if we see it.
        if (Logging.authorityConnectors.isDebugEnabled())
            Logging.authorityConnectors
                    .debug("SharePoint: Got an unexpected remote exception usergroups for site " + site, e);
        throw new ManifoldCFException("Unexpected remote procedure exception: " + e.getMessage(), e);
    }
}

From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java

private String getAppInfoValue(String regex) {
    Element appInfo = getAppInfo(regex);
    if (appInfo == null) {
        return null;
    }/*  w w  w  .  java2  s.c o  m*/
    return appInfo.getFirstChild().getNodeValue();
}

From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java

public String getDocumentation() {
    Element appInfo = getDocumentationElement();
    if (appInfo == null) {
        return null;
    }// w  ww .  j  av  a2s  . c om
    return appInfo.getFirstChild().getNodeValue();
}