当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryModel类代码示例

本文整理汇总了Java中com.gitblit.models.RepositoryModel的典型用法代码示例。如果您正苦于以下问题:Java RepositoryModel类的具体用法?Java RepositoryModel怎么用?Java RepositoryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RepositoryModel类属于com.gitblit.models包,在下文中一共展示了RepositoryModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setChannel

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Optionally sets the channel of the payload based on the repository.
 *
 * @param repository
 * @param payload
 */
public void setChannel(RepositoryModel repository, Payload payload) {
	boolean useProjectChannels = runtimeManager.getSettings().getBoolean(Plugin.SETTING_USE_PROJECT_CHANNELS, false);
	if (!useProjectChannels) {
		return;
	}

	if (StringUtils.isEmpty(repository.projectPath)) {
		return;
	}

	String defaultChannel = runtimeManager.getSettings().getString(Plugin.SETTING_DEFAULT_CHANNEL, null);
	if (!StringUtils.isEmpty(defaultChannel)) {
		payload.setChannel(defaultChannel + "-" + repository.projectPath);
	} else {
		payload.setChannel(repository.projectPath);
	}
}
 
开发者ID:gitblit,项目名称:gitblit-slack-plugin,代码行数:24,代码来源:Slacker.java

示例2: sendDelete

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Sends a Slack message when a branch or a tag is deleted.
 *
 * @param receivePack
 * @param cmd
 * @param rType
 */
protected void sendDelete(GitblitReceivePack receivePack, ReceiveCommand cmd, RefType rType) throws IOException {
	UserModel user = receivePack.getUserModel();
	RepositoryModel repo = receivePack.getRepositoryModel();
	String shortRef = Repository.shortenRefName(cmd.getRefName());
	String repoUrl = getUrl(repo.name, null, null);
	boolean postAsUser = receivePack.getGitblit().getSettings().getBoolean(Plugin.SETTING_POST_AS_USER, true);

	String author;
   	if (postAsUser) {
   		// posting as user, do not BOLD username
   		author = user.getDisplayName();
   	} else {
   		// posting as Gitblit, BOLD username to draw attention
   		author = "*" + user.getDisplayName() + "*";
   	}

	String msg = String.format("%s has deleted %s *%s* from <%s|%s>", author,
   			rType.name().toLowerCase(), shortRef, repoUrl, StringUtils.stripDotGit(repo.name));

   	Payload payload = Payload.instance(msg);
   	attribute(payload, user);

   	slacker.setChannel(repo, payload);
   	slacker.sendAsync(payload);
}
 
开发者ID:gitblit,项目名称:gitblit-slack-plugin,代码行数:33,代码来源:SlackReceiveHook.java

示例3: setRoom

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Optionally sets the room of the payload based on the repository.
 *
 * @param repository
 * @param payload
 */
public void setRoom(RepositoryModel repository, Payload payload) {
	boolean useProjectChannels = runtimeManager.getSettings().getBoolean(Plugin.SETTING_USE_PROJECT_ROOMS, false);
	if (!useProjectChannels) {
		return;
	}

	if (StringUtils.isEmpty(repository.projectPath)) {
		return;
	}

	String defaultRoom = runtimeManager.getSettings().getString(Plugin.SETTING_DEFAULT_ROOM, null);
	if (!StringUtils.isEmpty(defaultRoom)) {
		payload.setRoom(defaultRoom + "-" + repository.projectPath);
	} else {
		payload.setRoom(repository.projectPath);
	}
}
 
开发者ID:gitblit,项目名称:gitblit-hipchat-plugin,代码行数:24,代码来源:HipChatter.java

示例4: sendCreate

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Sends a HipChat message when a branch or a tag is created.
 *
 * @param receivePack
 * @param cmd
 * @param rType
 */
protected void sendCreate(GitblitReceivePack receivePack, ReceiveCommand cmd, RefType rType) throws IOException {
	UserModel user = receivePack.getUserModel();
	RepositoryModel repo = receivePack.getRepositoryModel();
	String shortRef = Repository.shortenRefName(cmd.getRefName());
	String repoUrl = getUrl(repo.name, null, null);
	String logUrl = getUrl(repo.name, shortRef, null);

	String msg = String.format("<b>%s</b> has created %s <a href=\"%s\">%s</a> in <a href=\"%s\">%s</a>",
			user.getDisplayName(), rType.name().toLowerCase(), logUrl, shortRef, repoUrl, StringUtils.stripDotGit(repo.name));

   	Payload payload = Payload.html(msg);
   	payload.setColor(Color.gray);
   	hipChatter.setRoom(repo, payload);
   	hipChatter.sendAsync(payload);
   }
 
开发者ID:gitblit,项目名称:gitblit-hipchat-plugin,代码行数:23,代码来源:HipChatReceiveHook.java

