GeoStoreClient { public void updateResource(Long id, RESTResource resource) { getBaseWebResource("resources", "resource", id) .header("Content-Type", MediaType.TEXT_XML) .put(resource); } GeoStoreClient(); @Deprecated ShortResourceList searchResources(SearchFilter searchFilter); ResourceList searchResources(SearchFilter searchFilter,
            Integer page, Integer entries,
            Boolean includeAttributes, Boolean includeData); Long insert(RESTResource resource); Resource getResource(Long id, boolean full); Resource getResource(Long id); void deleteResource(Long id); void updateResource(Long id, RESTResource resource); ShortResourceList getAllShortResource(Integer page, Integer entries); SecurityRuleList getSecurityRules(Long resourceId); void updateSecurityRules(Long resourceId, SecurityRuleList rules); String getData(Long id); String getData(Long id, MediaType acceptMediaType); byte[] getRawData(Long id, RawFormat decodeFrom); T getRawData(Class<T> clazz, Long id, RawFormat decodeFrom); void setData(Long id, String data); void updateData(Long id, String data); Long insert(RESTCategory category); Category getCategory(Long id); Long getCategoryCount(String nameLike); CategoryList getCategories(Integer page, Integer entries); CategoryList getCategories(); void deleteCategory(Long id); ExtGroupList searchUserGroup(Integer start,Integer limit, String nameLike, boolean all); ExtGroupList searchUserGroup(Integer start,Integer limit, String nameLike); ShortResource getShortResource(long id); String getPassword(); void setPassword(String password); String getUsername(); void setUsername(String username); String getGeostoreRestUrl(); void setGeostoreRestUrl(String geostoreRestUrl);  }
@Test public void testUpdateResource() { final String KEY_STRING = "stringAtt"; final String KEY_DATE = "dateAtt"; final Date origDate = new Date(); final String origString = "OrigStringValue"; Long rid; createDefaultCategory(); { RESTStoredData storedData = new RESTStoredData(); storedData.setData("we wish you a merry xmas and a happy new year"); List<ShortAttribute> attrList = new ArrayList<ShortAttribute>(); attrList.add(new ShortAttribute("string1", "value1", DataType.STRING)); attrList.add(new ShortAttribute("string2", "value2", DataType.STRING)); attrList.add(new ShortAttribute("string3", "value3", DataType.STRING)); String timeid = Long.toString(System.currentTimeMillis()); RESTResource origResource = new RESTResource(); origResource.setCategory(new RESTCategory(DEFAULTCATEGORYNAME)); origResource.setName("rest_test_resource_" + timeid); origResource.setStore(storedData); origResource.setAttribute(attrList); rid = client.insert(origResource); } System.out.println("RESOURCE has ID " + rid); String name1 = "rest_test_resource_" + Long.toString(System.currentTimeMillis()); { RESTResource updResource = new RESTResource(); updResource.setName(name1); List<ShortAttribute> attrList = new ArrayList<ShortAttribute>(); attrList.add(new ShortAttribute("string1", "value1", DataType.STRING)); attrList.add(new ShortAttribute("string2", "value2.2", DataType.STRING)); attrList.add(new ShortAttribute("string4", "value4", DataType.STRING)); updResource.setAttribute(attrList); client.updateResource(rid, updResource); } { Resource loaded = client.getResource(rid); System.out.println("RESOURCE: " + loaded); List<Attribute> loadedAttrs = loaded.getAttribute(); assertEquals(3, loadedAttrs.size()); Map<String, String> attMap = new HashMap<String, String>(); for (Attribute attribute : loadedAttrs) { attMap.put(attribute.getName(), attribute.getTextValue()); } assertEquals("value1", attMap.get("string1")); assertEquals("value2.2", attMap.get("string2")); assertEquals("value4", attMap.get("string4")); } { RESTResource res = new RESTResource(); res.setCategory(new RESTCategory("TestCategory2")); try { client.updateResource(rid, res); fail("Undetected error"); } catch (UniformInterfaceException e) { String response = "COULD NOT READ RESPONSE"; try { response = IOUtils.toString(e.getResponse().getEntityInputStream()); } catch (Exception e2) { LOGGER.warn("Error reading response: " + e2.getMessage()); } LOGGER.info("Error condition successfully detected: " + response); } catch (Exception e) { LOGGER.info("Error condition successfully detected:" + e.getMessage(), e); } } client.deleteResource(rid); }