Alfresco Content Services REST API Tutorial | Upload, Download, Metadata & Search with Java

 Alfresco Content Services (ACS) provides powerful REST APIs to manage documents and metadata.

Using these APIs, you can:

  • 📄 Upload documents
  • 📥 Download files
  • 🏷️ Manage metadata
  • 🔍 Perform search

👉 This tutorial shows real Java examples for production use.


🖼️ REST API Architecture (JPG)



🏗️ 1. Alfresco REST API Overview

ACS exposes REST APIs for:

  • Nodes (files/folders)
  • Metadata
  • Search
  • Permissions

👉 Base URL:

http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/

📄 2. Upload Document (Java Example)

API Endpoint:

POST /nodes/{parentId}/children

🧪 Java Code

String url = baseUrl + "/nodes/-root-/children";

HttpPost post = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();

builder.addBinaryBody("filedata", new File("test.pdf"));
builder.addTextBody("name", "test.pdf");

post.setEntity(builder.build());
post.setHeader("Authorization", "Basic ...");

HttpResponse response = client.execute(post);

✅ Best Practices

✔ Validate file size/type
✔ Use proper folder structure
✔ Add metadata during upload


📥 3. Download Document

API Endpoint:

GET /nodes/{nodeId}/content

Java Example

HttpGet get = new HttpGet(baseUrl + "/nodes/" + nodeId + "/content");
get.setHeader("Authorization", "Basic ...");

HttpResponse response = client.execute(get);

🏷️ 4. Manage Metadata

Update Metadata:

PUT /nodes/{nodeId}

Java Example

String json = "{ \"properties\": { \"cm:title\": \"Loan Doc\" } }";

HttpPut put = new HttpPut(baseUrl + "/nodes/" + nodeId);
put.setEntity(new StringEntity(json));
put.setHeader("Content-Type", "application/json");

🔍 5. Search Documents

ACS uses Apache Solr internally.

Search API:

POST /search

Java Example

String query = "{ \"query\": { \"query\": \"name:test.pdf\" } }";

HttpPost post = new HttpPost(baseUrl + "/search");
post.setEntity(new StringEntity(query));
post.setHeader("Content-Type", "application/json");

🖼️ Search Flow Diagram



⚡ 6. Performance Optimization

✔ Use pagination for search
✔ Index metadata properly
✔ Avoid large payloads
✔ Enable caching


📈 7. Security Best Practices

✔ Use OAuth or Basic Auth securely
✔ Enable HTTPS
✔ Restrict API access
✔ Validate inputs


⚠️ 8. Common Mistakes

❌ Not using metadata
❌ Poor folder structure
❌ No pagination
❌ Ignoring security


🏆 9. Enterprise Use Cases

  • Document management systems
  • Loan processing platforms
  • Digital archives
  • Workflow automation

🎯 Final Thoughts

Alfresco REST APIs allow you to:

✔ Build scalable ECM systems
✔ Integrate with microservices
✔ Manage documents efficiently

👉 Essential skill for enterprise Java developers.


🔗 Recommended Articles 


📢 Need help with Java, workflows, or backend systems?

I help teams design scalable, high-performance, production-ready applications and solve critical real-world issues.

Services:

  • Java & Spring Boot development
  • Camunda Training / consulting
  • Alfresco Training / consulting
  • Workflow architecture guidance
  • Workflow implementation (Camunda, Flowable – BPMN, DMN)
  • Backend & API integrations (REST, microservices)
  • Document management & ECM integrations (Alfresco)
  • Performance optimization & production issue resolution

🔗 https://shikhanirankari.blogspot.com/p/professional-services.html

📩 Email: ishikhanirankari@gmail.com info@realtechnologiesindia.com
🌐 https://realtechnologiesindia.com

✔ Available for quick consultations
✔ Response within 24 hours

Comments

Popular posts from this blog

Top 50 Camunda BPM Interview Questions and Answers for Developers (2026 Guide)

OOPs Concepts in Java | English | Object Oriented Programming Explained

Scopes of Signal in jBPM