Search in sources :

Example 71 with ApplicationKey

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

the class ApplicationFactoryServiceImplTest method findActiveApplication.

@Test
void findActiveApplication() throws Exception {
    final BundleContext bundleContext = getBundleContext();
    final ApplicationFactoryServiceImpl service = new ApplicationFactoryServiceImpl(bundleContext);
    service.activate();
    final String appName = "app1";
    final ApplicationKey applicationKey = ApplicationKey.from(appName);
    final Bundle bundle = deploy(appName, newBundle(appName, true));
    assertThat(service.findActiveApplication(applicationKey)).isEmpty();
    bundle.start();
    assertThat(service.findActiveApplication(applicationKey)).isNotEmpty();
    bundle.stop();
    assertThat(service.findActiveApplication(applicationKey)).isEmpty();
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Bundle(org.osgi.framework.Bundle) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.jupiter.api.Test)

Example 72 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey 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 73 with ApplicationKey

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

the class ApplicationServiceImpl method doInstallStoredApplication.

private Application doInstallStoredApplication(final NodeId nodeId) {
    final ByteSource byteSource = this.repoService.getApplicationSource(nodeId);
    if (byteSource == null) {
        throw new ApplicationInstallException("Cannot install application with id [" + nodeId + "], source not found");
    }
    final ApplicationKey applicationKey = getApplicationKey(byteSource);
    if (!appFilterService.accept(applicationKey)) {
        LOG.info("Application {} is not permitted on this instance", applicationKey);
        return null;
    }
    return installOrUpdateApplication(byteSource, applicationKey, false, false);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) ByteSource(com.google.common.io.ByteSource)

Example 74 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey 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 75 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey 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)

Aggregations

ApplicationKey (com.enonic.xp.app.ApplicationKey)78 Test (org.junit.jupiter.api.Test)40 Application (com.enonic.xp.app.Application)16 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)12 Bundle (org.osgi.framework.Bundle)10 ResourceKey (com.enonic.xp.resource.ResourceKey)6 PropertyTree (com.enonic.xp.data.PropertyTree)5 ExtraData (com.enonic.xp.content.ExtraData)4 Site (com.enonic.xp.site.Site)4 Node (com.enonic.xp.node.Node)3 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 PortalRequest (com.enonic.xp.portal.PortalRequest)3 PortalResponse (com.enonic.xp.portal.PortalResponse)3 XDataName (com.enonic.xp.schema.xdata.XDataName)3 ByteSource (com.google.common.io.ByteSource)3 ApplicationInvalidator (com.enonic.xp.app.ApplicationInvalidator)2 ExtraDatas (com.enonic.xp.content.ExtraDatas)2 PropertySet (com.enonic.xp.data.PropertySet)2 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)2 RenderException (com.enonic.xp.portal.impl.rendering.RenderException)2