Opérations modifiant le contenu du document

Problème : Que faire en cas de conflit insert/delete ou delete/insert ?

Solutions :

  1. combiner l'effet de l'insertion et deletion
  2. insérer uniquement le texte sans tenir compte du conflit.
  3. générer une sorte de bloc à la RCS qui indique les conflits (problème des conflits imbriqués)
  4. annuler l'insertion
Solution retenue : (a)

Warning: Comment est conservé le contenu d'une opération ? si c'est en base64 cela risque de poser de problème pour connaître la taille ou encore découper un bloc à  partir d'un index (nécessite un décode/encodage)

Opérations

/* insert(String text, Position position); */
insert(String text, int position)

/* delete(String text, Position position); */
delete(String text, int position)

Error: remplacer Position par une position absolue

Transformations

Warning: vérifier que l'effet de insert(3) est situé devant celui de del(3)

la méthode String substring(index1, index2) retourne la sous chaîne. 0 est le premier indice

t(insert(String text1, int position1), insert(String text2, int position2)) {
  if (position1 < position2) {
     return insert(text1, position1)
  } else if (position1 > position 2) {
     return insert(text1, position1+text2.length)
  } else {
    // position1 == position2
    if (text1.equals(text2)) {
       return nop
    } elseif (text1.hashCode() < text2.hashCode()) {
      return insert(text1, position1)
    } else {
      return insert(text1, position1+text2.length)
    }
  }
}

t(insert(String text1, int position1), delete(String text2, int position2)) {
  if (position1 <= position2) {
     return insert(text1, position1)
  } else if (position2+text2.length-1 < position1) {
     return insert(text1, position1-text2.length)
  } else {
     return insert(text1, position2)
  }
}

t(delete(String text1, int position1), insert(String text2, int position2)) {
  if (position2 <= position1) {
     return delete(text1, position1+text2.length)
  } else if (position1+text1.length-1 < position2) {
     return delete(text1, position1)
  } else {
     return delete(text1.substring(text1,0,position2-position1), position1)
           +delete(text1.substring(text1,position2-position1,text1.length),position2+text2.length-(position2-position1)) 
     /* ou */ 
     /*
     return delete(text1.substring(text1,position2-position1,text1.length),position2+text2.length)
           +delete(text1.substring(text1,0,position2-position1), position1)
     */
  }
}

t(delete(String text1, int position1), delete(String text2, int position2)) {
  if (position1+text1.length <= position2) {
     return delete(text1, position1)
  } else if (position1 >= position2+text2.length) {
    return delete(text1, position1-text2.length)
  } else {
    // position1-text1.length < position1 < position2+text2.length
    if (position1 < position2 and position1+text1.length <= position2+text2.length) {
       return delete(text1.substring(0,position2-position1), position1)
    } else {
      if (position1 < position2) {
         // position1+text1.length > position2+text2.length
         return delete(text1.substring(0,position2-position1)+text1.substring(position2-position1+text2.length,text1.length), position1) 
      } else 
        // position1 >= position2
        if (position2+text2.length >= position1+text1.length) {
        return nop
        /* return delete(new String(), position1) */
      } else {
        return delete(text1.substring(position2+text2.length-position1,text1.length),position2)
      }
    }
  }
}

Opérations affectant les méta-données d'un document (nom, auteur, langue, etc.)

Opérations

setProperty(String property, String value);

Transformations

