是否可以使用应用令牌从图api检索任何隐藏的帖子和评论?我的印象是,只有使用用户或页面令牌才能实现此功能,但被告知如果您包含参数[include_hidden = true],它将返回您从中获取供稿的页面中的隐藏帖子。有人可以确认这一点,因为我在测试新页面时需要先进行验证,因此我很难进行此测试?
package redacted.primavera.common.spring;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.Resource;
/**
* Extends the PropertyPlaceholderConfigurer to implement nested resource
* location placeholders. Properties from the top-level resources may be
* used to define nested resources.
*
* @author redacted
*
*/
public class NestedPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer implements ApplicationContextAware {
private ApplicationContext applicationContext;
private Resource[] topLocations;
private List<String> nestedLocations;
/*
* Post-process the bean factory. Add the nested resource locations to the
* top-level resource locations before processing.
*
* (non-Javadoc)
* @see org.springframework.beans.factory.config.PropertyResourceConfigurer#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
*/
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
try {
Properties props = mergeProperties();
List<Resource> merged = new ArrayList<Resource>();
for (int i = 0; i < topLocations.length; i++) {
merged.add(topLocations[i]);
}
for (String nestedLocation : this.nestedLocations) {
String location = parseStringValue(nestedLocation.replaceAll("#\\{", "\\${"), props, new HashSet<String>());
if (location != null) {
Resource[] resources = this.applicationContext.getResources(location);
for (int i = 0; i < resources.length; i++) {
Resource resource = resources[i];
if (!merged.contains(resource)) {
merged.add(resource);
}
}
}
}
setLocations(merged.toArray(new Resource[merged.size()]));
}
catch (Exception e) {
throw new RuntimeException("", e);
}
super.postProcessBeanFactory(beanFactory);
}
/*
* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
/*
* Set resource locations and save a local copy.
*
* (non-Javadoc)
* @see org.springframework.core.io.support.PropertiesLoaderSupport#setLocations(org.springframework.core.io.Resource[])
*/
@Override
public void setLocations(Resource[] locations) {
this.topLocations = new Resource[locations.length];
System.arraycopy(locations, 0, this.topLocations, 0, locations.length);
super.setLocations(locations);
}
/**
* Set the nested resource locations.
* @param nestedLocations
*/
public void setNestedLocations(List<String> nestedLocations) {
this.nestedLocations = nestedLocations;
}
}