Examples of LockHandle


Examples of io.fabric8.api.LockHandle

    }

    @Override
    public String createVersion(GitContext context, final Version version) {
        IllegalStateAssertion.assertNotNull(version, "version");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            LOGGER.debug("Create version: {}", version);
            GitOperation<String> gitop = new GitOperation<String>() {
                public String call(Git git, GitContext context) throws Exception {
                    String versionId = version.getId();
                    IllegalStateAssertion.assertNull(checkoutProfileBranch(git, context, versionId, null), "Version already exists: " + versionId);
                    GitHelpers.checkoutTag(git, GitHelpers.ROOT_TAG);
                    createOrCheckoutVersion(git, version.getId());
                    setVersionAttributes(git, context, versionId, version.getAttributes());
                    context.commitMessage("Create version: " + version);
                    for (Profile profile : version.getProfiles()) {
                        createOrUpdateProfile(context, null, profile, new HashSet<String>());
                    }
                    return versionId;
                }
            };
            return executeInternal(context, null, gitop);
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

        return getVersionIds(newGitReadContext());
    }

    @Override
    public List<String> getVersionIds(GitContext context) {
        LockHandle readLock = aquireReadLock();
        try {
            assertValid();
            GitOperation<List<String>> gitop = new GitOperation<List<String>>() {
                public List<String> call(Git git, GitContext context) throws Exception {
                    List<String> result = new ArrayList<>(versions);
                    // we do not want to expose master branch as a version
                    if (result.contains(GitHelpers.MASTER_BRANCH)) {
                        result.remove(GitHelpers.MASTER_BRANCH);
                    }
                    Collections.sort(result, VersionSequence.getComparator());
                    return Collections.unmodifiableList(result);
                }
            };
            return executeInternal(context, null, gitop);
        } finally {
            readLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    }

    @Override
    public boolean hasVersion(GitContext context, final String versionId) {
        IllegalStateAssertion.assertNotNull(versionId, "versionId");
        LockHandle readLock = aquireReadLock();
        try {
            assertValid();
            GitOperation<Boolean> gitop = new GitOperation<Boolean>() {
                public Boolean call(Git git, GitContext context) throws Exception {
                    return versions.contains(versionId);
                }
            };
            return executeInternal(context, null, gitop);
        } finally {
            readLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    }

    @Override
    public void deleteVersion(GitContext context, final String versionId) {
        IllegalStateAssertion.assertNotNull(versionId, "versionId");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            LOGGER.debug("Delete version: " + versionId);
            GitOperation<Void> gitop = new GitOperation<Void>() {
                public Void call(Git git, GitContext context) throws Exception {
                    removeVersionFromCaches(versionId);
                    GitHelpers.removeBranch(git, versionId);
                    return null;
                }
            };
            executeInternal(context, null, gitop);
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    }

    @Override
    public String createProfile(GitContext context, final Profile profile) {
        IllegalStateAssertion.assertNotNull(profile, "profile");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            GitOperation<String> gitop = new GitOperation<String>() {
                public String call(Git git, GitContext context) throws Exception {
                    String versionId = profile.getVersion();
                    String profileId = profile.getId();
                    Version version = getRequiredVersion(versionId);
                    IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
                    checkoutRequiredProfileBranch(git, context, versionId, profileId);
                    return createOrUpdateProfile(context, null, profile, new HashSet<String>());
                }
            };
            return executeInternal(context, null, gitop);
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    }

    @Override
    public String updateProfile(GitContext context, final Profile profile) {
        IllegalStateAssertion.assertNotNull(profile, "profile");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
           
            // Get the existing profile
            final String versionId = profile.getVersion();
            final String profileId = profile.getId();
            final Profile lastProfile = getRequiredProfile(versionId, profileId);
           
            if (!lastProfile.equals(profile)) {
                GitOperation<String> gitop = new GitOperation<String>() {
                    public String call(Git git, GitContext context) throws Exception {
                        checkoutRequiredProfileBranch(git, context, versionId, profileId);
                        return createOrUpdateProfile(context, lastProfile, profile, new HashSet<String>());
                    }
                };
                return executeInternal(context, null, gitop);
            } else {
                LOGGER.debug("Skip unchanged profile update for: {}", profile);
                return lastProfile.getId();
            }
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    @Override
    public void deleteProfile(GitContext context, final String versionId, final String profileId) {
        IllegalStateAssertion.assertNotNull(versionId, "versionId");
        IllegalStateAssertion.assertNotNull(profileId, "profileId");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            LOGGER.debug("Delete " + ProfileBuilder.Factory.create(versionId, profileId).getProfile());
            GitOperation<Void> gitop = new GitOperation<Void>() {
                public Void call(Git git, GitContext context) throws Exception {
                    checkoutRequiredProfileBranch(git, context, versionId, profileId);
                    File profileDirectory = GitHelpers.getProfileDirectory(git, profileId);
                    recursiveDeleteAndRemove(git, profileDirectory);
                    context.commitMessage("Removed profile " + profileId);
                    return null;
                }
            };
            executeInternal(context, null, gitop);
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    @Override
    public void importProfiles(final String versionId, final List<String> profileZipUrls) {
        IllegalStateAssertion.assertNotNull(versionId, "versionId");
        IllegalStateAssertion.assertNotNull(profileZipUrls, "profileZipUrls");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            GitOperation<String> gitop = new GitOperation<String>() {
                public String call(Git git, GitContext context) throws Exception {
                    // TODO(tdi): Is it correct to implicitly create the version?
                    createOrCheckoutVersion(git, versionId);
                    //checkoutRequiredProfileBranch(git, versionId, null);
                    return doImportProfiles(git, context, profileZipUrls);
                }
            };
            executeWrite(gitop);
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    @Override
    public Iterable<PushResult> doPush(Git git, GitContext context) throws Exception {
        IllegalArgumentAssertion.assertNotNull(git, "git");
        IllegalArgumentAssertion.assertNotNull(context, "context");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            LOGGER.debug("External call to push");
            PushPolicyResult pushResult = doPushInternal(context, getCredentialsProvider());
            return pushResult.getPushResults();
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here

Examples of io.fabric8.api.LockHandle

    @Override
    public <T> T gitOperation(GitContext context, GitOperation<T> gitop, PersonIdent personIdent) {
        IllegalArgumentAssertion.assertNotNull(gitop, "gitop");
        IllegalArgumentAssertion.assertNotNull(context, "context");
        LockHandle writeLock = aquireWriteLock();
        try {
            assertValid();
            LOGGER.debug("External call to execute a git operation: " + gitop);
            return executeInternal(context, personIdent, gitop);
        } finally {
            writeLock.unlock();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.