if(siteId == null || siteId.isEmpty()){
throw new IllegalStateException("Parsed SiteId MUST NOT be NULL nor empty!");
}
this.site = siteId;
this.representation = representation;
Reference representationRef;
if(metadata != null){
if(representation.getId().equals(metadata.getId())){
throw new IllegalArgumentException("The ID of the Representation and " +
"the Metadata MUST NOT BE the same!");
}
representationRef = metadata.getFirstReference(
RdfResourceEnum.aboutRepresentation.getUri());
if(representationRef != null && !representationRef.getReference().equals(
representation.getId())){
throw new IllegalArgumentException(String.format(
"The parsed Metadata are not about the representation of the" +
"Entity to be created (metadata aboutness=%s, representation=%s).",
representationRef.getReference(),representation.getId()));
}
this.metadata = metadata;
} else { //init new metadata
//This is typically used if no metadata are persisted for an entity
//(e.g. for entities of a remote site).