Adding support to set last-updater on header refs #9999

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@157620 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-10-26 15:09:07 +00:00
parent ea7a49b6d7
commit 56a36499cd
7 changed files with 148 additions and 67 deletions

View File

@ -78,6 +78,7 @@ import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientElement; import com.tinkerpop.blueprints.impls.orient.OrientElement;
import com.tinkerpop.blueprints.impls.orient.OrientGraph; import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
import com.tinkerpop.blueprints.util.StringFactory; import com.tinkerpop.blueprints.util.StringFactory;
/** /**
@ -325,28 +326,102 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
public abstract JSONObject serializeAsJson() public abstract JSONObject serializeAsJson()
throws ResourceRegistryException; throws ResourceRegistryException;
public abstract El reallyCreate() throws ERAlreadyPresentException, protected abstract El reallyCreate() throws ERAlreadyPresentException,
ResourceRegistryException; ResourceRegistryException;
public abstract El reallyUpdate() throws ERNotFoundException, public El internalCreate() throws ERAlreadyPresentException, ResourceRegistryException {
ResourceRegistryException;
public El reallyCreateOrUdate() throws ResourceRegistryException {
try { try {
return reallyUpdate(); reallyCreate();
}catch (ERNotFoundException e) { Header entityHeader = HeaderUtility.getHeader(jsonNode, true);
return reallyCreate(); if (entityHeader != null) {
element.setProperty(Entity.HEADER_PROPERTY, entityHeader);
} else {
entityHeader = HeaderUtility.addHeader(element, null);
}
ContextUtility.addToActualContext(orientGraph, element);
((OrientVertex) element).save();
return element;
}catch (ResourceRegistryException e) {
throw e;
} catch (Exception e) {
throw new ResourceRegistryException("Error Creating " + erType + " with " + jsonNode, e.getCause());
} }
} }
public abstract boolean reallyDelete() throws ERNotFoundException, protected abstract El reallyUpdate() throws ERNotFoundException,
ResourceRegistryException; ResourceRegistryException;
public abstract boolean reallyAddToContext() throws ContextException, public El internalUpdate() throws ERNotFoundException, ResourceRegistryException {
try {
reallyUpdate();
// TODO update lastUpdater and lastUpdatetime
((OrientVertex) element).save();
return element;
}catch (ResourceRegistryException e) {
throw e;
} catch (Exception e) {
throw new ResourceRegistryException("Error Updating " + erType + " with " + jsonNode, e.getCause());
}
}
public El internalCreateOrUdate() throws ResourceRegistryException {
try {
return internalUpdate();
}catch (ERNotFoundException e) {
return internalCreate();
}
}
protected abstract boolean reallyDelete() throws ERNotFoundException,
ResourceRegistryException; ResourceRegistryException;
public abstract boolean reallyRemoveFromContext() throws ContextException, public boolean internalDelete() throws ERNotFoundException, ResourceRegistryException {
// Added for consistency with create and update addToContext removeFromContext.
return reallyDelete();
}
protected abstract boolean reallyAddToContext() throws ContextException,
ResourceRegistryException; ResourceRegistryException;
public boolean internalAddToContext() throws ContextException, ResourceRegistryException {
try {
boolean ret = reallyAddToContext();
// TODO update lastUpdater and lastUpdatetime
((OrientVertex) element).save();
return ret && true;
}catch (ResourceRegistryException e) {
throw e;
} catch (Exception e) {
throw new ResourceRegistryException("Error Adding " + erType + " to Current Context ", e.getCause());
}
}
protected abstract boolean reallyRemoveFromContext() throws ContextException,
ResourceRegistryException;
public boolean internalRemoveFromContext() throws ContextException, ResourceRegistryException {
try {
boolean ret = reallyRemoveFromContext();
// TODO update lastUpdater and lastUpdatetime
((OrientVertex) element).save();
return ret && true;
}catch (ResourceRegistryException e) {
throw e;
} catch (Exception e) {
throw new ResourceRegistryException("Error Removing " + erType + " from Current Context ", e.getCause());
}
}
public void setElement(El element) throws ResourceRegistryException { public void setElement(El element) throws ResourceRegistryException {
if (element == null) { if (element == null) {
@ -498,10 +573,12 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
try { try {
orientGraph = ContextUtility.getActualSecurityContextGraph(PermissionMode.WRITER); orientGraph = ContextUtility.getActualSecurityContextGraph(PermissionMode.WRITER);
element = reallyCreate(); element = internalCreate();
orientGraph.commit(); orientGraph.commit();
// TODO Notify to subscriptionNotification
return serialize(); return serialize();
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
@ -548,12 +625,16 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
orientGraph = ContextUtility orientGraph = ContextUtility
.getActualSecurityContextGraph(PermissionMode.WRITER); .getActualSecurityContextGraph(PermissionMode.WRITER);
element = reallyUpdate(); element = internalUpdate();
orientGraph.commit(); orientGraph.commit();
// TODO Notify to subscriptionNotification
return serialize(); return serialize();
// TODO Serialized resource is the old version. This really strange and should be an orient bug
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
if (orientGraph != null) { if (orientGraph != null) {
orientGraph.rollback(); orientGraph.rollback();

View File

@ -6,7 +6,6 @@ package org.gcube.informationsystem.resourceregistry.er.entity;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.gcube.informationsystem.model.AccessType; import org.gcube.informationsystem.model.AccessType;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.model.entity.Entity; import org.gcube.informationsystem.model.entity.Entity;
import org.gcube.informationsystem.model.entity.Facet; import org.gcube.informationsystem.model.entity.Facet;
import org.gcube.informationsystem.model.entity.Resource; import org.gcube.informationsystem.model.entity.Resource;
@ -19,7 +18,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFound
import org.gcube.informationsystem.resourceregistry.context.ContextUtility; import org.gcube.informationsystem.resourceregistry.context.ContextUtility;
import org.gcube.informationsystem.resourceregistry.er.ERManagement; import org.gcube.informationsystem.resourceregistry.er.ERManagement;
import org.gcube.informationsystem.resourceregistry.er.relation.RelationManagement; import org.gcube.informationsystem.resourceregistry.er.relation.RelationManagement;
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.utils.Utility; import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -62,10 +60,6 @@ public abstract class EntityManagement<E extends Entity> extends
this.orientGraph = orientGraph; this.orientGraph = orientGraph;
} }
@Override
public abstract Vertex reallyCreate() throws EntityAlreadyPresentException,
ResourceRegistryException;
protected Vertex createVertex() throws EntityAlreadyPresentException, protected Vertex createVertex() throws EntityAlreadyPresentException,
ResourceRegistryException { ResourceRegistryException {
@ -110,25 +104,25 @@ public abstract class EntityManagement<E extends Entity> extends
this.element = vertexEntity; this.element = vertexEntity;
Header entityHeader = HeaderUtility.getHeader(jsonNode, true); if (accessType==AccessType.RESOURCE) {
if (entityHeader != null) {
element.setProperty(Entity.HEADER_PROPERTY, entityHeader);
} else {
entityHeader = HeaderUtility.addHeader(element, null);
}
if (accessType.compareTo(AccessType.RESOURCE)==0) {
// Facet and relation are created in calling method // Facet and relation are created in calling method
} else { } else {
ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys,
ignoreStartWithKeys); ignoreStartWithKeys);
} }
/* This code has been moved in ERManagement.internalCreate()
Header entityHeader = HeaderUtility.getHeader(jsonNode, true);
if (entityHeader != null) {
element.setProperty(Entity.HEADER_PROPERTY, entityHeader);
} else {
entityHeader = HeaderUtility.addHeader(element, null);
}
ContextUtility.addToActualContext(orientGraph, element); ContextUtility.addToActualContext(orientGraph, element);
((OrientVertex) element).save(); ((OrientVertex) element).save();
*/
logger.info("Created {} is {}", Vertex.class.getSimpleName(), logger.info("Created {} is {}", Vertex.class.getSimpleName(),
Utility.toJsonString((OrientVertex) element, true)); Utility.toJsonString((OrientVertex) element, true));
@ -144,7 +138,7 @@ public abstract class EntityManagement<E extends Entity> extends
} }
@Override @Override
public boolean reallyAddToContext() throws ContextException, protected boolean reallyAddToContext() throws ContextException,
ResourceRegistryException { ResourceRegistryException {
ContextUtility.addToActualContext(orientGraph, getElement()); ContextUtility.addToActualContext(orientGraph, getElement());
@ -155,14 +149,14 @@ public abstract class EntityManagement<E extends Entity> extends
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
RelationManagement relationManagement = RelationManagement RelationManagement relationManagement = RelationManagement
.getRelationManagement(orientGraph, edge); .getRelationManagement(orientGraph, edge);
relationManagement.reallyAddToContext(); relationManagement.internalAddToContext();
} }
return true; return true;
} }
@Override @Override
public boolean reallyRemoveFromContext() throws ContextException, protected boolean reallyRemoveFromContext() throws ContextException,
ResourceRegistryException { ResourceRegistryException {
ContextUtility.removeFromActualContext(orientGraph, getElement()); ContextUtility.removeFromActualContext(orientGraph, getElement());
@ -173,7 +167,7 @@ public abstract class EntityManagement<E extends Entity> extends
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
RelationManagement relationManagement = RelationManagement RelationManagement relationManagement = RelationManagement
.getRelationManagement(orientGraph, edge); .getRelationManagement(orientGraph, edge);
relationManagement.reallyRemoveFromContext(); relationManagement.internalRemoveFromContext();
} }
return true; return true;

