Package maqetta.core.server.command

Source Code of maqetta.core.server.command.SetPreferences

package maqetta.core.server.command;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.davinci.server.user.IUser;
import org.maqetta.server.Command;
import org.maqetta.server.IDavinciServerConstants;
import org.maqetta.server.IStorage;

public class SetPreferences extends Command {


    public void handleCommand(HttpServletRequest req, HttpServletResponse resp, IUser user) throws IOException {
        String id = req.getParameter("id");
        String base = req.getParameter("base");
       
        IStorage settingsDir = user.getWorkbenchSettings(base);
        IStorage settingsFile = settingsDir.newInstance(settingsDir, id + IDavinciServerConstants.SETTINGS_EXTENSION);
       
        if(! user.isValid(settingsFile.getAbsolutePath()) ) return;
       
        if (!settingsFile.exists()) {
            settingsFile.createNewFile();
        }
        OutputStream os = new BufferedOutputStream(settingsFile.getOutputStream());
        Command.transferStreams(req.getInputStream(), os, false);
    }

}
TOP

Related Classes of maqetta.core.server.command.SetPreferences

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.