33import java .util .HashSet ;
44import java .util .Set ;
55
6+ import org .apache .log4j .Logger ;
7+
68import com .arangodb .blueprints .client .ArangoDBBaseDocument ;
79import com .arangodb .blueprints .client .ArangoDBException ;
810import com .arangodb .blueprints .utils .ArangoDBUtil ;
1921 * @author Guido Schwab (http://www.triagens.de)
2022 */
2123
22- abstract public class ArangoDBBatchElement implements Element {
24+ abstract class ArangoDBBatchElement implements Element {
25+
26+ /**
27+ * the logger
28+ */
29+ private static final Logger logger = Logger .getLogger (ArangoDBBatchElement .class );
2330
2431 /**
2532 * the graph of the document
@@ -46,7 +53,7 @@ abstract public class ArangoDBBatchElement implements Element {
4653 * if an error occurs
4754 */
4855
49- abstract public void save () throws ArangoDBException ;
56+ public abstract void save () throws ArangoDBException ;
5057
5158 /**
5259 * Return the object value associated with the provided string key. If no
@@ -56,6 +63,7 @@ abstract public class ArangoDBBatchElement implements Element {
5663 * the key of the key/value property
5764 * @return the object value related to the string key
5865 */
66+ @ Override
5967 public Object getProperty (String key ) {
6068 return document .getProperty (ArangoDBUtil .normalizeKey (key ));
6169 }
@@ -70,6 +78,7 @@ public void setDocument(ArangoDBBaseDocument document) {
7078 this .document = document ;
7179 }
7280
81+ @ Override
7382 public Set <String > getPropertyKeys () {
7483 Set <String > ps = document .getPropertyKeys ();
7584 HashSet <String > result = new HashSet <String >();
@@ -79,44 +88,57 @@ public Set<String> getPropertyKeys() {
7988 return result ;
8089 }
8190
91+ @ Override
8292 public void setProperty (String key , Object value ) {
8393 if (created ) {
8494 throw new UnsupportedOperationException ();
8595 }
8696
87- if (key == null || key . equals ( StringFactory . EMPTY_STRING ))
97+ if (isEmptyString ( key ))
8898 throw ExceptionFactory .propertyKeyCanNotBeEmpty ();
8999 if (key .equals (StringFactory .ID ))
90100 throw ExceptionFactory .propertyKeyIdIsReserved ();
91101
92102 try {
93103 document .setProperty (ArangoDBUtil .normalizeKey (key ), value );
94104 } catch (ArangoDBException e ) {
105+ logger .warn ("could not set property" , e );
95106 throw new IllegalArgumentException (e .getMessage ());
96107 }
97108 }
98109
110+ @ Override
99111 public Object removeProperty (String key ) {
112+ checkRemovePropertyKey (key );
113+
114+ Object o = null ;
115+ try {
116+ o = document .removeProperty (ArangoDBUtil .normalizeKey (key ));
117+ } catch (ArangoDBException e ) {
118+ logger .warn ("could not remove property" , e );
119+ throw new IllegalArgumentException (e .getMessage ());
120+ }
121+ return o ;
122+ }
123+
124+ private void checkRemovePropertyKey (String key ) {
100125 if (created ) {
101126 throw new UnsupportedOperationException ();
102127 }
103128
104- if (key == null || key . equals ( StringFactory . EMPTY_STRING ))
129+ if (isEmptyString ( key ))
105130 throw ExceptionFactory .propertyKeyCanNotBeEmpty ();
106131 if (key .equals (StringFactory .ID ))
107132 throw ExceptionFactory .propertyKeyIdIsReserved ();
108133 if (key .equals (StringFactory .LABEL ) && this instanceof Edge )
109134 throw ExceptionFactory .propertyKeyLabelIsReservedForEdges ();
135+ }
110136
111- Object o = null ;
112- try {
113- o = document .removeProperty (ArangoDBUtil .normalizeKey (key ));
114- } catch (ArangoDBException e ) {
115- throw new IllegalArgumentException (e .getMessage ());
116- }
117- return o ;
137+ private boolean isEmptyString (String key ) {
138+ return key == null || key .equals (StringFactory .EMPTY_STRING );
118139 }
119140
141+ @ Override
120142 public Object getId () {
121143 return document .getDocumentKey ();
122144 }
0 commit comments