本文整理汇总了Java中com.atlassian.jira.component.ComponentAccessor类的典型用法代码示例。如果您正苦于以下问题:Java ComponentAccessor类的具体用法?Java ComponentAccessor怎么用?Java ComponentAccessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentAccessor类属于com.atlassian.jira.component包,在下文中一共展示了ComponentAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkWebSudo
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
protected boolean checkWebSudo(final HttpServletRequest req, final HttpServletResponse resp) {
if (!isWebSudoNecessary()) {
return true;
}
WebSudoManager webSudoManager =
ComponentAccessor.getOSGiComponentInstanceOfType(WebSudoManager.class);
if (!webSudoManager.canExecuteRequest(req)) {
if ("XMLHttpRequest".equals(req.getHeader("X-Requested-With"))) {
webSudoManager.enforceWebSudoProtection(req, new AjaxRedirectCatchServletResponse(resp));
} else {
webSudoManager.enforceWebSudoProtection(req, resp);
}
return false;
}
return true;
}
示例2: shouldDisplay
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
public boolean shouldDisplay(User user, Issue issue, JiraHelper jiraHelper) {
ProjectRoleManager roleManager = (ProjectRoleManager)ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
Collection<ProjectRole> roles = roleManager.getProjectRoles(user, jiraHelper.getProjectObject());
// Check if the user has the required role.
boolean hasJamRole = false;
for (ProjectRole role : roles) {
if (role.getName().equals(JamUser)) {
hasJamRole = true;
break;
}
}
if (!hasJamRole) {
return false;
}
// Check if we are filtering based on creation time or not.
if (displayIfNewerThanJam) {
Long jamTs = JamClient.getProjectJamTimestamp(issue.getProjectObject());
Long issueTs = issue.getCreated().getTime();
return (jamTs <= issueTs);
}
return true;
}
示例3: getProjectJamTimestamp
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
public static Long getProjectJamTimestamp(Project project) {
AOWrapper aoWrapper = ComponentAccessor.getOSGiComponentInstanceOfType(AOWrapper.class);
ActiveObjects activeObjects = aoWrapper.getActiveObjects();
JamPluginTimestamp[] mappings = activeObjects.find(JamPluginTimestamp.class, "PROJECT_ID = ?", project.getId());
if ( mappings.length > 0) {
return mappings[0].getJamTimestamp();
}
Long now = System.currentTimeMillis();
activeObjects.create(
JamPluginTimestamp.class,
new DBParam("JAM_TIMESTAMP", now),
new DBParam("PROJECT_ID", project.getId())
);
return now;
}
示例4: getApplicationUser
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
/**
* Gets an instance of an application user by key or by name
* @param umgr UserManager
* @param userKeyOrName the application user key. if no application user could be fopund, the key is treated as name
* @return the jira application user
*/
public static ApplicationUser getApplicationUser(UserManager umgr, String userKeyOrName){
if(umgr == null){
umgr = ComponentAccessor.getUserManager();
}
// application user keys are always lower case
String userKeyLowerCase = userKeyOrName.toLowerCase();
ApplicationUser appUser = umgr.getUserByKey(userKeyLowerCase);
if(appUser == null){
appUser = umgr.getUserByName(userKeyOrName);
logger.warn("did not find an application user with key '" + userKeyOrName + "'. found application user by using as name: " + String.valueOf(appUser));
Collection<ApplicationUser> allApplicationUser = umgr.getAllApplicationUsers();
for(ApplicationUser au : allApplicationUser){
logger.debug("app user: key='" + au.getKey() + "' username='" + au.getUsername() + "' name='" + au.getName() + "' displayname='" + au.getName() + "'");
}
}
return appUser;
}
示例5: sendEmailToNotifyUsers
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
public void sendEmailToNotifyUsers() throws Exception {
for (ApplicationUser user : parseNotifyUserList()) {
Email em = new Email(user.getEmailAddress());
em.setSubject("New planning poker session has been created for issue " + getIssueObject().getKey() + ".");
StringWriter body = new StringWriter();
Map<String, Object> context = Maps.newHashMap();
context.put("issue", getIssueObject());
String baseUrl = getHttpRequest().getRequestURL().toString()
.replaceAll(getHttpRequest().getServletPath(), "");
context.put("baseUrl", baseUrl);
templateRenderer.render("views/emails/notify.vm", context, body);
em.setBody(body.toString());
em.setMimeType("text/html");
SingleMailQueueItem smqi = new SingleMailQueueItem(em);
ComponentAccessor.getMailQueue().addItem(smqi);
}
}
示例6: getHtml
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@Override
public String getHtml(Map<String, Object> context) {
if (!authContext.isLoggedInUser()) {
return "You must be logged in to view planning poker session.";
}
String issueKey = ((Issue) context.get("issue")).getKey();
Session session = sessionService.get(issueKey);
if (session == null) {
return "No session.";
}
context.put("session", session);
context.put("pokerComponent", this);
String baseurl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL);
context.put("baseurl", baseurl);
StringWriter stringWriter = new StringWriter();
try {
templateRenderer.render("views/panel.vm", context, stringWriter);
} catch (IOException e) {
log.error("Failed to render Planning Poker panel, exception message: {}", e.getMessage());
return null;
}
return stringWriter.toString();
}
示例7: doDelete
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
logger.debug("Delete request for Control received");
if (ComponentAccessor.getJiraAuthenticationContext().isLoggedInUser()) {
int controlID = Integer.parseInt(req.getParameter("id"));
String deleteReason = req.getParameter("reason");
logger.info("Delete request for Control id: " + controlID + ", reason: " + deleteReason);
Hazard_Controls control = controlService.deleteControl(controlID, deleteReason);
JSONObject jsonResponse = new JSONObject();
if (control != null) {
createJson(jsonResponse, "updateSuccess", true);
createJson(jsonResponse, "errorMessage", "none");
logger.info("Control id " + controlID + " deleted successfully.");
} else {
createJson(jsonResponse, "updateSuccess", false);
createJson(jsonResponse, "errorMessage", "Could not find Control.");
logger.warn("Control id " + controlID + " could not be deleted: could not find Control.");
}
res.setContentType("application/json");
res.getWriter().println(jsonResponse);
} else {
res.sendRedirect(req.getContextPath() + "/login.jsp");
}
}
示例8: doDelete
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.debug("Delete request for Cause received");
if (ComponentAccessor.getJiraAuthenticationContext().isLoggedInUser()) {
int causeID = Integer.parseInt(req.getParameter("id"));
String deleteReason = req.getParameter("reason");
logger.info("Delete request for Cause id: " + causeID + ", reason: " + deleteReason);
Hazard_Causes cause = causeService.deleteCause(causeID, deleteReason);
JSONObject jsonResponse = new JSONObject();
if (cause != null) {
createJson(jsonResponse, "updateSuccess", true);
createJson(jsonResponse, "errorMessage", "none");
logger.info("Cause id " + causeID + " deleted successfully.");
} else {
createJson(jsonResponse, "updateSuccess", false);
createJson(jsonResponse, "errorMessage", "Could not find Cause.");
logger.warn("Cause id " + causeID + " could not be deleted: could not find Cause.");
}
resp.setContentType("application/json");
resp.getWriter().println(jsonResponse);
} else {
resp.sendRedirect(req.getContextPath() + "/login.jsp");
}
}
示例9: hasHazardPermission
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
/**
* Determine if a user has permission to access a specified JIRA project.
* Permission is defined as having {@link ProjectPermissions#CREATE_ISSUES}
* {@link ProjectPermission#EDIT_ISSUES}.
*
* @param projectID
* the JIRA project id to be checked
* @param user
* the ApplicationUser object whose permission is checked.
* @return <code>true</code> if the user has create or edit permission on
* the project, <code>false</code> otherwise.
*/
public boolean hasHazardPermission(long projectID, ApplicationUser user) {
checkNotNull(user);
boolean hasPermission = false;
ProjectManager projectManager = ComponentAccessor.getProjectManager();
Project jiraProject = projectManager.getProjectObj(projectID);
if (jiraProject != null) {
PermissionManager permissionManager = ComponentAccessor.getPermissionManager();
if (permissionManager.hasPermission(Permissions.CREATE_ISSUE, jiraProject, user)
|| permissionManager.hasPermission(Permissions.EDIT_ISSUE, jiraProject, user)) {
hasPermission = true;
}
}
return hasPermission;
}
示例10: renumberHazardContents
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@GET
@Path("{hazardID}/renumber")
@Produces({ MediaType.APPLICATION_JSON })
public Response renumberHazardContents(@PathParam("hazardID") int hazardID) {
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getUser();
if (user == null) {
return ResponseHelper.notLoggedIn();
}
if (hazardID < 0) {
return ResponseHelper.badRequest("Invalid hazardID");
}
Hazards hazard = hazardService.getHazardById(hazardID);
if(hazard == null ) {
return ResponseHelper.badRequest("No hazard with that ID exists");
}
if (!hazardService.hasHazardPermission(hazard.getProjectID(), user)) {
return ResponseHelper.forbidden("User does not have permission to access hazard reports for that project");
}
hazardService.renumberHazardElements(hazardID);
return Response.ok().build();
}
示例11: getProjectsForUser
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@GET
@Path("/user")
@Produces({ MediaType.APPLICATION_JSON })
public Response getProjectsForUser() {
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
if (jiraAuthenticationContext.isLoggedInUser()) {
Map<Long, JIRAProject> userProjects = Maps.newHashMap();
ProjectManager projectManager = ComponentAccessor.getProjectManager();
for (Hazards hazard : hazardService.getUserHazards(jiraAuthenticationContext.getUser())) {
if (userProjects.get(hazard.getProjectID()) == null) {
Project project = projectManager.getProjectObj(hazard.getProjectID());
userProjects.put(hazard.getProjectID(), JIRAProject.create(project));
}
}
return Response.ok(Lists.newArrayList(userProjects.values())).build();
} else {
return ResponseHelper.notLoggedIn();
}
}
示例12: getAllVerificationsBelongingToControl
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@GET
@Path("/{controlID}/verifications")
@Produces({ MediaType.APPLICATION_JSON })
public Response getAllVerificationsBelongingToControl(@PathParam("controlID") int controlID) {
if (ComponentAccessor.getJiraAuthenticationContext().isLoggedInUser()) {
Hazard_Controls control = controlService.getHazardControlByID(controlID);
if (control == null) {
return ResponseHelper.badRequest("No control by that ID found.");
} else {
List<VerificationJSON> associatedVerifications = Lists.newArrayList();
Verifications[] verifications = control.getVerifications();
Hazards hazard = control.getHazard()[0];
if(verifications != null) {
for (Verifications verification : verifications) {
associatedVerifications.add(new VerificationJSON(verification, hazard));
}
}
return Response.ok(associatedVerifications).build();
}
} else {
return ResponseHelper.notLoggedIn();
}
}
示例13: tryCreateOrUpdateUser
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@Override
protected Object tryCreateOrUpdateUser(String username) throws Exception {
if (saml2Config.getAutoCreateUserFlag()){
log.warn("Creating user account for " + username );
UserManager userManager = ComponentAccessor.getUserManager();
String fullName = credential.getAttributeAsString("cn");
String email = credential.getAttributeAsString("mail");
UserDetails newUserDetails = new UserDetails(username, username).withEmail(email);
ApplicationUser newUser = userManager.createUser(newUserDetails);
addUserToGroup(newUser);
return newUser;
} else {
// not allowed to auto-create user
log.error("User not found and auto-create disabled: " + username);
}
return null;
}
示例14: getContextMap
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
@Override
public Map<String, Object> getContextMap(Map<String, Object> context) {
final MapBuilder<String, Object> paramsBuilder = MapBuilder
.newBuilder(JiraVelocityUtils.getDefaultVelocityParams(context,
authenticationContext));
paramsBuilder.addAll(params);
Boolean trackLogin = segmentIOConfig.getTrackLogin();
if (trackLogin) {
ApplicationUser user = authenticationContext.getUser();
if (user != null) {
paramsBuilder.add("username", user.getUsername());
paramsBuilder.add("name", user.getDisplayName());
paramsBuilder.add("email", user.getEmailAddress());
}
}
ApplicationProperties applicationProperties = ComponentAccessor
.getApplicationProperties();
String baseUrl = applicationProperties.getString(APKeys.JIRA_BASEURL);
paramsBuilder.add("baseUrl", baseUrl);
paramsBuilder.add("segmentIOKey", segmentIOConfig.getSegmentIOKey());
return paramsBuilder.toMap();
}
示例15: AbstractPageServlet
import com.atlassian.jira.component.ComponentAccessor; //导入依赖的package包/类
/**
* Initializes the compiled page template.
*/
public AbstractPageServlet() {
try {
querydslSupport = new QuerydslSupportImpl();
} catch (Exception e) {
throw new RuntimeException(e);
}
transactionTemplate =
ComponentAccessor.getOSGiComponentInstanceOfType(TransactionTemplate.class);
ClassLoader classLoader = this.getClass().getClassLoader();
pageTemplate = new LocalizedTemplate(getTemplateBase(), classLoader);
}