Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.Account$Builder


    private String twitterOAuthSecret = twitterProperties.getString("nodeable.integrations.twitter.oauth_secret");
    private Connection connection;

    @Before
    public void setUp() throws Exception {
        Account testAccount = new Account.Builder()
                .url("http://nodeable.com")
                .description("Nodeable Test Account")
                .name("Nodeable Testing")
                .build();
View Full Code Here


            // if this is the sender, should we override the ownerId? how?
            User nodebelly = userService.getSuperUser();

            // if this is null, it's a global metric so only persist the message to the Nodeable account
            if (event.getAccountId() != null) {
                Account account = userService.getAccount(event.getAccountId());

                // send an email if these are your first insights
                // SOBA-1600
                if (!account.getConfigValue(Account.ConfigKey.RECIEVED_INSIGHTS)) {
                    userService.handleInitialInsightForAccount(account);
                }

                // trickery to send from Nodebelly to a certain account
                // DO NOT PERSIST THIS!!!!!
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public <T extends ObjectWithId> Event createEvent(EventId eventId, T target, Map<String, Object> extraMetadata) {
        Account account = null;
        User user = null;

        try {
            user = securityService.getCurrentUser();
            account = user.getAccount();
        } catch (AuthenticationException ae) {
            // We will not persist any READ_* events when a user is not logged in
            if (eventId == EventId.READ) {
                logger.debug("Anonymous read events are not persisted (" + target + "): " + eventId);
                return null;
            }
        } catch (UnavailableSecurityManagerException e) {
            logger.warn("Unable to derive user from SecurityService.  A User will be derived from the target (" +
                              target + ") if possible.  If not, no event will be persisted", e);
        } catch (Exception nfi) {
            logger.warn("Unknown exception type in EventService", nfi);
        }

        if (extraMetadata == null) {
            extraMetadata = new HashMap<>();
        }

        // TODO: Figure out a way to make these automatically-generated metadata keys constants somewhere

        // Extend the context with T information
        if (target != null) {
            // Fill out ObjectWithId information
            extraMetadata.put("targetId", target.getId());
            extraMetadata.put("targetVersion", target.getVersion());
            // Fill out type (camel casing of the object type)
            extraMetadata.put("targetType", target.getClass().getSimpleName());

            // Fill out the SobaObject information
            if (target instanceof SobaObject) {
                SobaObject tSobaObject = (SobaObject) target;

                // Attempt to gather the user/account from the target of the event when there is no user logged in.
                // We can only do this for subclasses of SobaObject because the other two objects that create events
                // (Account/User) can only provide one piece of the puzzle.
                if (user == null) {
                    user = tSobaObject.getUser();
                    account = tSobaObject.getAccount();
                }

                extraMetadata.put("targetVisibility", tSobaObject.getVisibility());
                extraMetadata.put("targetAlias", tSobaObject.getAlias());
                extraMetadata.put("targetHashtags", tSobaObject.getHashtags());
            }

            // Fill in specific object information
            if (target instanceof Account) {
                Account tAccount = (Account) target;
                extraMetadata.put("targetFuid", tAccount.getFuid());
                extraMetadata.put("targetName", tAccount.getName());

            } else if (target instanceof InventoryItem) {
                InventoryItem inventoryItem = (InventoryItem)target;
                Connection connection = inventoryItem.getConnection();
                ConnectionProvider tConnectionProvider = connectionProviderFactory.connectionProviderFromId(
View Full Code Here

        String username = getJSON(json, "username");
        if (isEmpty(username)) {
            return error("Username cannot be empty.", Response.status(Response.Status.BAD_REQUEST));
        }

        Account account = null;
        try {
            account = userService.getAccount(new ObjectId(accountId));
        }
        catch (AccountNotFoundException anfe) {
            return error("No account found with specified ID.", Response.status(Response.Status.BAD_REQUEST));
View Full Code Here

    }

    @Test
    @Ignore("Ignored until embedded ElasticSearch is setup")
    public void createRiverForAccount() throws Exception{
        Account account = new Account.Builder()
                .name("foo")
                .build();
        accountDAO.save(account);

        URL accountTypeUrl = searchService.createRiverForAccount(account);
View Full Code Here

            user.setUserLocked(false);

            // we want to make this a one time thing, blow away the secret key
            user.setSecretKey(null);

            Account account = new Account.Builder()
                    .name(accountName)
                    .build();

            // create the account and fire events
            userService.createAccount(account);
View Full Code Here

     */
    @GET
    public Response getAccount() {
        User currentUser = applicationManager.getSecurityService().getCurrentUser();

        Account account;
        try {
            account = applicationManager.getUserService().getAccount(currentUser.getAccount().getId());
        } catch (AccountNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }
View Full Code Here

    public Response getAccountUsers() {

        User currentUser = applicationManager.getSecurityService().getCurrentUser();
        List<User> users;
        try {
            Account account = applicationManager.getUserService().getAccount(currentUser.getAccount().getId());
            users = applicationManager.getUserService().allEnabledUsersForAccount(account);
        } catch (AccountNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }
View Full Code Here

    @Path("users/active")
    public Response getActiveLoggedInUsers() {
        User currentUser = applicationManager.getSecurityService().getCurrentUser();
        Set<User> theUsers;
        try {
            Account account = applicationManager.getUserService().getAccount(currentUser.getAccount().getId());
            theUsers = applicationManager.getSecurityService().getActiveUsers(account, (Constants.PERIOD_MINUTE * 3));
        } catch (AccountNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }
        List<User> users = new ArrayList<>(theUsers);
View Full Code Here

    }

    @Test
    public void testSendRawMessage_noOutbound() throws Exception {
        Connection connection = Mockito.mock(Connection.class);
        Account account = Mockito.mock(Account.class);
        Mockito.when(connection.getAccount()).thenReturn(account);
        HashSet<OutboundConfiguration> outboundConfigurations = Sets.newHashSet(Mockito.mock(OutboundConfiguration.class));
        Mockito.when(connection.getOutboundConfigurations()).thenReturn(outboundConfigurations);

        OutboundStorageServiceImpl outboundStorageService = new OutboundStorageServiceImpl();
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.Account$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.