Skip to content

Commit 2c15f27

Browse files
committed
Fixed javadocs.
1 parent 4387353 commit 2c15f27

File tree

14 files changed

+59
-54
lines changed

14 files changed

+59
-54
lines changed

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/internal/conversion/swagger/v2_0/Swagger2Translator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.restlet.ext.apispark.internal.model.Representation;
4343
import org.restlet.ext.apispark.internal.model.Resource;
4444
import org.restlet.ext.apispark.internal.model.Response;
45+
import org.restlet.ext.apispark.internal.utils.SampleUtils;
4546
import org.restlet.ext.apispark.internal.introspection.util.Types;
4647

4748
import com.wordnik.swagger.models.ArrayModel;
@@ -135,6 +136,11 @@ private static void fillDefinitions(Definition definition, Swagger swagger) {
135136

136137
com.wordnik.swagger.models.properties.Property propertySwagger;
137138

139+
Object exampleObject = SampleUtils
140+
.getFieldSampleValue(property);
141+
String example = exampleObject == null ? null : exampleObject
142+
.toString();
143+
138144
// property type
139145
if (property.getMaxOccurs() != null
140146
&& (property.getMaxOccurs() > 1 || property

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/internal/utils/SampleUtils.java

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424

2525
package org.restlet.ext.apispark.internal.utils;
2626

27-
import org.restlet.data.MediaType;
28-
import org.restlet.ext.apispark.internal.model.Property;
29-
import org.restlet.ext.apispark.internal.model.Representation;
30-
import org.restlet.ext.jackson.JacksonRepresentation;
31-
import org.restlet.service.MetadataService;
32-
3327
import java.io.IOException;
3428
import java.util.Arrays;
3529
import java.util.HashMap;
3630
import java.util.List;
3731
import java.util.Map;
3832

33+
import org.restlet.data.MediaType;
34+
import org.restlet.ext.apispark.internal.model.Property;
35+
import org.restlet.ext.apispark.internal.model.Representation;
36+
import org.restlet.ext.jackson.JacksonRepresentation;
37+
import org.restlet.service.MetadataService;
38+
3939
public class SampleUtils {
4040

4141
private static final List<String> supportedExtensions = Arrays.asList(
@@ -44,11 +44,12 @@ public class SampleUtils {
4444
private static final List<String> numberTypes = Arrays.asList("byte",
4545
"short", "integer", "long");
4646

47-
private static final List<String> decimalTypes = Arrays.asList("float", "double");
47+
private static final List<String> decimalTypes = Arrays.asList("float",
48+
"double");
4849

49-
public static String convertSampleAccordingToMediaType(Map<String, Object> content,
50-
String mediaTypeAsString,
51-
String representationName) {
50+
public static String convertSampleAccordingToMediaType(
51+
Map<String, Object> content, String mediaTypeAsString,
52+
String representationName) {
5253
MetadataService ms = new MetadataService();
5354
MediaType mediaType = MediaType.valueOf(mediaTypeAsString);
5455
if (!supportedExtensions.contains(ms.getExtension(mediaType))) {
@@ -76,12 +77,13 @@ public static Map<String, Object> getRepresentationSample(
7677
return content;
7778
}
7879

79-
private static Object getFieldSampleValue(Property property) {
80-
Object sampleValue = property.getExample() != null ?
81-
convertSampleValue(property.getType(), property.getExample()) :
82-
getPropertyDefaultSampleValue(property.getType(), property.getName());
80+
public static Object getFieldSampleValue(Property property) {
81+
Object sampleValue = property.getExample() != null ? convertSampleValue(
82+
property.getType(), property.getExample())
83+
: getPropertyDefaultSampleValue(property.getType(),
84+
property.getName());
8385

84-
if (property.getMaxOccurs() != 1) {
86+
if (property.getMaxOccurs() != null && property.getMaxOccurs() != 1) {
8587
if (sampleValue != null) {
8688
sampleValue = Arrays.asList(sampleValue);
8789
} else {
@@ -91,7 +93,8 @@ private static Object getFieldSampleValue(Property property) {
9193
return sampleValue;
9294
}
9395

94-
public static Object getPropertyDefaultSampleValue(String propertyType, String propertyName) {
96+
public static Object getPropertyDefaultSampleValue(String propertyType,
97+
String propertyName) {
9598
if ("string".equals(propertyType)) {
9699
return "sample " + propertyName;
97100
} else if (numberTypes.contains(propertyType)) {
@@ -101,14 +104,16 @@ public static Object getPropertyDefaultSampleValue(String propertyType, String p
101104
} else if ("boolean".equals(propertyType)) {
102105
return false;
103106
} else if ("date".equals(propertyType)) {
104-
//do not set default value for date because we don't know the expected type
107+
// do not set default value for date because we don't know the
108+
// expected type
105109
return null;
106110
} else {
107111
return null;
108112
}
109113
}
110114

111-
public static Object convertSampleValue(String propertyType, String sampleValue) {
115+
public static Object convertSampleValue(String propertyType,
116+
String sampleValue) {
112117
if ("string".equals(propertyType)) {
113118
return sampleValue;
114119
} else if (numberTypes.contains(propertyType)) {
@@ -118,7 +123,8 @@ public static Object convertSampleValue(String propertyType, String sampleValue)
118123
} else if ("boolean".equals(propertyType)) {
119124
return Boolean.parseBoolean(sampleValue);
120125
} else if ("date".equals(propertyType)) {
121-
//do not convert date sample because we don't know the expected type
126+
// do not convert date sample because we don't know the expected
127+
// type
122128
return sampleValue;
123129
} else {
124130
return null;

modules/org.restlet.ext.thymeleaf/src/org/restlet/ext/thymeleaf/TemplateFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* Filters response's entity and wraps it with a Thymeleaf's template
4242
* representation. By default, the template representation provides a data model
4343
* based on the request and response objects. In order for the wrapping to
44-
* happen, the representations must have the {@link Encoding#THYMELEAF} encoding
44+
* happen, the representations must have the {@link #THYMELEAF} encoding
4545
* set.<br>
4646
* <br>
4747
* Concurrency note: instances of this class or its subclasses can be invoked by

modules/org.restlet.ext.thymeleaf/src/org/restlet/ext/thymeleaf/TemplateRepresentation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ protected void setContext(IContext context) {
317317
*
318318
* @param dataModel
319319
* The template's data model.
320-
* @param locale
321320
*/
322321
public void setDataModel(Map<String, Object> dataModel) {
323322
Context ctx = new Context(locale);

modules/org.restlet.ext.xstream/src/org/restlet/ext/xstream/XstreamRepresentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* arbitrary code or shell commands in the context of the server running the
5959
* XStream process.<br>
6060
* You can configure the Xstream object used by this representation (cf
61-
* {@link #createXstream()} or {@link #getXstream()}) and apply security
61+
* {@link #createXstream(MediaType)} or {@link #getXstream()}) and apply security
6262
* permissions. You can find more documentation about the security fix and how
6363
* to configure the XStream object from here: <a href=
6464
* "https://github.com/restlet/restlet-framework-java/wiki/XStream-security-enhancements"

modules/org.restlet.test/src/org/restlet/test/ext/apispark/conversion/swagger/v2_0/Swagger2TranslatorTestCase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,8 @@ public void testGetSwagger2() throws IOException {
632632
.getFile(), MediaType.APPLICATION_JSON),
633633
Definition.class).getObject();
634634

635+
System.out.println(new JacksonRepresentation<>(Swagger2Translator.getSwagger(savedDefinition)).getText());
636+
635637
Swagger translatedSwagger = Swagger2Translator
636638
.getSwagger(savedDefinition);
637639

modules/org.restlet/src/org/restlet/engine/application/CorsFilter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
* Router router = new Router(getContext());
4444
*
4545
* CorsFilter corsFilter = new CorsFilter(getContext(), router);
46-
* corsFilter.setAllowedOrigins(
47-
* new HashSet(Arrays.asList(&quot;http://server.com&quot;)));
46+
* corsFilter.setAllowedOrigins(new HashSet(Arrays.asList(&quot;http://server.com&quot;)));
4847
* corsFilter.setAllowedCredentials(true);
4948
* </pre>
5049
*
@@ -156,7 +155,8 @@ protected CorsResponseHelper getCorsResponseHelper() {
156155
corsResponseHelper = new CorsResponseHelper();
157156
corsResponseHelper.setAllowedCredentials(allowedCredentials);
158157
corsResponseHelper.setAllowedOrigins(allowedOrigins);
159-
corsResponseHelper.setAllowAllRequestedHeaders(allowAllRequestedHeaders);
158+
corsResponseHelper
159+
.setAllowAllRequestedHeaders(allowAllRequestedHeaders);
160160
corsResponseHelper.setAllowedHeaders(allowedHeaders);
161161
corsResponseHelper.setExposedHeaders(exposedHeaders);
162162
}
@@ -200,15 +200,15 @@ public boolean isAllowedCredentials() {
200200
* header into the 'Access-Control-Allow-Headers' response header. If false,
201201
* use {@link #allowedHeaders}.
202202
*
203-
* @param allowAllRequestedHeaders
203+
* @param allowingAllRequestedHeaders
204204
* True to copy the value of 'Access-Control-Request-Headers'
205205
* request header into the 'Access-Control-Allow-Headers'
206206
* response header. If false, use {@link #allowedHeaders}.
207207
* @return Itself for chaining methods calls.
208208
*/
209-
public CorsFilter setAllowAllRequestedHeaders(
210-
boolean allowAllRequestedHeaders) {
211-
this.allowAllRequestedHeaders = allowAllRequestedHeaders;
209+
public CorsFilter setAllowingAllRequestedHeaders(
210+
boolean allowingAllRequestedHeaders) {
211+
this.allowAllRequestedHeaders = allowingAllRequestedHeaders;
212212
return this;
213213
}
214214

modules/org.restlet/src/org/restlet/engine/application/StatusFilter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ public StatusFilter(Context context, StatusService statusService) {
9393
* is not set, set {@link org.restlet.data.Status#SUCCESS_OK} by default.
9494
*
9595
* If this is an error status, try to get a representation of it with
96-
* {@link org.restlet.service.StatusService#toStatus(Throwable, org.restlet.Request, org.restlet.Response)}
97-
* . If the representation is null, get a default one with
98-
* {@link #getDefaultRepresentation(org.restlet.data.Status, org.restlet.Request, org.restlet.Response)}
96+
* {@link org.restlet.service.StatusService#toRepresentation(Status, Request, Response)}
9997
* .
10098
*
10199
* @param request

modules/org.restlet/src/org/restlet/engine/application/TunnelFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private List<HeaderReplacer> getAcceptReplacers() {
247247
* unconditionnaly set.
248248
* @param newHeaderName
249249
* The name of the property that gives the replacement value.
250-
* @return
250+
* @return The list of new header values.
251251
*/
252252
private List<HeaderReplacer> getheaderReplacers(
253253
final URL userAgentPropertiesUrl, String oldHeaderName,

modules/org.restlet/src/org/restlet/engine/converter/StatusInfoHtmlConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.restlet.representation.StringRepresentation;
3939
import org.restlet.representation.Variant;
4040
import org.restlet.resource.Resource;
41+
import org.restlet.service.StatusService;
4142

4243
/**
4344
* Converter for the {@link StatusInfo} class.
@@ -72,7 +73,7 @@ public List<Class<?>> getObjectClasses(Variant source) {
7273
* @param status
7374
* The status.
7475
* @return The status information.
75-
* @see #getDefaultRepresentation(Status, Request, Response)
76+
* @see StatusService#toRepresentation(Status, Request, Response)
7677
*/
7778
protected String getStatusLabel(StatusInfo status) {
7879
return (status.getReasonPhrase() != null) ? status.getReasonPhrase()

0 commit comments

Comments
 (0)