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


Java ComponentAccessor.getJiraAuthenticationContext方法代码示例

本文整理汇总了Java中com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentAccessor.getJiraAuthenticationContext方法的具体用法?Java ComponentAccessor.getJiraAuthenticationContext怎么用?Java ComponentAccessor.getJiraAuthenticationContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.atlassian.jira.component.ComponentAccessor的用法示例。


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

示例1: 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

示例2: Admin

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param pluginSettingsFactory object to save data
 * @param userManager           manage users of JIRA
 * @param i18nResolver          translate
 */
public Admin(PluginSettingsFactory pluginSettingsFactory, UserManager userManager, I18nResolver i18nResolver) {
    this.modelo = new LatchModel(pluginSettingsFactory);
    this.request = ServletActionContext.getRequest();
    this.i18nResolver = i18nResolver;
    this.jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
    this.userManager = userManager;
}
 
开发者ID:ElevenPaths,项目名称:latch-plugin-jira,代码行数:15,代码来源:Admin.java

示例3: Unpair

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
/**
 * Constructor
 * @param pluginSettingsFactory object to save data
 * @param i18nResolver translate
 */
public Unpair(PluginSettingsFactory pluginSettingsFactory, I18nResolver i18nResolver) {
	this.modelo = new LatchModel(pluginSettingsFactory);
	this.request = ServletActionContext.getRequest();
	this.i18nResolver = i18nResolver;
	this.jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
}
 
开发者ID:ElevenPaths,项目名称:latch-plugin-jira,代码行数:12,代码来源:Unpair.java

示例4: Index

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param pluginSettingsFactory object to save data
 */

public Index(PluginSettingsFactory pluginSettingsFactory, I18nResolver i18nResolver) {
    this.request = ServletActionContext.getRequest();
    this.i18nResolver = i18nResolver;
    this.model = new LatchModel(pluginSettingsFactory);
    this.jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
}
 
开发者ID:ElevenPaths,项目名称:latch-plugin-jira,代码行数:13,代码来源:Index.java

示例5: Pair

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param pluginSettingsFactory object to save data
 * @param i18nResolver          translate
 */
public Pair(PluginSettingsFactory pluginSettingsFactory, I18nResolver i18nResolver) {
    this.modelo = new LatchModel(pluginSettingsFactory);
    this.request = ServletActionContext.getRequest();
    this.i18nResolver = i18nResolver;
    this.jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
}
 
开发者ID:ElevenPaths,项目名称:latch-plugin-jira,代码行数:13,代码来源:Pair.java

示例6: getAuthContext

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
public JiraAuthenticationContext getAuthContext() {
    return ComponentAccessor.getJiraAuthenticationContext();
}
 
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:4,代码来源:JiraServices.java

