use of digilib.io.DocuDirent in project digilib by robcast.
the class Manifester method writeCanvases.
/**
* @param dlDir
* @param url
* @param manifest
* @param servletUrl
*/
protected void writeCanvases(JsonGenerator manifest, ManifestParams params) {
/*
* list of canvases
*/
manifest.writeStartArray("canvases");
int idx = 0;
for (DocuDirent imgFile : params.docuDir) {
idx += 1;
ImageFileSet imgFs = (ImageFileSet) imgFile;
ImageInput img = imgFs.getBiggest();
ImageSize imgSize = img.getSize();
if (imgSize == null)
continue;
/*
* canvas
*/
writeCanvas(manifest, idx, imgFile, imgSize, params);
}
// canvases
manifest.writeEnd();
}
use of digilib.io.DocuDirent in project digilib by robcast.
the class MetaAccessAuthzOps method rolesForPath.
/**
* Return authorization roles needed for request.
*
* Returns the list of authorization roles that are needed to access the
* specified path. No list means the path is free.
*
* The location information of the request is also considered.
*
* @param request
* ServletRequest with address information.
* @throws AuthOpException
* Exception thrown on error.
* @return List of Strings with role names.
*/
@Override
public List<String> rolesForPath(DigilibServletRequest dlRequest) throws AuthOpException {
DocuDirent imgs;
try {
// try to get image file from JobDescription
ImageJobDescription ticket = dlRequest.getJobDescription();
if (ticket != null) {
imgs = (DocuDirent) ticket.getImageSet();
} else {
// try to get image file from DirCache
DigilibConfiguration config = dlRequest.getDigilibConfig();
DocuDirCache cache = (DocuDirCache) config.getValue(DigilibServletConfiguration.DIR_CACHE_KEY);
imgs = cache.getFile(dlRequest.getFilePath(), dlRequest.getAsInt("pn"));
}
} catch (FileOpException e) {
throw new AuthOpException("No file for auth check!");
}
/*
* get access restrictions from metadata
*/
String access = null;
try {
imgs.checkMeta();
MetadataMap meta = imgs.getMeta().getFileMeta();
if (meta != null) {
access = meta.get("access");
}
} catch (Exception e) {
logger.error("Error getting access meta for file!");
}
if (access == null) {
// no access tag - use default
logger.debug("Roles required for " + imgs.getName() + ": " + defaultRoles + "(default)");
return defaultRoles;
} else if (access.equalsIgnoreCase("free")) {
// access free
logger.debug("Roles required for " + imgs.getName() + ": (free)");
return null;
}
// get required roles
if (rolesMap.containsKey(access)) {
List<String> required = rolesMap.get(access);
logger.debug("Roles required for " + imgs.getName() + ": " + required);
return required;
} else {
// no mapping to role
logger.error("Error: no role for access type '" + access + "'");
// use default
logger.debug("Roles required for " + imgs.getName() + ": " + defaultRoles + "(substituted default)");
return defaultRoles;
}
}
use of digilib.io.DocuDirent in project digilib by robcast.
the class IndexMetaDirMeta method readFileMeta.
/**
* Read metadata for the files in this directory.
*
* Takes a Map with meta-information, adding the relative path before the
* lookup.
* @param dir
*
* @param fileMeta
* @param relPath
* @param fc
* fileClass
*/
protected void readFileMeta(DocuDirectory dir, Map<String, MetadataMap> fileMeta, String relPath) {
String path = (relPath != null) ? (relPath + "/") : "";
// go through all file classes
int ds = dir.size();
if (ds == 0) {
return;
}
// iterate through the list of files in this directory
for (int i = 0; i < ds; ++i) {
DocuDirent f = dir.get(i);
// prepend path to the filename
String fn = path + f.getName();
// look up meta for this file and remove from dir
MetadataMap meta = fileMeta.remove(fn);
if (meta != null) {
// store meta in file
f.getMeta().setFileMeta(meta);
}
}
}
Aggregations