List of usage examples for org.jdom2 Element getChild
public Element getChild(final String cname)
From source file:count_dep.Miscellaneous.java
private void MergeACE() throws FileNotFoundException, JDOMException, IOException { String[] corpusfolders = {//from w ww . j a va 2 s . c o m "D:\\LDC2006D06\\LDC2006D06\\Data\\LDC2006T06_Original\\data\\English\\bn\\fp1\\", "D:\\LDC2006D06\\LDC2006D06\\Data\\LDC2006T06_Original\\data\\English\\nw\\fp1\\", "D:\\LDC2006D06\\LDC2006D06\\Data\\LDC2006T06_Original\\data\\English\\wl\\fp1\\" }; PrintStream ps = new PrintStream(new FileOutputStream("D:\\wordvec\\ACE.txt")); for (int i = 0; i < corpusfolders.length; i++) { File folder = new File(corpusfolders[i]); File[] listFiles = folder.listFiles(); for (File f : listFiles) { if (f.getName().contains(".sgm")) { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(f); Element foo = doc.getRootElement(); String text = foo.getChild("BODY").getChild("TEXT").getText(); // int titleend = text.indexOf("\n\n"); // text = text.substring(titleend + 1); ps.println(text); } } } ps.close(); }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
/** * Creates Adobe Connect user.//from w w w. ja va 2 s . co m * * @return user identification (principal-id) */ protected String createAdobeConnectUser(String principalName, UserInformation userInformation) throws CommandException { if (principalName == null) { throw new IllegalArgumentException("Principal mustn't be null."); } RequestAttributeList userSearchAttributes = new RequestAttributeList(); userSearchAttributes.add("filter-login", principalName); Element principalList = execApi("principal-list", userSearchAttributes); if (principalList.getChild("principal-list").getChild("principal") != null) return principalList.getChild("principal-list").getChild("principal").getAttributeValue("principal-id"); RequestAttributeList newUserAttributes = new RequestAttributeList(); newUserAttributes.add("first-name", userInformation.getFirstName()); newUserAttributes.add("last-name", userInformation.getLastName()); newUserAttributes.add("login", principalName); newUserAttributes.add("email", userInformation.getPrimaryEmail()); newUserAttributes.add("type", "user"); newUserAttributes.add("has-children", "false"); Element response = execApi("principal-update", newUserAttributes); return response.getChild("principal").getAttributeValue("principal-id"); }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
/** * Set session state//from ww w.jav a2 s . c om * * @param roomId identifier of the room * @param state state of session; true for end, false for start session */ protected void endMeetingUpdate(String roomId, Boolean state, String message, Boolean redirect, String url) throws CommandException { RequestAttributeList sessionsAttributes = new RequestAttributeList(); sessionsAttributes.add("sco-id", roomId); Element sessionsResponse = execApi("report-meeting-sessions", sessionsAttributes); if (sessionsResponse.getChild("report-meeting-sessions").getChildren().size() == 0) { return; } RequestAttributeList endMeetingAttributes = new RequestAttributeList(); endMeetingAttributes.add("sco-id", roomId); endMeetingAttributes.add("state", state.toString()); // Not working on connect.cesnet.cz /*if (message != null) { // Replace all sequences of " " and "." by single space message = message.replaceAll("[ \\.]+", " "); try { endMeetingAttributes.add("message",URLEncoder.encode(message,"UTF8")); } catch (UnsupportedEncodingException e) { throw new CommandException("Error while message encoding.", e); } }*/ if (redirect == true && url != null) { endMeetingAttributes.add("redirect", redirect.toString()); endMeetingAttributes.add("url", url); } try { logger.debug("{} meeting (sco-ID: {}) session.", (state ? "Starting" : "Ending"), roomId); execApi("meeting-roommanager-endmeeting-update", endMeetingAttributes); } catch (CommandException exception) { logger.warn( "Failed to end/start meeting. Probably just AC error, everything should be working properly.", exception); } }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
@Override public MediaData getRoomContent(String roomId) throws CommandException, CommandUnsupportedException { RequestAttributeList attributes = new RequestAttributeList(); attributes.add("sco-id", roomId); Element response = execApi("sco-contents", attributes); for (Element child : response.getChild("scos").getChildren("sco")) { //TODO: archive all }/*from w w w . jav a 2 s .co m*/ return null; //To change body of implemented methods use File | Settings | File Templates. }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
@Override public void removeRoomContentFile(String roomId, String name) throws CommandException { RequestAttributeList attributes = new RequestAttributeList(); attributes.add("sco-id", roomId); attributes.add("filter-name", name); Element response = execApi("sco-contents", attributes); if (response.getChild("scos").getChild("sco") != null) { deleteSCO(response.getChild("scos").getChild("sco").getAttributeValue("sco-id")); }/*from w w w. j a v a 2s.c om*/ }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
@Override public Collection<RoomSummary> listRooms() throws CommandException { RequestAttributeList attributes = new RequestAttributeList(); attributes.add("filter-type", "meeting"); Element response = execApi("report-bulk-objects", attributes); List<RoomSummary> meetings = new ArrayList<RoomSummary>(); for (Element room : response.getChild("report-bulk-objects").getChildren("row")) { if (room.getChildText("name").matches("(?i).*Template")) { continue; }/*from w w w. j av a 2 s . c om*/ RoomSummary roomSummary = new RoomSummary(); roomSummary.setId(room.getAttributeValue("sco-id")); roomSummary.setName(room.getChildText("name")); roomSummary.setDescription(room.getChildText("description")); roomSummary.setAlias(room.getChildText("url")); String dateCreated = room.getChildText("date-created"); if (dateCreated != null) { roomSummary.setStartDateTime(DateTime.parse(dateCreated)); } meetings.add(roomSummary); } return Collections.unmodifiableList(meetings); }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
@Override public String createRoom(Room room) throws CommandException { try {// ww w. j av a 2 s .c om RequestAttributeList attributes = new RequestAttributeList(); attributes.add("folder-id", (this.meetingsFolderId != null ? this.meetingsFolderId : this.getMeetingsFolderId())); attributes.add("type", "meeting"); attributes.add("date-begin", URLEncoder.encode(DateTime.now().toString(), "UTF8")); // Set room attributes setRoomAttributes(attributes, room); // Room name must be filled if (attributes.getValue("name") == null) { throw new RuntimeException("Room name must be filled for the new room."); } Element response = execApi("sco-update", attributes); String roomId = response.getChild("sco").getAttributeValue("sco-id"); // Add room participants if (room.getLicenseCount() > 0) { startMeeting(roomId); addRoomParticipants(roomId, room.getParticipantRoles()); } else if (room.getLicenseCount() == 0) { endMeeting(roomId); } // Set passcode (pin), since Adobe Connect 9.0 RequestAttributeList passcodeAttributes = new RequestAttributeList(); passcodeAttributes.add("acl-id", roomId); passcodeAttributes.add("field-id", "meeting-passcode"); String pin = ""; AdobeConnectAccessMode accessMode = null; AdobeConnectRoomSetting adobeConnectRoomSetting = room.getRoomSetting(AdobeConnectRoomSetting.class); if (adobeConnectRoomSetting != null) { pin = adobeConnectRoomSetting.getPin() == null ? "" : adobeConnectRoomSetting.getPin(); accessMode = adobeConnectRoomSetting.getAccessMode(); } // Set pin for room if set passcodeAttributes.add("value", pin); execApi("acl-field-update", passcodeAttributes); // Set room access mode, when null setRoomAccessMode set default value {@link AdobeConnectAccessMode.PROTECTED} setRoomAccessMode(roomId, accessMode); //importRoomSettings(response.getChild("sco").getAttributeValue("sco-id"),room.getConfiguration()); return roomId; } catch (UnsupportedEncodingException ex) { throw new CommandException("Error while encoding date: ", ex); } }
From source file:cz.cesnet.shongo.connector.device.AdobeConnectConnector.java
/** * @param userPrincipalId principal-id of an user * @return user-original-id (EPPN) for given {@code userPrincipalId} or null when user was not found * @throws CommandException/*from www.j ava2 s .c o m*/ */ public String getUserPrincipalNameByPrincipalId(String userPrincipalId) throws CommandException { String userPrincipalName; if (cachedPrincipalNameByPrincipalId.contains(userPrincipalId)) { logger.debug("Using cached user-original-id by principal-id '{}'...", userPrincipalId); userPrincipalName = cachedPrincipalNameByPrincipalId.get(userPrincipalId); } else { logger.debug("Fetching user-original-id by principal-id '{}'...", userPrincipalId); RequestAttributeList userAttributes = new RequestAttributeList(); userAttributes.add("filter-principal-id", userPrincipalId); Element userResponse = execApi("principal-list", userAttributes); if (userResponse.getChild("principal-list").getChild("principal") == null) { return null; } userPrincipalName = userResponse.getChild("principal-list").getChild("principal").getChildText("login"); cachedPrincipalNameByPrincipalId.put(userPrincipalId, userPrincipalName); } return userPrincipalName; }
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; try {/*w ww . j ava 2s . co m*/ 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 w w w. j a v 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; }