@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.setBaseUri(URI.create(config.getBaseUri().getPath() + "/api")); config.exposeIdsFor(AbTestConfiguration.class); config.exposeIdsFor(AbTestVariant.class); config.setDefaultPageSize(1000); }
@Override public RepositoryRestConfiguration config() { RepositoryRestConfiguration config = super.config(); config.exposeIdsFor(Post.class); config.setBasePath("/api"); return config; }
private List<Descriptor> getProjectionDescriptor(Class<?> type, HttpMethod method) { if (!Type.SAFE.equals(getType(method))) { return Collections.emptyList(); } ProjectionDefinitionConfiguration projectionConfiguration = configuration.projectionConfiguration(); return projectionConfiguration.hasProjectionFor(type) ? Arrays.asList(buildProjectionDescriptor(mappings.getMetadataFor(type))) : Collections.<Descriptor>emptyList(); }
private String resolveMessage(ResourceDescription description) { if (!description.isDefault()) { return description.getMessage(); } try { return messageSource.getMessage(description); } catch (NoSuchMessageException o_O) { return configuration.metadataConfiguration().omitUnresolvableDescriptionKeys() ? null : description.getMessage(); } }
/** * Builds a descriptor for the projection parameter of the given resource. * * @param metadata * @param projectionConfiguration * @return */ private Descriptor buildProjectionDescriptor(ResourceMetadata metadata) { ProjectionDefinitionConfiguration projectionConfiguration = configuration.projectionConfiguration(); String projectionParameterName = projectionConfiguration.getParameterName(); Map<String, Class<?>> projections = projectionConfiguration.getProjectionsFor(metadata.getDomainType()); List<Descriptor> projectionDescriptors = new ArrayList<Descriptor>(projections.size()); for (Entry<String, Class<?>> projection : projections.entrySet()) { Class<?> type = projection.getValue(); String key = String.format( "%s.%s.%s", metadata.getRel(), projectionParameterName, projection.getKey()); ResourceDescription fallback = SimpleResourceDescription.defaultFor(key); AnnotationBasedResourceDescription projectionDescription = new AnnotationBasedResourceDescription(type, fallback); projectionDescriptors.add( // descriptor() . // type(Type.SEMANTIC) . // name(projection.getKey()) . // doc(getDocFor(projectionDescription)) . // descriptors(createJacksonDescriptor(projection.getKey(), type)) . // build()); } return descriptor() . // type(Type.SEMANTIC) . // name(projectionParameterName) . // doc(getDocFor(SimpleResourceDescription.defaultFor(projectionParameterName))) . // descriptors(projectionDescriptors) .build(); }
/** * Creates the {@link Descriptor}s for pagination parameters. * * @param type * @return */ private List<Descriptor> getPaginationDescriptors(Class<?> type, HttpMethod method) { RepositoryInformation information = repositories.getRepositoryInformationFor(type); if (!information.isPagingRepository() || !getType(method).equals(Type.SAFE)) { return Collections.emptyList(); } Link linkToCollectionResource = entityLinks.linkToCollectionResource(type); List<TemplateVariable> variables = linkToCollectionResource.getVariables(); List<Descriptor> descriptors = new ArrayList<Descriptor>(variables.size()); ProjectionDefinitionConfiguration projectionConfiguration = configuration.projectionConfiguration(); for (TemplateVariable variable : variables) { // Skip projection parameter if (projectionConfiguration.getParameterName().equals(variable.getName())) { continue; } ResourceDescription description = SimpleResourceDescription.defaultFor(variable.getDescription()); descriptors.add( // descriptor() . // name(variable.getName()) . // type(Type.SEMANTIC) . // doc(getDocFor(description)) . // build()); } return descriptors; }
/** * Sets the base URL for the REST API. Also ensure that the primary IDs of the domain classes are * serialized as part of the JSON response. */ @Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.exposeIdsFor(Plant.class, Image.class, Garden.class); config.setBaseUri(URI.create("/api")); }
/** * Method is changing config of {@code RepositoryRestConfigurerAdapter} for exposing Id for {@link * Word} and {@link User} instances. * * @param config * @see org.springframework.data.rest.core.config.RepositoryRestConfiguration */ @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.exposeIdsFor(Word.class); config.exposeIdsFor(User.class); }
@Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.setDefaultMediaType(MEDIA_TYPE).useHalAsDefaultJsonMediaType(false); }
@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.metadataConfiguration().setAlpsEnabled(false); config.setBasePath("/api"); }
private void verifyAlpsEnabled() { if (!configuration.getMetadataConfiguration().alpsEnabled()) { throw new ResourceNotFoundException(); } }
/** * Return the href for the profile root link of a given baseUri. * * @param configuration is the source of the app's baseUri. * @return */ public static String getRootPath(RepositoryRestConfiguration configuration) { BaseUri baseUri = new BaseUri(configuration.getBaseUri()); return baseUri.getUriComponentsBuilder().path(MASTER_ROOT_MAPPING).build().toString(); }