Skip to content

Latest commit

 

History

History
206 lines (156 loc) · 9.21 KB

legal_holds.md

File metadata and controls

206 lines (156 loc) · 9.21 KB

Legal Holds Policy

Legal Hold Policy information describes the basic characteristics of the Policy, such as name, description, and filter dates.

Get Legal Hold Policy

Calling getInfo(String...) will return a BoxLegalHoldPolicy.Info object containing information about the legal hold policy. If necessary to retrieve limited set of fields, it is possible to specify them using param.

BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, id);
BoxLegalHoldPolicy.Info policyInfo = policy.getInfo();

Get List of Legal Hold Policies

Calling the static getAll(BoxAPIConnection) will return an iterable that will page through all of the legal hold policies. It is possible to specify name of legal hold policy, maximum number of items per response and fields to retrieve by calling the static getAll(BoxAPIConnection, String, int, String...) method.

Iterable<BoxLegalHoldPolicy.Info> policies = BoxLegalHoldPolicy.getAll(api);
for (BoxLegalHoldPolicy.Info policyInfo : policies) {
    // Do something with the legal hold policy.
}

Create New Legal Hold Policy

The static create(BoxAPIConnection api, String name, String description, Date startDate, Date endDate) method will let you create a new legal hold policy with a specified name, description, start and end dates.

BoxLegalHoldPolicy.Info policyInfo = BoxLegalHoldPolicy.create(api, name, description, startedAt, endedAt);

If you wish to create an ongoing Legal Hold Policy with no end date and a description, call createOngoing(BoxAPIConnection api, String name, String description).

BoxLegalHoldPolicy.Info policyInfo = BoxLegalHoldPolicy.createOngoing(api, name, description);

Update Existing Legal Hold Policy

Updating a legal hold policy's information is done by calling updateInfo(BoxLegalHoldPolicy.Info fieldsToUpdate).

BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, id);
BoxLegalHoldPolicy.Info policyInfo = policy.new Info();
info.setDescription("new description");
info.setPolicyName("new policy name");
policy.updateInfo(info);

Delete Legal Hold Policy

A legal hold policy can be deleted by calling the delete() method.

BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, id);
policy.delete();

Get Assignment

Calling getInfo(String... fields) will return a BoxLegalHoldAssignment.Info object containing information about the legal hold policy assignment.

BoxLegalHoldAssignment assignment = new BoxLegalHoldAssignment(api, id);
BoxLegalHoldAssignment.Info info = assignment.getInfo("assigned_by");

Get List of Assignments

Calling the static getAssignments(String... fields) will return an iterable that will page through all of the assignments of the legal hold policy. It is possible to specify filters for type and id, maximum number of items per single response and fields to retrieve by calling getAssignments(String type, String id, int limit, String... fields).

BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, id);
Iterable<BoxLegalHoldAssignment.Info> assignments = policy.getAssignments(BoxResource.getResourceType(BoxFolder.class), null, 50, "assigned_at");
for (BoxLegalHoldAssignment.Info assignmentInfo : assignments) {
	// Do something with the legal hold policy assignment.
}

Create New Assignment

To create new legal hold policy assignment call assignTo(BoxResource target) method. Currently only BoxFile, BoxFileVersion, BoxFolder and BoxUser objects are supported as a parameter.

BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, policyID);
BoxFolder folder = new BoxFolder(api, folderID);
policy.assignTo(folder);

Delete Assignment

A legal hold policy assignment can be deleted by calling the delete() method of BoxLegalHoldAssignment object.

BoxLegalHoldAssignment assignment = new BoxLegalHoldAssignment(api, id);
assignment.delete();

Get File Version Legal Hold

Calling getInfo(String... fields) will return a BoxFileVersionLegalHold.Info object containing information about the file version legal hold policy.

BoxFileVersionLegalHold hold = new BoxFileVersionLegalHold(api, id);
hold.getInfo("file");

Get List of File Version Legal Holds

To get an iterable with all non-deleted file version legal holds for current legal hold policy, call getFileVersionHolds(String... fields). It is possible to specify maximum number of items per single response by calling getFileVersionHolds(int limit, String... fields).

BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, id);
Iterable<BoxFileVersionLegalHold.Info> fileVersionHolds = policy.getFileVersionHolds();
for (BoxFileVersionLegalHold.Info fileVersionHold : fileVersionHolds) {
	// Do something with the file version legal hold.
}