本文整理汇总了Java中org.raml.model.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于org.raml.model包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.raml.model.Action; //导入依赖的package包/类
@Override
public void apply(Action action, ResourceClassBuilder resourceClassBuilder) {
LOG.info("Process action {}", action);
resourceClassBuilder.getApiClass().withMethod(
new ActionMethod(resourceClassBuilder.getReq(),
resourceClassBuilder.getResp(),
resourceClassBuilder.getUri(),
action));
action.getQueryParameters().forEach(resourceClassBuilder.applyParamRule);
action.getHeaders().forEach(resourceClassBuilder.applyParamRule);
if (action.getBody() != null) {
action.getBody().values().forEach(resourceClassBuilder.applyBodyRule);
}
action.getResponses().values().forEach(resourceClassBuilder.applyResponseRule);
}
示例2: cleanupMethods
import org.raml.model.Action; //导入依赖的package包/类
private void cleanupMethods (Resource resource, Map<ActionType, Action> actions) {
final HashSet<String> methods = new HashSet<>();
for (ActionType action : actions.keySet()) {
methods.add(action.toString());
}
for (Method m : resource.getResourceMethods().values()) {
String httpMethod = m.getHttpMethod().toUpperCase();
if (!methods.contains(httpMethod)) {
LOG.info(format("Removing deleted method %s for resource %s", httpMethod, resource.getId()));
m.deleteMethod();
}
}
}
示例3: processResourceActions
import org.raml.model.Action; //导入依赖的package包/类
private void processResourceActions(Resource resource, DataObjectInfo doi, DataObjectInfo parentDataObject, boolean isNestedResource)
{
Map<ActionType, Action> actions = resource.getActions();
for (ActionType actionType: actions.keySet())
{
Action action = actions.get(actionType);
if ("GET".equalsIgnoreCase(actionType.name()))
{
processGETResponse(resource, doi, parentDataObject, action, isNestedResource);
}
else
{
processNonGETRequest(resource, doi, parentDataObject, action);
}
}
}
示例4: addQueryParameters
import org.raml.model.Action; //导入依赖的package包/类
private void addQueryParameters(Action action, DCMethod method)
{
Map<String, QueryParameter> params = action.getQueryParameters();
for (String paramName : params.keySet())
{
QueryParameter param = params.get(paramName);
DCMethodParameter methodParam = new DCMethodParameter();
methodParam.setPathParam(false);
methodParam.setName(paramName);
ParamType paramType = param.getType();
String type = paramType != null? paramType.name(): "string";
Class javaType = typeMapping.get(type);
if (javaType==null)
{
javaType = String.class;
methodParam.setJavaType(javaType.getName());
}
method.addParam(methodParam);
}
}
示例5: addHeaders
import org.raml.model.Action; //导入依赖的package包/类
private void addHeaders(Action action, DCMethod method)
{
// first add common headers, based on mediaType
method.getHeaderParams().addAll(headerParams);
Map<String, Header> headers = action.getHeaders();
for (String headerName : headers.keySet())
{
Header header = headers.get(headerName);
HeaderParam param = new HeaderParam();
// for some strange reason, the header param names are suffixed with "-header". so we remove it
String name = headerName.endsWith("-header") ? headerName.substring(0,headerName.length()-7) : headerName;
param.setName(name);
if (header.getDefaultValue()!=null)
{
param.setValue(header.getDefaultValue());
}
method.addHeaderParam(param);
}
}
示例6: check
import org.raml.model.Action; //导入依赖的package包/类
public void check(RamlRequest request, RamlResponse response, Action action, MediaTypeMatch typeMatch) {
final String accept = acceptHeader(request, response, typeMatch);
if (accept == null) {
return;
}
MediaType bestMatch = null;
for (final MediaType acceptType : acceptMediaTypes(accept)) {
for (final MediaType modelType : typeMatch.getDefinedTypes()) {
if (acceptType.isCompatibleWith(modelType)) {
if (bestMatch == null) {
bestMatch = acceptType;
}
if (typeMatch.getMatchingMedia().equals(modelType)) {
if (acceptType.getQualityParameter() < bestMatch.getQualityParameter()) {
final Locator locator = new Locator(action);
locator.responseCode(Integer.toString(response.getStatus()));
responseViolations.add(new Message("mediaType.better", locator, accept, bestMatch, response.getContentType()));
}
return;
}
}
}
}
responseViolations.add(new Message("contentType.mismatch", accept, response.getContentType()));
}
示例7: renderExample
import org.raml.model.Action; //导入依赖的package包/类
public String renderExample(String uri, String method, String status, String mimeType) {
Action action = getResourceContext(uri).getAction(ActionType.valueOf(method.toUpperCase()));
String exampleFormat = "<div class=\"listingblock\">" +
"<div class=\"content\">" +
"<pre class=\"CodeRay highlight raml_example\">%s</pre>" +
"</div>" +
"</div>";
if (status != null) {
String exampleForResponse = getResponseForAction(action, status).getBody().get(mimeType).getExample();
return String.format(exampleFormat, exampleForResponse);
} else {
return String.format(exampleFormat, action.getBody().get(mimeType).getExample());
}
}
示例8: ActionMethod
import org.raml.model.Action; //导入依赖的package包/类
public ActionMethod(ReqSpecField reqFieldName, RespSpecField respFieldName, UriConst uriConst, Action action) {
this.reqFieldName = reqFieldName.name();
this.respFieldName = respFieldName.name();
this.uriConst = uriConst.name();
this.action = action;
this.httpMethod = action.getType().name().toLowerCase();
this.name = defaultIfEmpty(action.getDisplayName(), httpMethod);
}
示例9: getProperty
import org.raml.model.Action; //导入依赖的package包/类
@Override
public Object getProperty(Interpreter interp, ST self, Object o, Object property, String propertyName) throws STNoSuchPropertyException {
final Action a = (Action) o;
switch (propertyName) {
case "securitySchemes":
if (a.getSecuredBy() != null && !a.getSecuredBy().isEmpty()) {
return a.getSecuredBy();
}
if (a.getResource().getSecuredBy() != null && !a.getResource().getSecuredBy().isEmpty()) {
return a.getResource().getSecuredBy();
}
if (raml.getSecuredBy() != null && !raml.getSecuredBy().isEmpty()) {
return raml.getSecuredBy();
}
return Collections.emptyList();
case "type":
return a.getType().toString();
case "responses":
return new TreeMap<>(a.getResponses());
case "queryParameters":
return new TreeMap<>(a.getQueryParameters());
case "headers":
return new TreeMap<>(a.getHeaders());
case "body":
return a.getBody() == null ? null : new TreeMap<>(a.getBody());
default:
return super.getProperty(interp, self, o, property, propertyName);
}
}
示例10: createMethods
import org.raml.model.Action; //导入依赖的package包/类
private void createMethods(RestApi api, Resource resource, Map<String, UriParameter> requestParameters,
Map<ActionType, Action> actions, boolean update) {
for (Map.Entry<ActionType, Action> entry : actions.entrySet()) {
createMethod(api, resource, entry.getKey(), entry.getValue(), requestParameters, update);
}
if (update) {
cleanupMethods(resource, actions);
}
}
示例11: toJavaMethodName
import org.raml.model.Action; //导入依赖的package包/类
public static String toJavaMethodName(Action action) {
final List<String> nameElements =
stream(spliterator(action.getResource().getUri().split("\\/")), false)
.filter(path -> !path.matches(".*\\{[^\\}]*\\}.*"))
.map(path -> stream(spliterator(path.split("(?i:[^a-z0-9])")), false)
.map(StringUtils::capitalize)
.collect(toList()))
.flatMap(tokens -> tokens.stream())
.collect(toList());
return Joiner.on("").join(Iterables.concat(Collections.singleton(action.getType().name().toLowerCase()), nameElements));
}
示例12: validate
import org.raml.model.Action; //导入依赖的package包/类
@Override
public ValidationErrors validate() {
ValidationErrors errors = new ValidationErrors();
Action action = expectation.getAction()
.orElseThrow(() -> new NoValidActionException(expectation));
if (!action.hasBody())
return errors;
Optional<String> requestBody = expectation.getRequestBody();
if (action.hasBody() && !requestBody.isPresent()) {
errors.addMessage("[ request ] Has an expected request body but none provided.");
return errors;
}
MediaType contentType = expectation.getRequestContentType();
if (contentType.isWildcardType()) {
errors.addMessage("[ request ] Wildcard or no content type provided in request.");
return errors;
}
Optional<BodySpecification> body = expectation.getRequestBodySpecification();
if (!body.isPresent()) {
errors.addMessage("[ request ] No request specification exists for [ %s ]. Acceptable content types are [ %s ]", contentType, getAllowedContentTypes(action.getBody()));
return errors;
}
errors.combineWith(body.get().validate(requestBody.get()));
return errors;
}
示例13: createMethods
import org.raml.model.Action; //导入依赖的package包/类
private void createMethods(RestApi api, Resource resource, Map<ActionType, Action> actions, boolean update) {
for (Map.Entry<ActionType, Action> entry : actions.entrySet()) {
createMethod(api, resource, entry.getKey(), entry.getValue(), update);
}
if (update) {
cleanupMethods(resource, actions);
}
}
示例14: createRamlAction
import org.raml.model.Action; //导入依赖的package包/类
@Override
public RamlAction createRamlAction(Object action) {
if (action == null) {
return null;
}
return new RJP08V1RamlAction((Action) action);
}
示例15: render
import org.raml.model.Action; //导入依赖的package包/类
@Override
public Bundle render(Raml aRoot, Map<String, String> someOpts) {
STGroup stg = new STGroupFile(stgFile);
stg.registerModelAdaptor(Resource.class, new ResourceAdaptator());
stg.registerModelAdaptor(Raml.class, new RamlAdaptator());
stg.registerModelAdaptor(Action.class, new ActionAdaptator(aRoot));
stg.registerModelAdaptor(Response.class, new ResponseAdaptator());
stg.registerModelAdaptor(MimeType.class, new MimeTypeAdaptator());
Map<String, String> oOpts=new HashMap<String, String>(someOpts);
oOpts.put("title", Utils.cleanString(aRoot.getTitle()));
if(someOpts.get("baseUri")!=null) {
aRoot.setBaseUri(someOpts.get("baseUri"));
}
aRoot.setBaseUri(Utils.resolve(aRoot.getBaseUri(), "version", aRoot.getVersion()));
Bundle oBundle=null;
ST oRootPath=getST(stg,"rootPath", aRoot, oOpts);
if(oRootPath!=null) {
oBundle=new Bundle(oRootPath.render());
} else {
oBundle=new Bundle(someOpts.get(Generator.GENERATED_PATH));
}
for(String oName:rootTemplateNames) {
ST oContent = getST(stg,oName, aRoot, oOpts);
ST oFileName = getST(stg,oName+"_file", aRoot,oOpts);
oBundle.addItem(oFileName.render(), oContent.render());
}
return oBundle;
}