Skip to main content

Standard Integration Example

A document management integration example project based on Spring Boot, demonstrating how to integrate with the document platform.

Integration Solution Details

If you need to view the complete API documentation, please visit Docs API Manual.

How to Get Sample Code

GitHub Repository Standard integration is in the server-callback-solution/java/filez-demo directory

Important Notice

This project is for testing and demonstration purposes only. Do not use it directly on production servers. Appropriate code modifications and security hardening are required!

Technology Stack

  • Framework: Spring Boot 2.5.4
  • Database: SQLite (embedded database, no additional installation required)
  • ORM: MyBatis Plus 3.4.3.4
  • Template Engine: FreeMarker
  • API Documentation: Knife4j (Swagger)
  • JSON Processing: Fastjson 1.2.83
  • JWT: JJWT 0.9.1
  • HTTP Client: Apache HttpClient 4.5.13

Prerequisites

  • Java: JDK 8 or higher
  • Maven: 3.6 or higher

Project Structure

filez-demo/
├── src/main/java/com/filez/demo/
│ ├── controller/ # Controller layer
│ │ ├── LoginController.java # Login controller
│ │ ├── HomeController.java # Home controller
│ │ ├── FileController.java # File operation controller
│ │ └── ZOfficeController.java # ZOffice integration controller ⭐
│ ├── service/ # Business logic layer
│ ├── config/ # Configuration classes
│ │ └── ZOfficeConfig.java # ZOffice configuration ⭐
│ └── common/ # Common components
├── src/main/resources/
│ ├── application.yml # Main configuration file
│ └── zoffice.yml # ZOffice integration configuration ⭐
├── target/ # Compilation output directory
└── logs/ # Log files

Quick Start

1. Build Project

# Clone code
git clone <repository-url>
cd filez-demo

# Build package
mvn clean package -DskipTests

After successful compilation, the filez-demo-1.0.0.RELEASE.jar file will be generated in the target/ directory.

2. Configure Application

Edit src/main/resources/application.yml:

server:
port: 8000

demo:
host: 172.16.34.165 # Current application server address
context: /v2/context

Edit src/main/resources/zoffice.yml:

zoffice:
service:
host: 172.16.34.165 # ZOffice server address
port: 8001 # ZOffice server port

3. Start Application

Foreground Start (Development Environment)

java -jar target/filez-demo-1.0.0.RELEASE.jar

Background Start (Production Environment)

Linux/macOS:

nohup java -jar target/filez-demo-1.0.0.RELEASE.jar > logs/app.log 2>&1 &

Windows PowerShell:

Start-Process java -ArgumentList "-jar","target/filez-demo-1.0.0.RELEASE.jar" -WindowStyle Hidden

4. Access Application

ServiceAddressDescription
Homehttp://localhost:8000Application main entry
API Documentationhttp://localhost:8000/doc.htmlSwagger API documentation
File Managementhttp://localhost:8000/home/localDocument management interface

Default Account: Username admin, Password zOffice

ZOffice Integration Key Code

1. ZOfficeController.java

Core controller that handles all ZOffice integration interfaces:

@RestController
@RequestMapping("/v2/context")
public class ZOfficeController {

// Get editor URL
@GetMapping("/openDoc")
public Result getOpenDocUrl(@RequestParam String docId,
@RequestParam String mode) {
// Return editor access address
}

// Download document content
@GetMapping("/{docId}/content")
public void downloadContent(@PathVariable String docId,
HttpServletResponse response) {
// Return document binary stream
}

// Upload document content
@PostMapping("/{docId}/content")
public Result uploadContent(@PathVariable String docId,
HttpServletRequest request) {
// Save edited document
}

// Get document metadata
@GetMapping("/{docId}/meta")
public Result getDocMeta(@PathVariable String docId) {
// Return document information
}

// Document status notification callback
@PostMapping("/{docId}/notify")
public Result notify(@PathVariable String docId,
@RequestBody NotifyRequest request) {
// Handle document status change notification
}
}

2. ZOfficeConfig.java

ZOffice service configuration:

@Component
@ConfigurationProperties(prefix = "zoffice")
public class ZOfficeConfig {
private Service service;

public static class Service {
private String host; // ZOffice server address
private Integer port; // ZOffice server port
}
}

3. zoffice.yml

ZOffice configuration file:

zoffice:
service:
host: 172.16.34.165
port: 8001

Stop Service

# Linux/macOS - Find process
ps aux | grep filez-demo

# Stop process
kill <PID>

# Windows - Find process
tasklist | findstr java

# Stop process
taskkill /PID <PID> /F

View Logs

# Linux/macOS
tail -f logs/filezDemo.log

# Windows
Get-Content logs/filezDemo.log -Wait -Tail 50

Reference Resources