Return-Path:
* It adds:
*
*
*
* Sitemap parameters that can be specified to control processing are: *
version
(true
)
* whether to generate versioning information.locking
(true
)
* whether to generate locking information.permission
(true
)
* whether to generate permission information.properties
(true
)
* whether to generate source property information.SourceResolver
, objectModel Map
,
* the source and sitemap Parameters
used to process the request.
*
* @param resolver Source Resolver
* @param objectModel Object model.
* @param location Location of the source.
* @param parameters Parameters for the generator.
*/
public void setup(SourceResolver resolver, Map objectModel,
String location,
Parameters parameters)
throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, location, parameters);
this.properties = parameters.getParameterAsBoolean("properties", true);
this.permissions = parameters.getParameterAsBoolean("permissions", true);
this.locks = parameters.getParameterAsBoolean("locks", true);
this.version = parameters.getParameterAsBoolean("version", true);
}
/**
* Augments source nodes with additional information.
*
* @param source the Source to describe.
*/
protected void addContent(TraversableSource source)
throws SAXException, ProcessingException {
super.addContent(source);
try {
pushSourceDescription(source);
} catch (SourceException e) {
throw new ProcessingException(e);
}
}
/**
* Push a XML description of specified source.
*
* @param source the Source to describe.
*/
private void pushSourceDescription(Source source)
throws SAXException, SourceException {
if (source == null) {
return;
}
try {
if (this.properties) {
pushComputedSourceProperties(source);
if ((source instanceof InspectableSource)) {
pushLiveSourceProperties((InspectableSource) source);
}
}
if (this.permissions) {
try {
if (source instanceof RestrictableSource) {
pushSourcePermissions((RestrictableSource) source);
}
} catch (SourceException se) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Could not retrieve source permissions", se);
}
}
}
if (this.locks && (source instanceof LockableSource)) {
pushSourceLocks((LockableSource) source);
}
} catch (SAXException saxe) {
throw saxe;
}
}
/**
* Push a XML description about all properties, which
* the source owns.
*
* @param source the Source to describe.
*/
private void pushLiveSourceProperties(InspectableSource source)
throws SAXException, SourceException {
SourceProperty[] properties = source.getSourceProperties();
if (properties != null && properties.length > 0) {
SourceProperty property;
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute("", PROPERTY_TYPE_ATTR_NAME,
PROPERTY_TYPE_ATTR_NAME, "CDATA", "live");
this.contentHandler.startElement(URI, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME, attributes);
for (int i = 0; i < properties.length; i++) {
property = properties[i];
this.contentHandler.startPrefixMapping("",
property.getNamespace());
property.toSAX(this.contentHandler);
this.contentHandler.endPrefixMapping("");
}
this.contentHandler.endElement(URI, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME);
}
}
/**
* Push a XML description about all properties, which
* were computed by source inspectors.
*
* @param source the Source to describe.
*/
private void pushComputedSourceProperties(Source source)
throws SAXException, SourceException {
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute("", PROPERTY_TYPE_ATTR_NAME,
PROPERTY_TYPE_ATTR_NAME, "CDATA", "computed");
this.contentHandler.startElement(URI, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME, attributes);
SourceInspector inspector = null;
try {
inspector = (SourceInspector) this.manager.lookup(SourceInspector.ROLE);
SourceProperty[] properties = inspector.getSourceProperties(source);
for (int i = 0; i < properties.length; i++) {
this.contentHandler.startPrefixMapping("", properties[i].getNamespace());
properties[i].toSAX(this.contentHandler);
this.contentHandler.endPrefixMapping("");
}
} catch (ServiceException ce) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Could not retrieve source inspector", ce);
}
} finally {
if (inspector!=null) {
this.manager.release(inspector);
}
}
this.contentHandler.endElement(URI, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME);
}
/**
* Push a XML description of all permissions of a source.
*
* @param source the Source to describe.
*/
private void pushSourcePermissions(RestrictableSource source)
throws SAXException, SourceException {
SourcePermission[] permissions = source.getSourcePermissions();
if (permissions != null && permissions.length > 0) {
this.contentHandler.startElement(URI,
PERMISSIONS_NODE_NAME,
PERMISSIONS_NODE_QNAME,
new AttributesImpl());
for (int i = 0; i < permissions.length; i++) {
AttributesImpl attributes = new AttributesImpl();
if (permissions[i] instanceof PrincipalSourcePermission) {
attributes.addAttribute("", PRINCIPAL_ATTR_NAME,
PRINCIPAL_ATTR_NAME, "CDATA",
((PrincipalSourcePermission) permissions[i]).getPrincipal());
} else if (permissions[i] instanceof GroupSourcePermission) {
attributes.addAttribute("", GROUP_ATTR_NAME,
GROUP_ATTR_NAME, "CDATA",
((GroupSourcePermission) permissions[i]).getGroup());
}
attributes.addAttribute("", PRIVILEGE_ATTR_NAME,
PRIVILEGE_ATTR_NAME, "CDATA",
permissions[i].getPrivilege());
attributes.addAttribute("", INHERITABLE_ATTR_NAME,
INHERITABLE_ATTR_NAME, "CDATA",
String.valueOf(permissions[i].isInheritable()));
attributes.addAttribute("", NEGATIVE_ATTR_NAME,
NEGATIVE_ATTR_NAME, "CDATA",
String.valueOf(permissions[i].isNegative()));
this.contentHandler.startElement(URI,
PERMISSION_NODE_NAME,
PERMISSION_NODE_QNAME,
attributes);
this.contentHandler.endElement(URI,
PERMISSION_NODE_NAME,
PERMISSION_NODE_QNAME);
}
this.contentHandler.endElement(URI, PERMISSIONS_NODE_NAME,
PERMISSIONS_NODE_QNAME);
}
}
/**
* Push a XML description about all locks of a source.
*
* @param source the Source to describe.
*/
public void pushSourceLocks(LockableSource source)
throws SAXException, SourceException {
Enumeration locks = source.getSourceLocks();
SourceLock lock;
if (locks != null && locks.hasMoreElements()) {
this.contentHandler.startElement(URI, LOCKS_NODE_NAME,
LOCKS_NODE_QNAME,
new AttributesImpl());
while (locks.hasMoreElements()) {
lock = (SourceLock) locks.nextElement();
AttributesImpl attributes = new AttributesImpl();
attributes = new AttributesImpl();
attributes.addAttribute("", PRINCIPAL_ATTR_NAME,
PRINCIPAL_ATTR_NAME, "CDATA",
lock.getSubject());
attributes.addAttribute("", TYPE_ATTR_NAME, TYPE_ATTR_NAME,
"CDATA", lock.getType());
attributes.addAttribute("", EXPIRATION_ATTR_NAME,
EXPIRATION_ATTR_NAME, "CDATA",
lock.getExpiration().toString());
attributes.addAttribute("", INHERITABLE_ATTR_NAME,
INHERITABLE_ATTR_NAME, "CDATA",
String.valueOf(lock.isInheritable()));
attributes.addAttribute("", EXCLUSIVE_ATTR_NAME,
EXCLUSIVE_ATTR_NAME, "CDATA",
String.valueOf(lock.isExclusive()));
this.contentHandler.startElement(URI, LOCK_NODE_NAME,
LOCK_NODE_QNAME, attributes);
this.contentHandler.endElement(URI, LOCK_NODE_NAME,
LOCK_NODE_QNAME);
}
this.contentHandler.endElement(URI, LOCKS_NODE_NAME,
LOCKS_NODE_QNAME);
}
}
/**
* Augments node elements with additional attributes describing the Source.
* The additional attributes are a mimeType
attribute,
* and iff the Source is an instance of VersionableSource and the generator
* is configured to output versioning information two attributes:
* revision
and branch
.
*
* @param source the Source to describe.
*/
protected void setNodeAttributes(TraversableSource source) throws SAXException, ProcessingException {
super.setNodeAttributes(source);
if (!source.isCollection()) {
String mimeType = source.getMimeType();
if (mimeType != null) {
attributes.addAttribute("", MIME_TYPE_ATTR_NAME, MIME_TYPE_ATTR_NAME,
"CDATA", source.getMimeType());
}
}
if (this.version && (source instanceof VersionableSource)) {
try {
VersionableSource versionablesource = (VersionableSource) source;
if (versionablesource.isVersioned()) {
if ((versionablesource.getSourceRevision()!=null) &&
(versionablesource.getSourceRevision().length()>0)) {
attributes.addAttribute("",
REVISION_ATTR_NAME,
REVISION_ATTR_NAME, "CDATA",
versionablesource.getSourceRevision());
}
if ((versionablesource.getSourceRevisionBranch()!=null) &&
(versionablesource.getSourceRevisionBranch().length()>
0)) {
attributes.addAttribute("",
REVISIONBRANCH_ATTR_NAME,
REVISIONBRANCH_ATTR_NAME,
"CDATA",
versionablesource.getSourceRevisionBranch());
}
}
} catch (SourceException e) {
throw new ProcessingException(e);
}
}
}
}
1.94 +1 -2 cocoon-2.1/gump.xml
Index: gump.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/gump.xml,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- gump.xml 22 Oct 2003 19:28:08 -0000 1.93
+++ gump.xml 22 Oct 2003 21:11:19 -0000 1.94
@@ -109,7 +109,6 @@