.status(401).build();
}
String cfId = req.getParameter("cf_id");
AutocompleteUniversalData data;
List<AutocompleteUniversalData> values = null;
if (Utils.isValidStr(cfId))
{
CustomField cf = ComponentManager.getInstance()
.getCustomFieldManager().getCustomFieldObject(cfId);
if (cf == null)
{
log.error("QueryAutocompleteService::getCfVals - Custom field is null. Incorrect data in plugin settings");
return Response
.ok(i18n.getText("queryfields.service.error.cfid.invalid"))
.status(400).build();
}
String jqlData;
if (cf.isAllProjects())
{
jqlData = qfMgr.getQueryFieldData(cf.getIdAsLong(),
Consts.PROJECT_ID_FOR_GLOBAL_CF);
}
else
{
UserProjectHistoryManager userProjectHistoryManager = ComponentManager
.getComponentInstanceOfType(UserProjectHistoryManager.class);
Project currentProject = userProjectHistoryManager
.getCurrentProject(Permissions.BROWSE,
authCtx.getLoggedInUser());
if (currentProject == null)
{
log.error("QueryAutocompleteService::getCfVals - Current project is null");
return Response
.ok(i18n.getText("queryfields.service.error.curproject"))
.status(400).build();
}
jqlData = qfMgr.getQueryFieldData(cf.getIdAsLong(),
currentProject.getId());
}
List<Issue> issues = Utils.executeJQLQuery(jqlData);
values = new ArrayList<AutocompleteUniversalData>(issues.size());
for (Issue issue : issues)
{
String icon;
data = new AutocompleteUniversalData();
data.setName(issue.getKey());
data.setDescription(issue.getSummary());
if (issue.getIssueTypeObject() != null)
{
data.setType(issue.getIssueTypeObject().getName());
icon = issue.getIssueTypeObject().getIconUrl();
if (Utils.isValidStr(icon))
{
data.setTypeimage(icon);
}
}
if (issue.getStatusObject() != null)
{
data.setState(issue.getStatusObject().getName());
}
values.add(data);
}
}