t(setProperty(String property1, String value1), setProperty(String property2, String value2)) {
 if (! property1.equals(property2)) {
    return setProperty(property1, value1)
 else {
   if (value1.equals(value2)) {
      return id()
      /* return setProperty(property1, value1) */
   } else {
      if (value1.hashCode() > value2.hashCode()) {
         return setProperty(property1, value1)
      } else {
         return id()
         /* return setProperty(property1, value2) */
      }
   }
 }
}

Opérations modifiant une XObjectDefinition stockée dans un document

Opérations

createType(String className, String propertyName, String propertyType, Map properties);

modifyType(String className, String propertyName, Map properties);

deleteType(String className, String propertyName);

Hypothèse: la mise à jour remplace toutes les propriétés (même celles qui n'ont pas été modifiées)

Error: modifyType() doit fournir le type de la propriété propertyType bien qu'il ne soit pas forcément modifié / ce qui implique qu'il peut modifier le type

Transformations

t(createType(String className1, String propertyName1, String propertyType1, Map properties1),
 createType(String className2, String propertyName2, String propertyType2, Map properties2)) {
  if (className1.equals(className2) && propertyName1.equals(PropertyName2)) {
     if (propertyType1.equals(propertyType2)) {
        if (properties1.hashCode() > properties2.hashCode()) 
           return modifyType(className1, propertyName1, propertyType1, properties1)
        else 
           return nop 
     } else if (propertyType1.hashCode() > propertyType2.hashCode()) {
        return modifyType(className1, propertyName1, propertyType1, properties1)        
     } else 
        return nop
  } else {
    return createType(String className1, String propertyName1, String propertyType1, Map properties1)
  } 
}

t(createType(String className1, String propertyName1, String propertyType1, Map properties1),
 modifyType(String className2, String propertyName2, String propertyType2, Map properties2)) {
  if (className1.equals(className2) && propertyName1.equals(PropertyName2)) {
     if (propertyType1.equals(propertyType2)) {
        if (properties1.hashCode() > properties2.hashCode()) 
           return modifyType(className1, propertyName1, propertyType1, properties1)
        else 
           return nop 
     } else if (propertyType1.hashCode() > propertyType2.hashCode()) {
        return modifyType(className1, propertyName1, propertyType1, properties1)        
     } else 
        return nop
  } else {
     return createType(String className1, String propertyName1, String propertyType1, Map properties1)
  } 
}

t(createType(String className1, String propertyName1, String propertyType1, Map properties1),
 deleteType(String className2, String propertyName2)) {
  return createType(String className1, String propertyName1, String propertyType1, Map properties1)
}

t(modifyType(String className1, String propertyName1, String propertyType1, Map properties1),
 createType(String className2, String propertyName2, String propertyType2, Map properties2)) {
 if (className1.equals(className2) && propertyName1.equals(propertyName2)) {
   if (propertyType1.equals(propertyType2)) {
      if (properties1.hashCode() > properties2.hashCode()) {
         return modifyType(String className1, String propertyName1, String propertyType1, Map properties1)
      } else {
         return nop
      }
   } else if (propertyType1.hashCode() > propertyType2.hashCode()) {
     return modifyType(String className1, String propertyName1, String propertyType1, Map properties1)      
   } else {
     return nop
   }
 } else {
   return modifyType(String className1, String propertyName1, String propertyType1, Map properties1)
 }
}

t(modifyType(String className1, String propertyName1, String propertyType1, Map properties1),
 modifyType(String className2, String propertyName2, String propertyType2, Map properties2)) {
  if (className1.equals(className2) && propertyName1.equals(PropertyName2)) {
     if (propertyType1.equals(propertyType2)) {
        if (properties1.hashCode() > properties2.hashCode()) 
           return modifyType(className1, propertyName1, propertyType1, properties1)
        else 
           return nop 
     } else if (propertyType1.hashCode() > propertyType2.hashCode()) {
        return modifyType(className1, propertyName1, propertyType1, properties1)        
     } else 
        return nop
  } else {
    return modifyType(String className1, String propertyName1, String propertyType1, Map properties1)
  } 
}

t(modifyType(String className1, String propertyName1, String propertyType1, Map properties1),
 deleteType(String className2, String propertyName2)) {
  return modifyType(String className1, String propertyName1, String propertyType1, Map properties1)
}

t(deleteType(String className1, String propertyName1)),
 createType(String className2, String propertyName2, String propertyType2, Map properties2)) {
  if (className1.equals(className2) && propertyName1.equals(propertyName2)) 
     return nop
  else
     return deleteType(String className1, String propertyName1)
}

t(deleteType(String className1, String propertyName1)),
 modifyType(String className2, String propertyName2, Map properties2)) {
  if (className1.equals(className2) && propertyName1.equals(propertyName2)) 
     return nop
  else
     return deleteType(String className1, String propertyName1)
}

t(deleteType(String className1, String propertyName1)),
 deleteType(String className2, String propertyName2)) {
  if (className1.equals(className2) && propertyName1.equals(propertyName2)) 
     return nop
  else
     return deleteType(String className1, String propertyName1)
}

