Package com.datasift.client.managedsource

Examples of com.datasift.client.managedsource.ManagedSource$ResourceParams


        m.setMessage(message);
    }

    @Test
    public void testIfUserCanCreateManagedSource() {
        ManagedSource create = datasift.managedSource().create(name, source).sync();
        assertTrue(create.isSuccessful());

        assertEquals(create.getName(), name);
        assertEquals(create.getSourceType(), source_type);
        assertEquals(create.getParameters(), parameters);

        Set<ManagedSource.AuthParams> auth_array = create.getAuth();
        for (ManagedSource.AuthParams p : auth_array) {
            assertEquals(p.identityId(), identityId);
            assertEquals(p.status(), status);
            assertEquals(p.sourceId(), sourceId);
        }
        Set<ManagedSource.ResourceParams> res_set = create.getResources();
        for (ManagedSource.ResourceParams r : res_set) {
            assertEquals(r.identityId(), identityId);
            assertEquals(r.sourceId(), sourceId);
            assertEquals(r.status(), status);
        }
        assertEquals(create.getCreatedAt(), created_at);
        assertEquals(create.getId(), id);
    }
View Full Code Here


        assertEquals(create.getId(), id);
    }

    @Test
    public void testIfUserCanUpdateManagedSource() {
        ManagedSource update = datasift.managedSource().update(name, source, m_id).sync();
        assertTrue(update.isSuccessful());

        assertEquals(update.getName(), name);
        assertEquals(update.getSourceType(), source_type);
        assertEquals(update.getParameters(), parameters);
        Set<ManagedSource.AuthParams> auth_array = update.getAuth();
        for (ManagedSource.AuthParams p : auth_array) {
            assertEquals(p.identityId(), identityId);
            assertEquals(p.status(), status);
            assertEquals(p.sourceId(), sourceId);
        }
        Set<ManagedSource.ResourceParams> res_set = update.getResources();
        for (ManagedSource.ResourceParams r : res_set) {
            assertEquals(r.identityId(), identityId);
            assertEquals(r.sourceId(), sourceId);
            assertEquals(r.status(), status);
        }
        assertEquals(update.getCreatedAt(), created_at);
        assertEquals(update.getId(), id);
    }
View Full Code Here

        assertEquals(update.getId(), id);
    }

    @Test
    public void testIfUserCanDeleteManagedSource() {
        ManagedSource delete = datasift.managedSource().update(name, source, m_id).sync();
        assertEquals(delete.getName(), name);
        assertEquals(delete.getSourceType(), source_type);
        assertEquals(delete.getParameters(), parameters);
        Set<ManagedSource.AuthParams> auth_array = delete.getAuth();
        for (ManagedSource.AuthParams p : auth_array) {
            assertEquals(p.identityId(), identityId);
            assertEquals(p.status(), status);
            assertEquals(p.sourceId(), sourceId);
        }
        Set<ManagedSource.ResourceParams> res_set = delete.getResources();
        for (ManagedSource.ResourceParams r : res_set) {
            assertEquals(r.identityId(), identityId);
            assertEquals(r.sourceId(), sourceId);
            assertEquals(r.status(), status);
        }
        assertEquals(delete.getCreatedAt(), created_at);
        assertEquals(delete.getId(), id);

        assertTrue(delete.isSuccessful());
    }
View Full Code Here

        }
    }

    @Test
    public void testIfUserCanGetManagedSource() {
        ManagedSource get = datasift.managedSource().get(id).sync();
        assertTrue(get.isSuccessful());

        assertEquals(get.getName(), name);
        assertEquals(get.getSourceType(), source_type);
        assertEquals(get.getParameters(), parameters);
        Set<ManagedSource.AuthParams> auth_array = get.getAuth();
        for (ManagedSource.AuthParams p : auth_array) {
            assertEquals(p.identityId(), identityId);
            assertEquals(p.status(), status);
            assertEquals(p.sourceId(), sourceId);
        }
        Set<ManagedSource.ResourceParams> res_set = get.getResources();
        for (ManagedSource.ResourceParams r : res_set) {
            assertEquals(r.identityId(), identityId);
            assertEquals(r.sourceId(), sourceId);
            assertEquals(r.status(), status);
        }
        assertEquals(get.getCreatedAt(), created_at);
        assertEquals(get.getId(), id);
    }
View Full Code Here

        assertEquals(get.getId(), id);
    }

    @Test
    public void testIfUserCanStopDataDelivery() {
        ManagedSource stop = datasift.managedSource().stop(id).sync();
        assertTrue(stop.isSuccessful());

        assertEquals(stop.getName(), name);
        assertEquals(stop.getSourceType(), source_type);
        assertEquals(stop.getParameters(), parameters);
        Set<ManagedSource.AuthParams> auth_array = stop.getAuth();
        for (ManagedSource.AuthParams p : auth_array) {
            assertEquals(p.identityId(), identityId);
            assertEquals(p.status(), status);
            assertEquals(p.sourceId(), sourceId);
        }
        Set<ManagedSource.ResourceParams> res_set = stop.getResources();
        for (ManagedSource.ResourceParams r : res_set) {
            assertEquals(r.identityId(), identityId);
            assertEquals(r.sourceId(), sourceId);
            assertEquals(r.status(), status);
        }
        assertEquals(stop.getId(), id);
    }
View Full Code Here

        source.enableComments(true)
                .enableLikes(true)
                .enablePostsByOthers(true);
        //or all at once
        source.setParams(true, true, true);
        ManagedSource managedSource = datasift.managedSource().create("My managed source", source).sync();
        if (managedSource.isSuccessful()) {
            //and now we can do filtering on this page e.g.
            Stream stream = datasift
                    .compile(String.format("interaction.content contains \"news\" AND source.id == \"%s\"",
                            managedSource.getId())).sync();

            System.out.println(managedSource);
        }
    }
