@@ -0,0 +1,1468 @@
+package nz.ac.lconz.irr.dspace.app.xmlui.aspect.general;%0A%0Aimport org.apache.avalon.framework.logger.AbstractLogEnabled;%0Aimport org.apache.avalon.framework.parameters.Parameters;%0Aimport org.apache.cocoon.selection.Selector;%0Aimport org.dspace.app.xmlui.utils.ContextUtil;%0Aimport org.dspace.app.xmlui.utils.HandleUtil;%0Aimport org.dspace.content.DSpaceObject;%0Aimport org.dspace.core.Constants;%0Aimport org.dspace.core.Context;%0A%0Aimport java.sql.SQLException;%0Aimport java.util.Map;%0A%0A/**%0A * @author Andrea Schweer schweer@waikato.ac.nz%0A *%0A * Cocoon sitemap selector that indicates what type of item where looking at%0A *%0A */%0Apublic class HandleTypeSelector extends AbstractLogEnabled implements%0A%09%09Selector %7B%0A%0A%09@Override%0A%09public boolean select(String expression, Map objectModel, Parameters parameters) %7B%0A%0A%09%09try %7B%0A%09%09%09Context context = ContextUtil.obtainContext(objectModel);%0A%09%09%09DSpaceObject dso = HandleUtil.obtainHandle(objectModel);%0A%09%09%09if (dso == null) %7B%0A%09%09%09%09return expression.equals(%22other%22);%0A%09%09%09%7D%0A%09%09%09int type = dso.getType();%0A%09%09%09if (type == Constants.COMMUNITY && expression.equals(%22community%22)) %7B%0A%09%09%09%09return true;%0A%09%09%09%7D else if (type == Constants.COLLECTION && expression.equals(%22collection%22)) %7B%0A%09%09%09%09return true;%0A%09%09%09%7D else if (type == Constants.ITEM && expression.equals(%22item%22)) %7B%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%09return expression.equals(%22other%22);%0A%09%09%7D catch (SQLException e) %7B%0A%09%09%09getLogger().warn(%22Cannot obtain context%22, e);%0A%09%09%7D%0A%09%09return false; // fallback in case of errors%0A%09%7D%0A%7D%0A

Handle type selector, generic util selector