Opérations modifiant les objets d'un document

Opérations

addObject(String objectClass);

deleteObject(String objectClass, int index);

setObjectProperty(String objectClass, int index, String propertyName, String value);

/* insertInProperty(String objectClass, int index, String property, String text, Position position); */
insertInProperty(String objectClass, int index, String property, String text, int position);

/* deleteFromProperty(String objectClass, int index, String property, String text, Position position); */
deleteFromProperty(String objectClass, int index, String property, String text, int position);

Error: remplacer Position par une position absolue

Error: ajouter un paramètre index à la méthode addObject()

Error: ajouter le paramètre siteid (l'identificateur du site où l'operation a été générée) aux méthodes addObject(), setObjectProperty(), insertInProperty() pour résoudre des situations de conflit

Transformations

t(addObject(String objectClass1, int index1, int site1), addObject(String objectClass2, int index2, int site2))
  if (objectClass1.equals(objectClass2))
     if ((index1 < index2) || ((index1 == index2) && (site1 > site2)))
         return addObject(objectClass1, index1, site1)
     else 
         return addObject(objectClass1, index1 + 1, site1)
  else 
     return addObject(objectClass1, index1, site1)


t(addObject(String objectClass1, int index1, int site1), deleteObject(String objectClass2, int index2))
  if (objectClass1.equals(objectClass2) && (index1 > index2) )
     return addObject(objectClass1, index1 - 1, site1)
   else 
     return addObject(objectClass1, index1, site1)


t(addObject(String objectClass1, int index1, int site1), setObjectProperty(String objectClass2, int index2, String propertyName2, String value2, int site2))
     return addObject(objectClass1, index1, site1)