View Full Code Here

   protected PortletInvocation internalInitInvocation(WSRPPortletInvocationContext context)
   {
      ResourceInvocation resourceInvocation = new ResourceInvocation(context);

      ResourceParams resourceParams = this.request.getResourceParams();

      // only set the resource id if it's different from the place holder we use if the portlet doesn't set one
      String id = this.request.getResourceParams().getResourceID();
      if (!WSRPResourceURL.DEFAULT_RESOURCE_ID.equals(id))
      {
         resourceInvocation.setResourceId(id);
      }

      WSRPRequestContext requestContext = WSRPRequestContext.createRequestContext(markupRequest, resourceParams);
      resourceInvocation.setRequestContext(requestContext);
      resourceInvocation.setForm(requestContext.getForm());

      //TODO: property set validation token for caching (ie ETAG)
      String validationToken = null;
      resourceInvocation.setValidationToken(validationToken);

      resourceInvocation.setResourceState(createNavigationalState(resourceParams.getResourceState()));

      String resourceCacheability = resourceParams.getResourceCacheability();
      if (resourceCacheability != null)
      {
         CacheLevel cacheLevel = WSRPUtils.getCacheLevelFromResourceCacheability(resourceParams.getResourceCacheability());
         resourceInvocation.setCacheLevel(cacheLevel);
      }
      else
      {
         // according to JSR 286, cache level must default to ResourceURL.PAGE
View Full Code Here

      {
         throw new IllegalArgumentException("GetResource needs a valid resource id.");
      }

      // Create ResourceParams
      ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(params.isSecureClientCommunication(),
         params.getLocales(), params.getMimeTypes(), params.getMode(), params.getWindowState(), resourceId,
         WSRPUtils.getStateChangeFromAccessMode(accessMode));

      resourceParams.setNavigationalContext(params.getNavigationalContext());
      resourceParams.setClientData(params.getClientData());
      resourceParams.setResourceCacheability(WSRPUtils.getResourceCacheabilityFromCacheLevel(invocation.getCacheLevel()));

      for (Map.Entry<String, String[]> entry : invocation.getForm().entrySet())
      {
         String name = entry.getKey();
         for (String value : entry.getValue())
         {
            resourceParams.getFormParameters().add(WSRPTypeFactory.createNamedString(name, value));
         }
      }

      StateString resourceState = invocation.getResourceState();
      if (resourceState != null)
      {
         String state = resourceState.getStringValue();
         if (!StateString.JBPNS_PREFIX.equals(state))  // fix-me: see JBPORTAL-900
         {
            resourceParams.setResourceState(state);
         }
      }

      return WSRPTypeFactory.createGetResource(requestPrecursor.getRegistrationContext(), portletContext,
         requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), resourceParams);
View Full Code Here

      {
         throw new IllegalArgumentException("GetResource needs a valid resource id.");
      }

      // Create ResourceParams
      ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(params.isSecureClientCommunication(),
         params.getLocales(), params.getMimeTypes(), params.getMode(), params.getWindowState(), resourceId,
         WSRPUtils.getStateChangeFromAccessMode(accessMode));

      resourceParams.setNavigationalContext(params.getNavigationalContext());
      resourceParams.setClientData(params.getClientData());
      resourceParams.setResourceCacheability(WSRPUtils.getResourceCacheabilityFromCacheLevel(invocation.getCacheLevel()));
      resourceParams.getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(ResourceParams.class));

      for (Map.Entry<String, String[]> entry : invocation.getForm().entrySet())
      {
         String name = entry.getKey();
         for (String value : entry.getValue())
         {
            resourceParams.getFormParameters().add(WSRPTypeFactory.createNamedString(name, value));
         }
      }

      StateString resourceState = invocation.getResourceState();
      if (resourceState != null)
      {
         String state = resourceState.getStringValue();
         if (!StateString.JBPNS_PREFIX.equals(state))  // fix-me: see JBPORTAL-900
         {
            resourceParams.setResourceState(state);
         }
      }
     
      MultiPartResult multiPartResult = MultiPartUtil.getMultiPartContent(invocation.getRequestContext());
      if (multiPartResult != null)
      {
         resourceParams.getFormParameters().addAll(multiPartResult.getFormParameters());
         resourceParams.getUploadContexts().addAll(multiPartResult.getUploadContexts());
      }

      return WSRPTypeFactory.createGetResource(requestPrecursor.getRegistrationContext(), portletContext,
         requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), resourceParams);
   }
View Full Code Here

         WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE, resourceID, StateChange.READ_ONLY);
   }

   public static ResourceParams createResourceParams(boolean secureClientCommunication, List<String> locales, List<String> mimeTypes, String mode, String windowState, String resourceID, StateChange stateChange, Map<String, String[]> parameters)
   {
      ResourceParams resourceParams = createResourceParams(secureClientCommunication, locales, mimeTypes, mode, windowState, resourceID, stateChange);
      List<NamedString> formParameters = new ArrayList<NamedString>(parameters.size());
      for (String key : parameters.keySet())
      {
         NamedString namedString = new NamedString();
         namedString.setName(key);
         namedString.setValue(parameters.get(key)[0]);
         resourceParams.getFormParameters().add(namedString);
      }
      return resourceParams;
   }
View Full Code Here

TOP

Related Classes of com.datasift.client.managedsource.ManagedSource$ResourceParams

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.