Example usage for org.jdom2 Element getChildText

List of usage examples for org.jdom2 Element getChildText

Introduction

In this page you can find the example usage for org.jdom2 Element getChildText.

Prototype

public String getChildText(final String cname) 

Source Link

Document

Returns the textual content of the named child element, or null if there's no such child.

Usage

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

@Override
public Room getRoom(String roomId) throws CommandException {
    Room room = new Room();
    try {/*from w  ww  .j  a v  a  2  s  . c om*/
        Element sco = getScoInfo(roomId);

        room.setId(roomId);
        room.addAlias(AliasType.ROOM_NAME, sco.getChildText("name"));
        room.setDescription(sco.getChildText("description"));
        if (sco.getChildText("sco-tag") != null) {
            room.setLicenseCount(Integer.valueOf(sco.getChildText("sco-tag")));
        } else {
            logger.warn("Licence count not set for room " + roomId + " (using 0 licenses).");
            room.setLicenseCount(0);
        }
        room.addTechnology(Technology.ADOBE_CONNECT);

        String uri = "https://" + deviceAddress + sco.getChildText("url-path");
        room.addAlias(new Alias(AliasType.ADOBE_CONNECT_URI, uri));

        // options
        AdobeConnectRoomSetting adobeConnectRoomSetting = new AdobeConnectRoomSetting();
        String pin = sco.getChildText("meeting-passcode");
        if (pin != null) {
            adobeConnectRoomSetting.setPin(pin);
        }

        adobeConnectRoomSetting.setAccessMode(getRoomAccessMode(roomId));
        room.addRoomSetting(adobeConnectRoomSetting);

    } catch (RequestFailedCommandException exception) {
        if ("no-data".equals(exception.getCode())) {
            return null;
        }
    }
    return room;
}

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

@Override
public Collection<RoomParticipant> listRoomParticipants(String roomId) throws CommandException {
    RequestAttributeList attributes = new RequestAttributeList();
    attributes.add("sco-id", roomId);

    ArrayList<RoomParticipant> participantList = new ArrayList<RoomParticipant>();

    Element response;/*from w w  w.j  a  va  2s.  co m*/
    try {
        response = execApi("meeting-usermanager-user-list", attributes);
    } catch (RequestFailedCommandException exception) {
        // Participant list is not available, so return empty list
        if ("no-access".equals(exception.getCode()) && "not-available".equals(exception.getSubCode())) {
            return participantList;
        }
        // Participant list cannot be retrieved because of internal error
        else if ("internal-error".equals(exception.getCode())) {
            logger.debug(
                    "Adobe Connect issued internal error while getting meeting participants (UNSAFE API CALL)."
                            + " This should just mean, that there is no participants.",
                    exception);
            return participantList;
        }
        throw exception;
    }

    for (Element userDetails : response.getChild("meeting-usermanager-user-list").getChildren()) {
        RoomParticipant roomParticipant = new RoomParticipant();
        roomParticipant.setId(userDetails.getChildText("user-id"));
        roomParticipant.setRoomId(roomId);
        roomParticipant.setDisplayName(userDetails.getChildText("username"));

        String role = userDetails.getChildText("role");
        if ("participant".equals(role)) {
            roomParticipant.setRole(ParticipantRole.PARTICIPANT);
        } else if ("presenter".equals(role)) {
            roomParticipant.setRole(ParticipantRole.PRESENTER);
        } else if ("host".equals(role)) {
            roomParticipant.setRole(ParticipantRole.ADMINISTRATOR);
        }

        String userPrincipalName = getUserPrincipalNameByPrincipalId(userDetails.getChildText("principal-id"));

        // If participant is registered (is not guest)
        if (userPrincipalName != null) {
            UserInformation userInformation = getUserInformationByPrincipalName(userPrincipalName);
            if (userInformation != null) {
                roomParticipant.setUserId(userInformation.getUserId());
            }
        }

        participantList.add(roomParticipant);
    }

    return Collections.unmodifiableList(participantList);
}

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

