Package org.eurekastreams.server.action.request.profile

Examples of org.eurekastreams.server.action.request.profile.ResizeAvatarRequest


     *             not expected
     */
    @Test
    public void performActionWithRefresh() throws Exception
    {
        final ResizeAvatarRequest request = new ResizeAvatarRequest(1, 2, 3, Boolean.TRUE, 1L);

        context.checking(new Expectations()
        {
            {
                ignoring(user);
View Full Code Here


     *             not expected
     */
    @Test
    public void performActionWithOutRefresh() throws Exception
    {
        final ResizeAvatarRequest request = new ResizeAvatarRequest(1, 2, 3, Boolean.FALSE, 1L);

        context.checking(new Expectations()
        {
            {
                ignoring(user);
View Full Code Here

        {
            public void onClick(final ClickEvent inArg0)
            {
                List<Integer> coords = getCoords();

                ResizeAvatarRequest request = new ResizeAvatarRequest(coords.get(0), coords.get(1), coords.get(2),
                        Boolean.TRUE, strategy.getId());

                // TODO: refactor to new simplified model design (and thus eliminiate use of the action processor here)
                processor.makeRequest(strategy.getResizeAction(), request, new AsyncCallback<AvatarEntity>()
                {
View Full Code Here

    }

    @Override
    public T execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext)
    {
        ResizeAvatarRequest request = (ResizeAvatarRequest) inActionContext.getActionContext().getParams();
        Integer x = request.getX();
        Integer y = request.getY();
        Integer size = request.getSize();
        Boolean refreshFiles = request.getRefreshFiles();
        T avatarEntity;
        try
        {
            avatarEntity = finder.findEntity(inActionContext.getActionContext().getPrincipal(), request.getEntityId());
        }
        catch (Exception e1)
        {
            throw new ExecutionException(e1);
        }

        String avatarId = avatarEntity.getAvatarId();

        if (refreshFiles)
        {
            // Delete the three files there now.
            imageWriter.delete("n" + avatarId);
            imageWriter.delete("s" + avatarId);

            String originalPath = "o" + avatarId;

            avatarId = hasher.hash(((Long) avatarEntity.getId()).toString());
            avatarEntity.setAvatarId(avatarId);

            imageWriter.rename(originalPath, "o" + avatarId);
        }

        avatarEntity.setAvatarCropX(x);
        avatarEntity.setAvatarCropY(y);
        avatarEntity.setAvatarCropSize(size);
        mapper.flush();

        try
        {
            BufferedImage bufferedImage = (BufferedImage) imageWriter.read("o" + avatarId);

            imageWriter.write(createResizedCopy(bufferedImage, x, y, NORMAL_AVATAR_SIZE, size), "n" + avatarId);
            imageWriter.write(createResizedCopy(bufferedImage, x, y, SMALL_AVATAR_SIZE, size), "s" + avatarId);

        }
        catch (Exception e)
        {
            log.error("Error resizing avatar", e);
            return null;
        }

        // if we have a cache updating strategy, call it.
        if (cacheUpdaterStategy != null)
        {
            inActionContext.getUserActionRequests().addAll(
                    cacheUpdaterStategy.getUpdateCacheRequests(inActionContext.getActionContext().getPrincipal(),
                            request.getEntityId()));
        }

        return avatarEntity;
    }
View Full Code Here

            {
                cropSize = scaledImage.getWidth(null);
                y = (scaledImage.getHeight(null) - scaledImage.getWidth(null)) / 2;
            }

            ResizeAvatarRequest resizeRequest = new ResizeAvatarRequest(x, y, cropSize, Boolean.FALSE, entityId);

            T newEntity = (T) new InlineExecutionStrategyExecutor().execute(avatarResizer, resizeRequest,
                    inActionContext);

            // If all is well, delete the old avatar:
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Serializable transform(final ActionContext inActionContext)
    {
        ResizeAvatarRequest request = (ResizeAvatarRequest) inActionContext.getParams();
        return returnValueAsString ? request.getEntityId().toString() : request.getEntityId();

    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.action.request.profile.ResizeAvatarRequest

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.