View File

@ -13,7 +13,6 @@ import org.gcube.informationsystem.resourceregistry.er.ERManagement;
import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph; import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
@ -40,20 +39,19 @@ public class FacetManagement extends EntityManagement<Facet> {
} }
@Override @Override
public Vertex reallyCreate() throws FacetAlreadyPresentException, ResourceRegistryException { protected Vertex reallyCreate() throws FacetAlreadyPresentException, ResourceRegistryException {
return createVertex(); return createVertex();
} }
@Override @Override
public Vertex reallyUpdate() throws FacetNotFoundException, ResourceRegistryException { protected Vertex reallyUpdate() throws FacetNotFoundException, ResourceRegistryException {
Vertex facet = getElement(); Vertex facet = getElement();
facet = (Vertex) ERManagement.updateProperties(oClass, facet, jsonNode, ignoreKeys, ignoreStartWithKeys); facet = (Vertex) ERManagement.updateProperties(oClass, facet, jsonNode, ignoreKeys, ignoreStartWithKeys);
((OrientVertex) facet).save();
return facet; return facet;
} }
@Override @Override
public boolean reallyDelete() throws FacetNotFoundException, ResourceRegistryException { protected boolean reallyDelete() throws FacetNotFoundException, ResourceRegistryException {
getElement().remove(); getElement().remove();
return true; return true;
} }

