Search in sources :

Example 56 with Application

use of com.enonic.xp.app.Application in project xp by enonic.

the class ApplicationServiceImpl method doInstallGlobalApplication.

private Application doInstallGlobalApplication(final ByteSource byteSource) {
    final ApplicationKey applicationKey = getApplicationKey(byteSource);
    if (!appFilterService.accept(applicationKey)) {
        throw new ApplicationInstallException(String.format("Application %s is not permitted on this instance", applicationKey));
    }
    final Application application = installOrUpdateApplication(byteSource, applicationKey, false, true);
    LOG.info("Global Application [{}] installed successfully", applicationKey);
    doPublishInstalledEvent(applicationKey);
    doStartApplication(applicationKey, true, false);
    return application;
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Application(com.enonic.xp.app.Application)

Example 57 with Application

use of com.enonic.xp.app.Application in project xp by enonic.

the class ApplicationServiceImpl method installGlobalApplication.

@Override
public Application installGlobalApplication(final URL url, final byte[] sha512) {
    return ApplicationHelper.callWithContext(() -> {
        final Application application = doInstallGlobalApplication(applicationLoader.load(url, sha512));
        applicationAuditLogSupport.installApplication(application.getKey(), url);
        return application;
    });
}
Also used : Application(com.enonic.xp.app.Application)

Example 58 with Application

use of com.enonic.xp.app.Application in project xp by enonic.

the class ApplicationServiceImpl method doInstallStoredApplications.

private void doInstallStoredApplications(final ApplicationInstallationParams params) {
    LOG.info("Searching for installed applications");
    final Nodes applicationNodes = repoService.getApplications();
    LOG.info("Found [" + applicationNodes.getSize() + "] installed applications");
    for (final Node applicationNode : applicationNodes) {
        try {
            final Application application = doInstallStoredApplication(applicationNode.id());
            if (application == null) {
                continue;
            }
            final ApplicationKey applicationKey = application.getKey();
            LOG.info("Stored application [{}] installed successfully", applicationKey);
            if (params.isTriggerEvent()) {
                doPublishInstalledEvent(applicationNode);
            }
            if (params.isStart() && storedApplicationIsStarted(applicationNode)) {
                doStartApplication(applicationKey, params.isTriggerEvent(), false);
            }
        } catch (Exception e) {
            LOG.error("Cannot install application [{}]", applicationNode.name(), e);
        }
    }
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Node(com.enonic.xp.node.Node) Application(com.enonic.xp.app.Application) Nodes(com.enonic.xp.node.Nodes) BundleException(org.osgi.framework.BundleException) IOException(java.io.IOException)

Example 59 with Application

use of com.enonic.xp.app.Application in project xp by enonic.

the class ApplicationServiceImpl method doInstallStoredApplication.

private Application doInstallStoredApplication(final NodeId nodeId, final ApplicationInstallationParams params) {
    final Application application = doInstallStoredApplication(nodeId);
    if (application == null) {
        return null;
    }
    final ApplicationKey applicationKey = application.getKey();
    LOG.info("Stored application [{}] installed successfully", applicationKey);
    if (params.isTriggerEvent()) {
        doPublishInstalledEvent(applicationKey);
    }
    if (params.isStart()) {
        doStartApplication(applicationKey, params.isTriggerEvent(), false);
    }
    return application;
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Application(com.enonic.xp.app.Application)

Example 60 with Application

use of com.enonic.xp.app.Application in project xp by enonic.

the class ApplicationClusterEventListenerTest method uninstall.

@Test
void uninstall() {
    final Application application = mock(Application.class);
    final ApplicationKey appKey = ApplicationKey.from("appKey");
    when(application.getKey()).thenReturn(appKey);
    this.applicationClusterEventListener.onEvent(Event.create(ApplicationClusterEvents.EVENT_TYPE).localOrigin(false).value(ApplicationClusterEvents.EVENT_TYPE_KEY, ApplicationClusterEvents.UNINSTALL).value(ApplicationClusterEvents.APPLICATION_KEY_PARAM, appKey).build());
    verify(this.applicationService, times(1)).uninstallApplication(appKey, false);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Aggregations

Application (com.enonic.xp.app.Application)68 Test (org.junit.jupiter.api.Test)42 ApplicationKey (com.enonic.xp.app.ApplicationKey)20 Node (com.enonic.xp.node.Node)16 Bundle (org.osgi.framework.Bundle)16 ByteSource (com.google.common.io.ByteSource)12 URL (java.net.URL)11 ResourceKey (com.enonic.xp.resource.ResourceKey)9 ApplicationService (com.enonic.xp.app.ApplicationService)8 ResourceService (com.enonic.xp.resource.ResourceService)8 BundleContext (org.osgi.framework.BundleContext)8 UrlResource (com.enonic.xp.resource.UrlResource)7 ScriptAsyncService (com.enonic.xp.script.impl.async.ScriptAsyncService)7 ScriptRuntimeFactoryImpl (com.enonic.xp.script.impl.standard.ScriptRuntimeFactoryImpl)7 PortalScriptServiceImpl (com.enonic.xp.portal.impl.script.PortalScriptServiceImpl)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 IOException (java.io.IOException)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 PropertyTree (com.enonic.xp.data.PropertyTree)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4