Merge pull request #1509 from sedici/DS-3280

DS-3280 Fix HQL Syntax at HandleDAOImpl
This commit is contained in:
Pascal-Nicolas Becker
2016-09-21 17:56:03 +02:00
committed by GitHub
3 changed files with 9 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.content.dao.MetadataValueDAO;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.DSpaceObjectService;
import org.dspace.content.service.MetadataValueService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
@@ -80,7 +81,10 @@ public class MetadataValueServiceImpl implements MetadataValueService {
public void update(Context context, MetadataValue metadataValue, boolean updateLastModified) throws SQLException, AuthorizeException {
if(updateLastModified){
authorizeService.authorizeAction(context, metadataValue.getDSpaceObject(), Constants.WRITE);
contentServiceFactory.getDSpaceObjectService(metadataValue.getDSpaceObject()).updateLastModified(context, metadataValue.getDSpaceObject());
DSpaceObjectService<DSpaceObject> dSpaceObjectService = contentServiceFactory.getDSpaceObjectService(metadataValue.getDSpaceObject());
// get the right class for our dspaceobject not the DSpaceObject lazy proxy
DSpaceObject dso = dSpaceObjectService.find(context, metadataValue.getDSpaceObject().getID());
dSpaceObjectService.updateLastModified(context, dso);
}
update(context, metadataValue);
}

View File

@@ -81,6 +81,7 @@ public class UpdateHandlePrefix
if (choiceString.equalsIgnoreCase("y"))
{
context.turnOffAuthorisationSystem();
try {
log.info("Updating handle prefix from " + oldH + " to " + newH);
@@ -96,7 +97,7 @@ public class UpdateHandlePrefix
List<MetadataValue> metadataValues = metadataValueService.findByValueLike(context, "http://hdl.handle.net/");
int updMeta = metadataValues.size();
for (MetadataValue metadataValue : metadataValues) {
metadataValue.setValue("http://hdl.handle.net/" + newH);
metadataValue.setValue(metadataValue.getValue().replace("http://hdl.handle.net/" + oldH, "http://hdl.handle.net/" + newH));
metadataValueService.update(context, metadataValue, true);
}
System.out.println(
@@ -146,6 +147,7 @@ public class UpdateHandlePrefix
);
throw e;
}
context.restoreAuthSystemState();
}
else
{

View File

@@ -93,7 +93,7 @@ public class HandleDAOImpl extends AbstractHibernateDAO<Handle> implements Handl
@Override
public int updateHandlesWithNewPrefix(Context context, String newPrefix, String oldPrefix) throws SQLException
{
String hql = "UPDATE handle set handle = concat(:newPrefix,'/',id WHERE handle like :oldPrefix%";
String hql = "UPDATE Handle set handle = concat(:newPrefix,'/',id) WHERE handle like concat(:oldPrefix,'%')";
Query query = createQuery(context, hql);
query.setString("newPrefix", newPrefix);
query.setString("oldPrefix", oldPrefix);