/** * Computes the name of the resource to be created by a POST operation. Returns an empty string if * the name was not specified. */ private String computeName(HttpServletRequest request, JSONObject requestObject) { // get the slug first String name = request.getHeader(ProtocolConstants.HEADER_SLUG); // If the requestObject has a name then it must be used due to UTF-8 issues with names Bug // 376671 if (requestObject.has("Name")) { try { name = requestObject.getString("Name"); } catch (JSONException e) { } } // next comes the source location for a copy/move if (name == null || name.length() == 0) { String location = requestObject.optString(ProtocolConstants.KEY_LOCATION); int lastSlash = location.lastIndexOf('/'); if (lastSlash >= 0) name = location.substring(lastSlash + 1); } // finally use the name attribute from the request body if (name == null || name.length() == 0) name = requestObject.optString(ProtocolConstants.KEY_NAME); return name; }