*
* @param foreignAttributes the foreign attributes
* @return the resource level
*/
public AFPResourceLevel getResourceLevel(Map/*<QName, String>*/ foreignAttributes) {
AFPResourceLevel resourceLevel = null;
if (foreignAttributes != null && !foreignAttributes.isEmpty()) {
if (foreignAttributes.containsKey(RESOURCE_LEVEL)) {
String levelString = (String)foreignAttributes.get(RESOURCE_LEVEL);
resourceLevel = AFPResourceLevel.valueOf(levelString);
// if external get resource group file attributes
if (resourceLevel != null && resourceLevel.isExternal()) {
String resourceGroupFile
= (String)foreignAttributes.get(RESOURCE_GROUP_FILE);
if (resourceGroupFile == null) {
String msg = RESOURCE_GROUP_FILE + " not specified";
log.error(msg);
throw new UnsupportedOperationException(msg);
}
File resourceExternalGroupFile = new File(resourceGroupFile);
SecurityManager security = System.getSecurityManager();
try {
if (security != null) {
security.checkWrite(resourceExternalGroupFile.getPath());
}
} catch (SecurityException ex) {
String msg = "unable to gain write access to external resource file: "
+ resourceGroupFile;
log.error(msg);
}
try {
boolean exists = resourceExternalGroupFile.exists();
if (exists) {
log.warn("overwriting external resource file: "
+ resourceGroupFile);
}
resourceLevel.setExternalFilePath(resourceGroupFile);
} catch (SecurityException ex) {
String msg = "unable to gain read access to external resource file: "
+ resourceGroupFile;
log.error(msg);
}