t(addObject(String objectClass1, int index1, int site1), insertInProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
     return addObject(objectClass1, index1, site1)


t(addObject(String objectClass1, int index1, int site1), deleteFromProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
     return addObject(objectClass1, index1, site1)


t(deleteObject(String objectClass1, int index1), addObject(String objectClass2, int index2, int site2))
  if (objectClass1.equals(objectClass2) && (index2 <= index1)) 
     return deleteObject(objectClass1, index1 + 1)
  else
     return deleteObject(objectClass1, index1)


t(deleteObject(String objectClass1, int index1), deleteObject(String objectClass2, int index2))
  if (objectClass1.equals(objectClass2))
    if (index2 < index1)
       return deleteObject(objectClass1, index1-1)
    else if (index1 == index2) )
            return nop
         else return deleteObject(objectClass1, index1)
  else return deleteObject(objectClass1, index1)


t(deleteObject(String objectClass1, int index1), setObjectProperty(String objectClass2, int index2, String propertyName2, String value2, int site2))
  return deleteObject(objectClass1, index1)


t(deleteObject(String objectClass1, int index1), insertInProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
  return deleteObject(objectClass1, index1)


t(deleteObject(String objectClass1, int index1), deleteFromProperty(String objectClass2, int index2, String property2, String text2, int position2))
  return deleteObject(objectClass1, index1)


t(setObjectProperty(String objectClass1, int index1, String propertyName1, String value1, int site1), addObject(String objectClass2, int index2, int site2))
   if (objectClass1.equals(objectClass2) && (index2 <= index1))
      return setObjectProperty(objectClass1, index1 +1, propertyName1, value1, site1)
   else 
      return setObjectProperty(objectClass1, index1, propertyName1, value1, site1)


t(setObjectProperty(String objectClass1, int index1, String propertyName1, String value1, int site1), deleteObject(String objectClass2, int index2))
   if (objectClass1.equals(objectClass2))
      if (index2 < index1)
          return setObjectProperty(objectClass1, index1 - 1, propertyName1, value1, site1)
      else if (index1 == index2)
              return nop
           else return setObjectProperty(objectClass1, index1, propertyName1, value1, site1)
   else 
      return setObjectProperty(objectClass1, index1, propertyName1, value1, site1)
  

t(setObjectProperty(String objectClass1, int index1, String propertyName1, String value1, int site1), setObjectProperty(String objectClass2, int index2, String propertyName2, String value2, int site2))
   if (objectClass1.equals(objectClass2) && (index1 == index2) && propertyName1.equals(propertyName2) && (site1 < site2))
       return nop
   else 
       return setObjectProperty(objectClass1, index1, propertyName1, value1, site1)


t(setObjectProperty(String objectClass1, int index1, String propertyName1, String value1, int site1), insertInProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
  return setObjectProperty(objectClass1, index1, propertyName1, value1, site1)


t(setObjectProperty(String objectClass1, int index1, String propertyName1, String value1, int site1), deleteFromProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
  return setObjectProperty(objectClass1, index1, propertyName1, value1, site1)


t(insertInProperty(String objectClass1, int index1, String property1, String text1, int position1, int site1), addObject(String objectClass2, int index2, int site2))
   if (objectClass1.equals(objectClass2) && (index2 <= index1))
      return insertInProperty(objectClass1, index1 + 1, property1, text1, position1, site1)
   else 
      return insertInProperty(objectClass1, index1, property1, text1, position1, site1)


t(insertInProperty(String objectClass1, int index1, String property1, String text1, int position1, int site1), deleteObject(String objectClass2, int index2))
   if (objectClass1.equals(objectClass2))
      if (index2 < index1)
          return insertInProperty(objectClass1, index1 - 1, property1, text1, position1, site1)
      else if (index1 = index2)
              return nop
           else return insertInProperty(objectClass1, index1, property1, text1, position1, site1)
   else 
      return insertInProperty(objectClass1, index1, property1, text1, position1, site1)


t(insertInProperty(String objectClass1, int index1, String property1, String text1, int position1, int site1), setObjectProperty(String objectClass2, int index2, String propertyName2, String value2, int site2))
   return insertInProperty(objectClass1, index1, property1, text1, position1, site1)


t(insertInProperty(String objectClass1, int index1, String property1, String text1, int position1, int site1), insertInProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
    if (objectClass1.equals(objectClass2) && (index1 == index2) && property1.equals(property2))
       if (position1 < position2)
          return insertInProperty(objectClass1, index1, property1, text1, position1, site1)
       else if (position1 > position 2) 
               return insertInProperty(objectClass1, index1, property1, text1, position1 + text2.length, site1)
            else 
                 // position1 == position2
                 if (text1.equals(text2)) 
                    return nop
                 else if (site1 > site 2)
                         return insertInProperty(objectClass1, index1, property1, text1, position1, site1)
                      else
                         return insertInProperty(objectClass1, index1, property1, text1, position1 + text2.length , site1)
    else return insertInProperty(objectClass1, index1, property1, text1, position1, site1)


t(insertInProperty(String objectClass1, int index1, String property1, String text1, int position1, int site1), deleteFromProperty(String objectClass2, int index2, String property2, String text2, int position2))
    if (objectClass1.equals(objectClass2) && (index1 == index2) && property1.equals(property2))
       if (position1 <= position2)
          return insertInProperty(objectClass1, index1, property1, text1, position1, site1)       
       else if (position2+text2.length-1 < position1)
               return insertInProperty(objectClass1, index1, property1, text1, position1 - text2.length, site1)
            else insertInProperty(objectClass1, index1, property1, text1, position2, site1)
    else insertInProperty(objectClass1, index1, property1, text1, position1, site1)


t(deleteFromProperty(String objectClass1, int index1, String property1, String text1, int position1), addObject(String objectClass2, int index2, int site2))
   if (objectClass1.equals(objectClass2) && (index2 <= index1))
      return deleteFromProperty(objectClass1, index1 + 1, property1, text1, position1)
   else 
      return deleteFromProperty(objectClass1, index1, property1, text1, position1)


t(deleteFromProperty(String objectClass1, int index1, String property1, String text1, int position1), deleteObject(String objectClass2, int index2))
   if (objectClass1.equals(objectClass2)
      if (index2 < index1)
          return deleteFromProperty(objectClass1, index1 - 1, property1, text1, position1)
      else if (index1 == index2)
              return nop
           else return deleteFromProperty(objectClass1, index1, property1, text1, position1)
   else 
      return deleteFromProperty(objectClass1, index1, property1, text1, position1)
  

t(deleteFromProperty(String objectClass1, int index1, String property1, String text1, int position1), setObjectProperty(String objectClass2, int index2, String propertyName2, String value2, int site2))
   return deleteFromProperty(objectClass1, index1, property1, text1, position1)


t(deleteFromProperty(String objectClass1, int index1, String property1, String text1, int position1), insertInProperty(String objectClass2, int index2, String property2, String text2, int position2, int site2))
    if (objectClass1.equals(objectClass2) && (index1 == index2) && property1.equals(property2))
       if (position2 <= position1)
           return deleteFromProperty(objectClass1, index1, property1, text1, position1 + text2.length)
       else if (position1+text1.length-1 < position2) 
               return deleteFromProperty(objectClass1, index1, property1, text1, position1)
            else
               return deleteFromProperty(objectClass1, index1, property1, text1.substring(text1,position2-position1,text1.length), position2+text2.length)
                      + deleteFromProperty(objectClass1, index1, property1, text1.substring(text1,0,position2-position1), position1)
    else return deleteFromProperty(objectClass1, index1, property1, text1, position1)


t(deleteFromProperty(String objectClass1, int index1, String property1, String text1, int position1), deleteFromProperty(String objectClass2, int index2, String property2, String text2, int position2))
    if (objectClass1.equals(objectClass2) && (index1 == index2) && property1.equals(property2))
       if (position1+text1.length <= position2)
           return deleteFromProperty(objectClass1, index1, property1, text1, position1)
       else if (position1 >= position2+text2.length)
                return deleteFromProperty(objectClass1, index1, property1, text1, position1-text2.length)
            else if ((position1 < position2) && (position1+text1.length <= position2+text2.length))
                     return deleteFromProperty(objectClass1, index1, property1, text1.substring(0,position2-position1), position1)
                 else if (position1 < position2)
                         return deleteFromProperty(objectClass1, index1, property1, text1.substring(0,position2-position1)+text1.substring(position2-position1+text2.length,text1.length), position1)
                      else if (position2+text2.length >= position1+text1.length)
                               return nop
                           else return deleteFromProperty(objectClass1, index1, property1, text1.substring(position2+text2.length-position1,text1.length), position2)
    else deleteFromProperty(objectClass1, index1, property1, text1, position1)

Opérations relatives aux pièces attachées

Opérations

addAttachment(InputStream is, String filename, String author);
    
setAttachment(InputStream is, String filename, String author);

deleteAttachment(String filename);

Error: La méthode addAttachment() n'est pas nécessaire, la méthode setAttachment() est suffisante pour remplacer son effet. Si setAttachment() prend comme paramètre un nom de fichier inexistant, alors la création du fichier sera automatique.

Transformations

t(setAttachment(InputStream is1, String filename1, String author1, int site1), setAttachment(InputStream is2, String filename2, String author2, int site2))
  if (filename1.equals(filename2))
     if (site1 < site2)
        return setAttachment(is1, filename1 + site1, author1)
     else
        return setAttachment(is1, filename1, author1)
  else
     return setAttachment(is1, filename1, author1)


t(setAttachment(InputStream is1, String filename1, String author1, int site1), deleteAttachment(String filename2))
  return setAttachment(is1, filename1, author1)


t(deleteAttachment(String filename1), setAttachment(InputStream is2, String filename2, String author2, int site2))
  if (filename1.equals(filename2))
     return nop
  else
     return deleteAttachment(filename1)


t(deleteAttachment(String filename1), deleteAttachment(String filename2))
  if (filename1.equals(filename2))
     return nop
  else
     return deleteAttachment(filename1)

Transformations par rapport à l'opération nop, où op remplace n'importe quelle opération

t(op,nop)
 return op

t(nop,op)
 return nop

Autres opérations

Opérations

Warning: une opération de destruction d'une page doit être fournie (deletePage) ???

Transformations
Version 1.23 last modified by Claudia Ignat on 06/08/2008 at 17:34

Comments 0

No comments for this document

Attachments 0

No attachments for this document
Partenaires


Creator: Gérald Oster on 2008/07/16 13:12
Copyright INRIA, ENST, EISTI, Mandriva, XPertNet
1.1.1