示例5: run

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
@Override
public void run() throws UnloggedFailure {

	RepositoryModel repo = getRepository(true);

	if (!getContext().getClient().getUser().canAdmin(repo)) {
		throw new UnloggedFailure(1,  String.format("Sorry, you do not have permission to delete %s", repository));
	}

	IGitblit gitblit = getContext().getGitblit();
	if (gitblit.deleteRepositoryModel(repo)) {
		stdout.println(String.format("%s has been deleted.", repository));
	} else {
		throw new UnloggedFailure(1, String.format("Failed to delete %s!", repository));
	}
}
 
开发者ID:gitblit,项目名称:gitblit-powertools-plugin,代码行数:17,代码来源:RepositoriesDispatcher.java

示例6: getRepositoryModel

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Checks and returns the corresponding RepositoryModel instance for the given username in the repository at baseUrl
 *
 * @param baseUrl Gitblit server url
 * @param repositoryName repository name
 * @param adminUserName admin user name of the server
 * @param adminPassword admin password of the server
 * @return RepositoryModel instance if exists, else null
 */
private RepositoryModel getRepositoryModel(String baseUrl, String repositoryName, String adminUserName,
                                           String adminPassword) {

    RepositoryModel repositoryModel = null;
    Map<String, RepositoryModel> repositories;

    try {
        repositories = RpcUtils.getRepositories(baseUrl, adminUserName, adminPassword.toCharArray());

    } catch (IOException e) {
        log.error("Error retrieving repository details from git server " + baseUrl, e);
        return null;
    }

    for (RepositoryModel model : repositories.values()) {
        if (model.name.equals(repositoryName)) {
            repositoryModel = model;
            break;
        }
    }
    return repositoryModel;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:32,代码来源:GitBlitBasedRepositoryCreator.java

示例7: deleteAll

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Deletes all tickets for the the repository from the index.
 */
public boolean deleteAll(RepositoryModel repository) {
	try {
		IndexWriter writer = getWriter();
		StandardAnalyzer analyzer = new StandardAnalyzer();
		QueryParser qp = new QueryParser(Lucene.rid.name(), analyzer);
		BooleanQuery query = new BooleanQuery();
		query.add(qp.parse(repository.getRID()), Occur.MUST);

		int numDocsBefore = writer.numDocs();
		writer.deleteDocuments(query);
		writer.commit();
		closeSearcher();
		int numDocsAfter = writer.numDocs();
		if (numDocsBefore == numDocsAfter) {
			log.debug(MessageFormat.format("no records found to delete in {0}", repository));
			return false;
		} else {
			log.debug(MessageFormat.format("deleted {0} records in {1}", numDocsBefore - numDocsAfter, repository));
			return true;
		}
	} catch (Exception e) {
		log.error("error", e);
	}
	return false;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:29,代码来源:TicketIndexer.java

示例8: getTicketImpl

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Retrieves the ticket from the repository by first looking-up the changeId associated with the ticketId.
 * 
 * @param repository
 * @param ticketId
 * @return a ticket, if it exists, otherwise null
 */
@Override
protected TicketModel getTicketImpl(RepositoryModel repository, long ticketId) {
	Repository db = repositoryManager.getRepository(repository.name);
	try {
		List<Change> changes = getJournal(db, ticketId);
		if (ArrayUtils.isEmpty(changes)) {
			log.warn("Empty journal for {}:{}", repository, ticketId);
			return null;
		}
		TicketModel ticket = TicketModel.buildTicket(changes);
		if (ticket != null) {
			ticket.project = repository.projectPath;
			ticket.repository = repository.name;
			ticket.number = ticketId;
		}
		return ticket;
	} finally {
		db.close();
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:28,代码来源:BranchTicketService.java

示例9: commitChangeImpl

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Commit a ticket change to the repository.
 * 
 * @param repository
 * @param ticketId
 * @param change
 * @return true, if the change was committed
 */
@Override
protected synchronized boolean commitChangeImpl(RepositoryModel repository, long ticketId, Change change) {
	boolean success = false;

	Repository db = repositoryManager.getRepository(repository.name);
	try {
		DirCache index = createIndex(db, ticketId, change);
		success = commitIndex(db, index, change.author, "#" + ticketId);

	} catch (Throwable t) {
		log.error(MessageFormat.format("Failed to commit ticket {0,number,0} to {1}", ticketId, db.getDirectory()), t);
	} finally {
		db.close();
	}
	return success;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:25,代码来源:BranchTicketService.java

示例10: deleteAllImpl

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
@Override
protected boolean deleteAllImpl(RepositoryModel repository) {
	Repository db = repositoryManager.getRepository(repository.name);
	try {
		RefModel branch = getTicketsBranch(db);
		if (branch != null) {
			return JGitUtils.deleteBranchRef(db, BRANCH);
		}
		return true;
	} catch (Exception e) {
		log.error(null, e);
	} finally {
		if (db != null) {
			db.close();
		}
	}
	return false;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:19,代码来源:BranchTicketService.java

示例11: getRepositoryModel

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
protected RepositoryModel getRepositoryModel() {
	if (m == null) {
		RepositoryModel model = app().repositories().getRepositoryModel(
				GitBlitWebSession.get().getUser(), repositoryName);
		if (model == null) {
			if (app().repositories().hasRepository(repositoryName, true)) {
				// has repository, but unauthorized
				authenticationError(getString("gb.unauthorizedAccessForRepository") + " " + repositoryName);
			} else {
				// does not have repository
				error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);
			}
			return null;
		}
		m = model;
	}
	return m;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:19,代码来源:RepositoryPage.java

示例12: setLastModified

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
@Override
protected void setLastModified() {
	if (getClass().isAnnotationPresent(CacheControl.class)) {
		CacheControl cacheControl = getClass().getAnnotation(CacheControl.class);
		switch (cacheControl.value()) {
		case REPOSITORY:
			RepositoryModel repository = getRepositoryModel();
			if (repository != null) {
				setLastModified(repository.lastChange);
			}
			break;
		case COMMIT:
			RevCommit commit = getCommit();
			if (commit != null) {
				Date commitDate = JGitUtils.getCommitDate(commit);
				setLastModified(commitDate);
			}
			break;
		default:
			super.setLastModified();
		}
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:24,代码来源:RepositoryPage.java

示例13: canAccess

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
@Override
protected boolean canAccess(final RepositoryModel repository, final AccessRestrictionType ifRestriction, final AccessPermission requirePermission) {
	try {
		ProjectControl control = projectControlFactory.controlFor(new NameKey(StringUtils.stripDotGit(repository.name)), userProvider.get());
		if (control == null) {
			return false;
		}
		switch (ifRestriction) {
		case VIEW:
			return control.isVisible();
		case CLONE:
			return control.canRunUploadPack();
		case PUSH:
			return control.canRunReceivePack();
		default:
			return true;
		}
	} catch (NoSuchProjectException | IOException e) {
		return false;
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:22,代码来源:GerritGitBlitUserModel.java

示例14: sendCreate

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Sends a Glip message when a branch or a tag is created.
 *
 * @param receivePack
 * @param cmd
 * @param rType
 */
protected void sendCreate(GitblitReceivePack receivePack, ReceiveCommand cmd, RefType rType) throws IOException {
	UserModel user = receivePack.getUserModel();
	RepositoryModel repo = receivePack.getRepositoryModel();
	String shortRef = Repository.shortenRefName(cmd.getRefName());
	String repoUrl = getUrl(repo.name, null, null);
	String logUrl = getUrl(repo.name, shortRef, null);

	String activity = String.format("%s has pushed to %s",
			user.getDisplayName(), StringUtils.stripDotGit(repo.name));

	String msg = String.format("**%s** has created %s [%s](%s) in [%s](%s)", user.getDisplayName(),
			rType.name().toLowerCase(), shortRef, logUrl, StringUtils.stripDotGit(repo.name), repoUrl);

   	Payload payload = new Payload()
   		.icon(getIconUrl(user))
   		.activity(activity)
   		.body(msg);

   	glip.setConversation(repo, payload);
   	glip.sendAsync(payload);
   }
 
开发者ID:gitblit,项目名称:gitblit-glip-plugin,代码行数:29,代码来源:GlipReceiveHook.java

示例15: sendDelete

import com.gitblit.models.RepositoryModel; //导入依赖的package包/类
/**
 * Sends a Glip message when a branch or a tag is deleted.
 *
 * @param receivePack
 * @param cmd
 * @param rType
 */
protected void sendDelete(GitblitReceivePack receivePack, ReceiveCommand cmd, RefType rType) throws IOException {
	UserModel user = receivePack.getUserModel();
	RepositoryModel repo = receivePack.getRepositoryModel();
	String shortRef = Repository.shortenRefName(cmd.getRefName());
	String repoUrl = getUrl(repo.name, null, null);

	String activity = String.format("%s has pushed to %s",
			user.getDisplayName(), StringUtils.stripDotGit(repo.name));

	String msg = String.format("**%s** has deleted %s **%s** from [%s](%s)",
			user.getDisplayName(), rType.name().toLowerCase(), shortRef, StringUtils.stripDotGit(repo.name), repoUrl);

   	Payload payload = new Payload()
   		.icon(getIconUrl(user))
   		.activity(activity)
   		.body(msg);

   	glip.setConversation(repo, payload);
   	glip.sendAsync(payload);
}
 
开发者ID:gitblit,项目名称:gitblit-glip-plugin,代码行数:28,代码来源:GlipReceiveHook.java


注:本文中的com.gitblit.models.RepositoryModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。