@SuppressWarnings("unchecked") public HandlerDelegate( final org.eclipse.scout.rt.server.jaxws.provider.annotation.Handler handlerAnnotation) { m_handler = BEANS.get(ClazzUtil.resolve(handlerAnnotation.value(), Handler.class, "@Handler.value")); final RunWithRunContext runHandleWithRunContext = m_handler.getClass().getAnnotation(RunWithRunContext.class); m_handlerRunContextProducer = (runHandleWithRunContext != null ? BEANS.get(runHandleWithRunContext.value()) : null); injectInitParams(m_handler, toInitParamMap(handlerAnnotation.initParams())); }
@Override public void init(FilterConfig filterConfig) throws ServletException { m_trivialAccessController = BEANS .get(TrivialAccessController.class) .init( new TrivialAuthConfig() .withExclusionFilter(filterConfig.getInitParameter("filter-exclude")) .withLoginPageInstalled(true)); m_formBasedAccessController = BEANS .get(FormBasedAccessController.class) .init( new FormBasedAuthConfig() .withCredentialVerifier(BEANS.get(ConfigFileCredentialVerifier.class))); m_developmentAccessController = BEANS.get(DevelopmentAccessController.class).init(); }
/** * Writes a bookmark folder. * * @since 3.8.2 */ private void writeBookmarkFolder(BookmarkFolder folder, String filename, Permission permission) { try { if (ACCESS.check(permission)) { byte[] bytes = SerializationUtility.createObjectSerializer().serialize(folder); // RemoteFile spec = new RemoteFile("bookmarks", filename, 0); spec.readData(new ByteArrayInputStream(bytes)); BEANS.get(IRemoteFileService.class).putRemoteFile(spec); } } catch (IOException e) { throw new ProcessingException("", e); } }
public void autoCreateDatabase() { if (CONFIG.getPropertyValue(ConfigProperties.DatabaseAutoCreateProperty.class)) { try { BEANS .get(SuperUserRunContextProducer.class) .produce() .run( new IRunnable() { @Override public void run() throws Exception { Set<String> tables = getExistingTables(); createOrganizationTable(tables); createPersonTable(tables); } }); } catch (RuntimeException e) { BEANS.get(ExceptionHandler.class).handle(e); } } }
/** * Reads a bookmark folder. * * @since 3.8.2 */ private BookmarkFolder readBookmarkFolder(String filename) { RemoteFile spec = new RemoteFile("bookmarks", filename, 0); RemoteFile f = BEANS.get(IRemoteFileService.class).getRemoteFile(spec); if (f.exists()) { try { byte[] bytes = f.extractData(); return SerializationUtility.createObjectSerializer() .deserialize(bytes, BookmarkFolder.class); } catch (Exception t) { LOG.error("Could not deserialize bookmark folder", t); } } return null; }
@Test public void testSetStartBookmark() throws Exception { Bookmark bookmark = new Bookmark(); bookmark.setText("My Bookmark Text"); Mockito.when(m_mockDesktop.createBookmark()).thenReturn(bookmark); IBookmarkService s = BEANS.get(IBookmarkService.class); Assert.assertNotNull(s); s.setStartBookmark(); // Get the Bookmark Bookmark startBookmark = s.getStartBookmark(); assertEquals("Kind", Bookmark.USER_BOOKMARK, startBookmark.getKind()); assertEquals("Text", "My Bookmark Text", startBookmark.getText()); }
@Test public void testExecValidate() throws Exception { BEANS.get(IExtensionRegistry.class).register(NameFieldExtension.class, NameField.class); MyForm myForm = new MyForm(); myForm.start(); NameField nameField = myForm.getNameField(); nameField.getUIFacade().parseAndSetValueFromUI("hans"); Assert.assertNull(nameField.getErrorStatus()); nameField.getUIFacade().parseAndSetValueFromUI("bernd"); Assert.assertNotNull(nameField.getErrorStatus()); nameField.getUIFacade().parseAndSetValueFromUI("berndExtension"); Assert.assertNotNull(nameField.getErrorStatus()); }
public void dispatchNotifications(List<ClientNotificationMessage> notifications) { IClientSessionRegistry notificationService = BEANS.get(IClientSessionRegistry.class); if (notifications == null) { LOG.error("Notifications null. Please check your configuration"); return; } for (ClientNotificationMessage message : notifications) { ClientNotificationAddress address = message.getAddress(); Serializable notification = message.getNotification(); LOG.debug("Processing client notification {}", notification); if (address.isNotifyAllNodes()) { // notify all nodes LOG.debug("Notify all nodes"); dispatch(notification); } else if (address.isNotifyAllSessions()) { // notify all sessions LOG.debug("Notify all sessions"); for (IClientSession session : notificationService.getAllClientSessions()) { dispatch(session, notification); } } else if (CollectionUtility.hasElements(address.getSessionIds())) { // notify all specified sessions LOG.debug("Notify sessions by session id: {}", address.getSessionIds()); for (String sessionId : address.getSessionIds()) { IClientSession session = notificationService.getClientSession(sessionId); if (session == null) { LOG.warn("received notification for invalid session '{}'.", sessionId); } else { dispatch(session, notification); } } } else if (CollectionUtility.hasElements(address.getUserIds())) { LOG.debug("Notify sessions by user id: {}", address.getUserIds()); for (String userId : address.getUserIds()) { for (IClientSession session : notificationService.getClientSessionsForUser(userId)) { dispatch(session, notification); } } } } }
@Test public void testDeleteBookmark() throws Exception { Bookmark bookmark = new Bookmark(); bookmark.setText("My Bookmark Text"); Mockito.when(m_mockDesktop.createBookmark()).thenReturn(bookmark); IBookmarkService s = BEANS.get(IBookmarkService.class); Assert.assertNotNull(s); s.setStartBookmark(); // Get the Bookmark Bookmark startBookmark = s.getStartBookmark(); assertNotNull(startBookmark); // Delete the bookmark s.deleteStartBookmark(); startBookmark = s.getStartBookmark(); assertNull(startBookmark); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse resp = (HttpServletResponse) response; if (m_trivialAccessController.handle(req, resp, chain)) { return; } if (m_formBasedAccessController.handle(req, resp, chain)) { return; } if (m_developmentAccessController.handle(req, resp, chain)) { return; } BEANS.get(ServletFilterHelper.class).forwardToLoginForm(req, resp); }
@SuppressWarnings("unchecked") @Override protected void initConfig() { super.initConfig(); m_innerFormPropertyListener = new P_InnerFormPropertyChangeListener(); m_innerFormSubtreePropertyListener = new P_InnerFormSubtreePropertyChangeListener(); m_innerFormListener = new P_InnerFormListener(); if (getConfiguredInnerForm() != null) { try { setInnerForm((FORM) getConfiguredInnerForm().newInstance(), true); } catch (Exception e) { BEANS .get(ExceptionHandler.class) .handle( new ProcessingException( "error creating instance of class '" + getConfiguredInnerForm().getName() + "'.", e)); } } }
protected void dispatchSync(Serializable notification) { NotificationHandlerRegistry reg = BEANS.get(NotificationHandlerRegistry.class); reg.notifyHandlers(notification); }