Search in sources :

Example 21 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class ZooKeeperGroupTest method setUp.

@Before
public void setUp() throws Exception {
    int port = findFreePort();
    curator = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryOneTime(1)).build();
    // curator.start();
    group = new ZooKeeperGroup<>(curator, PATH, NodeState.class);
// group.start();
// Starting curator and group is not necessary for the current tests.
}
Also used : RetryOneTime(org.apache.curator.retry.RetryOneTime) NodeState(io.fabric8.groups.NodeState) Before(org.junit.Before)

Example 22 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class FabricGitFacade method write.

@Override
public CommitInfo write(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail, final String contents) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {

        public CommitInfo call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            byte[] data = contents.getBytes();
            CommitInfo answer = doWrite(git, rootDir, branch, path, data, personIdent, commitMessage);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 23 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class FabricGitFacade method writeBase64.

@Override
public CommitInfo writeBase64(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail, final String contents) {
    assertValid();
    final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
    return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {

        public CommitInfo call(Git git, GitContext context) throws Exception {
            checkoutBranch(git, branch);
            File rootDir = getRootGitDirectory(git);
            byte[] data = Base64.decode(contents);
            CommitInfo answer = doWrite(git, rootDir, branch, path, data, personIdent, commitMessage);
            context.commitMessage(commitMessage);
            return answer;
        }
    });
}
Also used : Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GitContext(io.fabric8.api.GitContext) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException)

Example 24 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class AgentUtils method storeInDefaultKarafRepository.

/**
 * Tries to store resource resolved by some {@link StreamProvider} into karaf default repository
 * @param finalTargetLocation
 * @param file
 * @param uri
 */
private static void storeInDefaultKarafRepository(File finalTargetLocation, File file, String uri) {
    if (finalTargetLocation != null && file != null && file.isFile()) {
        try {
            String path = Utils.mvnurlToPath(uri);
            if (path != null) {
                File target = new File(finalTargetLocation, path);
                if (!target.isFile()) {
                    LOGGER.info("Copying resolved {} to {}", file, finalTargetLocation);
                    target.getParentFile().mkdirs();
                    Files.copy(file, target);
                }
            } else {
                LOGGER.warn("Can't resolve Maven URI {} to path", uri);
            }
        } catch (Exception e) {
            LOGGER.warn(e.getMessage(), e);
        }
    }
}
Also used : File(java.io.File) MalformedURLException(java.net.MalformedURLException) MultiException(io.fabric8.common.util.MultiException)

Example 25 with Path

use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.

the class FileWatcherDynamicCompiler method removeCompilePath.

protected void removeCompilePath(Path path) {
    try {
        String url = toUrlString(path);
        Path old = urlMap.remove(url);
        if (old != null) {
            scheduleRecompile();
        }
    } catch (MalformedURLException e) {
        LOG.warn("Ignored path " + path + " due to: " + e, e);
    }
}
Also used : Path(java.nio.file.Path) MalformedURLException(java.net.MalformedURLException) PathHelper.toUrlString(io.fabric8.watcher.PathHelper.toUrlString)

Aggregations

Test (org.junit.Test)45 File (java.io.File)41 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)18 PathTestUtil.createTmpFile (io.fabric8.maven.docker.util.PathTestUtil.createTmpFile)17 HashMap (java.util.HashMap)12 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)11 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)11 Path (java.nio.file.Path)11 FabricService (io.fabric8.api.FabricService)10 RuntimeProperties (io.fabric8.api.RuntimeProperties)9 Properties (java.util.Properties)9 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)8 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)8 InputStream (java.io.InputStream)8 Path (javax.ws.rs.Path)8 HttpProxyRule (io.fabric8.gateway.model.HttpProxyRule)7 NodeState (io.fabric8.groups.NodeState)7 URISyntaxException (java.net.URISyntaxException)7 List (java.util.List)6