Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.CompositeEntity


    @Test
    public void represent() throws ResourceException, IOException
    {
        final Variant variant = context.mock(Variant.class);

        final CompositeEntity cmpEntity = context.mock(CompositeEntity.class);

        final String overview = "Entity overview";

        final Set<Person> coordinators = new HashSet<Person>();
View Full Code Here


     *             not expected
     */
    @Test
    public void storeRepresentation() throws ResourceException, IOException
    {
        final CompositeEntity cmpEntity = context.mock(CompositeEntity.class);

        final Representation entity = context.mock(Representation.class);

        final String overview = "This is the overview.";

View Full Code Here

    @Test
    public void storeRepresentationWithBadData() throws IOException, ResourceException
    {
        final Representation rep = context.mock(Representation.class);

        final CompositeEntity cmpEntity = context.mock(CompositeEntity.class);

        context.checking(new Expectations()
        {
            {
                oneOf(entityMapper).findByShortName(with(any(String.class)));
View Full Code Here

     *             on error
     */
    @Override
    public Representation represent(final Variant variant) throws ResourceException
    {
        CompositeEntity entity = entityMapper.findByShortName(entityShortName);

        Set<Person> coordinators = entity.getCoordinators();

        JSONObject json = new JSONObject();

        // add the overview
        json.put(OVERVIEW_KEY, entity.getOverview());

        JSONArray jsonCoordinators = new JSONArray();
        for (Person person : coordinators)
        {
            jsonCoordinators.add(person.getOpenSocialId());
View Full Code Here

     *             hopefully not
     */
    @Override
    public void storeRepresentation(final Representation entity) throws ResourceException
    {
        CompositeEntity cmpEntity = entityMapper.findByShortName(entityShortName);

        try
        {
            String text = entity.getText();
            log.debug("PUT entity overview for " + entityShortName + ": " + text);

            JSONObject jsonObject = JSONObject.fromObject(text);
            String overview = jsonObject.getString(OVERVIEW_KEY);
            cmpEntity.setOverview(overview);
            entityMapper.flush();
        }
        catch (IOException e)
        {
            log.error("Unable to read update to overview for " + entityShortName, e);
View Full Code Here

    @Override
    public Representation represent(final Variant variant) throws ResourceException
    {
        verifyEntityShortNameParam();               
                          
        CompositeEntity ent = this.getEntityByShortName(entityShortName);
        Representation rep = new StringRepresentation(convertEntityToJSONObject(ent).toString(),
                MediaType.APPLICATION_JSON);
       
        rep.setExpirationDate(new Date(0L));
       
View Full Code Here

    public void storeRepresentation(final Representation entity) throws ResourceException
    {
        verifyEntityShortNameParam();
       
        //get entity first because if this fails, no reason to do anything else.
        CompositeEntity cmpEnt = (CompositeEntity) this.getEntityByShortName(entityShortName);
       
        try
        {           
            String jsontext = entity.getText();
            JSONObject jsonObject = JSONObject.fromObject(jsontext);
            JSONArray jsonCapabilities = jsonObject.getJSONArray(CAP_ARRAY_KEY);
           
            //create list of capabilities from json.
            List<BackgroundItem> capabilities = new ArrayList<BackgroundItem>(jsonCapabilities.size());
            for (Object capability : jsonCapabilities)
            {
               if (Pattern.matches(REGEXP_PATTERN, (String) capability))
               {
                   capabilities.add(new BackgroundItem((String) capability,
                           BackgroundItemType.CAPABILITY));
               }
               else
               {
                   String msg = "Capability: " + (String) capability + " contains invalid characters.  "
                       + "Valid characters include alphanumeric, space, (!@$%^&*#-.,')";
                   log.error(msg);
                   JSONObject validationErrors = new JSONObject();
                   validationErrors.put(VALIDATION_ERRORS_KEY, msg);
                   getAdaptedResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                   getAdaptedResponse().setEntity(validationErrors.toString(), MediaType.APPLICATION_JSON);
                   return;
               }
            }
                       
            cmpEnt.setCapabilities(capabilities);
            entityMapper.flush();
           
        }
        catch (Exception e)
        {
View Full Code Here

     * @return The entity.
     * @throws ResourceException If entity not found.
     */
    private CompositeEntity getEntityByShortName(final String inEntShortName) throws ResourceException
    {
        CompositeEntity cmpEnt = entityMapper.findByShortName(entityShortName);
        if (cmpEnt == null)
        {
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                    "Unable to find enitity with short name: " + entityShortName + ".")
        }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.CompositeEntity

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.