diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/contentImport/ContentImportHelper.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/contentImport/ContentImportHelper.java index 13d32fe07c52..25ed0bc53680 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/contentImport/ContentImportHelper.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/contentImport/ContentImportHelper.java @@ -19,51 +19,75 @@ import java.util.HashMap; import java.util.Map; +/** + * Helper class for managing content import operations in the dotCMS application. + *
+ * This class provides methods to create and manage jobs for importing content
+ * from external sources, such as CSV files, into the system. It handles the
+ * validation of import parameters, processes file uploads, and constructs
+ * the necessary job parameters to enqueue content import tasks in the job queue.
+ */
@ApplicationScoped
public class ContentImportHelper {
private JobQueueManagerAPI jobQueueManagerAPI;
private JobQueueManagerHelper jobQueueManagerHelper;
+ /**
+ * Constructor for dependency injection.
+ *
+ * @param jobQueueManagerAPI The API for managing job queues.
+ * @param jobQueueManagerHelper Helper for job queue management.
+ */
@Inject
public ContentImportHelper(final JobQueueManagerAPI jobQueueManagerAPI, final JobQueueManagerHelper jobQueueManagerHelper) {
this.jobQueueManagerAPI = jobQueueManagerAPI;
this.jobQueueManagerHelper = jobQueueManagerHelper;
}
+ /**
+ * Default constructor required for CDI.
+ */
public ContentImportHelper() {
- //default constructor Mandatory for CDI
+ // Default constructor mandatory for CDI
}
+ /**
+ * Initializes the helper by registering job processors during application startup.
+ */
@PostConstruct
public void onInit() {
jobQueueManagerHelper.registerProcessors();
}
+ /**
+ * Cleans up resources and shuts down the helper during application shutdown.
+ */
@PreDestroy
public void onDestroy() {
jobQueueManagerHelper.shutdown();
}
/**
- * Creates a content import job with the provided parameters
+ * Creates a content import job with the provided parameters and submits it to the job queue.
*
- * @param command Whether this is a preview job
- * @param queueName The name of the queue to submit the job to
- * @param params The import parameters
- * @param user The user initiating the import
- * @param request The HTTP request
- * @return The ID of the created job
+ * @param command The command indicating the type of operation (e.g., "preview" or "import").
+ * @param queueName The name of the queue to which the job should be submitted.
+ * @param params The content import parameters containing the details of the import operation.
+ * @param user The user initiating the import.
+ * @param request The HTTP request associated with the import operation.
+ * @return The ID of the created job.
+ * @throws DotDataException If there is an error creating the job.
+ * @throws JsonProcessingException If there is an error processing JSON data.
*/
public String createJob(
final String command,
- final String queueName,
+ final String queueName,
final ContentImportParams params,
final User user,
final HttpServletRequest request) throws DotDataException, JsonProcessingException {
params.checkValid();
-
final Map