(Scott Phillips) Fixed language tags in the restricted item code that were not translatable into other languages because "item", "community", "collection" were being passed in as parameters to the string.

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2705 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Scott Phillips
2008-02-21 18:01:06 +00:00
parent 68defbecef
commit f9aa8b801b
2 changed files with 81 additions and 46 deletions

View File

@@ -57,6 +57,7 @@ import org.dspace.content.Bitstream;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.xml.sax.SAXException;
/**
@@ -76,11 +77,36 @@ public class RestrictedItem extends AbstractDSpaceTransformer //implements Cache
private static final Message T_trail =
message("xmlui.ArtifactBrowser.RestrictedItem.trail");
private static final Message T_head =
message("xmlui.ArtifactBrowser.RestrictedItem.head");
private static final Message T_head_resource =
message("xmlui.ArtifactBrowser.RestrictedItem.head_resource");
private static final Message T_head_community =
message("xmlui.ArtifactBrowser.RestrictedItem.head_community");
private static final Message T_head_collection =
message("xmlui.ArtifactBrowser.RestrictedItem.head_collection");
private static final Message T_head_item =
message("xmlui.ArtifactBrowser.RestrictedItem.head_item");
private static final Message T_head_bitstream =
message("xmlui.ArtifactBrowser.RestrictedItem.head_bitstream");
private static final Message T_para_resource =
message("xmlui.ArtifactBrowser.RestrictedItem.para_resource");
private static final Message T_para_community =
message("xmlui.ArtifactBrowser.RestrictedItem.para_community");
private static final Message T_para_collection =
message("xmlui.ArtifactBrowser.RestrictedItem.para_collection");
private static final Message T_para_item =
message("xmlui.ArtifactBrowser.RestrictedItem.para_item");
private static final Message T_para_bitstream =
message("xmlui.ArtifactBrowser.RestrictedItem.para_bitstream");
private static final Message T_para =
message("xmlui.ArtifactBrowser.RestrictedItem.para");
public void addPageMeta(PageMeta pageMeta) throws SAXException,
WingException, UIException, SQLException, IOException,
@@ -104,58 +130,65 @@ public class RestrictedItem extends AbstractDSpaceTransformer //implements Cache
Request request = ObjectModelHelper.getRequest(objectModel);
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
String type = null;
String identifier = null;
Division unauthorized = body.addDivision("unauthorized-resource","primary");
if (dso == null)
{
type = "resource";
identifier = "unknown";
unauthorized.setHead(T_head_resource);
unauthorized.addPara(T_para_resource);
}
else if (dso instanceof Community)
{
Community community = (Community) dso;
identifier = community.getMetadata("name");
type = "community";
unauthorized.setHead(T_head_community);
unauthorized.addPara(T_para_community.parameterize(community.getMetadata("name")));
}
else if (dso instanceof Collection)
{
Collection collection = (Collection) dso;
identifier = collection.getMetadata("name");
type = "collection";
}
else
unauthorized.setHead(T_head_collection);
unauthorized.addPara(T_para_collection.parameterize(collection.getMetadata("name")));
}
else if (dso instanceof Item)
{
String handle = dso.getHandle();
type = "item";
if (handle == null || "".equals(handle))
// The dso may be an item but it could still be an item's bitstream. So let's check for the parameter.
if (request.getParameter("bitstreamId") != null)
{
identifier = "internal ID: " + dso.getID();
}
else
{
identifier = "hdl:"+handle;
}
if (request.getParameter("bitstreamId")!=null){
type = "bitstream";
try{
String identifier = "unknown";
try {
Bitstream bit = Bitstream.find(context, new Integer(request.getParameter("bitstreamId")));
if(bit!=null){
if (bit != null) {
identifier = bit.getName();
}
else{
identifier = "unknown";
}
}
catch(Exception e){
catch(Exception e) {
// just forget it - and display the restricted message.
}
unauthorized.setHead(T_head_bitstream);
unauthorized.addPara(T_para_bitstream.parameterize(identifier));
}
else
{
String identifier = "unknown";
String handle = dso.getHandle();
if (handle == null || "".equals(handle))
{
identifier = "internal ID: " + dso.getID();
}
else
{
identifier = "hdl:"+handle;
}
unauthorized.setHead(T_head_item);
unauthorized.addPara(T_para_item.parameterize(identifier));
}
}
else
{
// This case should not occure, but if it does just fall back to the resource message.
unauthorized.setHead(T_head_resource);
unauthorized.addPara(T_para_resource);
}
Division unauthorized = body.addDivision("unauthorized-item","primary");
unauthorized.setHead(T_head.parameterize(type));
unauthorized.addPara(T_para.parameterize(new Object[]{type,identifier}));
}
}

View File

@@ -271,17 +271,19 @@
<message key="xmlui.ArtifactBrowser.SimpleSearch.search_scope">Search Scope</message>
<message key="xmlui.ArtifactBrowser.SimpleSearch.full_text_search">Full Text Search</message>
<!-- org.dspace.app.xmlui.artifactbrowser.RestrictedItem.java -->
<message key="xmlui.ArtifactBrowser.RestrictedItem.title">This item is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.trail">Restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head">This item is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para">The item you tried to access, <b>{0}</b>, is a restricted item and requires credentials that you do not have.</message>
<!-- org.dspace.app.xmlui.artifactbrowser.RestrictedItem.java -->
<message key="xmlui.ArtifactBrowser.RestrictedItem.title">This resource is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.trail">Restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head">This {0} is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para">The {0} you tried to access, <b>{1}</b>, is a restricted {0} and requires credentials that you do not have.</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head_resource">This resource is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head_community">This community is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head_collection">This collection is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head_item">This item is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.head_bitstream">This bitstream is restricted</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para_resource">You do not have the credentials to access the restricted resource.</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para_community">You do not have the credentials to access the restricted community <b>{0}</b>.</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para_collection">You do not have the credentials to access the restricted collection <b>{0}</b>.</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para_item">You do not have the credentials to access the restricted item <b>{0}</b>.</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.para_bitstream">You do not have the credentials to access the restricted bitstream <b>{0}</b>.</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.type_collection">collection</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.type_community">community</message>
<message key="xmlui.ArtifactBrowser.RestrictedItem.type_bitstream">bitstream</message>