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


Java ComponentAccessor类代码示例

本文整理汇总了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;
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:19,代码来源:AbstractPageServlet.java

示例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;
}
 
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:27,代码来源:CanAccessJamPluginCondition.java

示例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;
}
 
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:19,代码来源:JamClient.java

示例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;
}
 
开发者ID:SecSign,项目名称:SecSign-ID-JIRA-Plugin,代码行数:28,代码来源:SecSignIDUserManager.java

示例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);
    }
}
 
开发者ID:VaclavDedik,项目名称:planning-poker-plugin,代码行数:21,代码来源:SessionAction.java

示例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();
}
 
开发者ID:VaclavDedik,项目名称:planning-poker-plugin,代码行数:27,代码来源:PlanningPokerPanel.java

示例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");
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:26,代码来源:ControlsServlet.java

示例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");
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:26,代码来源:CauseServlet.java

示例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;
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:28,代码来源:HazardService.java

示例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(); 
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:27,代码来源:HazardRestService.java

示例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();
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:22,代码来源:MissionRestService.java

示例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();
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:25,代码来源:ControlRestService.java

示例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;
}
 
开发者ID:bitium,项目名称:jira-saml-plugin,代码行数:22,代码来源:SsoJiraLoginServlet.java

示例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();
}
 
开发者ID:ldoguin,项目名称:segmentio-jira-plugin,代码行数:23,代码来源:SegmentIOTracker.java

示例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);
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:16,代码来源:AbstractPageServlet.java


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