/**
 * Sets and returns SCO-ID of folder for meetings.
 *
 * @return meeting folder SCO-ID/*from   ww  w  .  j av  a 2s  .c o m*/
 * @throws CommandException
 */
protected String getMeetingsFolderId() throws CommandException {
    if (meetingsFolderId == null) {
        Element response = execApi("sco-shortcuts", null);
        for (Element sco : response.getChild("shortcuts").getChildren("sco")) {
            if ("meetings".equals(sco.getAttributeValue("type"))) {
                // Find sco-id of meetings folder
                RequestAttributeList searchAttributes = new RequestAttributeList();
                searchAttributes.add("sco-id", sco.getAttributeValue("sco-id"));
                searchAttributes.add("filter-is-folder", "1");

                Element shongoFolder = execApi("sco-contents", searchAttributes);

                for (Element folder : shongoFolder.getChild("scos").getChildren("sco")) {
                    if (meetingsFolderName.equals(folder.getChildText("name"))) {
                        meetingsFolderId = folder.getAttributeValue("sco-id");
                    }
                }

                // Creates meetings folder if not exists
                if (meetingsFolderId == null) {
                    logger.debug("Folder /" + meetingsFolderName
                            + " for shongo meetings does not exists, creating...");

                    RequestAttributeList folderAttributes = new RequestAttributeList();
                    folderAttributes.add("folder-id", sco.getAttributeValue("sco-id"));
                    folderAttributes.add("name", meetingsFolderName);
                    folderAttributes.add("type", "folder");

                    Element folder = execApi("sco-update", folderAttributes);

                    meetingsFolderId = folder.getChild("sco").getAttributeValue("sco-id");

                    logger.debug("Folder /" + meetingsFolderName + " for meetings created with sco-id: "
                            + meetingsFolderId);
                }

                break;
            }
        }
    }

    return meetingsFolderId;
}

From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java

/**
 *
 * @throws CommandException//  w  ww.j a  v  a 2s. co  m
 */
protected void checkAllRoomsCapacity() throws CommandException {
    Element response = execApi("report-active-meetings", new RequestAttributeList());

    RequestAttributeList attributes = new RequestAttributeList();
    attributes.add("sco-id", getMeetingsFolderId());
    attributes.add("type", "meeting");
    Element shongoRoomsElement = execApi("sco-contents", attributes);

    List<String> shongoRooms = new ArrayList<String>();
    for (Element sco : shongoRoomsElement.getChild("scos").getChildren()) {
        shongoRooms.add(sco.getAttributeValue("sco-id"));
    }

    for (Element sco : response.getChild("report-active-meetings").getChildren()) {
        String scoId = sco.getAttributeValue("sco-id");
        if (shongoRooms.contains(scoId)) {
            checkRoomCapacity(scoId);
        } else {
            logger.debug("There is active room (sco-id: " + scoId + ", url: " + sco.getChildText("url-path")
                    + ", name: " + sco.getChildText("name") + "), which was not created by shongo.");
        }
    }
}

From source file:cz.lbenda.dbapp.rc.SessionConfiguration.java

License:Apache License

private void fromElement(final Element element) {
    setId(element.getAttributeValue("id"));
    if (element.getChild("connectionTimeout") != null) {
        this.connectionTimeout = Integer.valueOf(element.getChildText("connectionTimeout"));
    } else {/* w  ww  .java 2  s .co m*/
        connectionTimeout = -1;
    }
    jdbcConfigurationFromElement(element.getChild("jdbc"));
    // tableOfKeysSQLFromElement(element.getChild("tableOfKeySQLs"));
    Element ed = element.getChild("extendedDescription");
    if (ed != null) {
        setExtendedConfigurationType(ExtendedConfigurationType.valueOf(ed.getAttributeValue("type")));
        setExtendedConfigurationPath(ed.getText());
    }
    Element e = element.getChild("libraries");
    this.librariesPaths.clear();
    if (e != null) {
        for (Element lib : e.getChildren("library")) {
            this.librariesPaths.add(lib.getText());
        }
    }
    loadExtendedConfiguration();
}

