1 /*
2 * The contents of this file are subject to the terms of the Common Development and
3 * Distribution License (the License). You may not use this file except in compliance with the
4 * License.
5 *
6 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7 * specific language governing permission and limitations under the License.
8 *
9 * When distributing Covered Software, include this CDDL Header Notice in each file and include
10 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11 * Header, with the fields enclosed by brackets [] replaced by your own identifying
12 * information: "Portions Copyright [year] [name of copyright owner]".
13 *
14 * Copyright 2012-2015 ForgeRock AS.
15 */
16
17 package org.forgerock.json.resource;
18
19 import java.util.List;
20 import java.util.Map;
21
22 import org.forgerock.http.routing.Version;
23 import org.forgerock.json.JsonPointer;
24 import org.forgerock.json.JsonValue;
25 import org.forgerock.util.i18n.PreferredLocales;
26
27 /**
28 * A request to delete a JSON resource.
29 */
30 public interface DeleteRequest extends Request {
31
32 /**
33 * The name of the field which contains the resource version in the JSON representation.
34 */
35 String FIELD_REVISION = "revision";
36
37
38 @Override
39 <R, P> R accept(final RequestVisitor<R, P> v, final P p);
40
41
42 @Override
43 DeleteRequest addField(JsonPointer... fields);
44
45
46 @Override
47 DeleteRequest addField(String... fields);
48
49
50 @Override
51 String getAdditionalParameter(String name);
52
53
54 @Override
55 Map<String, String> getAdditionalParameters();
56
57
58 @Override
59 List<JsonPointer> getFields();
60
61
62 @Override
63 PreferredLocales getPreferredLocales();
64
65
66 @Override
67 RequestType getRequestType();
68
69 @Override
70 String getResourcePath();
71
72 @Override
73 ResourcePath getResourcePathObject();
74
75 @Override
76 Version getResourceVersion();
77
78 /**
79 * Returns the expected version information associated with the JSON resource to be deleted. Version information can
80 * be used in order to implement multi-version concurrency control (MVCC).
81 * <p>
82 * The returned version information may be {@code null} indicating that the client does not care if the resource has
83 * been modified concurrently. If the version information is non-{@code null}, and it does not match the current
84 * version of the targeted JSON resource, then the delete request will be rejected by the provider.
85 *
86 * @return The expected version information associated with the JSON resource to be deleted.
87 */
88 String getRevision();
89
90 @Override
91 DeleteRequest setAdditionalParameter(String name, String value) throws BadRequestException;
92
93 @Override
94 DeleteRequest setPreferredLocales(PreferredLocales preferredLocales);
95
96 @Override
97 DeleteRequest setResourcePath(String path);
98
99 @Override
100 DeleteRequest setResourcePath(ResourcePath path);
101
102 @Override
103 DeleteRequest setResourceVersion(Version resourceVersion);
104
105 /**
106 * Sets the expected version information associated with the JSON resource to be deleted. Version information can be
107 * used in order to implement multi-version concurrency control (MVCC).
108 * <p>
109 * The provided version information may be {@code null} indicating that the client does not care if the resource has
110 * been modified concurrently. If the version information is non-{@code null}, and it does not match the current
111 * version of the targeted JSON resource, then the delete request will be rejected by the provider.
112 *
113 * @param version
114 * The expected version information associated with the JSON resource to be deleted.
115 * @return This delete request.
116 * @throws UnsupportedOperationException
117 * If this delete request does not permit changes to the version information.
118 */
119 DeleteRequest setRevision(String version);
120
121 @Override
122 JsonValue toJsonValue();
123 }