My jackson
implementation that should return a List<Alert>
returns this instead:
<List xmlns="">
<script id="tinyhippos-injected"/>
<item>
<id>8a1f88cb-e9ee-4164-a0ca-72f57c349b7e</id>
(...)
</item>
</List>
Though I understand the xmlns=""
is harmless, I'm not so sure about the <script />
bit.
Also, since my desired output is a list of Alert
, how come I'm getting a list of item?
My Alert
class has been annotated as:
@Entity
@Table(name="alert")
@JacksonXmlRootElement(localName = "alert")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Alert extends BasePojo {
private static final long serialVersionUID = 1L;
@JacksonXmlProperty(localName = "code")
@Column(name = "code", nullable = false, unique = true)
private String code;
(...)
// getters and setters
}
The method that returns the list is:
@GET
@RequestMapping(value = "/list/{companyId}/{agentName}/{pollInterval}/{lastExecutionDate}", produces = XML_CONTENT_TYPE)
public List<Alert> listAlertsByAgentId(@PathVariable String companyId,
@PathVariable String agentName,
@PathVariable String pollInterval,
@PathVariable String lastExecutionDate)
throws IOException {
List<Alert> list = new ArrayList<Alert>();
Agent agent = alertService.findAgentByAgentName(agentName);
agent.setPollInterval(Integer.parseInt(pollInterval));
int year = Integer.parseInt(lastExecutionDate.substring(0, 4));
int month = Integer.parseInt(lastExecutionDate.substring(4, 6)) - 1;
int date = Integer.parseInt(lastExecutionDate.substring(6, 8));
int hour = Integer.parseInt(lastExecutionDate.substring(8, 10));
int minute = Integer.parseInt(lastExecutionDate.substring(10, 12));
int second = Integer.parseInt(lastExecutionDate.substring(12, 14));
Calendar cal = Calendar.getInstance();
cal.set(year, month, date, hour, minute, second);
agent.setLastExecutionDate(cal.getTime());
alertService.updateAgent(agent);
list = fetchAlertListByAgentName(companyId, agentName);
if(list == null || list.size() == 0 || list.isEmpty()) {
list = new ArrayList<Alert>();
}
return list;
}
What am I not seeing here?