use of org.jboss.tools.openshift.internal.ui.wizard.newapp.fromtemplate.TemplateApplicationSource in project jbosstools-openshift by jbosstools.
the class NewApplicationWizardModel method getLocalAppSource.
private IApplicationSource getLocalAppSource(IProgressMonitor monitor, String filename) {
if (StringUtils.isBlank(filename)) {
return null;
}
IResource resource = null;
filename = VariablesHelper.replaceVariables(filename);
try {
if (!OpenshiftUIConstants.URL_VALIDATOR.isValid(filename) && !Files.isRegularFile(Paths.get(filename))) {
return null;
}
try (InputStream input = createInputStream(filename, monitor)) {
resource = resourceFactory.create(input);
if (resource != null && !(resource instanceof ITemplate)) {
throw new NotATemplateException(resource.getKind());
}
}
} catch (FileNotFoundException e) {
throw new OpenShiftException(e, NLS.bind("Could not find the file \"{0}\" to upload", filename));
} catch (IOException e) {
throw new OpenShiftException(e, NLS.bind("Error reading the file or URL \"{0}\" to upload", filename));
} catch (ResourceFactoryException | ClassCastException e) {
throw e;
}
switch(resource.getKind()) {
case ResourceKind.TEMPLATE:
return new TemplateApplicationSource((ITemplate) resource);
}
throw new OpenShiftException("Creating applications from local files is only allowed using a template");
}
Aggregations