public void intercept(MethodInvocation invocation) throws IllegalAccessException, InvocationTargetException { invocation.invoke(); HttpRequestContext request = invocation.getHttpContext().getRequest(); HttpResponseContext response = invocation.getHttpContext().getResponse(); final ExpandParameter expandParameter = new DefaultExpandParameter(request.getQueryParameters().get(expandParameterName)); new EntityCrawler(additionalExpandsProviders).crawl(response.getEntity(), expandParameter, expanderResolver); } }
public Option<String> marshallBeanToJson(Object object, Collection<String> expands) { checkNotNull(object); // expand stuff... if (!expands.isEmpty()) { new EntityCrawler().crawl(object, new DefaultExpandParameter(expands), getExpanders()); } JaxbJsonMarshaller m = DefaultJaxbJsonMarshaller.builder().modules(getModules()).build(); try { return option(m.marshal(object)); } catch (JsonMarshallingException e) { log.error(String.format("Unable to Atlassian marshall the object of class %s", object.getClass()), e); return none(); } }
private static String marshallBean(Object object, Collection<String> expand, List<Module> modules) throws JAXBException, IOException { // expand stuff... if (!expand.isEmpty()) { new EntityCrawler().crawl(object, new DefaultExpandParameter(expand), getExpanders()); } JaxbJsonMarshaller m = DefaultJaxbJsonMarshaller.builder().modules(modules).build(); final String result = m.marshal(object); LOG.log(Level.FINE, "Got marshalled output:\n" + result); return result; }
private ProjectBean createAndExpandProjectBean(Project project, ProjectBeanBuilder builder, String expand) { StringList expandList = StringList.fromQueryParam(expand); List<String> expandItems = (expandList == null ? ImmutableList.<String>of() : expandList.asList()); //Could be expensive call so only do when needed (vs SelfExpandingExpander / bean doing its own expansion) if (expandItems.contains(EXPAND_PROJECT_KEYS) || expandItems.contains(EXPAND_WILDCARD)) { builder.projectKeys(projectManager.getAllProjectKeys(project.getId())); } ProjectBean projectBean = builder.build(); EntityExpanderResolver expandResolver = new SelfExpandingExpander.Resolver(); EntityCrawler entityCrawler = new EntityCrawler(); ExpandParameter expandParameter = new DefaultExpandParameter(expandItems); entityCrawler.crawl(projectBean, expandParameter, expandResolver); return projectBean; }