本文整理汇总了Java中com.gitblit.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于com.gitblit包,在下文中一共展示了Constants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readTicketsFile
import com.gitblit.Constants; //导入依赖的package包/类
/**
* Reads a file from the tickets branch.
*
* @param db
* @param file
* @return the file content or null
*/
private String readTicketsFile(Repository db, String file) {
try {
ObjectId treeId = db.resolve(BRANCH + "^{tree}");
if (treeId == null) {
return null;
}
try (RevWalk rw = new RevWalk(db)) {
RevTree tree = rw.lookupTree(treeId);
if (tree != null) {
return JGitUtils.getStringContent(db, tree, file, Constants.ENCODING);
}
}
} catch (IOException e) {
log.error("failed to read " + file, e);
}
return null;
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:25,代码来源:BranchTicketService.java
示例2: asLink
import com.gitblit.Constants; //导入依赖的package包/类
/**
* Returns an url to this servlet for the specified parameters.
*
* @param baseURL
* @param repository
* @param branch
* @param path
* @return an url
*/
public static String asLink(String baseURL, String repository, String branch, String path) {
if (baseURL.length() > 0 && baseURL.charAt(baseURL.length() - 1) == '/') {
baseURL = baseURL.substring(0, baseURL.length() - 1);
}
char fsc = '!';
char c = GitblitContext.getManager(IRuntimeManager.class).getSettings().getChar(Keys.web.forwardSlashCharacter, '/');
if (c != '/') {
fsc = c;
}
if (branch != null) {
branch = Repository.shortenRefName(branch).replace('/', fsc);
}
String encodedPath = path == null ? "" : path.replace('/', fsc);
return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + encodedPath));
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:27,代码来源:RawServlet.java
示例3: getTicket
import com.gitblit.Constants; //导入依赖的package包/类
/**
* Returns the ticket (if any) that this commit references.
*
* @param commit
* @return null or a ticket
*/
protected TicketModel getTicket(RevCommit commit) {
try {
Map<String, Ref> refs = getRepository().getRefDatabase().getRefs(Constants.R_TICKETS_PATCHSETS);
for (Map.Entry<String, Ref> entry : refs.entrySet()) {
if (entry.getValue().getObjectId().equals(commit.getId())) {
long id = PatchsetCommand.getTicketNumber(entry.getKey());
TicketModel ticket = app().tickets().getTicket(getRepositoryModel(), id);
return ticket;
}
}
} catch (Exception e) {
logger().error("failed to determine ticket from ref", e);
}
return null;
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:22,代码来源:TicketPage.java
示例4: setCookie
import com.gitblit.Constants; //导入依赖的package包/类
@Override
public void setCookie(HttpServletRequest request, HttpServletResponse response, UserModel user) {
if (settings.getBoolean(Keys.web.allowCookieAuthentication, true) && isStandardLogin(request)) {
Cookie userCookie;
if (user == null) {
// clear cookie for logout
userCookie = new Cookie(Constants.NAME, "");
} else {
// set cookie for login
String cookie = userManager.getCookie(user);
if (Strings.isNullOrEmpty(cookie)) {
// create empty cookie
userCookie = new Cookie(Constants.NAME, "");
} else {
// create real cookie
userCookie = new Cookie(Constants.NAME, cookie);
// expire the cookie in 7 days
userCookie.setMaxAge((int) TimeUnit.DAYS.toSeconds(7));
}
}
userCookie.setPath(hostRelativePluginPath);
response.addCookie(userCookie);
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:25,代码来源:GerritGitBlitAuthenticationManager.java
示例5: loggedIn
import com.gitblit.Constants; //导入依赖的package包/类
private UserModel loggedIn(HttpServletRequest request, UserModel user, String credentials, AuthResult authentication) {
if (authentication != null && !gerritSession.get().getUser().isIdentifiedUser()) {
log.warn("Setting account after log-in for " + user.getName());
// We just logged in via Gerrit. However, if somehow somewhere some code called getCurrentUser() on that WebSession object before,
// the "current user object" remains stuck on the previous value. Happens for instance in WrappedSyndicationFilter after the 401
// challenge. Frankly said, I don't know if that is a bug in Gerrit, or what's up. Methinks CacheBasedWebSession.login() should
// (re-)set its private field "user" to null, so that the next call to getCurrentUser() re-computes the user object. We can get
// around this by forcing the account id to the account we just authenticated. In this request, this user won't be able to do
// Gerrit administration, but we're inside GitBlit anyway, so there's no need for this anyway.
gerritSession.get().setUserAccountId(authentication.getAccountId());
}
if (request != null) {
request.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CREDENTIALS);
}
user.cookie = StringUtils.getSHA1(user.getName() + credentials); // Code from GitBlit
return user;
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:18,代码来源:GerritGitBlitAuthenticationManager.java
示例6: ServerStatus
import com.gitblit.Constants; //导入依赖的package包/类
public ServerStatus(boolean isGO) {
this.bootDate = new Date();
this.version = Constants.getVersion();
this.releaseDate = Constants.getBuildDate();
this.isGO = isGO;
this.heapMaximum = Runtime.getRuntime().maxMemory();
this.systemProperties = new TreeMap<String, String>();
put("file.encoding");
put("java.home");
put("java.awt.headless");
put("java.io.tmpdir");
put("java.runtime.name");
put("java.runtime.version");
put("java.vendor");
put("java.version");
put("java.vm.info");
put("java.vm.name");
put("java.vm.vendor");
put("java.vm.version");
put("os.arch");
put("os.name");
put("os.version");
}
开发者ID:warpfork,项目名称:gitblit,代码行数:26,代码来源:ServerStatus.java
示例7: setMetadataDefaults
import com.gitblit.Constants; //导入依赖的package包/类
private void setMetadataDefaults(X509Metadata metadata) {
metadata.serverHostname = gitblitSettings.getString(Keys.web.siteName, Constants.NAME);
if (StringUtils.isEmpty(metadata.serverHostname)) {
metadata.serverHostname = Constants.NAME;
}
// set default values from config file
File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
FileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());
if (certificatesConfigFile.exists()) {
try {
config.load();
} catch (Exception e) {
Utils.showException(GitblitAuthority.this, e);
}
NewCertificateConfig certificateConfig = NewCertificateConfig.KEY.parse(config);
certificateConfig.update(metadata);
}
}
开发者ID:warpfork,项目名称:gitblit,代码行数:20,代码来源:GitblitAuthority.java
示例8: update
import com.gitblit.Constants; //导入依赖的package包/类
public void update(Config config) {
if (expires == null) {
config.unset("user", user.username, "expires");
} else {
SimpleDateFormat df = new SimpleDateFormat(Constants.ISO8601);
config.setString("user", user.username, "expires", df.format(expires));
}
if (StringUtils.isEmpty(notes)) {
config.unset("user", user.username, "notes");
} else {
config.setString("user", user.username, "notes", notes);
}
if (ArrayUtils.isEmpty(revoked)) {
config.unset("user", user.username, "revoked");
} else {
config.setStringList("user", user.username, "revoked", revoked);
}
}
开发者ID:warpfork,项目名称:gitblit,代码行数:19,代码来源:UserCertificateModel.java
示例9: updateTable
import com.gitblit.Constants; //导入依赖的package包/类
protected void updateTable(boolean pack) {
ServerStatus status = gitblit.getStatus();
header.setText(Translation.get("gb.status"));
version.setText(Constants.NAME + (status.isGO ? " GO v" : " WAR v") + status.version);
releaseDate.setText(status.releaseDate);
bootDate.setText(status.bootDate.toString() + " (" + Translation.getTimeUtils().timeAgo(status.bootDate)
+ ")");
url.setText(gitblit.url);
servletContainer.setText(status.servletContainer);
ByteFormat byteFormat = new ByteFormat();
heapMaximum.setText(byteFormat.format(status.heapMaximum));
heapAllocated.setText(byteFormat.format(status.heapAllocated));
heapUsed.setText(byteFormat.format(status.heapAllocated - status.heapFree) + " ("
+ byteFormat.format(status.heapFree) + " " + Translation.get("gb.free") + ")");
tableModel.setProperties(status.systemProperties);
tableModel.fireTableDataChanged();
}
开发者ID:warpfork,项目名称:gitblit,代码行数:18,代码来源:StatusPanel.java
示例10: setupPage
import com.gitblit.Constants; //导入依赖的package包/类
protected void setupPage(String repositoryName, String pageName) {
String siteName = GitBlit.getString(Keys.web.siteName, Constants.NAME);
if (StringUtils.isEmpty(siteName)) {
siteName = Constants.NAME;
}
if (repositoryName != null && repositoryName.trim().length() > 0) {
add(new Label("title", repositoryName + " - " + siteName));
} else {
add(new Label("title", siteName));
}
ExternalLink rootLink = new ExternalLink("rootLink", urlFor(GitBlitWebApp.HOME_PAGE_CLASS, null).toString());
WicketUtils.setHtmlTooltip(rootLink, GitBlit.getString(Keys.web.siteName, Constants.NAME));
add(rootLink);
// Feedback panel for info, warning, and non-fatal error messages
add(new FeedbackPanel("feedback"));
add(new Label("gbVersion", "v" + Constants.getVersion()));
if (GitBlit.getBoolean(Keys.web.aggressiveHeapManagement, false)) {
System.gc();
}
}
开发者ID:warpfork,项目名称:gitblit,代码行数:24,代码来源:BasePage.java
示例11: createRepositoryModel
import com.gitblit.Constants; //导入依赖的package包/类
/**
* creates a RepositoryModel in the given server at baseUrl, with repositoryName and userName
*
* @param baseUrl GitBlit server url
* @param repositoryName repository name
* @param userName user name of the owner of the repository
* @param repoUrl full repository url
* @param tenantId tenant Id
* @param adminUserName admin user name of the server
* @param adminPassword admin password of the server
* @return RepositoryModel instance if successfully created, else null
*/
private RepositoryModel createRepositoryModel (String baseUrl, String repositoryName, String userName,
String repoUrl, int tenantId, String adminUserName,
String adminPassword) {
RepositoryModel repositoryModel = new RepositoryModel();
repositoryModel.name = repositoryName;
repositoryModel.owner = userName;
//authenticated users can clone, push and view the repository
repositoryModel.accessRestriction = Constants.AccessRestrictionType.VIEW;
boolean isRepoCreated;
try {
isRepoCreated = RpcUtils.createRepository(repositoryModel, baseUrl, adminUserName, adminPassword.toCharArray());
} catch (IOException e) {
handleError("Repository creation failed for tenant " + tenantId, e);
return null;
}
if (isRepoCreated) {
log.info("Repository created successfully for tenant " + tenantId + ", url: " + repoUrl);
}
else {
handleError("Repository creation failed for tenant " + tenantId);
return null;
}
return repositoryModel;
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:42,代码来源:GitBlitBasedRepositoryCreator.java
示例12: setUserPermissions
import com.gitblit.Constants; //导入依赖的package包/类
/**
* Sets the permissions for the user described by UserModel to the repository describes by RepositoryModel
*
* @param baseUrl GitBlit server url
* @param repoModel RepositoryModel instance
* @param userModel UserModel instance
* @param adminUserName admin user name of the server
* @param adminPassword admin password of the server
*/
private void setUserPermissions(String baseUrl, RepositoryModel repoModel, UserModel userModel,
String adminUserName, String adminPassword) {
List<RegistrantAccessPermission> permissions;
try {
permissions = RpcUtils.
getRepositoryMemberPermissions(repoModel, baseUrl, adminUserName, adminPassword.toCharArray());
} catch (IOException e) {
log.error("Retrieving permissions failed for repository " + repoModel.name, e);
return;
}
for (RegistrantAccessPermission permission : permissions) {
if(permission.registrant.equals(userModel.username)) {
if(log.isDebugEnabled()) {
log.debug("Permission already set for user " + userModel.username + " for repository " +
repoModel.name);
}
return;
}
}
//permission for the user not found, therefore add them
permissions.add(new RegistrantAccessPermission(userModel.username, Constants.AccessPermission.PUSH,
Constants.PermissionType.EXPLICIT, Constants.RegistrantType.USER, null, true));
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:39,代码来源:GitBlitBasedRepositoryCreator.java
示例13: streamFromRepo
import com.gitblit.Constants; //导入依赖的package包/类
protected boolean streamFromRepo(HttpServletRequest request, HttpServletResponse response, Repository repository, RevCommit commit,
String requestedPath) throws IOException {
boolean served = false;
RevWalk rw = new RevWalk(repository);
TreeWalk tw = new TreeWalk(repository);
try {
tw.reset();
tw.addTree(commit.getTree());
PathFilter f = PathFilter.create(requestedPath);
tw.setFilter(f);
tw.setRecursive(true);
MutableObjectId id = new MutableObjectId();
ObjectReader reader = tw.getObjectReader();
while (tw.next()) {
FileMode mode = tw.getFileMode(0);
if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
continue;
}
tw.getObjectId(id, 0);
String filename = StringUtils.getLastPathElement(requestedPath);
try {
String userAgent = request.getHeader("User-Agent");
if (userAgent != null && userAgent.indexOf("MSIE 5.5") > -1) {
response.setHeader("Content-Disposition", "filename=\"" + URLEncoder.encode(filename, Constants.ENCODING) + "\"");
} else if (userAgent != null && userAgent.indexOf("MSIE") > -1) {
response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(filename, Constants.ENCODING) + "\"");
} else {
response.setHeader("Content-Disposition", "attachment; filename=\""
+ new String(filename.getBytes(Constants.ENCODING), "latin1") + "\"");
}
} catch (UnsupportedEncodingException e) {
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
}
long len = reader.getObjectSize(id, org.eclipse.jgit.lib.Constants.OBJ_BLOB);
setContentType(response, "application/octet-stream");
response.setIntHeader("Content-Length", (int) len);
ObjectLoader ldr = repository.open(id);
ldr.copyTo(response.getOutputStream());
served = true;
}
} finally {
tw.close();
rw.dispose();
}
response.flushBuffer();
return served;
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:52,代码来源:RawServlet.java
示例14: loginUser
import com.gitblit.Constants; //导入依赖的package包/类
private void loginUser(UserModel user) {
if (user != null) {
HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest();
HttpServletResponse response = ((WebResponse) getResponse()).getHttpServletResponse();
// Set the user into the session
GitBlitWebSession session = GitBlitWebSession.get();
// issue 62: fix session fixation vulnerability
session.replaceSession();
session.setUser(user);
request = ((WebRequest) getRequest()).getHttpServletRequest();
response = ((WebResponse) getResponse()).getHttpServletResponse();
request.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CREDENTIALS);
// Set Cookie
app().authentication().setCookie(request, response, user);
if (!session.continueRequest()) {
PageParameters params = getPageParameters();
if (params == null) {
// redirect to this page
redirectTo(getClass());
} else {
// Strip username and password and redirect to this page
params.remove("username");
params.remove("password");
redirectTo(getClass(), params);
}
}
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:34,代码来源:RootPage.java
示例15: LoginForm
import com.gitblit.Constants; //导入依赖的package包/类
public LoginForm(String id, String markupId, MarkupContainer markupProvider) {
super(id, markupId, markupProvider);
setRenderBodyOnly(true);
SessionlessForm<Void> loginForm = new SessionlessForm<Void>("loginForm", RootPage.this.getClass(), getPageParameters()) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit() {
String username = RootPage.this.username.getObject();
char[] password = RootPage.this.password.getObject().toCharArray();
HttpServletRequest request = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest();
UserModel user = app().authentication().authenticate(username, password, request.getRemoteAddr());
if (user == null) {
error(getString("gb.invalidUsernameOrPassword"));
} else if (user.username.equals(Constants.FEDERATION_USER)) {
// disallow the federation user from logging in via the
// web ui
error(getString("gb.invalidUsernameOrPassword"));
user = null;
} else {
loginUser(user);
}
}
};
TextField<String> unameField = new TextField<String>("username", username);
WicketUtils.setInputPlaceholder(unameField, markupProvider.getString("gb.username"));
loginForm.add(unameField);
NonTrimmedPasswordTextField pwField = new NonTrimmedPasswordTextField("password", password);
WicketUtils.setInputPlaceholder(pwField, markupProvider.getString("gb.password"));
loginForm.add(pwField);
add(loginForm);
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:37,代码来源:RootPage.java
示例16: createPersonPanel
import com.gitblit.Constants; //导入依赖的package包/类
protected Component createPersonPanel(String wicketId, PersonIdent identity,
Constants.SearchType searchType) {
String name = identity == null ? "" : identity.getName();
String address = identity == null ? "" : identity.getEmailAddress();
name = StringUtils.removeNewlines(name);
address = StringUtils.removeNewlines(address);
boolean showEmail = app().settings().getBoolean(Keys.web.showEmailAddresses, false);
if (!showEmail || StringUtils.isEmpty(name) || StringUtils.isEmpty(address)) {
String value = name;
if (StringUtils.isEmpty(value)) {
if (showEmail) {
value = address;
} else {
value = getString("gb.missingUsername");
}
}
Fragment partial = new Fragment(wicketId, "partialPersonIdent", this);
LinkPanel link = new LinkPanel("personName", "list", value, GitSearchPage.class,
WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType));
setPersonSearchTooltip(link, value, searchType);
partial.add(link);
return partial;
} else {
Fragment fullPerson = new Fragment(wicketId, "fullPersonIdent", this);
LinkPanel nameLink = new LinkPanel("personName", "list", name, GitSearchPage.class,
WicketUtils.newSearchParameter(repositoryName, objectId, name, searchType));
setPersonSearchTooltip(nameLink, name, searchType);
fullPerson.add(nameLink);
LinkPanel addressLink = new LinkPanel("personAddress", "hidden-phone list", "<" + address + ">",
GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,
address, searchType));
setPersonSearchTooltip(addressLink, address, searchType);
fullPerson.add(addressLink);
return fullPerson;
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:38,代码来源:RepositoryPage.java
示例17: setPersonSearchTooltip
import com.gitblit.Constants; //导入依赖的package包/类
protected void setPersonSearchTooltip(Component component, String value,
Constants.SearchType searchType) {
if (searchType.equals(Constants.SearchType.AUTHOR)) {
WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);
} else if (searchType.equals(Constants.SearchType.COMMITTER)) {
WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value);
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:9,代码来源:RepositoryPage.java
示例18: SearchForm
import com.gitblit.Constants; //导入依赖的package包/类
public SearchForm(String id, String repositoryName) {
super(id, RepositoryPage.this.getClass(), RepositoryPage.this.getPageParameters());
this.repositoryName = repositoryName;
DropDownChoice<Constants.SearchType> searchType = new DropDownChoice<Constants.SearchType>(
"searchType", Arrays.asList(Constants.SearchType.values()));
searchType.setModel(searchTypeModel);
add(searchType.setVisible(app().settings().getBoolean(Keys.web.showSearchTypeSelection, false)));
TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);
add(searchBox);
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:11,代码来源:RepositoryPage.java
示例19: getPageTitle
import com.gitblit.Constants; //导入依赖的package包/类
protected String getPageTitle(String repositoryName) {
String siteName = app().settings().getString(Keys.web.siteName, Constants.NAME);
if (StringUtils.isEmpty(siteName)) {
siteName = Constants.NAME;
}
if (repositoryName != null && repositoryName.trim().length() > 0) {
return repositoryName + " - " + siteName;
} else {
return siteName;
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:12,代码来源:BasePage.java
示例20: init
import com.gitblit.Constants; //导入依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
log.info(Constants.BORDER);
log.info("Starting GitBlit " + Constants.getVersion());
log.info(Constants.BORDER);
try {
ServletContext context = filterConfig.getServletContext();
applicationContext.contextInitialized(new ServletContextEvent(context));
super.init(new CustomFilterConfig(filterConfig));
} catch (Exception e) {
throw new ServletException(e);
}
}
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:14,代码来源:GerritWicketFilter.java
注:本文中的com.gitblit.Constants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论