/**
* @see org.apache.sling.installer.api.info.InfoProvider#getInstallationState()
*/
public InstallationState getInstallationState() {
synchronized ( this.resourcesLock ) {
final InstallationState state = new InstallationState() {
private final List<ResourceGroup> activeResources = new ArrayList<ResourceGroup>();
private final List<ResourceGroup> installedResources = new ArrayList<ResourceGroup>();
private final List<RegisteredResource> untransformedResources = new ArrayList<RegisteredResource>();
public List<ResourceGroup> getActiveResources() {
return activeResources;
}
public List<ResourceGroup> getInstalledResources() {
return installedResources;
}
public List<RegisteredResource> getUntransformedResources() {
return untransformedResources;
}
@Override
public String toString() {
return "InstallationState[active resources: " + this.activeResources +
", installed resources: " + this.installedResources +
", untransformed resources: " + this.untransformedResources + "]";
}
};
for(final String entityId : this.persistentList.getEntityIds()) {
if ( !this.persistentList.isSpecialEntityId(entityId) ) {
final EntityResourceList group = this.persistentList.getEntityResourceList(entityId);
final String alias = group.getAlias();
final List<Resource> resources = new ArrayList<Resource>();
for(final TaskResource tr : group.getResources()) {
resources.add(new Resource() {
public String getScheme() {
return tr.getScheme();
}
public String getURL() {
return tr.getURL();
}
public String getType() {
return tr.getType();
}
public InputStream getInputStream() throws IOException {
return tr.getInputStream();
}
public Dictionary<String, Object> getDictionary() {
return tr.getDictionary();
}
public String getDigest() {
return tr.getDigest();
}
public int getPriority() {
return tr.getPriority();
}
public String getEntityId() {
return tr.getEntityId();
}
public ResourceState getState() {
return tr.getState();
}
public Version getVersion() {
return tr.getVersion();
}
public long getLastChange() {
return ((RegisteredResourceImpl)tr).getLastChange();
}
public Object getAttribute(final String key) {
return tr.getAttribute(key);
}
@Override
public String toString() {
return "resource[entityId=" + this.getEntityId() +
", scheme=" + this.getScheme() +
", url=" + this.getURL() +
", type=" + this.getType() +
", state=" + this.getState() +
", version=" + this.getVersion() +
", lastChange=" + this.getLastChange() +
", priority=" + this.getPriority() +
", digest=" + this.getDigest() +
"]";
}
});
}
final ResourceGroup rg = new ResourceGroup() {
public List<Resource> getResources() {
return resources;
}
public String getAlias() {
return alias;
}
@Override
public String toString() {
return "group[" + resources + "]";
}
};
if ( group.getActiveResource() != null ) {
state.getActiveResources().add(rg);
} else {
state.getInstalledResources().add(rg);
}
}
}
Collections.sort(state.getActiveResources(), COMPARATOR);
Collections.sort(state.getInstalledResources(), COMPARATOR);
state.getUntransformedResources().addAll(this.persistentList.getUntransformedResources());
return state;
}
}