Index: xcap/appusage/__init__.py
===================================================================
--- xcap/appusage/__init__.py	(revision 612)
+++ xcap/appusage/__init__.py	(revision 615)
@@ -315,5 +315,5 @@
 
     def put_attribute(self, uri, attribute, check_etag):
-        ## TODO verifica daca atributul e valid
+        ## TODO verify if the attribute is valid
         d = self.get_document(uri, check_etag)
         return d.addCallbacks(self._cb_put_attribute, callbackArgs=(uri, attribute, check_etag))
@@ -510,5 +510,5 @@
 
     def put_document(self, uri, document, check_etag):
-        raise errors.ResourceNotFound("This application is read-only") # TODO: test and add better error
+        raise errors.ResourceNotFound("This application does not support PUT method")
 
 class XCAPDirectoryApplication(ApplicationUsage):
@@ -540,5 +540,5 @@
 
     def put_document(self, uri, document, check_etag):
-        raise errors.ResourceNotFound("This application is read-only") # TODO: test and add better error
+        raise errors.ResourceNotFound("This application does not support PUT method")
 
 class IconApplication(ApplicationUsage):
@@ -550,5 +550,5 @@
         allowed_mime_types = ['jpg', 'gif', 'png']
         allowed_encodings = ['base64']
-        allowed_sizes = [(256, 256)]
+        allowed_max_size = 256
         try:
             xml = StringIO(document)
@@ -577,5 +577,5 @@
                 raise errors.ConstraintFailureError(phrase="Can't detect an image in the payload.")
             else:
-                if img.size not in allowed_sizes:
+                if not (img.size[0] == img.size[1] and img.size[0] <= allowed_max_size):
                     raise errors.ConstraintFailureError(phrase="Image size error. Maximum allowed size is 256 pixels aspect ratio 1:1")
                 if img.format.lower() not in allowed_mime_types:
@@ -584,5 +584,5 @@
     def put_document(self, uri, document, check_etag):
         self._validate_icon(document)
-        return self.storage.put_icon(uri, document)
+        return self.storage.put_document(uri, document, check_etag)
 
 theStorage = ServerConfig.backend.Storage()
Index: xcap/interfaces/backend/database.py
===================================================================
--- xcap/interfaces/backend/database.py	(revision 612)
+++ xcap/interfaces/backend/database.py	(revision 615)
@@ -377,41 +377,4 @@
         return self.conn.runInteraction(self._get_documents_list, uri)
 
-    def put_icon(self, uri, document):
-        return repeat_on_error(10, (UpdateFailed, IntegrityError),
-                               self.conn.runInteraction, self._put_icon, uri, document)
-
-    def _put_icon(self, trans, uri, document):
-        username, domain = uri.user.username, uri.user.domain
-        doc_type = self.app_mapping[uri.application_id]
-        document_path = uri.doc_selector.document_path
-
-        query = """DELETE FROM %(table)s
-                   WHERE username = %%(username)s AND domain = %%(domain)s
-                   AND doc_type= %%(doc_type)s""" % {"table" : Config.xcap_table}
-        params = {"username": username,
-                  "domain"  : domain,
-                  "doc_type": doc_type}
-        trans.execute(*self.fixr(query, params))
-        deleted = getattr(trans._connection, 'affected_rows', lambda : 1)()
-        try:
-            if deleted:
-                pass
-        except NameError:
-            raise DeleteFailed
-
-        etag = make_random_etag(uri)
-        query = """INSERT INTO %(table)s (username, domain, doc_type, etag, doc, doc_uri)
-                 VALUES (%%(username)s, %%(domain)s, %%(doc_type)s, %%(etag)s, %%(document)s, %%(document_path)s)""" % {"table": Config.xcap_table}
-        params = {"username": username,
-                  "domain"  : domain,
-                  "doc_type": doc_type,
-                  "etag":     etag,
-                  "document": document,
-                  "document_path": document_path}
-        # may raise IntegrityError here, if the document was created in another connection
-        # will be catched by repeat_on_error
-        trans.execute(*self.fixr(query, params))
-        return StatusResponse(201, etag)
-
 
 installSignalHandlers = True
Index: xcap/interfaces/backend/sipthor.py
===================================================================
--- xcap/interfaces/backend/sipthor.py	(revision 612)
+++ xcap/interfaces/backend/sipthor.py	(revision 615)
@@ -284,9 +284,4 @@
         return defer
 
-    def put_icon(self, uri, document, new_etag):
-        defer = Deferred()
-        operation = lambda profile: self._put_icon_operation(uri, document, new_etag, profile)
-        reactor.callInThread(self.retrieve_profile, uri.user.username, uri.user.domain, operation, True, defer)
-        return defer
 
     # Methods to be called in a separate thread:
@@ -330,19 +325,4 @@
             raise NotFound()
         return xcap_docs
-
-    def _put_icon_operation(self, uri, document, new_etag, profile):
-        application_id = sanitize_application_id(uri.application_id)
-        xcap_docs = profile.setdefault("xcap", {})
-        del(xcap_docs[application_id])
-        try:
-            etag = xcap_docs[application_id][uri.doc_selector.document_path][1]
-        except KeyError:
-            found = False
-        else:
-            found = True
-            check_etag(etag)
-        xcap_app = xcap_docs.setdefault(application_id, {})
-        xcap_app[uri.doc_selector.document_path] = (document, new_etag)
-        return found
 
     def retrieve_profile(self, username, domain, operation, update, defer):
@@ -529,10 +509,4 @@
         return docs
 
-    def put_icon(self, uri, document):
-        etag = make_random_etag(uri)
-        result = self._database.put_icon(uri, document, etag)
-        result.addCallback(self._cb_put, etag, "%s@%s" % (uri.user.username, uri.user.domain))
-        result.addErrback(self._eb_not_found)
-        return result
 
 installSignalHandlers = False
