PAPIAttributes papiAttributes)
throws PAPIException {
ScriptAttributes attributes = (ScriptAttributes) papiAttributes;
MarinerPageContext pageContext
= ContextInternals.getMarinerPageContext(context);
VolantisProtocol protocol = pageContext.getProtocol();
// Check if the Policy x-element.script.supported is set to default, via
// the supportsScriptType() method of protocol. If so, exercise the same
// behaviour as before VBM 20080131102 ie. check the "protocol"
// support and followup check on boolean device policy "javascript".
if ((protocol.supportsScriptType() == null) ||
("default".equals(protocol.supportsScriptType())) ) {
// Check to see whether the protocol supports java script and the
// device supports JavaScript, if either don't then skip the body.
//
// Note: This functionality is copied directly from the ScriptTag.
if (!protocol.supportsJavaScript ()
|| !pageContext.getBooleanDevicePolicyValue (SUPPORTS_JAVASCRIPT)) {
return SKIP_ELEMENT_BODY;
}
} else if ("full".equals(protocol.supportsScriptType())) {
// Scripts are supported in an override due to the, so just check
// on the device javascript policy to enable it fully. If it's not
// set then return (SKIP), otherwise carry on. NOTE: Here, where are
// getting the opinion of the actual device, not an inference derived
// from the protocol.
if (!pageContext.getBooleanDevicePolicyValue (SUPPORTS_JAVASCRIPT)) {
return SKIP_ELEMENT_BODY;
}
} else {
// If "none" or other is specified, SKIP this entirely irrespective
// of any other settings.
return SKIP_ELEMENT_BODY;
}
PolicyReferenceResolver resolver =
pageContext.getPolicyReferenceResolver();
// Parse the source expression.
ScriptAssetReference src
= resolver.resolveQuotedScriptExpression(attributes.getSrc());
// Set the attributes used in both modes.
String id = attributes.getId();
pattributes.setId(id);
pattributes.setDefer(attributes.getDefer());
// @todo this code duplicates the functionality of the protocols Script
// object. we should refactor it away...
if (src != null && src.isPolicyReference()) {
ScriptAsset asset = src.getScriptAsset();
// If no asset was found then there is nothing more to do.
if (asset == null) {
return SKIP_ELEMENT_BODY;
}
// If an id was specified then we need to remember whether we found a
// suitable ScriptAsset, or not.
if (id != null) {
pageContext.putIdValue(id, asset);
}
pattributes.setScriptReference(src);
pattributes.setCharSet(asset.getCharacterSet());
pattributes.setType(asset.getMimeType());