mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-7556 Bulk update in Legal Holds (#2692)
* ACS-7557 Add Legal Holds Bulk v1 API (#2624) * ACS-7557 Add Legal Holds Bulk v1 API * ACS-7557 Improve v1 API * ACS-7557 Replace processId with bulkStatusId * ACS-7587 Implement v1 Bulk API to add items to a hold (#2656) * ACS-7557 Add bulk API design * ACS-7557 Fix * ACS-7557 Add permissions checks * ACS-7557 Add IT tests * ACS-7557 Add comments + logging * ACS-7557 Refactor * ACS-7557 Reimplement task container * ACS-7557 Refactor code * ACS-7587 Remove merge leftovers * ACS-7587 Refactor * ACS-7587 Tests * ACS-7587 Change DefaultHoldBulkMonitor * ACS-7587 Reimplement BulkStatusUpdater * ACS-7587 Fix PMD issues * ACS-7587 Fix PMD isues * ACS-7587 Refactor * ACS-7587 Add test files alternately * ACS-7587 Refactor code * ACS-7587 Improve search query * ACS-7587 Fix PMD issues * ACS-7587 Fix PMD issue * ACS-7587 Fix intermittent failure * ACS7587 Fix intermittent failure (#2681) * ACS-7587 Implement bulk cancellations (#2683)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.hold;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BulkBodyCancel
|
||||
{
|
||||
private String reason;
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.hold;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* POJO for hold bulk request
|
||||
*
|
||||
* @author Damian Ujma
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HoldBulkOperation extends TestModel
|
||||
{
|
||||
public enum HoldBulkOperationType
|
||||
{
|
||||
ADD
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private RestRequestQueryModel query;
|
||||
@JsonProperty(required = true)
|
||||
private HoldBulkOperationType op;
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.hold;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* POJO for hold bulk request entry
|
||||
*
|
||||
* @author Damian Ujma
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HoldBulkOperationEntry
|
||||
{
|
||||
private String bulkStatusId;
|
||||
|
||||
private long totalItems;
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.hold;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* POJO for hold bulk request
|
||||
*
|
||||
* @author Damian Ujma
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HoldBulkStatus extends TestModel
|
||||
{
|
||||
private String bulkStatusId;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
|
||||
private long processedItems;
|
||||
|
||||
private long errorsCount;
|
||||
|
||||
private long totalItems;
|
||||
|
||||
private String lastError;
|
||||
|
||||
private String status;
|
||||
|
||||
private boolean isCancelled;
|
||||
|
||||
private String cancellationReason;
|
||||
|
||||
private HoldBulkOperation holdBulkOperation;
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.hold;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* Handle collection of {@link HoldBulkStatusEntry}
|
||||
*
|
||||
* @author Damian Ujma
|
||||
*/
|
||||
public class HoldBulkStatusCollection extends RestModels<HoldBulkStatusEntry, HoldBulkStatusCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.hold;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HoldBulkStatusEntry extends RestModels<HoldBulkStatus, HoldBulkStatusEntry>
|
||||
{
|
||||
private HoldBulkStatus entry;
|
||||
}
|
@@ -48,5 +48,5 @@ import org.alfresco.rest.core.RestModels;
|
||||
public class HoldChildEntry extends RestModels<Hold, HoldChildEntry>
|
||||
{
|
||||
@JsonProperty
|
||||
private HoldChildEntry entry;
|
||||
private HoldChild entry;
|
||||
}
|
@@ -38,7 +38,12 @@ import static org.springframework.http.HttpMethod.POST;
|
||||
import static org.springframework.http.HttpMethod.PUT;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.hold.BulkBodyCancel;
|
||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperation;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperationEntry;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatus;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatusCollection;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldChildCollection;
|
||||
import org.alfresco.rest.rm.community.model.hold.HoldDeletionReason;
|
||||
@@ -287,4 +292,155 @@ public class HoldsAPI extends RMModelRequest
|
||||
{
|
||||
deleteHoldChild(holdId, holdChildId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a bulk process for a hold.
|
||||
*
|
||||
* @param holdBulkOperation The bulk operation details
|
||||
* @param hold The identifier of a hold
|
||||
* @param parameters The URL parameters to add
|
||||
* @return The {@link HoldBulkOperationEntry} for the started bulk process
|
||||
* @throws RuntimeException for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code hold} or {@code holdBulkOperation} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to start a bulk process for {@code hold}</li>
|
||||
* <li>{@code hold} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public HoldBulkOperationEntry startBulkProcess(HoldBulkOperation holdBulkOperation, String hold, String parameters)
|
||||
{
|
||||
mandatoryObject("holdBulkOperation", holdBulkOperation);
|
||||
mandatoryString("hold", hold);
|
||||
|
||||
return getRmRestWrapper().processModel(HoldBulkOperationEntry.class, requestWithBody(
|
||||
POST,
|
||||
toJson(holdBulkOperation),
|
||||
"holds/{hold}/bulk",
|
||||
hold,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #startBulkProcess(HoldBulkOperation, String, String)}
|
||||
*/
|
||||
public HoldBulkOperationEntry startBulkProcess(HoldBulkOperation holdBulkOperation, String hold)
|
||||
{
|
||||
return startBulkProcess(holdBulkOperation, hold, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status of a bulk process for a hold.
|
||||
*
|
||||
* @param holdId The identifier of a hold
|
||||
* @param holdBulkStatusId The identifier of a bulk status operation
|
||||
* @param parameters The URL parameters to add
|
||||
* @return The {@link HoldBulkStatus} for the given {@code holdId} and {@code holdBulkStatusId}
|
||||
* @throws RuntimeException for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code holdId} or {@code holdBulkStatusId} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to get the bulk status for {@code holdId}</li>
|
||||
* <li>{@code holdId} or {@code holdBulkStatusId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public HoldBulkStatus getBulkStatus(String holdId, String holdBulkStatusId, String parameters)
|
||||
{
|
||||
mandatoryString("holdId", holdId);
|
||||
mandatoryString("holdBulkStatusId", holdBulkStatusId);
|
||||
|
||||
return getRmRestWrapper().processModel(HoldBulkStatus.class, simpleRequest(
|
||||
GET,
|
||||
"holds/{holdId}/bulk-statuses/{holdBulkStatusId}",
|
||||
holdId,
|
||||
holdBulkStatusId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getBulkStatus(String, String, String)}
|
||||
*/
|
||||
public HoldBulkStatus getBulkStatus(String holdId, String holdBulkStatusId)
|
||||
{
|
||||
return getBulkStatus(holdId, holdBulkStatusId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statuses of all bulk processes for a hold.
|
||||
*
|
||||
* @param holdId The identifier of a hold
|
||||
* @param parameters The URL parameters to add
|
||||
* @return The {@link HoldBulkStatusCollection} for the given {@code holdId}
|
||||
* @throws RuntimeException for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code holdId} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to get the bulk statuses for {@code holdId}</li>
|
||||
* <li>{@code holdId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public HoldBulkStatusCollection getBulkStatuses(String holdId, String parameters)
|
||||
{
|
||||
mandatoryString("holdId", holdId);
|
||||
|
||||
return getRmRestWrapper().processModels(HoldBulkStatusCollection.class, simpleRequest(
|
||||
GET,
|
||||
"holds/{holdId}/bulk-statuses",
|
||||
holdId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getBulkStatuses(String, String)}
|
||||
*/
|
||||
public HoldBulkStatusCollection getBulkStatuses(String holdId)
|
||||
{
|
||||
return getBulkStatuses(holdId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a bulk operation for a hold.
|
||||
*
|
||||
* @param holdId The identifier of a hold
|
||||
* @param bulkStatusId The identifier of a bulk status operation
|
||||
* @param bulkBodyCancel The bulk body cancel model
|
||||
* @param parameters The URL parameters to add
|
||||
* @throws RuntimeException for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code holdId}, {@code bulkStatusId} or {@code bulkBodyCancel} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to cancel the bulk operation for {@code bulkStatusId}</li>
|
||||
* <li>{@code holdId} or {@code bulkStatusId} does not exist</li>
|
||||
* </ul>
|
||||
*/
|
||||
public void cancelBulkOperation(String holdId, String bulkStatusId, BulkBodyCancel bulkBodyCancel, String parameters)
|
||||
{
|
||||
mandatoryString("holdId", holdId);
|
||||
mandatoryString("bulkStatusId", bulkStatusId);
|
||||
mandatoryObject("bulkBodyCancel", bulkBodyCancel);
|
||||
|
||||
getRmRestWrapper().processEmptyModel(requestWithBody(
|
||||
POST,
|
||||
toJson(bulkBodyCancel),
|
||||
"holds/{holdId}/bulk-statuses/{bulkStatusId}/cancel",
|
||||
holdId,
|
||||
bulkStatusId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #cancelBulkOperation(String, String, BulkBodyCancel, String)}
|
||||
*/
|
||||
public void cancelBulkOperation(String holdId, String bulkStatusId, BulkBodyCancel bulkBodyCancel)
|
||||
{
|
||||
mandatoryString("holdId", holdId);
|
||||
mandatoryString("bulkStatusId", bulkStatusId);
|
||||
mandatoryObject("bulkBodyCancel", bulkBodyCancel);
|
||||
|
||||
cancelBulkOperation(holdId, bulkStatusId, bulkBodyCancel, EMPTY);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user