use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorage method load.
@Override
public List<ServerTemplate> load() {
logger.debug("About to load all available server templates...");
final List<ServerTemplate> result = new ArrayList<ServerTemplate>();
final Path dir = buildPath(null);
try {
ioService.startBatch(dir.getFileSystem());
for (final Path registeredServer : ioService.newDirectoryStream(dir)) {
try {
ServerTemplate serverTemplate = readServerTemplate(registeredServer);
logger.debug("Found server template {}", serverTemplate);
result.add(serverTemplate);
} catch (final Exception ignore) {
ioService.delete(registeredServer);
}
}
logger.debug("All found server templates {}", result);
return result;
} catch (final NotDirectoryException ignore) {
logger.debug("No directory found {}, returning empty result", dir);
return result;
} finally {
ioService.endBatch();
}
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorage method loadKeys.
@Override
public List<ServerTemplateKey> loadKeys() {
logger.debug("About to load all available server templates (as keys only)...");
final List<ServerTemplateKey> result = new ArrayList<ServerTemplateKey>();
final Path dir = buildPath(null);
try {
ioService.startBatch(dir.getFileSystem());
for (final Path registeredServer : ioService.newDirectoryStream(dir)) {
try {
ServerTemplate serverTemplate = readServerTemplate(registeredServer);
logger.debug("Found server template {}, taking its short key version...");
result.add(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
} catch (final Exception ignore) {
ioService.delete(registeredServer);
}
}
logger.debug("All found server template keys {}", result);
return result;
} catch (final NotDirectoryException ignore) {
logger.debug("No directory found {}, returning empty result", dir);
return result;
} finally {
ioService.endBatch();
}
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorage method delete.
@Override
public ServerTemplate delete(final String identifier) {
logger.debug("About to remove server template with id {}", identifier);
final Path path = buildPath(identifier);
ServerTemplate serverTemplate = null;
try {
ioService.startBatch(path.getFileSystem());
serverTemplate = readServerTemplate(path);
ioService.delete(path);
} finally {
ioService.endBatch();
}
logger.debug("Server template with id {}, removed successfully", identifier);
return serverTemplate;
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class RuntimeManagementServiceCDITest method getContainersByServerInstance_returnsEmptyList_whenInstanceWithIdDoesntExistInTemplate.
@Test
public void getContainersByServerInstance_returnsEmptyList_whenInstanceWithIdDoesntExistInTemplate() {
final String templateId = "templateId";
final String serverInstanceId = "serverInstanceId";
KieServerTemplateStorage templateStorageMock = mock(KieServerTemplateStorage.class);
when(templateStorageMock.load(eq(templateId))).thenReturn(new ServerTemplate(null, null, Collections.emptyList(), Collections.emptyMap(), Collections.emptyList(), Collections.emptyList()));
// Setup tested service
runtimeManagementService.setTemplateStorage(templateStorageMock);
specManagementService.setTemplateStorage(templateStorageMock);
// Tested method
Collection<Container> containers = runtimeManagementServiceCDI.getContainersByServerInstance(templateId, serverInstanceId);
assertThat(containers).as("List of containers should be empty, when Server template doesn't contain server instance id").isEmpty();
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class BuildExecutor method saveContainerSpec.
private void saveContainerSpec(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final Boolean startContainer, final Map<String, String> parameters) {
if (containerId != null && serverTemplate != null && serverTemplate.getId() != null) {
final ContainerSpec containerSpec = makeContainerSpec(containerId, containerAlias, serverTemplate, parameters);
specManagementService.call(aVoid -> {
notificationEvent.fire(new NotificationEvent(ProjectEditorResources.CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS));
if (startContainer) {
startContainer(containerSpec);
}
}).saveContainerSpec(serverTemplate.getId(), containerSpec);
}
}
Aggregations