View File

@ -138,7 +138,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
} }
@Override @Override
public Vertex reallyCreate() throws ResourceAlreadyPresentException, protected Vertex reallyCreate() throws ResourceAlreadyPresentException,
ResourceRegistryException { ResourceRegistryException {
createVertex(); createVertex();
@ -168,7 +168,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
} }
@Override @Override
public Vertex reallyUpdate() throws ResourceNotFoundException, ResourceRegistryException { protected Vertex reallyUpdate() throws ResourceNotFoundException, ResourceRegistryException {
getElement(); getElement();
@ -178,7 +178,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
for (JsonNode relationJsonNode : jsonNodeArray) { for (JsonNode relationJsonNode : jsonNodeArray) {
ConsistsOfManagement com = new ConsistsOfManagement(orientGraph); ConsistsOfManagement com = new ConsistsOfManagement(orientGraph);
com.setJSON(relationJsonNode); com.setJSON(relationJsonNode);
com.reallyCreateOrUdate(); com.internalCreateOrUdate();
} }
} }
@ -189,18 +189,16 @@ public class ResourceManagement extends EntityManagement<Resource> {
IsRelatedToManagement irtm = new IsRelatedToManagement( IsRelatedToManagement irtm = new IsRelatedToManagement(
orientGraph); orientGraph);
irtm.setJSON(relationJsonNode); irtm.setJSON(relationJsonNode);
irtm.reallyUpdate(); irtm.internalUpdate();
} }
} }
((OrientVertex) element).save();
return element; return element;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public boolean reallyDelete() throws ResourceNotFoundException, protected boolean reallyDelete() throws ResourceNotFoundException,
ResourceRegistryException { ResourceRegistryException {
// internalDeleteResource(orientGraph, uuid, null); // internalDeleteResource(orientGraph, uuid, null);
@ -226,7 +224,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
} }
if (relationManagement != null) { if (relationManagement != null) {
relationManagement.setElement(edge); relationManagement.setElement(edge);
relationManagement.reallyDelete(); relationManagement.internalDelete();
} }
} }

