@Test public void initPlaygroundRepository() { service.initPlaygroundRepository(); final ExampleRepository exampleRepository = service.getPlaygroundRepository(); assertNotNull(exampleRepository); }
@PostConstruct public void initPlaygroundRepository() { URL resource = getClass().getClassLoader().getResource(KIE_WB_PLAYGROUND_ZIP); if (resource == null) { logger.warn("Playground repository jar not found on classpath."); return; } String userDir = System.getProperty("user.dir"); md5 = calculateMD5(resource); playgroundRootDirectory = new File(userDir, PLAYGROUND_DIRECTORY); File playgroundDirectory = new File(playgroundRootDirectory, md5); File doneMarker = new File(playgroundDirectory, DONE_MARKER_NAME); this.playgroundSpaceName = PREFIX + md5; String repositoryUrl = resolveRepositoryUrl(playgroundDirectory.getAbsolutePath()); if (!playgroundDirectory.exists()) { playgroundDirectory.mkdirs(); } FileSystemLock physicalLock = createLock(); try { physicalLock.lock(); if (!doneMarker.exists()) { unzipPlayground(resource, playgroundDirectory); doneMarker.createNewFile(); } if (!this.existSpace(playgroundSpaceName)) { this.createPlaygroundHiddenSpace(md5); spaceConfigStorageRegistry.getBatch(playgroundSpaceName).run(spaceConfigStorageBatchContext -> { this.deleteOldPlaygrounds(md5); this.deleteOldHiddenSpaces(md5); this.cloneRepository(repositoryUrl); return null; }); } } catch (Exception e) { String message = "Can't create examples playground"; logger.error(message); throw new ImportExamplesException(message, e); } finally { physicalLock.unlock(); } playgroundRepository = new ExampleRepository(repositoryUrl); }
ExamplesServiceImpl extends BaseProjectImportService implements ExamplesService { @PostConstruct public void initPlaygroundRepository() { URL resource = getClass().getClassLoader().getResource(KIE_WB_PLAYGROUND_ZIP); if (resource == null) { logger.warn("Playground repository jar not found on classpath."); return; } String userDir = System.getProperty("user.dir"); md5 = calculateMD5(resource); playgroundRootDirectory = new File(userDir, PLAYGROUND_DIRECTORY); File playgroundDirectory = new File(playgroundRootDirectory, md5); File doneMarker = new File(playgroundDirectory, DONE_MARKER_NAME); this.playgroundSpaceName = PREFIX + md5; String repositoryUrl = resolveRepositoryUrl(playgroundDirectory.getAbsolutePath()); if (!playgroundDirectory.exists()) { playgroundDirectory.mkdirs(); } FileSystemLock physicalLock = createLock(); try { physicalLock.lock(); if (!doneMarker.exists()) { unzipPlayground(resource, playgroundDirectory); doneMarker.createNewFile(); } if (!this.existSpace(playgroundSpaceName)) { this.createPlaygroundHiddenSpace(md5); spaceConfigStorageRegistry.getBatch(playgroundSpaceName).run(spaceConfigStorageBatchContext -> { this.deleteOldPlaygrounds(md5); this.deleteOldHiddenSpaces(md5); this.cloneRepository(repositoryUrl); return null; }); } } catch (Exception e) { String message = "Can't create examples playground"; logger.error(message); throw new ImportExamplesException(message, e); } finally { physicalLock.unlock(); } playgroundRepository = new ExampleRepository(repositoryUrl); } }
ExamplesServiceImpl extends BaseProjectImportService implements ExamplesService { @PostConstruct public void initPlaygroundRepository() { URL resource = getClass().getClassLoader().getResource(KIE_WB_PLAYGROUND_ZIP); if (resource == null) { logger.warn("Playground repository jar not found on classpath."); return; } String userDir = System.getProperty("user.dir"); md5 = calculateMD5(resource); playgroundRootDirectory = new File(userDir, PLAYGROUND_DIRECTORY); File playgroundDirectory = new File(playgroundRootDirectory, md5); File doneMarker = new File(playgroundDirectory, DONE_MARKER_NAME); this.playgroundSpaceName = PREFIX + md5; String repositoryUrl = resolveRepositoryUrl(playgroundDirectory.getAbsolutePath()); if (!playgroundDirectory.exists()) { playgroundDirectory.mkdirs(); } FileSystemLock physicalLock = createLock(); try { physicalLock.lock(); if (!doneMarker.exists()) { unzipPlayground(resource, playgroundDirectory); doneMarker.createNewFile(); } if (!this.existSpace(playgroundSpaceName)) { this.createPlaygroundHiddenSpace(md5); spaceConfigStorageRegistry.getBatch(playgroundSpaceName).run(spaceConfigStorageBatchContext -> { this.deleteOldPlaygrounds(md5); this.deleteOldHiddenSpaces(md5); this.cloneRepository(repositoryUrl); return null; }); } } catch (Exception e) { String message = "Can't create examples playground"; logger.error(message); throw new ImportExamplesException(message, e); } finally { physicalLock.unlock(); } playgroundRepository = new ExampleRepository(repositoryUrl); } @Inject  ExamplesServiceImpl(final @Named("ioStrategy") IOService ioService,
                               final RepositoryFactory repositoryFactory,
                               final KieModuleService moduleService,
                               final OrganizationalUnitService ouService,
                               final WorkspaceProjectService projectService,
                               final MetadataService metadataService,
                               final Event<NewProjectEvent> newProjectEvent,
                               final ProjectScreenService projectScreenService,
                               final ImportProjectValidators validators,
                               final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                               final @Named("systemFS") FileSystem systemFS,
                               final PathUtil pathUtil,
                               final RepositoryService repoService); }
