/*
 * RESTHeart - the data REST API server
 * Copyright (C) SoftInstigate Srl
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.restheart.handlers.files;

import io.undertow.server.HttpServerExchange;
import org.restheart.handlers.PipedHttpHandler;
import org.restheart.handlers.RequestContext;

/**
 *
 * @author Maurizio Turatti <info@maurizioturatti.com>
 */
public class PutFileHandler extends PipedHttpHandler {

    public PutFileHandler() {
        super(null);
    }

    @Override
    public void handleRequest(HttpServerExchange exchange, RequestContext context) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}

@@ -798,583 +798,1979 @@
 ort 
-io.undertow.server.HttpServerExchange;%0Aimport org.restheart.handlers.PipedHttpHandler;%0Aimport org.restheart.handlers.RequestContext;%0A%0A/**%0A *%0A * @author Maurizio Turatti %3Cinfo@maurizioturatti.com%3E%0A */%0Apublic class PutFileHandler extends PipedHttpHandler %7B%0A%0A    public PutFileHandler() %7B%0A        super(null);%0A    %7D%0A%0A    @Override%0A    public void handleRequest(HttpServerExchange exchange, RequestContext context) throws Exception %7B%0A        throw new UnsupportedOperationException(%22Not supported yet.%22); //To change body of generated methods, choose Tools %7C Templates.
+com.mongodb.BasicDBList;%0Aimport com.mongodb.BasicDBObject;%0Aimport com.mongodb.DBObject;%0Aimport io.undertow.server.HttpServerExchange;%0Aimport org.bson.types.ObjectId;%0Aimport org.restheart.db.DocumentDAO;%0Aimport org.restheart.handlers.PipedHttpHandler;%0Aimport org.restheart.handlers.RequestContext;%0Aimport org.restheart.utils.HttpStatus;%0Aimport org.restheart.utils.RequestHelper;%0Aimport org.restheart.utils.ResponseHelper;%0A%0A/**%0A *%0A * @author Maurizio Turatti %3Cinfo@maurizioturatti.com%3E%0A */%0Apublic class PutFileHandler extends PipedHttpHandler %7B%0A%0A    public PutFileHandler() %7B%0A        super(null);%0A    %7D%0A%0A    @Override%0A    public void handleRequest(HttpServerExchange exchange, RequestContext context) throws Exception %7B%0A        DBObject content = context.getContent();%0A%0A        if (content == null) %7B%0A            content = new BasicDBObject();%0A        %7D%0A%0A        // cannot PUT an array%0A        if (content instanceof BasicDBList) %7B%0A            ResponseHelper.endExchangeWithMessage(exchange, HttpStatus.SC_NOT_ACCEPTABLE, %22data cannot be an array%22);%0A            return;%0A        %7D%0A%0A        String id = context.getDocumentId();%0A%0A        if (content.get(%22_id%22) == null) %7B%0A            content.put(%22_id%22, getId(id));%0A        %7D else if (!content.get(%22_id%22).equals(id)) %7B%0A            ResponseHelper.endExchangeWithMessage(exchange, HttpStatus.SC_NOT_ACCEPTABLE, %22_id in content body is different than id in URL%22);%0A            return;%0A        %7D%0A%0A        ObjectId etag = RequestHelper.getWriteEtag(exchange);%0A%0A        // int SC = DocumentDAO.upsertDocument(context.getDBName(), context.getCollectionName(), context.getDocumentId(), content, etag, false);%0A%0A        // send the warnings if any (and in case no_content change the return code to ok%0A        if (context.getWarnings() != null && !context.getWarnings().isEmpty()) %7B%0A            sendWarnings(SC, exchange, context);%0A        %7D else %7B%0A            exchange.setResponseCode(SC);%0A        %7D%0A%0A        exchange.endExchange();
 %0A    %7D%0A
-    
 %0A%7D%0A

Add PutFileHandler's body