use of com.enonic.xp.impl.server.rest.model.ApplicationInstalledJson in project xp by enonic.
the class ApplicationResource method installApplication.
private ApplicationInstallResultJson installApplication(final URL url, byte[] sha512) {
final ApplicationInstallResultJson result = new ApplicationInstallResultJson();
try {
final Application application = this.applicationService.installGlobalApplication(url, sha512);
result.setApplicationInstalledJson(new ApplicationInstalledJson(application, false));
} catch (Exception e) {
final String failure = "Failed to process application from " + url;
LOG.error(failure, e);
result.setFailure(failure);
}
return result;
}
use of com.enonic.xp.impl.server.rest.model.ApplicationInstalledJson in project xp by enonic.
the class ApplicationResource method installApplication.
private ApplicationInstallResultJson installApplication(final ByteSource byteSource, final String applicationName) {
final ApplicationInstallResultJson result = new ApplicationInstallResultJson();
try {
final Application application = this.applicationService.installGlobalApplication(byteSource, applicationName);
result.setApplicationInstalledJson(new ApplicationInstalledJson(application, false));
} catch (Exception e) {
final String failure = "Failed to process application " + applicationName;
LOG.error(failure, e);
result.setFailure(failure);
}
return result;
}
use of com.enonic.xp.impl.server.rest.model.ApplicationInstalledJson in project xp by enonic.
the class ApplicationResourceTest method install.
@Test
public void install() throws Exception {
ApplicationResource resource = getResourceInstance();
ByteSource byteSource = ByteSource.wrap("bytes".getBytes());
Application application = createApplication();
MultipartItem multipartItem = Mockito.mock(MultipartItem.class);
Mockito.when(multipartItem.getBytes()).thenReturn(byteSource);
String fileName = application.getDisplayName();
Mockito.when(multipartItem.getFileName()).thenReturn(fileName);
MultipartForm multipartForm = Mockito.mock(MultipartForm.class);
Mockito.when(this.applicationService.installGlobalApplication(Mockito.isA(ByteSource.class), eq(fileName))).thenReturn(application);
Mockito.when(multipartForm.get("file")).thenReturn(multipartItem);
ApplicationInstallResultJson result = resource.install(multipartForm);
assertEquals(new ApplicationInstalledJson(application, false), result.getApplicationInstalledJson());
}
Aggregations