DSpace 5.4 XMLUI – 更改文件名
DSpace 5.4 XMLUI – changing file names
我们在 DSpace XMLUI 工作流程中实施了一个新步骤。此步骤更改上传文件的文件名。
我们已经尝试了两种不同的方法:
- 第一个:
我们按照提示操作
here。
问题是我们的编辑(他们有自己的用户组)是
显然无权更改文件名。即使我们给了
他们在所有可选集合中的比特流写入权限
仍然出现授权错误。
我们的方法是这样的:
private void updateFileName(DBConnection dspaceDbConnection, Context c, Item item, String fName)
throws Exception {
Bundle[] bundles = item.getBundles("ORIGINAL");
for (int i = 0; i < bundles.length; i++) {
Bitstream[] bitstreams = bundles[i].getBitstreams();
for (int j = 0; j < bitstreams.length; j++) {
bitstreams[j].setName(fileName);
bitstreams[j].update();
log.info("file name change:" + fileName);
}
}
c.commit();
- 由于这种方式没有成功,我们决定直接在数据库上通过 java 方法更改文件名(SQL,类似于 UPDATE metadatavalue SET text_value = . ..).
它运行良好,除了索引不会更新我们的数据库更改之外。
因此我们得到了以下问题:
- 在 DSpace 中更改文件名的首选或最佳方法是什么?
- 是否有可行的方法告诉索引对数据库进行特定更改?
或
- 有没有办法让 DSpace 组有权更改比特流元数据?
提前感谢您的建议!
您可以使用方法 context.turnOffAuthorisationSystem() 来暂时防止发生授权异常。确保在使用方法 context.restoreAuthSystemState()!
调用 context.commit() 后恢复授权
例如:
private void updateFileName(DBConnection dspaceDbConnection, Context c, Item item, String fName)
throws Exception {
try{
c.turnOffAuthorisationSystem()
Bundle[] bundles = item.getBundles("ORIGINAL");
for (int i = 0; i < bundles.length; i++) {
Bitstream[] bitstreams = bundles[i].getBitstreams();
for (int j = 0; j < bitstreams.length; j++) {
bitstreams[j].setName(fileName);
bitstreams[j].update();
log.info("file name change:" + fileName);
}
}
c.commit();
}
finally {
c.restoreAuthSystemState()
}
查看 DSpace 5x 代码,我在创建项目时在 Item.create() 中调用了以下内容。
// Call update to give the item a last modified date. OK this isn't
// amazingly efficient but creates don't happen that often.
context.turnOffAuthorisationSystem();
i.update();
context.restoreAuthSystemState();
context.addEvent(new Event(Event.CREATE, Constants.ITEM, i.getID(),
null, i.getIdentifiers(context)));
对于比特流,存在以下方法 Bitstream.updateLastModified()。
public void updateLastModified()
{
//Also fire a modified event since the bitstream HAS been modified
ourContext.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM, getID(), null, getIdentifiers(ourContext)));
}
您是否正在尝试获取索引以发现您分配给比特流的文件名?我不相信文件名在全文 (SOLR) 索引中。
我们在 DSpace XMLUI 工作流程中实施了一个新步骤。此步骤更改上传文件的文件名。 我们已经尝试了两种不同的方法:
- 第一个:
我们按照提示操作 here。 问题是我们的编辑(他们有自己的用户组)是 显然无权更改文件名。即使我们给了 他们在所有可选集合中的比特流写入权限 仍然出现授权错误。
我们的方法是这样的:
private void updateFileName(DBConnection dspaceDbConnection, Context c, Item item, String fName)
throws Exception {
Bundle[] bundles = item.getBundles("ORIGINAL");
for (int i = 0; i < bundles.length; i++) {
Bitstream[] bitstreams = bundles[i].getBitstreams();
for (int j = 0; j < bitstreams.length; j++) {
bitstreams[j].setName(fileName);
bitstreams[j].update();
log.info("file name change:" + fileName);
}
}
c.commit();
- 由于这种方式没有成功,我们决定直接在数据库上通过 java 方法更改文件名(SQL,类似于 UPDATE metadatavalue SET text_value = . ..).
它运行良好,除了索引不会更新我们的数据库更改之外。
因此我们得到了以下问题: - 在 DSpace 中更改文件名的首选或最佳方法是什么?
- 是否有可行的方法告诉索引对数据库进行特定更改?
或 - 有没有办法让 DSpace 组有权更改比特流元数据?
提前感谢您的建议!
您可以使用方法 context.turnOffAuthorisationSystem() 来暂时防止发生授权异常。确保在使用方法 context.restoreAuthSystemState()!
调用 context.commit() 后恢复授权例如:
private void updateFileName(DBConnection dspaceDbConnection, Context c, Item item, String fName)
throws Exception {
try{
c.turnOffAuthorisationSystem()
Bundle[] bundles = item.getBundles("ORIGINAL");
for (int i = 0; i < bundles.length; i++) {
Bitstream[] bitstreams = bundles[i].getBitstreams();
for (int j = 0; j < bitstreams.length; j++) {
bitstreams[j].setName(fileName);
bitstreams[j].update();
log.info("file name change:" + fileName);
}
}
c.commit();
}
finally {
c.restoreAuthSystemState()
}
查看 DSpace 5x 代码,我在创建项目时在 Item.create() 中调用了以下内容。
// Call update to give the item a last modified date. OK this isn't
// amazingly efficient but creates don't happen that often.
context.turnOffAuthorisationSystem();
i.update();
context.restoreAuthSystemState();
context.addEvent(new Event(Event.CREATE, Constants.ITEM, i.getID(),
null, i.getIdentifiers(context)));
对于比特流,存在以下方法 Bitstream.updateLastModified()。
public void updateLastModified()
{
//Also fire a modified event since the bitstream HAS been modified
ourContext.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM, getID(), null, getIdentifiers(ourContext)));
}
您是否正在尝试获取索引以发现您分配给比特流的文件名?我不相信文件名在全文 (SOLR) 索引中。