From source file:de.andrena.tools.macker.rule.RuleSetBuilder.java

License:Open Source License

public AccessRule buildAccessRule(final Element ruleElem, final RuleSet ruleSet) throws RulesException {
    AccessRule prevRule = null, topRule = null;
    for (final Element subElem : getChildren(ruleElem)) {
        final AccessRule accRule = new AccessRule(ruleSet);

        if (subElem.getName().equals("allow")) {
            accRule.setType(AccessRuleType.ALLOW);
        } else if (subElem.getName().equals("deny")) {
            accRule.setType(AccessRuleType.DENY);
        } else if (subElem.getName().equals("from") || subElem.getName().equals("to")
                || subElem.getName().equals("message")) {
            continue;
        } else {/*from  w w w .  j a  va2 s .c o m*/
            throw new RulesDocumentException(subElem, "Invalid element <" + subElem.getName() + "> --"
                    + " expected an access rule (<deny> or <allow>)");
        }

        final Element fromElem = subElem.getChild("from");
        if (fromElem != null) {
            accRule.setFrom(buildPattern(fromElem, ruleSet));
        }

        final Element toElem = subElem.getChild("to");
        if (toElem != null) {
            accRule.setTo(buildPattern(toElem, ruleSet));
        }

        if (!subElem.getChildren().isEmpty()) {
            accRule.setChild(buildAccessRule(subElem, ruleSet));
        }

        if (topRule == null) {
            topRule = accRule;
        } else {
            prevRule.setNext(accRule);
        }
        prevRule = accRule;
    }
    if (topRule != null) {
        topRule.setMessage(ruleElem.getChildText("message"));
        buildSeverity(topRule, ruleElem);
    }
    return topRule;
}

From source file:de.bund.bfr.pmfml.file.PMFMetadataNode.java

License:Open Source License

public PMFMetadataNode(final Element node) {
    this.node = node;

    modelType = ModelType.valueOf(node.getChildText(MODEL_TYPE_TAG));
    final List<Element> masterFileElements = node.getChildren(MASTER_FILE_TAG);
    masterFiles = masterFileElements.stream().map(Element::getText).collect(Collectors.toSet());
}

From source file:de.ing_poetter.binview.variables.IntegerVariable.java

License:Open Source License

/**
 * @param curVar/* www  .ja va2 s .c  o m*/
 *
 */
public IntegerVariable(final Element variable) {
    super(variable);
    signed = Boolean.parseBoolean(variable.getChildText(SIGNED_ELEMENT_NAME));
    valuePresenation = variable.getChildText(VALUE_PRESENTATION_ELEMENT_NAME);
    checkVariablePresentation();
}

From source file:de.ing_poetter.binview.variables.Variable.java

License:Open Source License

protected Variable(final Element variable) {
    Name = variable.getChildText("Name");
    numBits = Integer.parseInt(variable.getChildText("numberOfBits"));
}

From source file:de.knewcleus.openradar.gui.flightplan.FpXml_1_0.java

License:Open Source License

public static List<FpAtc> parseAtcs(Element eAtcsInRange) {
    List<FpAtc> result = new ArrayList<FpAtc>();
    for (Element eAtc : eAtcsInRange.getChildren("atc")) {
        String callsign = eAtc.getChildText("callsign");
        String username = eAtc.getChildText("username");
        String frequency = eAtc.getChildText("frequency");
        double lon = Double.parseDouble(eAtc.getChildText("lon"));
        double lat = Double.parseDouble(eAtc.getChildText("lat"));
        double distance = Double.parseDouble(eAtc.getChildText("dist"));
        result.add(new FpAtc(callsign, username, frequency, new Point2D.Double(lon, lat), distance));
    }/*from ww  w .ja  v  a  2  s . co  m*/

    return result;
}