Refs #9999: Add modifiedBy in header of entities and relations
Task-Url: https://support.d4science.org/issues/9999 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158401 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ecbe981112
commit
4431d0f364
|
@ -356,11 +356,9 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
public El internalUpdate() throws ERNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
reallyUpdate();
|
||||
|
||||
// TODO update lastUpdater and lastUpdatetime
|
||||
|
||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
||||
((OrientVertex) element).save();
|
||||
|
||||
|
||||
return element;
|
||||
}catch (ResourceRegistryException e) {
|
||||
throw e;
|
||||
|
@ -391,11 +389,8 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
public boolean internalAddToContext() throws ContextException, ResourceRegistryException {
|
||||
try {
|
||||
boolean ret = reallyAddToContext();
|
||||
|
||||
// TODO update lastUpdater and lastUpdatetime
|
||||
|
||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
||||
((OrientVertex) element).save();
|
||||
|
||||
return ret && true;
|
||||
}catch (ResourceRegistryException e) {
|
||||
throw e;
|
||||
|
@ -410,11 +405,8 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
public boolean internalRemoveFromContext() throws ContextException, ResourceRegistryException {
|
||||
try {
|
||||
boolean ret = reallyRemoveFromContext();
|
||||
|
||||
// TODO update lastUpdater and lastUpdatetime
|
||||
|
||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
||||
((OrientVertex) element).save();
|
||||
|
||||
return ret && true;
|
||||
}catch (ResourceRegistryException e) {
|
||||
throw e;
|
||||
|
@ -621,18 +613,14 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
public String update() throws ERNotFoundException,
|
||||
ERAvailableInAnotherContextException, ResourceRegistryException {
|
||||
try {
|
||||
|
||||
orientGraph = ContextUtility
|
||||
.getActualSecurityContextGraph(PermissionMode.WRITER);
|
||||
|
||||
element = internalUpdate();
|
||||
|
||||
|
||||
orientGraph.commit();
|
||||
|
||||
// TODO Notify to subscriptionNotification
|
||||
|
||||
return serialize();
|
||||
|
||||
// TODO Serialized resource is the old version. This really strange and should be an orient bug
|
||||
|
||||
} catch (ResourceRegistryException e) {
|
||||
|
@ -657,14 +645,10 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
logger.debug("Going to delete {} with UUID {}", accessType.getName(), uuid);
|
||||
|
||||
try {
|
||||
/*
|
||||
orientGraph = ContextUtility
|
||||
.getActualSecurityContextGraph(PermissionMode.WRITER);
|
||||
*/
|
||||
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
orientGraph = SecurityContextMapper.getSecurityContextGraph(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.WRITER).getTx();
|
||||
PermissionMode.WRITER);
|
||||
|
||||
boolean deleted = reallyDelete();
|
||||
|
||||
|
@ -704,11 +688,11 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
accessType.getName(), uuid);
|
||||
|
||||
try {
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
orientGraph = SecurityContextMapper.getSecurityContextGraph(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.WRITER).getTx();
|
||||
PermissionMode.WRITER);
|
||||
|
||||
boolean added = reallyAddToContext();
|
||||
boolean added = internalAddToContext();
|
||||
|
||||
orientGraph.commit();
|
||||
logger.info("{} with UUID {} successfully added to actual Context",
|
||||
|
@ -734,11 +718,11 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
accessType.getName(), uuid);
|
||||
|
||||
try {
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
orientGraph = SecurityContextMapper.getSecurityContextGraph(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.WRITER).getTx();
|
||||
PermissionMode.WRITER);
|
||||
|
||||
boolean removed = reallyRemoveFromContext();
|
||||
boolean removed = internalRemoveFromContext();
|
||||
|
||||
orientGraph.commit();
|
||||
logger.info(
|
||||
|
|
|
@ -52,12 +52,12 @@ public class HeaderOrient extends ODocument implements org.gcube.informationsyst
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getLastUpdater() {
|
||||
return this.field(Header.LAST_UPDATER_PROPERTY);
|
||||
public String getModifiedBy() {
|
||||
return this.field(Header.MODIFIED_BY_PROPERTY);
|
||||
}
|
||||
|
||||
public void setLastUpdater(String lastUpdater){
|
||||
this.field(Header.LAST_UPDATER_PROPERTY, lastUpdater);
|
||||
public void setModifiedBy(String modifiedBy){
|
||||
this.field(Header.MODIFIED_BY_PROPERTY, modifiedBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.tinkerpop.blueprints.Element;
|
|||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class HeaderUtility {
|
||||
|
||||
|
@ -66,7 +65,7 @@ public class HeaderUtility {
|
|||
|
||||
String creator = getUser();
|
||||
header.setCreator(creator);
|
||||
header.setLastUpdater(creator);
|
||||
header.setModifiedBy(creator);
|
||||
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
|
||||
|
@ -110,7 +109,7 @@ public class HeaderUtility {
|
|||
headerOrient.setUUID(header.getUUID());
|
||||
headerOrient.setCreator(header.getCreator());
|
||||
headerOrient.setCreationTime(header.getCreationTime());
|
||||
headerOrient.setLastUpdater(header.getLastUpdater());
|
||||
headerOrient.setModifiedBy(header.getModifiedBy());
|
||||
headerOrient.setLastUpdateTime(header.getLastUpdateTime());
|
||||
return headerOrient;
|
||||
} catch (Exception e) {
|
||||
|
@ -125,7 +124,6 @@ public class HeaderUtility {
|
|||
return header;
|
||||
}
|
||||
|
||||
|
||||
public static Header addHeader(Edge edge, UUID uuid) {
|
||||
Header header = createHeader(uuid);
|
||||
edge.setProperty(Entity.HEADER_PROPERTY, header);
|
||||
|
@ -137,15 +135,12 @@ public class HeaderUtility {
|
|||
return Utility.getEmbedded(Header.class, element, Entity.HEADER_PROPERTY);
|
||||
}
|
||||
|
||||
|
||||
public static Header updateLastUpdateAndLastUpdater(Element element) throws ResourceRegistryException {
|
||||
HeaderOrient headerOrient = getHeaderOrient(element.getProperty(Entity.HEADER_PROPERTY));
|
||||
String lastUpdater = getUser();
|
||||
headerOrient.setLastUpdater(lastUpdater);
|
||||
public static void updateModifiedByAndLastUpdate(Element element) throws ResourceRegistryException {
|
||||
ODocument oDocument = element.getProperty(Entity.HEADER_PROPERTY);
|
||||
String modifiedBy = getUser();
|
||||
oDocument.field(Header.MODIFIED_BY_PROPERTY, modifiedBy);
|
||||
Date lastUpdateTime = Calendar.getInstance().getTime();
|
||||
headerOrient.setLastUpdateTime(lastUpdateTime);
|
||||
headerOrient.save();
|
||||
return headerOrient;
|
||||
oDocument.field(Header.LAST_UPDATE_TIME_PROPERTY, lastUpdateTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue