CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-cdap-cdap--cdap-common

CDAP Common provides core common utilities and abstractions for the CDAP (Cask Data Application Platform) ecosystem including exception handling, service management, configuration, HTTP utilities, metadata management, security abstractions, discovery services, and various utility classes that are shared across CDAP components.

Pending
Overview
Eval results
Files

exceptions.mddocs/

Exception Handling

Comprehensive exception hierarchy providing HTTP-status-mapped exceptions and domain-specific error types for consistent error handling across CDAP components.

Capabilities

HTTP Status Exceptions

Base exceptions that map directly to HTTP status codes for REST API error responses.

/**
 * Exception indicating a bad request (HTTP 400)
 */
public class BadRequestException extends Exception {
    public BadRequestException(String message);
    public BadRequestException(String message, Throwable cause);
}

/**
 * Exception indicating a resource was not found (HTTP 404)
 */
public class NotFoundException extends Exception {
    public NotFoundException(String message);
    public NotFoundException(String message, Throwable cause);
}

/**
 * Exception indicating a conflict (HTTP 409)
 */
public class ConflictException extends Exception {
    public ConflictException(String message);
    public ConflictException(String message, Throwable cause);
}

/**
 * Exception indicating forbidden access (HTTP 403)
 */
public class ForbiddenException extends Exception {
    public ForbiddenException(String message);
    public ForbiddenException(String message, Throwable cause);
}

/**
 * Exception indicating too many requests (HTTP 429)
 */
public class TooManyRequestsException extends Exception {
    public TooManyRequestsException(String message);
    public TooManyRequestsException(String message, Throwable cause);
}

Usage Examples:

import io.cdap.cdap.common.BadRequestException;
import io.cdap.cdap.common.NotFoundException;

// Validate input parameters
public void validateInput(String input) throws BadRequestException {
    if (input == null || input.trim().isEmpty()) {
        throw new BadRequestException("Input cannot be null or empty");
    }
}

// Resource lookup
public Application findApplication(String appId) throws NotFoundException {
    Application app = applicationStore.get(appId);
    if (app == null) {
        throw new NotFoundException("Application not found: " + appId);
    }
    return app;
}

Service-Level Exceptions

Exceptions for service-related errors and handler failures.

/**
 * Exception for service-related errors
 */
public class ServiceException extends Exception {
    public ServiceException(String message);
    public ServiceException(String message, Throwable cause);
}

/**
 * Exception for Netty pipeline handler failures
 */
public class HandlerException extends Exception {
    public HandlerException(String message);
    public HandlerException(String message, Throwable cause);
}

Application Management Exceptions

Domain-specific exceptions for CDAP application lifecycle operations.

/**
 * Exception indicating an application was not found
 */
public class ApplicationNotFoundException extends NotFoundException {
    public ApplicationNotFoundException(String message);
    public ApplicationNotFoundException(String message, Throwable cause);
}

/**
 * Exception indicating an application already exists
 */
public class ApplicationAlreadyExistsException extends ConflictException {
    public ApplicationAlreadyExistsException(String message);
    public ApplicationAlreadyExistsException(String message, Throwable cause);
}

/**
 * Exception indicating general already-exists condition
 */
public class AlreadyExistsException extends ConflictException {
    public AlreadyExistsException(String message);
    public AlreadyExistsException(String message, Throwable cause);
}

Artifact Management Exceptions

Exceptions for CDAP artifact operations including deployment and management.

/**
 * Exception indicating an artifact was not found
 */
public class ArtifactNotFoundException extends NotFoundException {
    public ArtifactNotFoundException(String message);
    public ArtifactNotFoundException(String message, Throwable cause);
}

/**
 * Exception indicating an artifact already exists
 */
public class ArtifactAlreadyExistsException extends ConflictException {
    public ArtifactAlreadyExistsException(String message);
    public ArtifactAlreadyExistsException(String message, Throwable cause);
}

/**
 * Exception indicating an invalid artifact
 */
public class InvalidArtifactException extends BadRequestException {
    public InvalidArtifactException(String message);
    public InvalidArtifactException(String message, Throwable cause);
}

Dataset Management Exceptions

Exceptions for CDAP dataset operations and dataset module management.

/**
 * Exception indicating a dataset was not found
 */
public class DatasetNotFoundException extends NotFoundException {
    public DatasetNotFoundException(String message);
    public DatasetNotFoundException(String message, Throwable cause);
}

/**
 * Exception indicating a dataset already exists
 */
public class DatasetAlreadyExistsException extends ConflictException {
    public DatasetAlreadyExistsException(String message);
    public DatasetAlreadyExistsException(String message, Throwable cause);
}

/**
 * Exception indicating a dataset module was not found
 */
public class DatasetModuleNotFoundException extends NotFoundException {
    public DatasetModuleNotFoundException(String message);
    public DatasetModuleNotFoundException(String message, Throwable cause);
}

Namespace Management Exceptions

Exceptions for CDAP namespace operations.

/**
 * Exception indicating a namespace was not found
 */
public class NamespaceNotFoundException extends NotFoundException {
    public NamespaceNotFoundException(String message);
    public NamespaceNotFoundException(String message, Throwable cause);
}

/**
 * Exception indicating a namespace already exists
 */
public class NamespaceAlreadyExistsException extends ConflictException {
    public NamespaceAlreadyExistsException(String message);
    public NamespaceAlreadyExistsException(String message, Throwable cause);
}

Security Exceptions

Exceptions for secure key management operations.

/**
 * Exception indicating a secure key was not found
 */
public class SecureKeyNotFoundException extends NotFoundException {
    public SecureKeyNotFoundException(String message);
    public SecureKeyNotFoundException(String message, Throwable cause);
}

/**
 * Exception indicating a secure key already exists
 */
public class SecureKeyAlreadyExistsException extends ConflictException {
    public SecureKeyAlreadyExistsException(String message);
    public SecureKeyAlreadyExistsException(String message, Throwable cause);
}

Usage Examples:

import io.cdap.cdap.common.*;

// Application management
public void deployApplication(String appId, ApplicationSpec spec) 
    throws ApplicationAlreadyExistsException, BadRequestException {
    
    if (applicationExists(appId)) {
        throw new ApplicationAlreadyExistsException("Application already deployed: " + appId);
    }
    
    if (spec == null) {
        throw new BadRequestException("Application specification cannot be null");
    }
    
    // Deploy application...
}

// Dataset operations
public Dataset createDataset(String datasetId, DatasetSpec spec) 
    throws DatasetAlreadyExistsException, InvalidArtifactException {
    
    if (datasetExists(datasetId)) {
        throw new DatasetAlreadyExistsException("Dataset already exists: " + datasetId);
    }
    
    if (!isValidDatasetType(spec.getType())) {
        throw new InvalidArtifactException("Invalid dataset type: " + spec.getType());
    }
    
    // Create dataset...
}

// Namespace operations
public void deleteNamespace(String namespaceId) throws NamespaceNotFoundException {
    if (!namespaceExists(namespaceId)) {
        throw new NamespaceNotFoundException("Namespace not found: " + namespaceId);
    }
    
    // Delete namespace...
}

Install with Tessl CLI

npx tessl i tessl/maven-io-cdap-cdap--cdap-common

docs

configuration.md

exceptions.md

http.md

index.md

io.md

logging.md

network.md

security.md

services.md

utilities.md

tile.json