Package ef.impl.command.mkfile

Source Code of ef.impl.command.mkfile.MkFileCommand

package ef.impl.command.mkfile;

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

import java.util.Arrays;

/**
* User: sduchenko
* Date: 23.04.13
* Time: 14:53
*/
public class MkFileCommand extends AbstractCommand<MkFileRequest> {

    public MkFileCommand(VolumeManager volumeManager) {
        super(volumeManager);
    }

    @Override
    public MkFileRequest buildRequest(SourceRequestReader requestReader) {
        MkFileRequest request = new MkFileRequest();
        request.target = requestReader.getRequiredString("target");
        request.name = requestReader.getRequiredString("name");
        return request;
    }

    @Override
    public Response execute(MkFileRequest request) {
        Volume volume = volumeManager.getRequiredVolume(request.target);
        FileEntry entry = volume.mkFile(request.target, request.name);
        MapResponse response = new MapResponse();
        response.put("added", Arrays.asList(entry));
        return response;
    }
}
TOP

Related Classes of ef.impl.command.mkfile.MkFileCommand

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.