private static void appendParam(Map<String, ExpandInformation> parameters, String expand) { final ExpandKey key = ExpandKey.from(StringUtils.substringBefore(expand, DOT)); String newParameter = StringUtils.substringAfter(expand, DOT); DefaultExpandParameter existingParameter = null; if (parameters.containsKey(key.getName())) { existingParameter = parameters.get(key.getName()).getExpandParameter(); } else { existingParameter = new DefaultExpandParameter(); parameters.put(key.getName(), new ExpandInformation(key.getIndexes(), existingParameter)); } if (StringUtils.isNotBlank(newParameter)) { appendParam(existingParameter.parameters, newParameter); } }
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 SearchRequestToFilterBean(UriInfo uriInfo, StringList expand, Boolean isFavourite) { this.uriInfo = uriInfo; this.expand = new DefaultExpandParameter(expand != null ? expand.asList() : Collections.<String>emptyList()); this.isFavourite = isFavourite; }
public IssueToIssueBean(IncludedFields fields, StringList expand) { this.fields = fields; this.expand = new DefaultExpandParameter(expand != null ? expand.asList() : Collections.<String>emptyList()); this.expandAsString = expand != null ? expand.toQueryParam() : null; this.issueBeanBuilder = beanBuilderFactory.newIssueBeanBuilder2(fields, expandAsString); }
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; }