List of usage examples for org.apache.wicket.util.string Strings isEmpty
public static boolean isEmpty(final CharSequence string)
string
is considered empty. From source file:org.apache.isis.viewer.wicket.ui.pages.accmngt.register.RegisterPage.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); add(new NotificationPanel("feedback")); final StringValue uuidValue = getPageParameters().get(0); if (uuidValue.isEmpty()) { pageNavigationService.navigateTo(PageType.SIGN_IN); } else {/*from w w w . ja va 2 s .c o m*/ String uuid = uuidValue.toString(); AccountConfirmationMap accountConfirmationMap = getApplication() .getMetaData(AccountConfirmationMap.KEY); final String email = accountConfirmationMap.get(uuid); if (Strings.isEmpty(email)) { pageNavigationService.navigateTo(PageType.SIGN_IN); } else { UserDetails userDetails = newUserDetails(); addOrReplace(new RegisterPanel("content", userDetails, uuidValue.toString()) { @Override protected MarkupContainer newExtraFieldsContainer(String id) { return RegisterPage.this.newExtraFieldsContainer(id); } }); } } }
From source file:org.apache.isis.viewer.wicket.ui.pages.entity.EntityPage.java
License:Apache License
/** * Creates an EntityModel from the given page parameters. * Redirects to the application home page if there is no OID in the parameters. * * @param parameters The page parameters with the OID * @return An EntityModel for the requested OID *//*from ww w . j a v a2s.c o m*/ private static EntityModel createEntityModel(final PageParameters parameters) { String oid = EntityModel.oidStr(parameters); if (Strings.isEmpty(oid)) { throw new RestartResponseException(Application.get().getHomePage()); } return new EntityModel(parameters); }
From source file:org.apache.isis.viewer.wicket.ui.pages.login.WicketSignInPage.java
License:Apache License
/** * Checks for a cookie with name {@value #FEEDBACK_COOKIE_NAME} that is * used as a temporary container for stateless session scoped success feedback * messages.// w w w . j a v a2 s. co m */ private void checkForSuccessFeedback() { CookieUtils cookieUtils = new CookieUtils(); String successFeedback = cookieUtils.load(FEEDBACK_COOKIE_NAME); if (!Strings.isEmpty(successFeedback)) { success(successFeedback); cookieUtils.remove(FEEDBACK_COOKIE_NAME); } }
From source file:org.apache.jetspeed.portlets.site.PortalSiteManager.java
License:Apache License
public PortalSiteManager() { super();//from w w w . j av a 2 s . c o m List<ITab> tabList = new ArrayList<ITab>(); DefaultMutableTreeNode rootNode = populateTree(); populateDocument(getInitSiteTreeNode()); PortalTree siteTree = new PortalTree("siteTree", new PropertyModel(this, "treeRoot")); siteTree.getTreeState().expandNode(rootNode); tabPanel = new AjaxTabbedPanel("tabs", tabList); tabPanel.setOutputMarkupId(true); add(siteTree); Form treeForm = new Form("treeForm"); treeForm.add(new AutoCompleteTextField<String>("userFolder", new PropertyModel(this, "userFolder")) { @Override protected Iterator<String> getChoices(String input) { if (Strings.isEmpty(input) || input.length() < 1) { List<String> emptyList = Collections.emptyList(); return emptyList.iterator(); } List<String> choices = new ArrayList<String>(10); List<String> userNames = null; try { userNames = getServiceLocator().getUserManager().getUserNames(input); } catch (SecurityException e) { log.error("Failed to retrieve user names.", e); } if (userNames == null) { List<String> emptyList = Collections.emptyList(); return emptyList.iterator(); } if (userNames.size() > 10) { return userNames.subList(0, 10).iterator(); } else { return userNames.iterator(); } } }.setRequired(true)); treeForm.add(new Button("userFolderButton") { @Override public void onSubmit() { ((LinkTree) getPage().get("siteTree")).getTreeState().expandNode(populateUserTree(userFolder)); } }); treeForm.add(new Button("portalFolderButton") { @Override public void onSubmit() { setUserFolder(""); ((LinkTree) getPage().get("siteTree")).getTreeState().expandNode(populateTree()); } }); add(new FeedbackPanel("feedback")); add(treeForm); add(tabPanel); controlTabs(); setVisibilitiesOfChildComponentsByPreferences("component.visibility.", true); }
From source file:org.apache.openmeetings.backup.BackupImport.java
License:Apache License
public void performImport(InputStream is) throws Exception { usersMap.clear();//from w ww . ja va 2 s .c o m groupMap.clear(); appointmentsMap.clear(); roomsMap.clear(); messageFoldersMap.clear(); userContactsMap.clear(); userEmailMap.clear(); messageFoldersMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID); messageFoldersMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID); messageFoldersMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID); File f = unzip(is); /* * ##################### Import Configs */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Long.class, LongTransform.class); registry.bind(Date.class, DateConverter.class); registry.bind(User.class, new UserConverter(userDao, usersMap)); List<Configuration> list = readList(serializer, f, "configs.xml", "configs", Configuration.class, true); for (Configuration c : list) { if (c.getKey() == null || c.isDeleted()) { continue; } Configuration cfg = configurationDao.forceGet(c.getKey()); if (cfg != null && !cfg.isDeleted()) { log.warn("Non deleted configuration with same key is found! old value: {}, new value: {}", cfg.getValue(), c.getValue()); } c.setId(cfg == null ? null : cfg.getId()); if (c.getUser() != null && c.getUser().getId() == null) { c.setUser(null); } if (CONFIG_CRYPT_KEY.equals(c.getKey())) { try { Class.forName(c.getValue()); } catch (ClassNotFoundException e) { c.setValue(SHA256Implementation.class.getCanonicalName()); } } configurationDao.update(c, null); } } log.info("Configs import complete, starting group import"); /* * ##################### Import Groups */ Serializer simpleSerializer = new Persister(); { List<Group> list = readList(simpleSerializer, f, "organizations.xml", "organisations", Group.class); for (Group o : list) { Long oldId = o.getId(); o.setId(null); o = groupDao.update(o, null); groupMap.put(oldId, o.getId()); } } log.info("Groups import complete, starting LDAP config import"); /* * ##################### Import LDAP Configs */ Long defaultLdapId = configurationDao.getConfValue(CONFIG_DEFAULT_LDAP_ID, Long.class, null); { List<LdapConfig> list = readList(simpleSerializer, f, "ldapconfigs.xml", "ldapconfigs", LdapConfig.class, true); for (LdapConfig c : list) { if (!"local DB [internal]".equals(c.getName())) { c.setId(null); c = ldapConfigDao.update(c, null); if (defaultLdapId == null) { defaultLdapId = c.getId(); } } } } log.info("Ldap config import complete, starting OAuth2 server import"); /* * ##################### OAuth2 servers */ { List<OAuthServer> list = readList(simpleSerializer, f, "oauth2servers.xml", "oauth2servers", OAuthServer.class, true); for (OAuthServer s : list) { s.setId(null); auth2Dao.update(s, null); } } log.info("OAuth2 servers import complete, starting user import"); /* * ##################### Import Users */ { String jNameTimeZone = configurationDao.getConfValue("default.timezone", String.class, "Europe/Berlin"); List<User> list = readUserList(f, "users.xml", "users"); int minLoginLength = getMinLoginLength(configurationDao); for (User u : list) { if (u.getLogin() == null) { continue; } if (u.getType() == User.Type.contact && u.getLogin().length() < minLoginLength) { u.setLogin(UUID.randomUUID().toString()); } //FIXME: OPENMEETINGS-750 //Convert old Backups with OmTimeZone to new schema String tz = u.getTimeZoneId(); if (tz == null) { u.setTimeZoneId(jNameTimeZone); u.setForceTimeZoneCheck(true); } else { u.setForceTimeZoneCheck(false); } Long userId = u.getId(); u.setId(null); if (u.getSipUser() != null && u.getSipUser().getId() != 0) { u.getSipUser().setId(0); } if (LDAP_EXT_TYPE.equals(u.getExternalType()) && User.Type.external != u.getType()) { log.warn("Found LDAP user in 'old' format, external_type == 'LDAP':: " + u); u.setType(User.Type.ldap); u.setExternalType(null); if (u.getDomainId() == null) { u.setDomainId(defaultLdapId); //domainId was not supported in old versions of OM } } if (!Strings.isEmpty(u.getExternalType())) { u.setType(User.Type.external); } userDao.update(u, Long.valueOf(-1)); usersMap.put(userId, u.getId()); } } log.info("Users import complete, starting room import"); /* * ##################### Import Rooms */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Long.class, LongTransform.class); matcher.bind(Integer.class, IntegerTransform.class); registry.bind(User.class, new UserConverter(userDao, usersMap)); registry.bind(Room.Type.class, RoomTypeConverter.class); List<Room> list = readList(serializer, f, "rooms.xml", "rooms", Room.class); for (Room r : list) { Long roomId = r.getId(); // We need to reset ids as openJPA reject to store them otherwise r.setId(null); if (r.getModerators() != null) { for (Iterator<RoomModerator> i = r.getModerators().iterator(); i.hasNext();) { RoomModerator rm = i.next(); if (rm.getUser().getId() == null) { i.remove(); } } } r = roomDao.update(r, null); roomsMap.put(roomId, r.getId()); } } log.info("Room import complete, starting room groups import"); /* * ##################### Import Room Groups */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(Group.class, new GroupConverter(groupDao, groupMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); List<RoomGroup> list = readList(serializer, f, "rooms_organisation.xml", "room_organisations", RoomGroup.class); for (RoomGroup ro : list) { if (!ro.isDeleted() && ro.getRoom() != null && ro.getRoom().getId() != null && ro.getGroup() != null && ro.getGroup().getId() != null) { // We need to reset this as openJPA reject to store them otherwise ro.setId(null); roomGroupDao.update(ro, null); } } } log.info("Room groups import complete, starting chat messages import"); /* * ##################### Import Chat messages */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(userDao, usersMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(Date.class, DateConverter.class); List<ChatMessage> list = readList(serializer, f, "chat_messages.xml", "chat_messages", ChatMessage.class, true); for (ChatMessage m : list) { m.setId(null); if (m.getFromUser() == null || m.getFromUser().getId() == null) { continue; } chatDao.update(m); } } log.info("Chat messages import complete, starting appointement import"); /* * ##################### Import Appointements */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(userDao, usersMap)); registry.bind(Appointment.Reminder.class, AppointmentReminderTypeConverter.class); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(Date.class, DateConverter.class); List<Appointment> list = readList(serializer, f, "appointements.xml", "appointments", Appointment.class); for (Appointment a : list) { Long appId = a.getId(); // We need to reset this as openJPA reject to store them otherwise a.setId(null); if (a.getOwner() != null && a.getOwner().getId() == null) { a.setOwner(null); } if (a.getRoom() == null || a.getRoom().getId() == null) { log.warn("Appointment without room was found, skipping: {}", a); continue; } if (a.getStart() == null || a.getEnd() == null) { log.warn("Appointment without start/end time was found, skipping: {}", a); continue; } a = appointmentDao.update(a, null, false); appointmentsMap.put(appId, a.getId()); } } log.info("Appointement import complete, starting meeting members import"); /* * ##################### Import MeetingMembers * * Reminder Invitations will be NOT send! */ { List<MeetingMember> list = readMeetingMemberList(f, "meetingmembers.xml", "meetingmembers"); for (MeetingMember ma : list) { ma.setId(null); meetingMemberDao.update(ma); } } log.info("Meeting members import complete, starting cluster server import"); /* * ##################### Cluster servers */ { List<Server> list = readList(simpleSerializer, f, "servers.xml", "servers", Server.class, true); for (Server s : list) { s.setId(null); serverDao.update(s, null); } } log.info("Cluster servers import complete, starting recordings import"); /* * ##################### Import Recordings */ { List<Recording> list = readRecordingList(f, "flvRecordings.xml", "flvrecordings"); for (Recording fr : list) { fr.setId(null); if (fr.getRoomId() != null) { fr.setRoomId(roomsMap.get(fr.getRoomId())); } if (fr.getOwnerId() != null) { fr.setOwnerId(usersMap.get(fr.getOwnerId())); } if (fr.getMetaData() != null) { for (RecordingMetaData meta : fr.getMetaData()) { meta.setId(null); meta.setRecording(fr); } } recordingDao.update(fr); } } log.info("Recording import complete, starting private message folder import"); /* * ##################### Import Private Message Folders */ { List<PrivateMessageFolder> list = readList(simpleSerializer, f, "privateMessageFolder.xml", "privatemessagefolders", PrivateMessageFolder.class, true); for (PrivateMessageFolder p : list) { Long folderId = p.getId(); PrivateMessageFolder storedFolder = privateMessageFolderDao.get(folderId); if (storedFolder == null) { p.setId(null); Long newFolderId = privateMessageFolderDao.addPrivateMessageFolderObj(p); messageFoldersMap.put(folderId, newFolderId); } } } log.info("Private message folder import complete, starting user contacts import"); /* * ##################### Import User Contacts */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(userDao, usersMap)); List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class, true); for (UserContact uc : list) { Long ucId = uc.getId(); UserContact storedUC = userContactDao.get(ucId); if (storedUC == null && uc.getContact() != null && uc.getContact().getId() != null) { uc.setId(null); if (uc.getOwner() != null && uc.getOwner().getId() == null) { uc.setOwner(null); } uc = userContactDao.update(uc); userContactsMap.put(ucId, uc.getId()); } } } log.info("Usercontact import complete, starting private messages item import"); /* * ##################### Import Private Messages */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(userDao, usersMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(Date.class, DateConverter.class); List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class, true); boolean oldBackup = true; for (PrivateMessage p : list) { if (p.getFolderId() == null || p.getFolderId().longValue() < 0) { oldBackup = false; break; } } for (PrivateMessage p : list) { p.setId(null); p.setFolderId(getNewId(p.getFolderId(), Maps.MESSAGEFOLDERS)); p.setUserContactId(getNewId(p.getUserContactId(), Maps.USERCONTACTS)); if (p.getRoom() != null && p.getRoom().getId() == null) { p.setRoom(null); } if (p.getTo() != null && p.getTo().getId() == null) { p.setTo(null); } if (p.getFrom() != null && p.getFrom().getId() == null) { p.setFrom(null); } if (p.getOwner() != null && p.getOwner().getId() == null) { p.setOwner(null); } if (oldBackup && p.getOwner() != null && p.getOwner().getId() != null && p.getFrom() != null && p.getFrom().getId() != null && p.getOwner().getId() == p.getFrom().getId()) { p.setFolderId(SENT_FOLDER_ID); } privateMessageDao.update(p, null); } } log.info("Private message import complete, starting file explorer item import"); /* * ##################### Import File-Explorer Items */ { List<FileExplorerItem> list = readFileExplorerItemList(f, "fileExplorerItems.xml", "fileExplorerItems"); for (FileExplorerItem file : list) { // We need to reset this as openJPA reject to store them otherwise file.setId(null); Long roomId = file.getRoomId(); file.setRoomId(roomsMap.containsKey(roomId) ? roomsMap.get(roomId) : null); if (file.getOwnerId() != null) { file.setOwnerId(usersMap.get(file.getOwnerId())); } if (file.getParentId() != null && file.getParentId().longValue() <= 0L) { file.setParentId(null); } fileExplorerItemDao.update(file); } } log.info("File explorer item import complete, starting room poll import"); /* * ##################### Import Room Polls */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Integer.class, IntegerTransform.class); registry.bind(User.class, new UserConverter(userDao, usersMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(RoomPoll.Type.class, PollTypeConverter.class); registry.bind(Date.class, DateConverter.class); List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class, true); for (RoomPoll rp : list) { rp.setId(null); if (rp.getRoom() == null || rp.getRoom().getId() == null) { //room was deleted continue; } if (rp.getCreator() == null || rp.getCreator().getId() == null) { rp.setCreator(null); } for (RoomPollAnswer rpa : rp.getAnswers()) { if (rpa.getVotedUser() == null || rpa.getVotedUser().getId() == null) { rpa.setVotedUser(null); } } pollDao.update(rp); } } log.info("Poll import complete, starting copy of files and folders"); /* * ##################### Import real files and folders */ importFolders(f); log.info("File explorer item import complete, clearing temp files"); FileHelper.removeRec(f); }
From source file:org.apache.openmeetings.backup.BackupImport.java
License:Apache License
private List<User> readUserList(InputSource xml, String listNodeName) throws Exception { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer ser = new Persister(strategy); registry.bind(Group.class, new GroupConverter(groupDao, groupMap)); registry.bind(Salutation.class, SalutationConverter.class); registry.bind(Date.class, DateConverter.class); DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = dBuilder.parse(xml); userEmailMap.clear();//from w ww . j a v a 2s.co m //add existence email from database List<User> users = userDao.getAllUsers(); for (User u : users) { if (u.getAddress() == null || u.getAddress().getEmail() == null || User.Type.user != u.getType()) { continue; } userEmailMap.put(u.getAddress().getEmail(), Integer.valueOf(-1)); } Node nList = getNode(getNode(doc, "root"), listNodeName); if (nList != null) { NodeList nl = nList.getChildNodes(); // one of the old OM version created 2 nodes "deleted" this code block handles this for (int i = 0; i < nl.getLength(); ++i) { Node user = nl.item(i); NodeList nl1 = user.getChildNodes(); boolean deletedFound = false; for (int j = 0; j < nl1.getLength(); ++j) { Node node = nl1.item(j); if (node.getNodeType() == Node.ELEMENT_NODE && "deleted".equals(node.getNodeName())) { if (deletedFound) { user.removeChild(node); break; } deletedFound = true; } } } } StringWriter sw = new StringWriter(); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(new DOMSource(doc), new StreamResult(sw)); List<User> list = new ArrayList<>(); InputNode root = NodeBuilder.read(new StringReader(sw.toString())); InputNode root1 = NodeBuilder.read(new StringReader(sw.toString())); //HACK to handle Address inside user InputNode root2 = NodeBuilder.read(new StringReader(sw.toString())); //HACK to handle old om_time_zone, level_id, status InputNode listNode = root.getNext(); InputNode listNode1 = root1.getNext(); //HACK to handle Address inside user InputNode listNode2 = root2.getNext(); //HACK to handle old om_time_zone if (listNodeName.equals(listNode.getName())) { InputNode item = listNode.getNext(); InputNode item1 = listNode1.getNext(); //HACK to handle Address inside user InputNode item2 = listNode2.getNext(); //HACK to handle old om_time_zone, level_id, status while (item != null) { User u = ser.read(User.class, item, false); boolean needToSkip1 = true; //HACK to handle Address inside user if (u.getAddress() == null) { Address a = ser.read(Address.class, item1, false); u.setAddress(a); needToSkip1 = false; } if (needToSkip1) { do { item1 = listNode1.getNext(); //HACK to handle Address inside user } while (item1 != null && !"user".equals(item1.getName())); } String levelId = null, status = null, stateId = null; do { if (u.getTimeZoneId() == null && "omTimeZone".equals(item2.getName())) { String jName = item2.getValue(); u.setTimeZoneId(jName == null ? null : tzUtil.getTimeZone(jName).getID()); } if ("level_id".equals(item2.getName())) { levelId = item2.getValue(); } if ("status".equals(item2.getName())) { status = item2.getValue(); } if ("state_id".equals(item2.getName())) { stateId = item2.getValue(); } item2 = listNode2.getNext(); //HACK to handle old om_time_zone, level_id, status } while (item2 != null && !"user".equals(item2.getName())); if (u.getRights().isEmpty()) { u.getRights().add(Right.Room); if ("1".equals(status)) { u.getRights().add(Right.Dashboard); u.getRights().add(Right.Login); } if ("3".equals(levelId)) { u.getRights().add(Right.Admin); u.getRights().add(Right.Soap); } if ("4".equals(levelId)) { u.getRights().add(Right.Soap); } } // check that email is unique if (u.getAddress() != null && u.getAddress().getEmail() != null && User.Type.user == u.getType()) { if (userEmailMap.containsKey(u.getAddress().getEmail())) { log.warn("Email is duplicated for user " + u.toString()); String updateEmail = "modified_by_import_<" + list.size() + ">" + u.getAddress().getEmail(); u.getAddress().setEmail(updateEmail); } userEmailMap.put(u.getAddress().getEmail(), Integer.valueOf(userEmailMap.size())); } // check old stateId if (!Strings.isEmpty(stateId)) { String country = getCountry(stateId); if (!Strings.isEmpty(country)) { if (u.getAddress() == null) { u.setAddress(new Address()); } u.getAddress().setCountry(country); } } if (u.getGroupUsers() != null) { for (GroupUser gu : u.getGroupUsers()) { gu.setUser(u); } } list.add(u); item = listNode.getNext(); } } return list; }
From source file:org.apache.openmeetings.calendar.TestAppointmentAddAppointment.java
License:Apache License
@Test public void saveAppointment() throws Exception { log.debug("- saveAppointment"); Calendar start = Calendar.getInstance(); start.setTimeInMillis(start.getTimeInMillis() + 600000); Calendar end = Calendar.getInstance(); end.setTimeInMillis(start.getTimeInMillis() + 600000); String appointmentName = "Test 01"; String appointmentDescription = "Descr"; Long userId = 1L;//from w w w .j av a 2s. c o m String appointmentLocation = "office"; Boolean isMonthly = false; Boolean isDaily = false; Boolean isWeekly = false; String remind = Appointment.Reminder.ical.name(); Boolean isYearly = false; String[] mmClient = new String[1]; for (int i = 0; i < 1; i++) { mmClient[0] = createClientObj("firstname" + i, "lastname" + i, "first" + i + ".last" + i + "@webbase-design.de", "Etc/GMT+1"); } Long languageId = 1L; Long roomType = 1L; Appointment a = new Appointment(); a.setTitle(appointmentName); a.setLocation(appointmentLocation); a.setDescription(appointmentDescription); a.setStart(start.getTime()); a.setEnd(end.getTime()); a.setIsDaily(isDaily); a.setIsWeekly(isWeekly); a.setIsMonthly(isMonthly); a.setIsYearly(isYearly); a.setReminder(Reminder.valueOf(remind)); a.setRoom(new Room()); a.getRoom().setComment(appointmentDescription); a.getRoom().setName(appointmentName); a.getRoom().setType(Room.Type.get(roomType)); a.getRoom().setAppointment(true); a.setOwner(userDao.get(userId)); a.setPasswordProtected(false); a.setPassword(""); a.setMeetingMembers(new ArrayList<MeetingMember>()); for (String singleClient : mmClient) { if (Strings.isEmpty(singleClient)) { continue; } MeetingMember mm = getMeetingMember(userId, languageId, singleClient); mm.setAppointment(a); a.getMeetingMembers().add(mm); } a = appointmentDao.update(a, userId); Thread.sleep(3000); appointmentLogic.doScheduledMeetingReminder(); Thread.sleep(3000); assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId()); }
From source file:org.apache.openmeetings.core.converter.BaseConverter.java
License:Apache License
private String getPath(String key, String app) { final String cfg = cfgDao.getString(key, ""); StringBuilder path = new StringBuilder(cfg); if (!Strings.isEmpty(path) && !cfg.endsWith(File.separator)) { path.append(File.separator); }/* w ww .jav a 2 s . co m*/ path.append(app).append(EXEC_EXT); return path.toString(); }
From source file:org.apache.openmeetings.core.converter.DocumentConverter.java
License:Apache License
public static void createOfficeManager(String officePath, Consumer<OfficeManager> consumer) { OfficeManager manager = null;/*from w w w . j a va 2 s . c o m*/ try { DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration(); if (!Strings.isEmpty(officePath)) { configuration.setOfficeHome(officePath); } manager = configuration.buildOfficeManager(); manager.start(); if (consumer != null) { consumer.accept(manager); } } finally { if (manager != null) { manager.stop(); } } }
From source file:org.apache.openmeetings.core.converter.InterviewConverter.java
License:Apache License
@Override public void startConversion(Recording r) { if (r == null) { log.warn("Conversion is NOT started. Recording passed is NULL"); return;// w w w . j a v a 2 s.c o m } ProcessResultList logs = new ProcessResultList(); List<File> waveFiles = new ArrayList<>(); try { // Default Image for empty interview video pods final File interviewCamFile = new File(OmFileHelper.getImagesDir(), "interview_webcam.png"); if (!interviewCamFile.exists()) { throw new ConversionException("defaultInterviewImageFile does not exist!"); } log.debug("recording {}", r.getId()); if (Strings.isEmpty(r.getHash())) { r.setHash(randomUUID().toString()); } r.setStatus(Recording.Status.CONVERTING); r = recordingDao.update(r); File streamFolder = getStreamFolder(r); List<RecordingChunk> chunks = chunkDao.getByRecording(r.getId()); File wav = new File(streamFolder, String.format("INTERVIEW_%s_FINAL_WAVE.wav", r.getId())); createWav(r, logs, streamFolder, waveFiles, wav, chunks); final String interviewCam = interviewCamFile.getCanonicalPath(); final int width = 320; final int height = 260; // Merge Audio with Video / Calculate resulting video // group by sid first to get all pods Map<String, List<RecordingChunk>> cunksBySid = chunks.stream() .collect(Collectors.groupingBy(RecordingChunk::getSid, LinkedHashMap::new, Collectors.collectingAndThen(Collectors.toList(), l -> l.stream().sorted(Comparator.comparing(RecordingChunk::getStart)) .collect(Collectors.toList())))); List<String> pods = new ArrayList<>(); int N = pods.size(); for (Entry<String, List<RecordingChunk>> e : cunksBySid.entrySet()) { Date pStart = r.getRecordStart(); List<PodPart> parts = new ArrayList<>(); pStart = processParts(r.getRoomId(), e.getValue(), logs, N, parts, pStart); if (!parts.isEmpty()) { String podX = new File(streamFolder, String.format("rec_%s_pod_%s.%s", r.getId(), N, EXTENSION_MP4)).getCanonicalPath(); long diff = diff(r.getRecordEnd(), pStart); PodPart.add(parts, diff); /* create continuous pod * ffmpeg \ * -loop 1 -framerate 24 -t 10 -i image1.jpg \ * -i video.mp4 \ * -loop 1 -framerate 24 -t 10 -i image2.jpg \ * -loop 1 -framerate 24 -t 10 -i image3.jpg \ * -filter_complex "[0][1][2][3]concat=n=4:v=1:a=0" out.mp4 */ List<String> args = new ArrayList<>(); args.add(getPathToFFMPEG()); args.add("-y"); StringBuilder videos = new StringBuilder(); StringBuilder concat = new StringBuilder(); for (int i = 0; i < parts.size(); ++i) { PodPart p = parts.get(i); if (p.getFile() == null) { args.add("-loop"); args.add("1"); args.add("-t"); args.add(formatMillis(p.getDuration())); args.add("-i"); args.add(interviewCam); } else { args.add("-t"); args.add(formatMillis(p.getDuration())); args.add("-i"); args.add(p.getFile()); } videos.append('[').append(i).append(']').append("scale=").append(width).append(':') .append(height).append(",setsar=1:1").append("[v").append(i).append("]; "); concat.append("[v").append(i).append(']'); } args.add("-filter_complex"); args.add(concat.insert(0, videos).append("concat=n=").append(parts.size()).append(":v=1:a=0") .toString()); args.add("-an"); args.add(podX); ProcessResult res = ProcessHelper.executeScript(String.format("Full video pod_%s", N), args.toArray(new String[0]), true); logs.add(res); if (res.isWarn()) { throw new ConversionException("Fail to create pod"); } pods.add(podX); N = pods.size(); } } if (N == 0) { ProcessResult res = new ProcessResult(); res.setProcess("CheckStreamFilesExists"); res.setError("No valid pods found"); res.setExitCode(-1); logs.add(res); return; } double ratio = Math.sqrt(N / Math.sqrt(2)); int w = ratio < 1 ? N : (int) Math.round(ratio); w = Math.max(w, (int) Math.round(1. * N / w)); r.setWidth(w * width); r.setHeight((N / w) * height); String mp4path = convertToMp4(r, getFinalArgs(N, pods, wav, w), logs); finalizeRec(r, mp4path, logs); } catch (Exception err) { log.error("[startConversion]", err); r.setStatus(Recording.Status.ERROR); } finally { if (Recording.Status.CONVERTING == r.getStatus()) { r.setStatus(Recording.Status.ERROR); } postProcess(r, logs); postProcess(waveFiles); recordingDao.update(r); } }