Package ef.impl.command.duplicate

Source Code of ef.impl.command.duplicate.DuplicateCommand

package ef.impl.command.duplicate;

import ef.api.*;
import ef.impl.command.AbstractCommand;
import ef.impl.response.MapResponse;

import java.util.ArrayList;
import java.util.List;

/**
* User: sduchenko
* Date: 23.04.13
* Time: 16:20
*/
public class DuplicateCommand extends AbstractCommand<DuplicateRequest> {
    public DuplicateCommand(VolumeManager volumeManager) {
        super(volumeManager);
    }

    @Override
    public DuplicateRequest buildRequest(SourceRequestReader requestReader) {
        DuplicateRequest request = new DuplicateRequest();
        request.targets = requestReader.getRequiredStringArray("targets[]");
        return request;
    }

    @Override
    public Response execute(DuplicateRequest request) {
        Volume volume = volumeManager.getRequiredVolume(request.targets[0]);
        List<FileEntry> added = new ArrayList<FileEntry>();

        for(String target: request.targets){
            added.add(volume.duplicate(target));
        }

        MapResponse response = new MapResponse();
        response.put("added", added);
        return response;
    }
}
TOP

Related Classes of ef.impl.command.duplicate.DuplicateCommand

TOP
Copyright © 2018 www.massapi.com. 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.