* @param defaultState the default state used if no one is yet defined for
* this entity
* @return the wrapped entity
*/
public static ManagedEntity init(Entity entity, ManagedEntityState defaultState){
Reference stateUri = entity.getMetadata().getFirstReference(STATE);
if(stateUri == null ||
!ManagedEntityState.isState(stateUri.getReference())){
entity.getMetadata().setReference(STATE, defaultState.getUri());
}
String entityId = ModelUtils.getAboutRepresentation(entity.getMetadata());
if(entityId == null){
entity.getMetadata().setReference(