/*
 * Copyright 2016 Yi-Kun Yang.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.allnix.restjson.web;

import org.allnix.core.JsonDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author Yi-Kun Yang &gt;ykyang@gmail.com&lt;
 */
@RestController
@RequestMapping(value="/json")
public class JsonController {
  static private Logger logger = LoggerFactory.getLogger(JsonController.class);
  
  private JsonDao dao;

  public JsonController() {
    
  }
  
  @Autowired
  public void setJsonDao(JsonDao dao) {
    logger.info("Set JsonDao");
    this.dao = dao;
  }

  @PostMapping(value="/{table}/{id}")
  public boolean create(@PathVariable("table") String tableName, @PathVariable String id,
    @RequestBody String json) {
    return dao.create(tableName, id, json);
  }

  
  @GetMapping(value="/{table}/{id}")
  public String read(@PathVariable("table") String tableName, @PathVariable String id) {
//    return table + ": " + id;
     String value = dao.read(tableName, id);
     if ( value == null ) {
       throw new JsonNotFoundException(tableName, id);
     } else {
       return value;
     }
  }
  

//  public boolean update(String tableName, String id, String json);
}

@@ -948,32 +948,91 @@
 on.PostMapping;%0A
+import org.springframework.web.bind.annotation.PutMapping;%0A
 import org.sprin
@@ -2143,79 +2143,349 @@
   %7D%0A
+%0A
   
-%0A%0A//  public boolean update(String tableName, String id, String json);
+@PutMapping(value=%22/%7Btable%7D/%7Bid%7D%22)  %0A  public boolean update(@PathVariable(%22table%22) String tableName, %0A    @PathVariable String id, @RequestBody String json) %7B%0A    %0A    boolean value = dao.update(tableName, id, json);%0A    %0A    if ( !value ) %7B%0A      throw new JsonNotFoundException(tableName, id); %0A    %7D else %7B%0A      return true;%0A    %7D%0A  %7D
 %0A%7D%0A

Add "update" to Json Rest