class WorkspaceProjectServiceImpl implements WorkspaceProjectService {

    @Override
    public void addBranch(final String newBranchName,
                          final String baseBranchName,
                          final WorkspaceProject project,
                          final String userIdentifier) {

        final Branch baseBranch = project
            .getRepository()
            .getBranch(baseBranchName)
            .orElseThrow(() -> new IllegalStateException("The base branch [" + baseBranchName + "] does not exists"));

        final org.uberfire.java.nio.file.Path baseBranchPath = pathUtil.convert(baseBranch.getPath());
        final String newBranchPathURI = pathUtil.replaceBranch(newBranchName,
                                                               baseBranch.getPath().toURI());
        try {
            final org.uberfire.java.nio.file.Path newBranchPath = ioService.get(new URI(newBranchPathURI));

            baseBranchPath
                .getFileSystem()
                .provider()
                .copy(baseBranchPath,
                      newBranchPath);

            final BranchPermissions branchPermissions = spaceConfigStorageRegistry
                .get(project.getSpace().getName())
                .loadBranchPermissions(baseBranchName,
                                       project.getRepository().getIdentifier());

            spaceConfigStorageRegistry
                .get(project.getSpace().getName())
                .saveBranchPermissions(newBranchName,
                                       project.getRepository().getIdentifier(),
                                       branchPermissions);

            final Repository repository = repositoryService.getRepositoryFromSpace(
                    project.getSpace(),
                    project.getRepository().getAlias());

            repositoryUpdatedEvent.fire(new RepositoryUpdatedEvent(repository));

            newBranchEvent.fire(new NewBranchEvent(repository,
                                                   newBranchName,
                                                   baseBranchName,
                                                   userIdentifier));

        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    public  WorkspaceProjectServiceImpl();
    @Inject public  WorkspaceProjectServiceImpl(final OrganizationalUnitService organizationalUnitService,
                                       final RepositoryService repositoryService,
                                       final SpacesAPI spaces,
                                       final Event<NewProjectEvent> newProjectEvent,
                                       final Event<RepositoryUpdatedEvent> repositoryUpdatedEvent,
                                       final Event<NewBranchEvent> newBranchEvent,
                                       final Instance<ModuleService<? extends Module>> moduleServices,
                                       final ModuleRepositoryResolver repositoryResolver,
                                       @Named("ioStrategy") final IOService ioService,
                                       final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                                       final PathUtil pathUtil,
                                       final ChangeRequestService changeRequestService,
                                       final POMService pomService);

}