use of javax.ws.rs.core.GenericEntity in project hadoop by apache.
the class AHSWebServices method getContainerLogMeta.
private Response getContainerLogMeta(ApplicationId appId, String appOwner, final String nodeId, final String containerIdStr, boolean emptyLocalContainerLogMeta) {
try {
List<ContainerLogMeta> containerLogMeta = LogToolUtils.getContainerLogMetaFromRemoteFS(conf, appId, containerIdStr, nodeId, appOwner);
if (containerLogMeta.isEmpty()) {
throw new NotFoundException("Can not get log meta for container: " + containerIdStr);
}
List<ContainerLogsInfo> containersLogsInfo = new ArrayList<>();
for (ContainerLogMeta meta : containerLogMeta) {
ContainerLogsInfo logInfo = new ContainerLogsInfo(meta, ContainerLogAggregationType.AGGREGATED);
containersLogsInfo.add(logInfo);
}
if (emptyLocalContainerLogMeta) {
ContainerLogMeta emptyMeta = new ContainerLogMeta(containerIdStr, "N/A");
ContainerLogsInfo empty = new ContainerLogsInfo(emptyMeta, ContainerLogAggregationType.LOCAL);
containersLogsInfo.add(empty);
}
GenericEntity<List<ContainerLogsInfo>> meta = new GenericEntity<List<ContainerLogsInfo>>(containersLogsInfo) {
};
ResponseBuilder response = Response.ok(meta);
// Sending the X-Content-Type-Options response header with the value
// nosniff will prevent Internet Explorer from MIME-sniffing a response
// away from the declared content-type.
response.header("X-Content-Type-Options", "nosniff");
return response.build();
} catch (Exception ex) {
throw new WebApplicationException(ex);
}
}
use of javax.ws.rs.core.GenericEntity in project exhibitor by soabase.
the class UIResource method getAdditionalTabSpecs.
@Path("tabs")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAdditionalTabSpecs() {
final AtomicInteger index = new AtomicInteger(0);
List<UITabSpec> names = Lists.transform(tabs, new Function<UITab, UITabSpec>() {
@Override
public UITabSpec apply(UITab tab) {
String base = tab.contentIsHtml() ? HTML_UI_TAB_BASE_URL : TEXT_UI_TAB_BASE_URL;
return new UITabSpec(tab.getName(), base + index.getAndIncrement(), tab.contentIsHtml(), tab.getUITabType());
}
});
// move out of Google's TransformingRandomAccessList
names = Lists.newArrayList(names);
GenericEntity<List<UITabSpec>> entity = new GenericEntity<List<UITabSpec>>(names) {
};
return Response.ok(entity).build();
}
use of javax.ws.rs.core.GenericEntity in project exhibitor by soabase.
the class ClusterResource method getClusterStatus.
@Path("status")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getClusterStatus() throws Exception {
InstanceConfig config = context.getExhibitor().getConfigManager().getConfig();
ServerList serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC));
ClusterStatusTask task = new ClusterStatusTask(context.getExhibitor(), serverList.getSpecs());
List<ServerStatus> statuses = context.getExhibitor().getForkJoinPool().invoke(task);
GenericEntity<List<ServerStatus>> entity = new GenericEntity<List<ServerStatus>>(statuses) {
};
return Response.ok(entity).build();
}
use of javax.ws.rs.core.GenericEntity in project cxf by apache.
the class ResponseImplTest method testGetEntityUnwrapped.
@Test
public void testGetEntityUnwrapped() {
final Book book = new Book();
Response r = Response.ok().entity(new GenericEntity<Book>(book) {
}).build();
assertSame(book, r.getEntity());
}
use of javax.ws.rs.core.GenericEntity in project cxf by apache.
the class JAXRS20ClientServerBookTest method testJAXBElementBookCollection.
@Test
public void testJAXBElementBookCollection() throws Exception {
String address = "http://localhost:" + PORT + "/bookstore/jaxbelementxmlrootcollections";
Client client = ClientBuilder.newClient();
WebTarget target = client.target(address);
Book b1 = new Book("CXF in Action", 123L);
Book b2 = new Book("CXF Rocks", 124L);
List<JAXBElement<Book>> books = new ArrayList<JAXBElement<Book>>();
books.add(new JAXBElement<Book>(new QName("bookRootElement"), Book.class, b1));
books.add(new JAXBElement<Book>(new QName("bookRootElement"), Book.class, b2));
GenericEntity<List<JAXBElement<Book>>> collectionEntity = new GenericEntity<List<JAXBElement<Book>>>(books) {
};
GenericType<List<JAXBElement<Book>>> genericResponseType = new GenericType<List<JAXBElement<Book>>>() {
};
List<JAXBElement<Book>> books2 = target.request().accept("application/xml").post(Entity.entity(collectionEntity, "application/xml"), genericResponseType);
assertNotNull(books2);
assertNotSame(books, books2);
assertEquals(2, books2.size());
Book b11 = books.get(0).getValue();
assertEquals(123L, b11.getId());
assertEquals("CXF in Action", b11.getName());
Book b22 = books.get(1).getValue();
assertEquals(124L, b22.getId());
assertEquals("CXF Rocks", b22.getName());
}
Aggregations