本文整理汇总了Java中com.google.api.server.spi.Constant类的典型用法代码示例。如果您正苦于以下问题:Java Constant类的具体用法?Java Constant怎么用?Java Constant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constant类属于com.google.api.server.spi包,在下文中一共展示了Constant类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSetScopesIfSpecified_unspecified
import com.google.api.server.spi.Constant; //导入依赖的package包/类
@Test
public void testSetScopesIfSpecified_unspecified() throws Exception {
String[] unspecified = {Api.UNSPECIFIED_STRING_FOR_LIST};
EndpointMethod method = getResultNoParamsMethod();
annotationConfig.setScopesIfSpecified(unspecified);
ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().getOrCreate(method);
assertEquals(toScopeExpression(Constant.API_EMAIL_SCOPE), methodConfig.getScopeExpression());
String[] scopes = {"bleh", "more bleh"};
annotationConfig.setScopesIfSpecified(scopes);
annotationConfig.setScopesIfSpecified(null);
assertEquals(toScopeExpression(scopes), config.getScopeExpression());
annotationConfig.setScopesIfSpecified(scopes);
annotationConfig.setScopesIfSpecified(unspecified);
assertEquals(toScopeExpression(scopes), config.getScopeExpression());
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:19,代码来源:ApiAnnotationConfigTest.java
示例2: testSetClientIdsIfSpecified_unspecified
import com.google.api.server.spi.Constant; //导入依赖的package包/类
@Test
public void testSetClientIdsIfSpecified_unspecified() throws Exception {
String[] unspecified = {Api.UNSPECIFIED_STRING_FOR_LIST};
EndpointMethod method = getResultNoParamsMethod();
annotationConfig.setScopesIfSpecified(unspecified);
ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().getOrCreate(method);
assertEquals(ImmutableList.of(Constant.API_EXPLORER_CLIENT_ID), methodConfig.getClientIds());
String[] clientIds = {"bleh", "more bleh"};
annotationConfig.setClientIdsIfSpecified(clientIds);
annotationConfig.setClientIdsIfSpecified(null);
assertEquals(Arrays.asList(clientIds), config.getClientIds());
annotationConfig.setClientIdsIfSpecified(clientIds);
annotationConfig.setClientIdsIfSpecified(unspecified);
assertEquals(Arrays.asList(clientIds), config.getClientIds());
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:19,代码来源:ApiAnnotationConfigTest.java
示例3: writeError
import com.google.api.server.spi.Constant; //导入依赖的package包/类
@Override
public void writeError(ServiceException e) throws IOException {
Map<String, String> errors = new HashMap<>();
errors.put(Constant.ERROR_MESSAGE, e.getMessage());
write(e.getStatusCode(), e.getHeaders(),
writeValueAsString(errors));
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:8,代码来源:ServletResponseResultWriter.java
示例4: wrapCollection
import com.google.api.server.spi.Constant; //导入依赖的package包/类
/**
* Wraps a collection in an "items" property.
*/
static Object wrapCollection(Object value) {
if (isCollection(value)) {
Map<String, Object> wrapped = new HashMap<String, Object>();
wrapped.put(Constant.ITEMS, value);
return wrapped;
} else {
return value;
}
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:13,代码来源:ResponseUtil.java
示例5: setIssuerAudiences
import com.google.api.server.spi.Constant; //导入依赖的package包/类
public void setIssuerAudiences(ApiIssuerAudienceConfig issuerAudiences) {
Preconditions.checkNotNull(issuerAudiences, "issuerAudiences should never be null");
this.issuerAudiences = issuerAudiences;
if (issuerAudiences.hasIssuer(Constant.GOOGLE_ID_TOKEN_NAME)) {
getApiClassConfig().getApiConfig().ensureGoogleIssuer();
}
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:8,代码来源:ApiMethodConfig.java
示例6: setIssuerAudiences
import com.google.api.server.spi.Constant; //导入依赖的package包/类
public void setIssuerAudiences(ApiIssuerAudienceConfig issuerAudiences) {
Preconditions.checkNotNull(issuerAudiences, "issuerAudiences should never be null");
this.issuerAudiences = issuerAudiences;
if (issuerAudiences.hasIssuer(Constant.GOOGLE_ID_TOKEN_NAME)) {
getApiConfig().ensureGoogleIssuer();
}
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:8,代码来源:ApiClassConfig.java
示例7: setIssuerAudiences
import com.google.api.server.spi.Constant; //导入依赖的package包/类
public void setIssuerAudiences(ApiIssuerAudienceConfig issuerAudiences) {
Preconditions.checkNotNull(issuerAudiences, "issuerAudiences should never be null");
this.issuerAudiences = issuerAudiences;
if (issuerAudiences.hasIssuer(Constant.GOOGLE_ID_TOKEN_NAME)) {
ensureGoogleIssuer();
}
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:8,代码来源:ApiConfig.java
示例8: withGoogleIdToken
import com.google.api.server.spi.Constant; //导入依赖的package包/类
public ApiIssuerConfigs withGoogleIdToken() {
if (hasIssuer(Constant.GOOGLE_ID_TOKEN_NAME)
&& hasIssuer(Constant.GOOGLE_ID_TOKEN_NAME_HTTPS)) {
return this;
}
Builder builder = builder();
if (isSpecified()) {
builder.issuerConfigs.putAll(issuerConfigs);
}
builder.addIssuer(GOOGLE_ID_TOKEN_ISSUER);
builder.addIssuer(GOOGLE_ID_TOKEN_ISSUER_ALT);
return builder.build();
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:14,代码来源:ApiIssuerConfigs.java
示例9: addTypeToNode
import com.google.api.server.spi.Constant; //导入依赖的package包/类
/**
* Adds a schema for a type into an output node. For arrays, this generates nested schemas inline
* for however many dimensions are necessary.
*
* @return an appropriate name for the schema if one isn't already assigned
*/
private String addTypeToNode(ObjectNode schemasNode, TypeToken<?> type,
TypeToken<?> enclosingType, ObjectNode node, ApiConfig apiConfig,
List<ApiParameterConfig> parameterConfigs) throws ApiConfigException {
TypeToken<?> itemType = Types.getArrayItemType(type);
if (typeLoader.isSchemaType(type)) {
String basicTypeName = typeLoader.getSchemaType(type);
addElementTypeToNode(schemasNode, type, basicTypeName, node, apiConfig);
return basicTypeName;
} else if (itemType != null) {
ObjectNode items = objectMapper.createObjectNode();
node.put("type", "array");
node.set(Constant.ITEMS, items);
String itemTypeName = addTypeToNode(schemasNode, itemType, enclosingType, items, apiConfig,
parameterConfigs);
String arraySuffix = "Collection";
StringBuilder sb = new StringBuilder(itemTypeName.length() + arraySuffix.length());
sb.append(itemTypeName).append(arraySuffix);
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
return sb.toString();
} else if (type instanceof TypeVariable) {
throw new IllegalArgumentException(
String.format("Object type %s not supported.", type));
} else {
String typeName = addTypeToSchema(schemasNode, type, enclosingType, apiConfig,
parameterConfigs);
addElementTypeToNode(schemasNode, type, typeName, node, apiConfig);
return typeName;
}
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:38,代码来源:JsonConfigWriter.java
示例10: googleAuth
import com.google.api.server.spi.Constant; //导入依赖的package包/类
@ApiMethod(
issuerAudiences = {
@ApiIssuerAudience(name = Constant.GOOGLE_ID_TOKEN_NAME, audiences = "googleaud")
}
)
public void googleAuth() { }
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:7,代码来源:SwaggerGeneratorTest.java
注:本文中的com.google.api.server.spi.Constant类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论