As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
main(); function main() { if (url.templateArgs.store_type === null) { status.setCode(status.STATUS_BAD_REQUEST, "NodeRef missing"); return; } // nodeRef input var storeType = url.templateArgs.store_type; var storeId = url.templateArgs.store_id; var id = url.templateArgs.id; var nodeRef = storeType + "://" + storeId + "/" + id; var node = search.findNode(nodeRef); if (node === null) { status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); return null; } // Set passed-in properties if (json.has("properties")) { var properties = jsonToObject("properties"); for (property in properties) { node.properties[property] = properties[property]; } } // Set passed-in mimetype if (json.has("mimetype")) { node.mimetype = json.get("mimetype"); } // Set passed-in tags if (json.has("tags")) { // Get the tags JSONArray and copy it to a native JavaScript array var jsonTags = json.get("tags"), tags = []; for (var t = 0; t < jsonTags.length(); t++) { tags.push(jsonTags.get(t)); } if (tags.length > 0) { node.tags = tags; } else { node.clearTags(); } } node.save(); } function jsonToObject(p_name) { var object = {}; var jsonObj = json.get(p_name); var names = jsonObj.names(); var name; for (var i = 0, j = names.length(); i < j; i++) { name = names.get(i); object[name] = jsonObj.get(name); } return object; } function jsonToArray(p_name) { var array = []; var jsonArray = json.get(p_name); for (var i = 0, j = jsonArray.length(); i < j; i++) { array.push(jsonArray.get(i)); } return array; }
Abdera abdera = new Abdera(); AbderaClient client = new AbderaClient(abdera); String uri = "http://localhost:8080/alfresco/service/api/metadata/node/workspace/SpaceStore/{id}?alf_ticket=ticket"; String jsonMessage ="{\"properties\":{\"cm:title\":\"Texas\",\"cm:description\":\"Descripción de Texas\"}}"; InputStream is = Utilidades.stringToInputStream(jsonMessage); RequestOptions options = new RequestOptions(); options.setHeader("Content-Type", "application/json"); ClientResponse resp = client.post(uri, is, options);
HTTP/1.1 404 Not Found body { "status" : { "code" : 404, "name" : "Not Found", "description" : "Requested resource is not available." }, "message" : "Not a valid nodeRef: 'workspace:\/\/SpaceStore\/de17d530-1f13-4eb1-91b5-7049892a5055\/'", "exception" : "", "callstack" : [ ], "server" : "Community v5.0.0 (c r91299-b145) schema 8,009", "time" : "Apr 24, 2015 4:21:29 AM" }
urlString = "http://'+ipaddress+':8080/alfresco/service/api/metadata/node/workspace/SpaceStore/'+nodeId+'/?alf_ticket=" + authTicket; System.out.println("The upload url:::" + urlString); client = new HttpClient(); mPost = new PostMethod(urlString); itemNameValue=new ArrayList(); itemNameValue.addAll(Arrays.asList(new String[] { "Item1","Item2"})); String jsonMessage ="{\"properties\":{\"rs:vendor\":\"Texas\",\"rs:itemName\":\"Descripción de Texas\"}}"; InputStream stream = new ByteArrayInputStream(jsonMessage.getBytes(StandardCharsets.UTF_8)); mPost.addRequestHeader("Content-Type", "application/json"); mPost.setRequestBody(stream); statusCode1 = client.executeMethod(mPost); System.out.println("statusLine>>>" + statusCode1 + "……" + "\n status line \n" + mPost.getStatusLine() + "\nbody \n" + mPost.getResponseBodyAsString()); mPost.releaseConnection();