ExamplesServiceImpl extends BaseProjectImportService implements ExamplesService { @PostConstruct public void initPlaygroundRepository() { URL resource = getClass().getClassLoader().getResource(KIE_WB_PLAYGROUND_ZIP); if (resource == null) { logger.warn("Playground repository jar not found on classpath."); return; } String userDir = System.getProperty("user.dir"); md5 = calculateMD5(resource); playgroundRootDirectory = new File(userDir, PLAYGROUND_DIRECTORY); File playgroundDirectory = new File(playgroundRootDirectory, md5); File doneMarker = new File(playgroundDirectory, DONE_MARKER_NAME); this.playgroundSpaceName = PREFIX + md5; String repositoryUrl = resolveRepositoryUrl(playgroundDirectory.getAbsolutePath()); if (!playgroundDirectory.exists()) { playgroundDirectory.mkdirs(); } FileSystemLock physicalLock = createLock(); try { physicalLock.lock(); if (!doneMarker.exists()) { unzipPlayground(resource, playgroundDirectory); doneMarker.createNewFile(); } if (!this.existSpace(playgroundSpaceName)) { this.createPlaygroundHiddenSpace(md5); spaceConfigStorageRegistry.getBatch(playgroundSpaceName).run(spaceConfigStorageBatchContext -> { this.deleteOldPlaygrounds(md5); this.deleteOldHiddenSpaces(md5); this.cloneRepository(repositoryUrl); return null; }); } } catch (Exception e) { String message = "Can't create examples playground"; logger.error(message); throw new ImportExamplesException(message, e); } finally { physicalLock.unlock(); } playgroundRepository = new ExampleRepository(repositoryUrl); } @Inject  ExamplesServiceImpl(final @Named("ioStrategy") IOService ioService,
                               final RepositoryFactory repositoryFactory,
                               final KieModuleService moduleService,
                               final OrganizationalUnitService ouService,
                               final WorkspaceProjectService projectService,
                               final MetadataService metadataService,
                               final Event<NewProjectEvent> newProjectEvent,
                               final ProjectScreenService projectScreenService,
                               final ImportProjectValidators validators,
                               final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                               final @Named("systemFS") FileSystem systemFS,
                               final PathUtil pathUtil,
                               final RepositoryService repoService); @PostConstruct void initPlaygroundRepository(); @Override ExamplesMetaData getMetaData(); @Override ExampleRepository getPlaygroundRepository(); @Override WorkspaceProjectContextChangeEvent setupExamples(final ExampleOrganizationalUnit exampleTargetOU,
                                                            final List<ImportProject> importProjects); @Override Set<ImportProject> getExampleProjects(OrganizationalUnit targetOu); @Override int priority(); @Override void dispose(); }
ExamplesServiceImpl extends BaseProjectImportService implements ExamplesService { @PostConstruct public void initPlaygroundRepository() { URL resource = getClass().getClassLoader().getResource(KIE_WB_PLAYGROUND_ZIP); if (resource == null) { logger.warn("Playground repository jar not found on classpath."); return; } String userDir = System.getProperty("user.dir"); md5 = calculateMD5(resource); playgroundRootDirectory = new File(userDir, PLAYGROUND_DIRECTORY); File playgroundDirectory = new File(playgroundRootDirectory, md5); File doneMarker = new File(playgroundDirectory, DONE_MARKER_NAME); this.playgroundSpaceName = PREFIX + md5; String repositoryUrl = resolveRepositoryUrl(playgroundDirectory.getAbsolutePath()); if (!playgroundDirectory.exists()) { playgroundDirectory.mkdirs(); } FileSystemLock physicalLock = createLock(); try { physicalLock.lock(); if (!doneMarker.exists()) { unzipPlayground(resource, playgroundDirectory); doneMarker.createNewFile(); } if (!this.existSpace(playgroundSpaceName)) { this.createPlaygroundHiddenSpace(md5); spaceConfigStorageRegistry.getBatch(playgroundSpaceName).run(spaceConfigStorageBatchContext -> { this.deleteOldPlaygrounds(md5); this.deleteOldHiddenSpaces(md5); this.cloneRepository(repositoryUrl); return null; }); } } catch (Exception e) { String message = "Can't create examples playground"; logger.error(message); throw new ImportExamplesException(message, e); } finally { physicalLock.unlock(); } playgroundRepository = new ExampleRepository(repositoryUrl); } @Inject  ExamplesServiceImpl(final @Named("ioStrategy") IOService ioService,
                               final RepositoryFactory repositoryFactory,
                               final KieModuleService moduleService,
                               final OrganizationalUnitService ouService,
                               final WorkspaceProjectService projectService,
                               final MetadataService metadataService,
                               final Event<NewProjectEvent> newProjectEvent,
                               final ProjectScreenService projectScreenService,
                               final ImportProjectValidators validators,
                               final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                               final @Named("systemFS") FileSystem systemFS,
                               final PathUtil pathUtil,
                               final RepositoryService repoService); @PostConstruct void initPlaygroundRepository(); @Override ExamplesMetaData getMetaData(); @Override ExampleRepository getPlaygroundRepository(); @Override WorkspaceProjectContextChangeEvent setupExamples(final ExampleOrganizationalUnit exampleTargetOU,
                                                            final List<ImportProject> importProjects); @Override Set<ImportProject> getExampleProjects(OrganizationalUnit targetOu); @Override int priority(); @Override void dispose();  }