Creating new document adapter nuxeo
A Nuxeo document adapter!
A document adapter in Nuxeo is a plugin that allows you to integrate a specific document format or protocol with the Nuxeo Platform. Here's a step-by-step guide to creating a new document adapter:
Prerequisites
- You have a basic understanding of Java and the Nuxeo Platform.
- You have installed the Nuxeo Studio (the Eclipse-based IDE for Nuxeo development).
- You have a Nuxeo Platform instance set up and running.
Step 1: Create a new project in Nuxeo Studio
- Open Nuxeo Studio and create a new project by selecting "File" > "New" > "Nuxeo Project".
- Choose "Document Adapter" as the project type and give your project a name (e.g., "MyDocumentAdapter").
- Click "Finish" to create the project.
Step 2: Define the document adapter
- In the project explorer, right-click on the project and select "New" > "Document Adapter".
- Fill in the required information:
- Name: Enter a name for your document adapter (e.g., "MyDocumentAdapter").
- Description: Enter a brief description of your document adapter.
- Format: Select the format you want to support (e.g., PDF, Word, Excel, etc.).
- Protocol: Select the protocol you want to use (e.g., HTTP, FTP, etc.).
- Click "Finish" to create the document adapter.
Step 3: Implement the document adapter
- In the project explorer, navigate to the
src/main/java
folder and create a new Java class with the same name as your document adapter (e.g.,MyDocumentAdapter.java
). - Implement the
DocumentAdapter
interface, which has several methods that you need to override:getDocumentFormat()
: Returns the format of the document (e.g., PDF, Word, etc.).getDocumentProtocol()
: Returns the protocol used to access the document (e.g., HTTP, FTP, etc.).getDocumentUrl()
: Returns the URL of the document.downloadDocument()
: Downloads the document and returns it as a byte array.uploadDocument()
: Uploads a document to the Nuxeo Platform.
- Implement the logic for your document adapter in these methods.
Step 4: Configure the document adapter
- In the project explorer, navigate to the
src/main/resources
folder and create a new file calleddocument-adapter.xml
. - In this file, define the configuration for your document adapter:
adapter-name
: The name of your document adapter.format
: The format of the document (e.g., PDF, Word, etc.).protocol
: The protocol used to access the document (e.g., HTTP, FTP, etc.).url
: The URL of the document.
- Save the file.
Step 5: Package and deploy the document adapter
- In the project explorer, right-click on the project and select "Export" > "Nuxeo Package".
- Choose the "Document Adapter" option and select the
document-adapter.xml
file. - Package the document adapter and deploy it to your Nuxeo Platform instance.
Step 6: Test the document adapter
- In the Nuxeo Platform, go to the "Document" tab and click on the "Upload" button.
- Select the document adapter you just created and upload a document.
- Verify that the document is uploaded successfully and can be viewed in the Nuxeo Platform.
That's it! You have now created a new document adapter in Nuxeo.