本文整理匯總了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;
}