本文整理汇总了Java中io.github.ibuildthecloud.gdapi.id.TypeIdFormatter类的典型用法代码示例。如果您正苦于以下问题:Java TypeIdFormatter类的具体用法?Java TypeIdFormatter怎么用?Java TypeIdFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeIdFormatter类属于io.github.ibuildthecloud.gdapi.id包,在下文中一共展示了TypeIdFormatter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: link
import io.github.ibuildthecloud.gdapi.id.TypeIdFormatter; //导入依赖的package包/类
@Override
public Object link(String name, Object obj, ApiRequest request) throws IOException {
Stack stack = (Stack) obj;
IdFormatter idFormatter = new TypeIdFormatter(request.getSchemaFactory());
String compose = composeExportService.buildComposeConfig(idFormatter.formatId(stack.getKind(), stack.getId()).toString());
if (StringUtils.isNotEmpty(compose)) {
ByteArrayOutputStream baos = zipFiles(compose);
HttpServletResponse response = request.getServletContext().getResponse();
response.setContentLength(baos.toByteArray().length);
response.setContentType("application/zip");
response.setHeader("Content-Encoding", "zip");
response.setHeader("Content-Disposition", String.format("attachment; filename=%s.zip", stack.getName()));
response.setHeader("Cache-Control", "private");
response.setHeader("Pragma", "private");
response.setHeader("Expires", "Wed 24 Feb 1982 18:42:00 GMT");
response.getOutputStream().write(baos.toByteArray());
return new Object();
}
return null;
}
示例2: perform
import io.github.ibuildthecloud.gdapi.id.TypeIdFormatter; //导入依赖的package包/类
@Override
public Object perform(Object obj, ApiRequest request) {
if (!(obj instanceof Stack)) {
return null;
}
Stack stack = (Stack) obj;
List<? extends Long> serviceIds = DataAccessor.fromMap(request.getRequestObject())
.withKey(ServiceConstants.FIELD_SERVICE_IDS).asList(Long.class);
List<? extends Service> services = objectManager.children(stack, Service.class);
List<Service> toExport = new ArrayList<>();
for (Service service : services) {
// export only non-removed requested services
if ((serviceIds == null || serviceIds.isEmpty()) || serviceIds.contains(service.getId())) {
if (service.getRemoved() == null && !service.getState().equals(CommonStatesConstants.REMOVED)) {
toExport.add(service);
}
}
}
String composeConfig = "";
try {
IdFormatter idFormatter = new TypeIdFormatter(request.getSchemaFactory());
composeConfig = composeExportService.buildComposeConfig(idFormatter.formatId(stack.getKind(), stack.getId()).toString());
} catch (IOException e) {
e.printStackTrace();
}
return new ComposeConfig(composeConfig);
}
示例3: buildIdFormatter
import io.github.ibuildthecloud.gdapi.id.TypeIdFormatter; //导入依赖的package包/类
private IdFormatter buildIdFormatter() {
TypeIdFormatter idFormatter = new TypeIdFormatter(coreSchemaFactory);
Map<String, String> mapping = new HashMap<>();
mapping.put("stack", "st");
mapping.put("secret", "se");
idFormatter.setSchemaFactory(coreSchemaFactory);
idFormatter.setPlainTypes(new HashSet<>(Arrays.asList("typeDocumentation", "scripts")));
idFormatter.setTypeMappings(mapping);
return idFormatter;
}