Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.Connection


            final Object id = SecurityUtils.getSubject().getPrincipal();
            if (id != null) {
                if (id instanceof ObjectId) {
                    return userDAO.get((ObjectId) id);
                } else if (id instanceof String) {  // must be IMG
                    Connection connection = connectionDAO.getByAPIKey((String) id, GatewayProvider.TYPE);
                    return connection.getUser();
                }
            }
        } catch (UnavailableSecurityManagerException e) {
            throw new AuthenticationException(e.getMessage());
        }
View Full Code Here


        account.setId(new ObjectId());

        User user = new User.Builder().username("hey").account(account).build();
        user.setId(new ObjectId());

        Connection connection = new Connection.Builder()
                .provider(ConnectionProvidersForTests.RSS_PROVIDER)
                .url("http://foo.url1.com/rss")
                .credentials(new ConnectionCredentials("ident", "pass"))
                .alias("connection1")
                .user(user)
                .authType(AuthType.NONE)
                .build();
        connection.setId(new ObjectId());

        return connection;

    }
View Full Code Here

        return baseResponseDTO;
    }

    protected InventoryItemResponseDTO toFullDTO(InventoryItem inventoryItem) {
        InventoryItemResponseDTO dto = new InventoryItemResponseDTO();
        Connection connection = inventoryItem.getConnection();
        BasicDBObject payload = applicationManager.getInventoryService().getInventoryItemPayload(inventoryItem);

        super.toBaseDTO(inventoryItem, dto);

        dto.setOwner(inventoryItem.getUser().getId().equals(securityService.getCurrentUser().getId()));

        dto.setConnectionAlias(connection.getAlias());
        dto.setConnectionId(connection.getId());
        dto.setConnectionType(connection.getType());
        dto.setConnectionProviderId(connection.getProviderId());

        dto.setExternalId(inventoryItem.getExternalId());
        dto.setType(inventoryItem.getType());

        // Prune any sensitive information from the payload
View Full Code Here

    public InventoryItem updateInventoryItem(InventoryItem inventoryItem, JSONObject json)
            throws ConnectionNotFoundException, InvalidCredentialsException, IOException {
        Preconditions.checkNotNull(inventoryItem, "inventoryItem cannot be null.");
        Preconditions.checkNotNull(json, "json cannot be null.");

        Connection connection = inventoryItem.getConnection();
        String providerId = connection.getProviderId();

        // No other way...
        if (providerId.equals(ProviderIdConstants.AWS_PROVIDER_ID)) {
            extendAWSInventoryItem(inventoryItem, json);
        } else if (providerId.equals(ProviderIdConstants.GITHUB_PROVIDER_ID)) {
View Full Code Here

     * @throws InvalidCredentialsException if the connection's credentials are invalid
     */
    private void extendAWSInventoryItem(InventoryItem inventoryItem, JSONObject json)
            throws InvalidCredentialsException {
        String externalType = json.getString("type");
        Connection connection = inventoryItem.getConnection();
        String externalId = inventoryItem.getExternalId();
        String name = inventoryItem.getAlias();
        String internalType;

        if (externalId == null) {
View Full Code Here

     *
     * @throws InvalidCredentialsException if the connection's credentials are invalid
     */
    private void extendJiraInventoryItem(InventoryItem inventoryItem, JSONObject json)
            throws InvalidCredentialsException, IOException {
        Connection connection = inventoryItem.getConnection();
        ObjectId connectionId = connection.getId();
        String key = json.getString("key");
        String name = json.getString("name");
        String description = json.getString("description");
        ExternalIntegrationClient rawClient = externalClientCache.getIfPresent(connectionId);
        JiraClient client;
View Full Code Here

            // Get the IMG connection API key
            apiKey = connection.getIdentity();

            // Validate the connection was created
            Connection cConnection = applicationManager.getSecurityService().getByApiKey(apiKey, GatewayProvider.TYPE);

            assertNotNull(cConnection);

            account = cConnection.getAccount();

            // Enable inbound IMG support
            account.setConfigValue(Account.ConfigKey.DISABLE_INBOUND_API, false);
            applicationManager.getUserService().updateAccount(account);
        } catch (Exception e) {
View Full Code Here

    }

    @Test
    public void testSendProcessedMessageAppearsInS3() throws Exception {
        JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
        Connection testIMGConnection = TestUtils.createIMGConnectionWithSpecificOutboundDatatypes(OutboundDataType.PROCESSED);
        testIMGConnection.setAccount(testAccount);
        testIMGConnection.setUser(testUser);
        testIMGConnection = connectionService.createConnection(testIMGConnection);
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.GATEWAY)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String key = "processed/" + sobaMessage.getConnectionId() + "/" + sobaMessage.getId();

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);

        Blob payload = s3TestUtils.getExpectedBlob(expectedBucketName, key);

        //Test that what made it to S3 is the same thing we get when we turn the sobaMessage into a dto
View Full Code Here

    public void testSendProcessedMessageDoesNotAppearInS3() throws Exception {
        //If our connection is not created to have an outbound datatype of PROCESSED, we shouldn't get
        //placed in S3

        JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
        Connection testIMGConnection =
                TestUtils.createIMGConnectionWithSpecificOutboundDatatypes(
                        OutboundDataType.RAW, OutboundDataType.INSIGHT, OutboundDataType.EVENT);
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.GATEWAY)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String prefix = "processed/" + sobaMessage.getConnectionId() + "/";
        List<Blob> payloads = s3TestUtils.getBlobsFromS3(expectedBucketName, prefix);

        Assert.assertEquals(0, payloads.size());
    }
View Full Code Here

    @Test
    public void testSendInsightMessageDoesAppearInS3() throws Exception {
        //Make sure if INSIGHT is an OutboundDataType that we send it to s3 for an SobaMessage with type NODEBELLY

        JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
        Connection testIMGConnection =
                TestUtils.createIMGConnectionWithSpecificOutboundDatatypes(
                        OutboundDataType.INSIGHT);
        testIMGConnection.setUser(testUser);
        testIMGConnection.setAccount(testAccount);
        testIMGConnection.setId(null);
        connectionService.createConnection(testIMGConnection);

        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.NODEBELLY) //This is a fakeout... no Nodebelly/Insight Message looks like this.
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));     //give this some time to go through the queue

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String prefix = "insight/" + sobaMessage.getConnectionId() + "/";
        Blob payload = s3TestUtils.getFirstBlobFromS3ThatMatchesPrefix(expectedBucketName, prefix);

        //Test that what made it to S3 is the same thing we get when we turn the sobaMessage into a dto
        JSONObject actualJSONPayloadFromS3 = JSONObject.fromObject(IOUtils.toString(payload.getPayload().getInput()));
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.Connection

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.