Nicholas DiPiazza created TIKA-4597:
---------------------------------------

             Summary: Implement fetcher management request handlers in 
PipesServer
                 Key: TIKA-4597
                 URL: https://issues.apache.org/jira/browse/TIKA-4597
             Project: Tika
          Issue Type: Task
          Components: tika-pipes
            Reporter: Nicholas DiPiazza


h2. Goal

Implement server-side request handlers for fetcher management operations.

h2. Implementation

h3. Location
Add new methods to PipesServer class or create a new ConfigManagementHandler 
class.

h3. Required Methods

*saveFetcher(ExtensionConfig config)*
{code:java}
private void handleSaveFetcher(DataInputStream input, DataOutputStream output) 
throws IOException {
    // Read ExtensionConfig from input
    ObjectInputStream ois = new ObjectInputStream(input);
    ExtensionConfig config = (ExtensionConfig) ois.readObject();
    
    try {
        fetcherManager.saveFetcher(config);
        output.writeByte(SUCCESS);
        output.writeUTF("Fetcher saved successfully");
    } catch (Exception e) {
        output.writeByte(ERROR);  
        output.writeUTF(ExceptionUtils.getStackTrace(e));
    }
    output.flush();
}
{code}

*deleteFetcher(String fetcherId)*
{code:java}
private void handleDeleteFetcher(DataInputStream input, DataOutputStream 
output) throws IOException {
    String fetcherId = input.readUTF();
    
    try {
        fetcherManager.deleteFetcher(fetcherId);
        output.writeByte(SUCCESS);
        output.writeUTF("Fetcher deleted successfully");
    } catch (Exception e) {
        output.writeByte(ERROR);
        output.writeUTF(ExceptionUtils.getStackTrace(e));
    }
    output.flush();
}
{code}

*listFetchers()*
*getFetcher(String fetcherId)*

h3. Integration with Main Loop

Update PipesServer.mainLoop() to handle new command types:
{code:java}
switch (command) {
    case SAVE_FETCHER:
        handleSaveFetcher(input, output);
        break;
    case DELETE_FETCHER:
        handleDeleteFetcher(input, output);
        break;
    // ... existing cases
}
{code}

h2. Error Handling

* Validate input before processing
* Return clear error messages
* Log all operations
* Handle concurrent access properly

h2. Testing

* Unit tests for each handler method
* Integration tests with real socket communication
* Concurrent access tests




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to