use of jetbrains.buildServer.users.User in project teamcity-rest by JetBrains.
the class InvestigationFinder method getPrefilteredItems.
@NotNull
@Override
public ItemHolder<InvestigationWrapper> getPrefilteredItems(@NotNull final Locator locator) {
final String problemDimension = locator.getSingleDimensionValue(PROBLEM_DIMENSION);
if (problemDimension != null) {
final ProblemWrapper problem = myProblemFinder.getItem(problemDimension);
return getItemHolder(problem.getInvestigations());
}
final String testDimension = locator.getSingleDimensionValue(TEST_DIMENSION);
if (testDimension != null) {
final STest test = myTestFinder.getItem(testDimension);
return getItemHolder(getInvestigationWrappers(test));
}
final String buildTypeDimension = locator.getSingleDimensionValue(BUILD_TYPE);
if (buildTypeDimension != null) {
final SBuildType buildType = myBuildTypeFinder.getBuildType(null, buildTypeDimension, false);
return getItemHolder(getInvestigationWrappersForBuildType(buildType));
}
@Nullable User user = null;
final String investigatorDimension = locator.getSingleDimensionValue(ASSIGNEE);
if (investigatorDimension != null) {
user = myUserFinder.getItem(investigatorDimension);
}
final String assignmentProjectDimension = locator.getSingleDimensionValue(ASSIGNMENT_PROJECT);
if (assignmentProjectDimension != null) {
@NotNull final SProject project = myProjectFinder.getItem(assignmentProjectDimension);
return getItemHolder(getInvestigationWrappersForProject(project, user));
}
final String affectedProjectDimension = locator.getSingleDimensionValue(AFFECTED_PROJECT);
if (affectedProjectDimension != null) {
@NotNull final SProject project = myProjectFinder.getItem(affectedProjectDimension);
return getItemHolder(getInvestigationWrappersForProjectWithSubprojects(project, user));
}
if (user != null) {
return getItemHolder(getInvestigationWrappersForProjectWithSubprojects(myProjectFinder.getRootProject(), user));
}
locator.markUnused(ASSIGNEE);
return getItemHolder(getInvestigationWrappersForProjectWithSubprojects(myProjectFinder.getRootProject(), null));
}
use of jetbrains.buildServer.users.User in project teamcity-rest by JetBrains.
the class InvestigationFinder method getFilter.
@NotNull
@Override
public ItemFilter<InvestigationWrapper> getFilter(@NotNull final Locator locator) {
final MultiCheckerFilter<InvestigationWrapper> result = new MultiCheckerFilter<InvestigationWrapper>();
final String investigatorDimension = locator.getSingleDimensionValue(ASSIGNEE);
if (investigatorDimension != null) {
@NotNull final User user = myUserFinder.getItem(investigatorDimension);
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
return user.equals(item.getResponsibleUser());
}
});
}
final String reporterDimension = locator.getSingleDimensionValue(REPORTER);
if (reporterDimension != null) {
@NotNull final User user = myUserFinder.getItem(reporterDimension);
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
return user.equals(item.getReporterUser());
}
});
}
final String typeDimension = locator.getSingleDimensionValue(TYPE);
if (typeDimension != null) {
if (ProblemTarget.getKnownTypesForInvestigation().stream().noneMatch(s -> typeDimension.equalsIgnoreCase(s))) {
throw new BadRequestException("Error in dimension '" + TYPE + "': unknown value '" + typeDimension + "'. Known values: " + StringUtil.join(ProblemTarget.getKnownTypesForInvestigation(), ", "));
}
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
return typeDimension.equalsIgnoreCase(ProblemTarget.getType(item));
}
});
}
final String stateDimension = locator.getSingleDimensionValue(STATE);
if (stateDimension != null) {
if (!InvestigationWrapper.getKnownStates().contains(stateDimension.toLowerCase())) {
throw new BadRequestException("Error in dimension '" + STATE + "': unknown value '" + stateDimension + "'. Known values: " + StringUtil.join(InvestigationWrapper.getKnownStates(), ", "));
}
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
return stateDimension.equalsIgnoreCase(item.getState().name());
}
});
}
final String resolutionDimension = locator.getSingleDimensionValue(RESOLUTION);
if (resolutionDimension != null) {
ResponsibilityEntry.RemoveMethod removeMethod = Resolution.getRemoveMethodForInvestigation(resolutionDimension);
result.add(item -> removeMethod.equals(item.getRemoveMethod()));
}
final String assignmentProjectDimension = locator.getSingleDimensionValue(ASSIGNMENT_PROJECT);
if (assignmentProjectDimension != null) {
@NotNull final SProject project = myProjectFinder.getItem(assignmentProjectDimension);
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
final BuildProject assignmentProject = item.getAssignmentProject();
return assignmentProject != null && project.getProjectId().equals(assignmentProject.getProjectId());
}
});
}
final String affectedProjectDimension = locator.getSingleDimensionValue(AFFECTED_PROJECT);
if (affectedProjectDimension != null) {
@NotNull final SProject project = myProjectFinder.getItem(affectedProjectDimension);
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
final BuildProject assignmentProject = item.getAssignmentProject();
final BuildType assignmentBuildType = item.getAssignmentBuildType();
final BuildProject buildTypeProject = assignmentBuildType != null ? myProjectFinder.findProjectByInternalId(assignmentBuildType.getProjectId()) : null;
return (assignmentProject != null && ProjectFinder.isSameOrParent(project, assignmentProject)) || (buildTypeProject != null && ProjectFinder.isSameOrParent(project, buildTypeProject));
}
});
}
final String sinceDateDimension = locator.getSingleDimensionValue(SINCE_DATE);
if (sinceDateDimension != null) {
final Date date = DataProvider.getDate(sinceDateDimension);
result.add(new FilterConditionChecker<InvestigationWrapper>() {
public boolean isIncluded(@NotNull final InvestigationWrapper item) {
return date.before(item.getTimestamp());
}
});
}
// todo: add assignmentBuildType
return result;
}
use of jetbrains.buildServer.users.User in project teamcity-rest by JetBrains.
the class DebugRequest method getCurrentSession.
@GET
@Path("/currentRequest/session")
@Produces({ "application/xml", "application/json" })
public Session getCurrentSession(@Context HttpServletRequest request, @QueryParam("fields") final String fields, @Context @NotNull final BeanContext beanContext) {
User currentUser = myServiceLocator.getSingletonService(PermissionChecker.class).getCurrent().getAssociatedUser();
HttpSession session = request.getSession();
return new Session(session.getId(), currentUser != null ? currentUser.getId() : null, new Date(session.getCreationTime()), new Date(session.getLastAccessedTime()), new Fields(fields), beanContext);
}
use of jetbrains.buildServer.users.User in project teamcity-rest by JetBrains.
the class BuildRequest method addProblemToBuild.
/**
* Experimental.
* Adds a build problem with given details. The same as marking the build as failed from UI.
*/
@POST
@Path("/{buildLocator}/problemOccurrences")
@Consumes({ "text/plain" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Add a build problem to the matching build.", nickname = "addProblemToBuild")
public ProblemOccurrence addProblemToBuild(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, String problemDetails, @QueryParam("fields") String fields) {
BuildPromotion buildPromotion = myBuildFinder.getBuildPromotion(null, buildLocator);
SBuild build = buildPromotion.getAssociatedBuild();
if (build == null) {
throw new NotFoundException("No finished build associated with promotion id " + buildPromotion.getId());
}
User user = myPermissionChecker.getCurrent().getAssociatedUser();
if (user == null) {
throw new BadRequestException("Cannot perform operation: no current user");
}
BuildProblemData problemData = build.addUserBuildProblem((SUser) user, problemDetails);
return new ProblemOccurrence(myBeanContext.getSingletonService(ProblemOccurrenceFinder.class).getProblem(build, problemData), myBeanContext, new Fields(fields));
}
Aggregations