Merge branch 'maint-rel-1.6' into develop
This commit is contained in:
commit
a408da5e9b
2 changed files with 22 additions and 40 deletions
|
@ -623,6 +623,8 @@ public class JenaIngestController extends BaseEditController {
|
||||||
String oldNamespace = vreq.getParameter("oldNamespace");
|
String oldNamespace = vreq.getParameter("oldNamespace");
|
||||||
String newNamespace = vreq.getParameter("newNamespace");
|
String newNamespace = vreq.getParameter("newNamespace");
|
||||||
String dNamespace = vreq.getParameter("defaultNamespace");
|
String dNamespace = vreq.getParameter("defaultNamespace");
|
||||||
|
newNamespace = (newNamespace == null || newNamespace.isEmpty()) ? oldNamespace : newNamespace;
|
||||||
|
newNamespace = (dNamespace != null) ? dNamespace : newNamespace;
|
||||||
if(modelName!=null){
|
if(modelName!=null){
|
||||||
Model m = maker.getModel(modelName);
|
Model m = maker.getModel(modelName);
|
||||||
ArrayList namespaceList = new ArrayList();
|
ArrayList namespaceList = new ArrayList();
|
||||||
|
@ -645,7 +647,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
vreq.setAttribute("bodyJsp",PERMANENT_URI);
|
vreq.setAttribute("bodyJsp",PERMANENT_URI);
|
||||||
} else if(oldModel != null) {
|
} else if(oldModel != null) {
|
||||||
JenaIngestUtils utils = new JenaIngestUtils();
|
JenaIngestUtils utils = new JenaIngestUtils();
|
||||||
utils.doPermanentURI(oldModel,newModel,oldNamespace,newNamespace,dNamespace,maker,vreq);
|
utils.doPermanentURI(oldModel, newModel, oldNamespace, newNamespace, maker, vreq);
|
||||||
vreq.setAttribute("title","Ingest Menu");
|
vreq.setAttribute("title","Ingest Menu");
|
||||||
vreq.setAttribute("bodyJsp",INGEST_MENU_JSP);
|
vreq.setAttribute("bodyJsp",INGEST_MENU_JSP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,16 +730,19 @@ public class JenaIngestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doPermanentURI(String oldModel, String newModel, String oldNamespace,
|
public void doPermanentURI(String oldModel, String newModel, String oldNamespace,
|
||||||
String newNamespace, String dNamespace, ModelMaker maker,
|
String newNamespace, ModelMaker maker,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
|
|
||||||
|
if(newNamespace.isEmpty()){
|
||||||
|
throw new RuntimeException("new namespace must be specified");
|
||||||
|
}
|
||||||
|
|
||||||
WebappDaoFactory wdf = vreq.getUnfilteredWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getUnfilteredWebappDaoFactory();
|
||||||
Model m = maker.getModel(oldModel);
|
Model m = maker.getModel(oldModel);
|
||||||
Model saveModel = maker.getModel(newModel);
|
Model saveModel = maker.getModel(newModel);
|
||||||
Model tempModel = ModelFactory.createDefaultModel();
|
Model tempModel = ModelFactory.createDefaultModel();
|
||||||
ResIterator rsItr = null;
|
ResIterator rsItr = null;
|
||||||
ArrayList<String> urlCheck = new ArrayList<String>();
|
ArrayList<String> urlCheck = new ArrayList<String>();
|
||||||
String changeNamespace = null;
|
|
||||||
boolean urlFound = false;
|
boolean urlFound = false;
|
||||||
if(!oldModel.equals(newModel)){
|
if(!oldModel.equals(newModel)){
|
||||||
StmtIterator stmtItr = m.listStatements();
|
StmtIterator stmtItr = m.listStatements();
|
||||||
|
@ -755,42 +758,20 @@ public class JenaIngestUtils {
|
||||||
String uri = null;
|
String uri = null;
|
||||||
while(rsItr.hasNext()){
|
while(rsItr.hasNext()){
|
||||||
Resource res = rsItr.next();
|
Resource res = rsItr.next();
|
||||||
if(oldNamespace.equals(res.getNameSpace())){
|
if(res.getNameSpace().equals(oldNamespace)){
|
||||||
if(!newNamespace.equals("")){
|
do{
|
||||||
do{
|
uri = getUnusedURI(newNamespace,wdf);
|
||||||
uri = getUnusedURI(newNamespace,wdf);
|
if(!urlCheck.contains(uri)){
|
||||||
if(!urlCheck.contains(uri)){
|
urlCheck.add(uri);
|
||||||
urlCheck.add(uri);
|
urlFound = true;
|
||||||
urlFound = true;
|
|
||||||
}
|
|
||||||
}while(!urlFound);
|
|
||||||
urlFound = false;
|
|
||||||
}
|
|
||||||
else if(dNamespace.equals(vreq.getUnfilteredWebappDaoFactory().getDefaultNamespace())){
|
|
||||||
try{
|
|
||||||
do{
|
|
||||||
uri = wdf.getIndividualDao().getUnusedURI(null);
|
|
||||||
if(!urlCheck.contains(uri)){
|
|
||||||
urlCheck.add(uri);
|
|
||||||
urlFound = true;
|
|
||||||
}
|
|
||||||
}while(!urlFound);
|
|
||||||
urlFound = false;
|
|
||||||
}catch(InsertException ex){
|
|
||||||
log.error("could not create uri");
|
|
||||||
}
|
}
|
||||||
}
|
}while(!urlFound);
|
||||||
|
urlFound = false;
|
||||||
ResourceUtils.renameResource(res, uri);
|
ResourceUtils.renameResource(res, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
boolean statementDone = false;
|
boolean statementDone = false;
|
||||||
if(!newNamespace.equals("")){
|
|
||||||
changeNamespace = newNamespace;
|
|
||||||
}
|
|
||||||
else if(dNamespace.equals(vreq.getUnfilteredWebappDaoFactory().getDefaultNamespace())){
|
|
||||||
changeNamespace = dNamespace;
|
|
||||||
}
|
|
||||||
if(!oldModel.equals(newModel)){
|
if(!oldModel.equals(newModel)){
|
||||||
StmtIterator stmtItr = tempModel.listStatements();
|
StmtIterator stmtItr = tempModel.listStatements();
|
||||||
while(stmtItr.hasNext()){
|
while(stmtItr.hasNext()){
|
||||||
|
@ -798,18 +779,17 @@ public class JenaIngestUtils {
|
||||||
Statement stmt = stmtItr.nextStatement();
|
Statement stmt = stmtItr.nextStatement();
|
||||||
Resource sRes = stmt.getSubject();
|
Resource sRes = stmt.getSubject();
|
||||||
Resource oRes = null;
|
Resource oRes = null;
|
||||||
if(sRes.getNameSpace().equals(changeNamespace)){
|
if(sRes.getNameSpace().equals(newNamespace)){
|
||||||
saveModel.add(stmt);
|
saveModel.add(stmt);
|
||||||
statementDone = true;
|
statementDone = true;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
oRes = (Resource)stmt.getObject();
|
oRes = (Resource) stmt.getObject();
|
||||||
if(oRes.getNameSpace().equals(changeNamespace) && !statementDone){
|
if(oRes.getNameSpace().equals(newNamespace) && !statementDone){
|
||||||
saveModel.add(stmt);
|
saveModel.add(stmt);
|
||||||
statementDone = true;
|
statementDone = true;
|
||||||
}
|
}
|
||||||
}
|
} catch(Exception e){
|
||||||
catch(Exception e){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue