@Override public String execute(CliContext context) { StringBuffer result = new StringBuffer(); WeldContainer container = context.getContainer(); RepositoryService repositoryService = container.instance().select(RepositoryService.class).get(); InputReader input = context.getInput(); System.out.print(">>Repository alias:"); String alias = input.nextLine(); Repository repo = repositoryService.getRepository(alias); if (repo == null) { return "No repository " + alias + " was found"; } System.out.print(">>Security groups (comma separated list):"); String groupsIn = input.nextLine(); if (groupsIn.trim().length() > 0) { String[] groups = groupsIn.split(","); for (String group : groups) { if (repo.getGroups().contains(group)) { continue; } repositoryService.addGroup(repo, group); result.append( "Group " + group + " added successfully to repository " + repo.getAlias() + "\n"); } } return result.toString(); }
public static String readRepositoryURI(RepositoryService repositoryService, String alias) { String uri = null; RepositoryInfo repositoryInfo = alias != null ? repositoryService.getRepositoryInfo(alias) : null; if (repositoryInfo != null && repositoryInfo.getRoot() != null) { uri = repositoryInfo.getRoot().toURI(); } return uri; }
@Override public String execute(CliContext context) { StringBuffer result = new StringBuffer(); WeldContainer container = context.getContainer(); OrganizationalUnitService organizationalUnitService = container.instance().select(OrganizationalUnitService.class).get(); RepositoryService repositoryService = container.instance().select(RepositoryService.class).get(); InputReader input = context.getInput(); System.out.print(">>Organizational Unit name:"); String name = input.nextLine(); System.out.print(">>Organizational Unit owner:"); String owner = input.nextLine(); System.out.print(">>Default Group Id for this Organizational Unit:"); String defaultGroupId = input.nextLine(); System.out.print(">>Repositories (comma separated list):"); String repos = input.nextLine(); Collection<Repository> repositories = new ArrayList<Repository>(); if (repos != null && repos.trim().length() > 0) { String[] repoAliases = repos.split(","); for (String alias : repoAliases) { Repository repo = repositoryService.getRepository(alias); if (repo != null) { repositories.add(repo); } else { System.out.println( "WARN: Repository with alias " + alias + " does not exists and will be skipped"); } } } OrganizationalUnit organizationalUnit = organizationalUnitService.createOrganizationalUnit( name, owner, defaultGroupId, repositories); result.append("Organizational Unit " + organizationalUnit.getName() + " successfully created"); return result.toString(); }
@Override public String execute(CliContext context) { StringBuffer result = new StringBuffer(); WeldContainer container = context.getContainer(); OrganizationalUnitService organizationalUnitService = container.instance().select(OrganizationalUnitService.class).get(); RepositoryService repositoryService = container.instance().select(RepositoryService.class).get(); ExplorerService projectExplorerService = container.instance().select(ExplorerService.class).get(); InputReader input = context.getInput(); System.out.print(">>Repository alias:"); String alias = input.nextLine(); Repository repo = repositoryService.getRepository(alias); if (repo == null) { return "No repository " + alias + " was found"; } OrganizationalUnit ou = null; Collection<OrganizationalUnit> units = organizationalUnitService.getOrganizationalUnits(); for (OrganizationalUnit unit : units) { if (unit.getRepositories().contains(repo)) { ou = unit; break; } } if (ou == null) { return "Could not find Organizational Unit containing repository. Unable to proceed."; } ArrayList<Project> projects = new ArrayList<Project>(); ProjectExplorerContentQuery query = new ProjectExplorerContentQuery(ou, repo, "master"); query.setOptions(new ActiveOptions()); ProjectExplorerContent content = projectExplorerService.getContent(query); projects.addAll(content.getProjects()); if (projects.size() == 0) { return "No projects found in repository " + alias; } int projectIndex = 0; while (projectIndex == 0) { System.out.println(">>Select project:"); for (int i = 0; i < projects.size(); i++) { System.out.println((i + 1) + ") " + projects.get(i).getProjectName()); } try { projectIndex = Integer.parseInt(input.nextLine()); } catch (NumberFormatException e) { System.out.println("Invalid index"); } if (projectIndex < 1 || projectIndex > projects.size()) { projectIndex = 0; System.out.println("Invalid index"); } } Project project = projects.get(projectIndex - 1); result.append("\tProject " + project.getProjectName() + "\n"); result.append("\t Modules: " + project.getModules() + "\n"); result.append("\t Root path: " + project.getRootPath().toURI() + "\n"); result.append("\t Pom path: " + project.getPomXMLPath().toURI() + "\n"); return result.toString(); }
@PostConstruct public void onStartup() { try { Repository jbpmRepo = repositoryService.getRepository(JBPM_REPO_PLAYGROUND); if (jbpmRepo == null) { jbpmRepo = repositoryService.createRepository( "git", JBPM_REPO_PLAYGROUND, new HashMap<String, Object>() { { put("origin", JBPM_URL); put("username", userName); put("crypt:password", password); } }); } // TODO in case repo is not defined in system repository so we add default // Repository guvnorRepo = repositoryService.getRepository( GUVNOR_REPO_PLAYGROUND // ); // if ( guvnorRepo == null ) { // guvnorRepo = repositoryService.createRepository( "git", // GUVNOR_REPO_PLAYGROUND, // new HashMap<String, // Object>() {{ // put( "origin", // GUVNOR_URL ); // put( "username", // userName ); // put( "crypt:password", // password ); // }} ); // } // TODO in case groups are not defined Collection<OrganizationalUnit> groups = organizationalUnitService.getOrganizationalUnits(); if (groups == null || groups.isEmpty()) { final List<Repository> repositories = new ArrayList<Repository>(); repositories.add(jbpmRepo); // repositories.add( guvnorRepo ); organizationalUnitService.createOrganizationalUnit( "demo", "*****@*****.**", null, repositories); } // Define mandatory properties List<ConfigGroup> globalConfigGroups = configurationService.getConfiguration(ConfigType.GLOBAL); boolean globalSettingsDefined = false; for (ConfigGroup globalConfigGroup : globalConfigGroups) { if (GLOBAL_SETTINGS.equals(globalConfigGroup.getName())) { globalSettingsDefined = true; break; } } if (!globalSettingsDefined) { configurationService.addConfiguration(getGlobalConfiguration()); } // notify cluster service that bootstrap is completed to start synchronization if (ioService instanceof IOClusteredService) { ((IOClusteredService) ioService).start(); } } catch (Exception e) { throw new RuntimeException("Error when starting designer " + e.getMessage(), e); } }
@Override public ExecutionResults execute(CommandContext ctx) throws Exception { try { ExecutionResults executionResults = new ExecutionResults(); String repository = (String) getParameter(ctx, "GitRepository"); if (repository.endsWith(".git")) { repository = repository.substring(0, repository.length() - 4); } String branchToUpdate = (String) getParameter(ctx, "BranchName"); String version = (String) getParameter(ctx, "Version"); if (version == null) { version = "1.0.0"; } else if (!version.endsWith("-SNAPSHOT")) { version = version.concat("-SNAPSHOT"); } BeanManager beanManager = CDIUtils.lookUpBeanManager(ctx); logger.debug("BeanManager " + beanManager); POMService pomService = CDIUtils.createBean(POMService.class, beanManager); logger.debug("POMService " + pomService); IOService ioService = CDIUtils.createBean(IOService.class, beanManager, new NamedLiteral("ioStrategy")); logger.debug("IoService " + ioService); if (ioService != null) { ProjectService projectService = CDIUtils.createBean(new TypeLiteral<ProjectService<?>>() {}.getType(), beanManager); RepositoryService repositoryService = CDIUtils.createBean(RepositoryService.class, beanManager); logger.debug("RepositoryService " + repositoryService); if (repositoryService != null) { Repository repo = repositoryService.getRepository(repository); repo = repositoryService.getRepository(repo.getBranchRoot(branchToUpdate + "-" + version)); logger.debug("Updated repository " + repo); // update all pom.xml files of projects on the dev branch Set<Project> projects = getProjects(repo, ioService, projectService); for (Project project : projects) { POM pom = pomService.load(project.getPomXMLPath()); pom.getGav().setVersion(version); pomService.save( project.getPomXMLPath(), pom, null, "Update project version on development branch"); executionResults.setData(project.getProjectName() + "-GAV", pom.getGav().toString()); } } } return executionResults; } catch (Throwable e) { throw new AssetManagementRuntimeException(e); } }