示例7: doGet

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO: Look into re-factoring permissions/generating error messages is
	// done - see issue on the Huboard.

	JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
	resp.setContentType("text/html;charset=utf-8");

	if (jiraAuthenticationContext.isLoggedInUser()) {
		Map<String, Object> context = Maps.newHashMap();
		context.put("dateFormatter", dateTimeFormatter);
		boolean error = false;
		String errorMessage = null;
		List<String> errorList = new ArrayList<String>();

		String hazardId = req.getParameter("id");
		Hazards hazard = null;
		if (Strings.isNullOrEmpty(hazardId)) {
			error = true;
			errorMessage = "Missing ID parameter in the URL. Valid URLs are of the following type:";
			errorList.add(".../hazards?id=[number]");
			errorList.add(".../causes?id=[number]");
			errorList.add(".../controls?id=[number]");
			errorList.add(".../verifications?id=[number]");
			errorList.add("where [number] is the unique identifier of the Hazard Report.");
		} else {
			try {
				hazard = hazardService.getHazardById(hazardId);
				if (hazard == null || !hazardService.hasHazardPermission(hazard.getProjectID(),
						jiraAuthenticationContext.getUser())) {
					error = true;
					errorMessage = "Either this Hazard Report doesn't exist (it may have been deleted) or you ("
							+ jiraAuthenticationContext.getUser().getUsername()
							+ ") do not have permission to view/edit it.";
				} else {
					context.put("hazard", hazard);
					
					Hazard_Controls[] hazardControls = hazard.getHazardControls();
					int numControls = 0;
					if(hazardControls != null) {
						for (Hazard_Controls controls : hazardControls) {
							if(Strings.isNullOrEmpty(controls.getDeleteReason())) {
								numControls++;
							}
						}
					}
						
					context.put("numControls", numControls);
					context.put("transferredCauses", causeService.getAllTransferredCauses(hazard));
					context.put("transferredControls", controlService.getAllTransferredControls(hazard));
					context.put("transferredVerifications", verificationService.getAllTransferredVerifications(hazard));
					
					context.put("orphanControls", hazardService.getOrphanControls(hazard));
					context.put("controlGroups", controlGroupsService.all());
					context.put("causes", hazard.getHazardCauses());
					context.put("allHazardsBelongingToMission",
							hazardService.getHazardsByProjectId(hazard.getProjectID()));
				}
			} catch (NumberFormatException e) {
				error = true;
				errorMessage = "ID parameter in the URL is not a valid a number.";
			}
		}

		// Decide which page to render for the user, error-page or
		// cause-page
		if (error == true) {
			context.put("errorMessage", errorMessage);
			context.put("errorList", errorList);
			templateRenderer.render("templates/error-page.vm", context, resp.getWriter());
		} else {
			templateRenderer.render("templates/control-page.vm", context, resp.getWriter());
		}
	} else {
		resp.sendRedirect(req.getContextPath() + "/login.jsp");
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:78,代码来源:ControlsServlet.java

示例8: doGet

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
	resp.setContentType("text/html;charset=utf-8");

	if (jiraAuthenticationContext.isLoggedInUser()) {
		Map<String, Object> context = Maps.newHashMap();
		context.put("dateFormatter", dateTimeFormatter.forLoggedInUser());

		boolean error = false;
		String errorMessage = null;
		List<String> errorList = new ArrayList<String>();

		String hazardId = req.getParameter("id");
		Hazards hazard = null;
		if (Strings.isNullOrEmpty(hazardId)) {
			error = true;
			errorMessage = "Missing ID parameter in the URL. Valid URLs are of the following type:";
			errorList.add(".../hazards?id=[number]");
			errorList.add(".../causes?id=[number]");
			errorList.add(".../controls?id=[number]");
			errorList.add(".../verifications?id=[number]");
			errorList.add("where [number] is the unique identifier of the Hazard Report.");
		} else {
			try {
				hazard = hazardService.getHazardById(hazardId);
				if (hazard == null || !hazardService.hasHazardPermission(hazard.getProjectID(),
						jiraAuthenticationContext.getUser())) {
					error = true;
					errorMessage = "Either this Hazard Report doesn't exist (it may have been deleted) or you ("
							+ jiraAuthenticationContext.getUser().getUsername()
							+ ") do not have permission to view/edit it.";
				} else {
					context.put("hazard", hazard);
					context.put("causes", hazard.getHazardCauses());
					context.put("causesForPrinting", causeService.getAllNonDeletedCausesWithinHazard(hazard));
					context.put("transferredCauses", causeService.getAllTransferredCauses(hazard));
					context.put("transferredControls", controlService.getAllTransferredControls(hazard));
					context.put("orphanControls", hazardService.getOrphanControls(hazard));

					int numVerifications = 0;
					Verifications[] verifications = hazard.getVerifications();
					List<Verifications> nonDeletedVerfications = Lists.newArrayList();
					if (verifications != null) {
						for (Verifications verification : hazard.getVerifications()) {
							if (Strings.isNullOrEmpty(verification.getDeleteReason())) {
								nonDeletedVerfications.add(verification);
								numVerifications++;
							}
						}
					}
					context.put("numVerifications", numVerifications);
					context.put("verifications", nonDeletedVerfications);

					context.put("transferredVerifications",
							verificationService.getAllTransferredVerifications(hazard));
					context.put("orphanVerifications", hazardService.getOrphanVerifications(hazard));
					context.put("statuses", verificationStatusService.all());
					context.put("types", verificationTypeService.all());
					context.put("allHazardsBelongingToMission",
							hazardService.getHazardsByProjectId(hazard.getProjectID()));
				}
			} catch (NumberFormatException e) {
				error = true;
				errorMessage = "ID parameter in the URL is not a valid a number.";
			}
		}

		// Decide which page to render for the user, error-page or
		// cause-page
		if (error == true) {
			context.put("errorMessage", errorMessage);
			context.put("errorList", errorList);
			templateRenderer.render("templates/error-page.vm", context, resp.getWriter());
		} else {
			templateRenderer.render("templates/verification-page.vm", context, resp.getWriter());
		}
	} else {
		resp.sendRedirect(req.getContextPath() + "/login.jsp");
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:82,代码来源:VerificationsServlet.java

示例9: doGet

import com.atlassian.jira.component.ComponentAccessor; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO: Look into re-factoring permissions/generating error messages is
	// done

	JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
	resp.setContentType("text/html;charset=utf-8");

	if (jiraAuthenticationContext.isLoggedInUser()) {
		Map<String, Object> context = Maps.newHashMap();
		context.put("dateFormatter", dateTimeFormatter);
		boolean error = false;
		String errorMessage = null;
		List<String> errorList = new ArrayList<String>();

		String hazardId = req.getParameter("id");
		Hazards hazard = null;
		if (Strings.isNullOrEmpty(hazardId)) {
			error = true;
			errorMessage = "Missing ID parameter in the URL. Valid URLs are of the following type:";
			errorList.add(".../hazards?id=[number]");
			errorList.add(".../causes?id=[number]");
			errorList.add(".../controls?id=[number]");
			errorList.add(".../verifications?id=[number]");
			errorList.add("where [number] is the unique identifier of the Hazard Report.");
		} else {
			try {
				hazard = hazardService.getHazardById(hazardId);
				if (hazard == null
						|| !hazardService.hasHazardPermission(hazard.getProjectID(),
								jiraAuthenticationContext.getUser())) {
					error = true;
					errorMessage = "Either this Hazard Report doesn't exist (it may have been deleted) or you ("
							+ jiraAuthenticationContext.getUser().getUsername()
							+ ") do not have permission to view/edit it.";
				} else {
					context.put("hazard", hazard);
					context.put("causes", causeService.getAllNonDeletedCausesWithinHazard(hazard));
					context.put("transferredCauses", causeService.getAllTransferredCauses(hazard));
					context.put("riskCategories", riskCategoryService.all());
					context.put("riskLikelihoods", riskLikelihoodService.all());
					context.put("allHazardsBelongingToMission",
							hazardService.getHazardsByProjectId(hazard.getProjectID()));
				}
			} catch (NumberFormatException e) {
				error = true;
				errorMessage = "ID parameter in the URL is not a valid a number.";
			}
		}

		// Decide which page to render for the user, error-page or
		// cause-page
		if (error == true) {
			context.put("errorMessage", errorMessage);
			context.put("errorList", errorList);
			templateRenderer.render("templates/error-page.vm", context, resp.getWriter());
		} else {
			templateRenderer.render("templates/cause-page.vm", context, resp.getWriter());
		}
	} else {
		resp.sendRedirect(req.getContextPath() + "/login.jsp");
	}
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:64,代码来源:CauseServlet.java


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