View File

@ -33,7 +33,6 @@ import org.gcube.informationsystem.resourceregistry.er.ERManagement;
import org.gcube.informationsystem.resourceregistry.er.entity.EntityManagement; import org.gcube.informationsystem.resourceregistry.er.entity.EntityManagement;
import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement; import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement;
import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement; import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement;
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.utils.Utility; import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -236,11 +235,13 @@ public abstract class RelationManagement<R extends Relation> extends
ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys,
ignoreStartWithKeys); ignoreStartWithKeys);
/* This code has been moved in ERManagement.internalCreate()
HeaderUtility.addHeader(element, null); HeaderUtility.addHeader(element, null);
ContextUtility.addToActualContext(orientGraph, element); ContextUtility.addToActualContext(orientGraph, element);
((OrientEdge) element).save(); ((OrientEdge) element).save();
*/
logger.info("{} successfully created", erType); logger.info("{} successfully created", erType);
return element; return element;
@ -258,7 +259,7 @@ public abstract class RelationManagement<R extends Relation> extends
try { try {
target = (Vertex) entityManagement.getElement(); target = (Vertex) entityManagement.getElement();
} catch (Exception e) { } catch (Exception e) {
target = entityManagement.reallyCreate(); target = (Vertex) entityManagement.internalCreate();
} }
return reallyCreate(source, target); return reallyCreate(source, target);
} }
@ -271,7 +272,7 @@ public abstract class RelationManagement<R extends Relation> extends
} }
@Override @Override
public Edge reallyCreate() throws ResourceRegistryException { protected Edge reallyCreate() throws ResourceRegistryException {
if(!jsonNode.has(Relation.SOURCE_PROPERTY)){ if(!jsonNode.has(Relation.SOURCE_PROPERTY)){
throw new ResourceRegistryException( throw new ResourceRegistryException(
"Error while creating relation. No source definition found"); "Error while creating relation. No source definition found");
@ -285,7 +286,7 @@ public abstract class RelationManagement<R extends Relation> extends
@Override @Override
public Edge reallyUpdate() throws ResourceRegistryException { protected Edge reallyUpdate() throws ResourceRegistryException {
logger.debug("Trying to update {} : {}", erType, jsonNode); logger.debug("Trying to update {} : {}", erType, jsonNode);
@ -298,7 +299,7 @@ public abstract class RelationManagement<R extends Relation> extends
if (target != null) { if (target != null) {
FacetManagement fm = new FacetManagement(orientGraph); FacetManagement fm = new FacetManagement(orientGraph);
fm.setJSON(target); fm.setJSON(target);
fm.reallyUpdate(); fm.internalUpdate();
} }
} }
@ -309,7 +310,7 @@ public abstract class RelationManagement<R extends Relation> extends
} }
@Override @Override
public boolean reallyAddToContext() throws ContextException, protected boolean reallyAddToContext() throws ContextException,
ResourceRegistryException { ResourceRegistryException {
getElement(); getElement();
@ -352,7 +353,7 @@ public abstract class RelationManagement<R extends Relation> extends
*/ */
EntityManagement entityManagement = EntityManagement EntityManagement entityManagement = EntityManagement
.getEntityManagement(orientGraph, target); .getEntityManagement(orientGraph, target);
entityManagement.reallyAddToContext(); entityManagement.internalAddToContext();
ContextUtility.addToActualContext(orientGraph, getElement()); ContextUtility.addToActualContext(orientGraph, getElement());
break; break;
@ -376,13 +377,13 @@ public abstract class RelationManagement<R extends Relation> extends
Vertex source = element.getVertex(Direction.OUT); Vertex source = element.getVertex(Direction.OUT);
EntityManagement entityManagement = EntityManagement EntityManagement entityManagement = EntityManagement
.getEntityManagement(orientGraph, source); .getEntityManagement(orientGraph, source);
entityManagement.reallyAddToContext(); entityManagement.internalAddToContext();
/* Adding target to Context */ /* Adding target to Context */
Vertex target = element.getVertex(Direction.IN); Vertex target = element.getVertex(Direction.IN);
entityManagement = EntityManagement entityManagement = EntityManagement
.getEntityManagement(orientGraph, target); .getEntityManagement(orientGraph, target);
entityManagement.reallyAddToContext(); entityManagement.internalAddToContext();
ContextUtility.addToActualContext(orientGraph, getElement()); ContextUtility.addToActualContext(orientGraph, getElement());
@ -394,7 +395,7 @@ public abstract class RelationManagement<R extends Relation> extends
EntityManagement entityManagement = EntityManagement EntityManagement entityManagement = EntityManagement
.getEntityManagement(orientGraph, target); .getEntityManagement(orientGraph, target);
if (entityManagement != null) { if (entityManagement != null) {
entityManagement.reallyRemoveFromContext(); entityManagement.internalRemoveFromContext();
return true; return true;
} else { } else {
return false; return false;
@ -402,7 +403,7 @@ public abstract class RelationManagement<R extends Relation> extends
} }
@Override @Override
public boolean reallyRemoveFromContext() throws ContextException, protected boolean reallyRemoveFromContext() throws ContextException,
ResourceRegistryException { ResourceRegistryException {
getElement(); getElement();
@ -545,15 +546,14 @@ public abstract class RelationManagement<R extends Relation> extends
EntityManagement entityManagement = EntityManagement EntityManagement entityManagement = EntityManagement
.getEntityManagement(orientGraph, target); .getEntityManagement(orientGraph, target);
if (entityManagement != null) { if (entityManagement != null) {
entityManagement.reallyDelete(); return entityManagement.internalDelete();
return true;
} else { } else {
return false; return false;
} }
} }
@Override @Override
public boolean reallyDelete() throws RelationNotFoundException, protected boolean reallyDelete() throws RelationNotFoundException,
ResourceRegistryException { ResourceRegistryException {
logger.debug( logger.debug(
"Going to remove {} with UUID {}. Related {}s will be detached.", "Going to remove {} with UUID {}. Related {}s will be detached.",

View File

@ -51,6 +51,15 @@ public class HeaderOrient extends ODocument implements org.gcube.informationsyst
this.field(Header.CREATION_TIME_PROPERTY, creationTime); this.field(Header.CREATION_TIME_PROPERTY, creationTime);
} }
@Override
public String getLastUpdater() {
return this.field(Header.LAST_UPDATER_PROPERTY);
}
public void setLastUpdater(String lastUpdater){
this.field(Header.LAST_UPDATER_PROPERTY, lastUpdater);
}
@Override @Override
public Date getLastUpdateTime() { public Date getLastUpdateTime() {
return this.field(Header.LAST_UPDATE_TIME_PROPERTY); return this.field(Header.LAST_UPDATE_TIME_PROPERTY);

View File

@ -26,7 +26,6 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.record.impl.ODocument;
import com.tinkerpop.blueprints.Edge; import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Element; import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.Vertex;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
@ -62,7 +61,8 @@ public class HeaderUtility {
logger.error("Unable to retrieve user. {} will be used", creator); logger.error("Unable to retrieve user. {} will be used", creator);
} }
header.setCreator(creator); header.setCreator(creator);
header.setLastUpdater(creator);
Date date = Calendar.getInstance().getTime(); Date date = Calendar.getInstance().getTime();
SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
logger.trace("Setting Last Update and Creation Time to " + ft.format(date)); logger.trace("Setting Last Update and Creation Time to " + ft.format(date));
@ -105,6 +105,7 @@ public class HeaderUtility {
headerOrient.setUUID(header.getUUID()); headerOrient.setUUID(header.getUUID());
headerOrient.setCreator(header.getCreator()); headerOrient.setCreator(header.getCreator());
headerOrient.setCreationTime(header.getCreationTime()); headerOrient.setCreationTime(header.getCreationTime());
headerOrient.setLastUpdater(header.getLastUpdater());
headerOrient.setLastUpdateTime(header.getLastUpdateTime()); headerOrient.setLastUpdateTime(header.getLastUpdateTime());
return headerOrient; return headerOrient;
} catch (Exception e) { } catch (Exception e) {
@ -113,9 +114,9 @@ public class HeaderUtility {
} }
} }
public static Header addHeader(Vertex vertex, UUID uuid) { public static Header addHeader(Element element, UUID uuid) {
Header header = createHeader(uuid); Header header = createHeader(uuid);
vertex.setProperty(Entity.HEADER_PROPERTY, header); element.setProperty(Entity.HEADER_PROPERTY, header);
return header; return header;
} }