Changeset 4130


Ignore:
Timestamp:
2010-07-09 12:18:02 (3 years ago)
Author:
bruno
Message:

Import tool:

  • add support for non-string value types (all except blob)
  • support user-defined IDs for records & record updating
  • allow unquoted field names and comments in the "json"

Updated to newer HBase snapshot for no particular reason.

Updated to latest SOLR, just because we can.

FieldTypeNotFoundException?: fix 'todo' in case of getFieldTypeByName

Location:
projects/lily/trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • projects/lily/trunk/README.txt

    r4111 r4130  
    1414------------- 
    1515 
    16 Download Solr 1.4.0 from http://lucene.apache.org/solr/ and extract it somewhere. 
     16Download Solr 1.4.1 from http://lucene.apache.org/solr/ and extract it somewhere. 
    1717 
    1818Configuring settings.xml 
     
    3030 
    3131      <properties> 
    32         <solr.war>/home/bruno/projects/lily-trunk/deps/apache-solr-1.4.0/dist/apache-solr-1.4.0.war</solr.war> 
     32        <solr.war>/path/to/apache-solr-1.4.1/dist/apache-solr-1.4.1.war</solr.war> 
    3333      </properties> 
    3434    </profile> 
  • projects/lily/trunk/indexer/pom.xml

    r4101 r4130  
    7777      <groupId>org.apache.solr</groupId> 
    7878      <artifactId>solr-solrj</artifactId> 
    79       <version>1.4.0</version> 
     79      <version>1.4.1</version> 
    8080    </dependency> 
    8181 
     
    8383      <groupId>org.apache.solr</groupId> 
    8484      <artifactId>solr-core</artifactId> 
    85       <version>1.4.0</version> 
     85      <version>1.4.1</version> 
    8686      <scope>test</scope> 
    8787      <exclusions> 
  • projects/lily/trunk/pom.xml

    r4126 r4130  
    2323 
    2424  <properties> 
    25     <hbase.version>0.21.0-r959305</hbase.version> 
     25    <hbase.version>0.21.0-r962435</hbase.version> 
    2626    <!-- When changing the hbase version, also change the hadoop version below to match 
    2727         what is in HBase's pom.xml --> 
  • projects/lily/trunk/process/server/conf/hbase/hbase.xml

    r4114 r4130  
    22<hbase xmlns:conf="http://kauriproject.org/configuration" 
    33       conf:inherit="shallow"> 
    4   <!-- 
    54  <zookeeperQuorum>localhost</zookeeperQuorum> 
    65  <zookeeperClientPort>2181</zookeeperClientPort> 
    7   --> 
    86</hbase> 
  • projects/lily/trunk/process/server/conf/repository/repository.xml

    r4114 r4130  
    22<repository xmlns:conf="http://kauriproject.org/configuration" 
    33            conf:inherit="shallow"> 
    4   <!-- 
    54  <zookeeperConnectString>localhost:2181</zookeeperConnectString> 
    6   --> 
    75 
    86  <!-- Filesystem to use to store blobs --> 
  • projects/lily/trunk/repo-util/src/main/java/org/lilycms/repoutil/JsonUtil.java

    r4125 r4130  
    4141    } 
    4242 
     43    public static boolean getBoolean(JsonNode node, String prop) throws JsonFormatException { 
     44        if (node.get(prop) == null) { 
     45            throw new JsonFormatException("Missing required property: " + prop); 
     46        } 
     47        if (!node.get(prop).isBoolean()) { 
     48            throw new JsonFormatException("Not a string property: " + prop); 
     49        } 
     50        return node.get(prop).getBooleanValue(); 
     51    } 
     52 
    4353    public static int getInt(JsonNode node, String prop, int defaultValue) throws JsonFormatException { 
    4454        if (node.get(prop) == null) { 
  • projects/lily/trunk/repository/api/src/main/java/org/lilycms/repository/api/FieldTypeNotFoundException.java

    r4116 r4130  
    2222 
    2323    private final String id; 
     24    private final QName name; 
    2425    private final Long version; 
    2526 
    2627    public FieldTypeNotFoundException(String id, Long version) { 
    2728        this.id = id; 
     29        this.name = null; 
    2830        this.version = version; 
    2931    } 
    3032     
     33    public FieldTypeNotFoundException(QName name, Long version) { 
     34        this.id = null; 
     35        this.name = name; 
     36        this.version = version; 
     37    } 
     38 
    3139    public String getId() { 
    3240        return id; 
    3341    } 
    34      
     42 
     43    public QName getName() { 
     44        return name; 
     45    } 
     46 
    3547    public Long getVersion() { 
    3648        return version; 
     
    4153        StringBuilder stringBuilder = new StringBuilder(); 
    4254        stringBuilder.append("FieldType <"); 
    43         stringBuilder.append(id); 
     55        stringBuilder.append(id != null ? id : name); 
    4456        stringBuilder.append("> "); 
    4557        if (version != null) { 
  • projects/lily/trunk/repository/api/src/main/java/org/lilycms/repository/api/Record.java

    r4076 r4130  
    161161     
    162162    boolean equals(Object obj); 
     163 
     164    /** 
     165     * Compares the two records, ignoring some aspects. This method is intended to compare 
     166     * a record loaded from the repository with a newly instantiated one in which some things 
     167     * are typically not supplied. 
     168     * 
     169     * <p>The aspects which are ignored are: 
     170     * <ul> 
     171     *   <li>the version 
     172     *   <li>the record types: only the name of the non-versioned record type is compared, if 
     173     *       it is not null in both. The version of the record type is not compared. 
     174     * </ul> 
     175     */ 
     176    boolean softEquals(Object obj); 
    163177} 
  • projects/lily/trunk/repository/impl/src/main/avro/lily.avpr

    r4122 r4130  
    179179      "type": "error", 
    180180      "fields": [ 
    181         {"name": "id", "type": "string"}, 
     181        {"name": "id", "type": ["string", "null"]}, 
     182        {"name": "name", "type": ["AvroQName", "null"]}, 
    182183        {"name": "version", "type": "long"}, 
    183184        {"name": "remoteCauses", "type": ["null", {"type": "array", "items": "AvroExceptionCause"}]} 
  • projects/lily/trunk/repository/impl/src/main/java/org/lilycms/repository/avro/AvroConverter.java

    r4123 r4130  
    248248 
    249249    public AvroQName convert(QName name) { 
     250        if (name == null) 
     251            return null; 
     252 
    250253        AvroQName avroQName = new AvroQName(); 
    251254        if (name.getNamespace() != null) { 
     
    328331    public AvroFieldTypeNotFoundException convert(FieldTypeNotFoundException exception) { 
    329332        AvroFieldTypeNotFoundException avroException = new AvroFieldTypeNotFoundException(); 
    330         avroException.id = new Utf8(exception.getId()); 
     333        if (exception.getId() != null) 
     334            avroException.id = new Utf8(exception.getId()); 
     335        if (exception.getName() != null) 
     336            avroException.name = convert(exception.getName()); 
    331337        Long version = exception.getVersion(); 
    332338        if (version != null) { 
     
    362368 
    363369    public FieldTypeNotFoundException convert(AvroFieldTypeNotFoundException avroException) { 
    364         FieldTypeNotFoundException exception = new FieldTypeNotFoundException(convert(avroException.id), avroException.version); 
     370        FieldTypeNotFoundException exception; 
     371        if (avroException.id != null) { 
     372            exception = new FieldTypeNotFoundException(convert(avroException.id), avroException.version); 
     373        } else { 
     374            exception = new FieldTypeNotFoundException(convert(avroException.name), avroException.version); 
     375        } 
    365376        restoreCauses(avroException.remoteCauses, exception); 
    366377        return exception; 
  • projects/lily/trunk/repository/impl/src/main/java/org/lilycms/repository/impl/HBaseTypeManager.java

    r4116 r4130  
    495495        // TODO the below is a temporary fix, should probably be fixed in getFieldTypeFromCache 
    496496        if (fieldType == null) { 
    497             throw new FieldTypeNotFoundException("todo", 1L); 
     497            throw new FieldTypeNotFoundException(name, 1L); 
    498498        } 
    499499        return fieldType; 
  • projects/lily/trunk/repository/impl/src/main/java/org/lilycms/repository/impl/IdRecordImpl.java

    r4076 r4130  
    137137        throw new UnsupportedOperationException("IdRecordImpl does not support equals."); 
    138138    } 
     139 
     140    public boolean softEquals(Object obj) { 
     141        throw new UnsupportedOperationException("IdRecordImpl does not support softEquals."); 
     142    } 
    139143} 
  • projects/lily/trunk/repository/impl/src/main/java/org/lilycms/repository/impl/RecordImpl.java

    r4084 r4130  
    164164    @Override 
    165165    public boolean equals(Object obj) { 
     166        if (!softEquals(obj)) 
     167            return false; 
     168 
     169        RecordImpl other = (RecordImpl) obj; 
     170 
     171        if (recordTypeIds == null) { 
     172            if (other.recordTypeIds != null) 
     173                return false; 
     174        } else if (!recordTypeIds.equals(other.recordTypeIds)) { 
     175            return false; 
     176        } 
     177 
     178        if (recordTypeVersions == null) { 
     179            if (other.recordTypeVersions != null) 
     180                return false; 
     181        } else if (!recordTypeVersions.equals(other.recordTypeVersions)) { 
     182            return false; 
     183        } 
     184 
     185        if (version == null) { 
     186            if (other.version != null) 
     187                return false; 
     188        } else if (!version.equals(other.version)) { 
     189            return false; 
     190        } 
     191 
     192        return true; 
     193    } 
     194 
     195    public boolean softEquals(Object obj) { 
    166196        if (this == obj) 
    167197            return true; 
     
    171201            return false; 
    172202        RecordImpl other = (RecordImpl) obj; 
     203 
    173204        if (fields == null) { 
    174205            if (other.fields != null) 
    175206                return false; 
    176         } else if (!fields.equals(other.fields)) 
    177             return false; 
     207        } else if (!fields.equals(other.fields)) { 
     208            return false; 
     209        } 
     210 
    178211        if (fieldsToDelete == null) { 
    179212            if (other.fieldsToDelete != null) 
    180213                return false; 
    181         } else if (!fieldsToDelete.equals(other.fieldsToDelete)) 
    182             return false; 
     214        } else if (!fieldsToDelete.equals(other.fieldsToDelete)) { 
     215            return false; 
     216        } 
     217 
    183218        if (id == null) { 
    184219            if (other.id != null) 
    185220                return false; 
    186         } else if (!id.equals(other.id)) 
    187             return false; 
    188         if (recordTypeIds == null) { 
    189             if (other.recordTypeIds != null) 
    190                 return false; 
    191         } else if (!recordTypeIds.equals(other.recordTypeIds)) 
    192             return false; 
    193         if (recordTypeVersions == null) { 
    194             if (other.recordTypeVersions != null) 
    195                 return false; 
    196         } else if (!recordTypeVersions.equals(other.recordTypeVersions)) 
    197             return false; 
    198         if (version == null) { 
    199             if (other.version != null) 
    200                 return false; 
    201         } else if (!version.equals(other.version)) 
    202             return false; 
     221        } else if (!id.equals(other.id)) { 
     222            return false; 
     223        } 
     224 
     225        String nonVersionedRT1 = recordTypeIds.get(Scope.NON_VERSIONED); 
     226        String nonVersionedRT2 = other.recordTypeIds.get(Scope.NON_VERSIONED); 
     227 
     228        if (nonVersionedRT1 != null && nonVersionedRT2 != null && !nonVersionedRT1.equals(nonVersionedRT2)) { 
     229            return false; 
     230        } 
     231 
    203232        return true; 
    204233    } 
  • projects/lily/trunk/tools/import/sample.json

    r4114 r4130  
     1/* 
     2  This is a sample input file for the import tool. 
     3 
     4  The syntax is not limited to strict json: unquoted property names 
     5  and comments are allowed. 
     6*/ 
    17{ 
    2   "namespaces": [ 
    3     { "prefix": "sample", "uri": "org.lilycms.tools.import_.sample"} 
     8  namespaces: [ 
     9    { prefix: "sample", uri: "org.lilycms.tools.import_.sample"} 
    410  ], 
    5   "fieldTypes": [ 
     11  fieldTypes: [ 
    612    { 
    7       "name": "sample:field1", 
    8       "valueType": { "primitive": "STRING" }, 
    9       "scope": "versioned" 
     13      name: "sample:stringfield", 
     14      valueType: { "primitive": "STRING" }, 
     15      scope: "versioned" 
    1016    }, 
    1117    { 
    12       "name": "sample:field2", 
    13       "valueType": { "primitive": "STRING" }, 
    14       "scope": "non_versioned" 
     18      name: "sample:multiValueString", 
     19      valueType: { "primitive": "STRING", multiValue: true }, 
     20      scope: "non_versioned" 
     21    }, 
     22    { 
     23      name: "sample:intfield", 
     24      valueType: { "primitive": "INTEGER" }, 
     25      scope: "non_versioned" 
     26    }, 
     27    { 
     28      name: "sample:longfield", 
     29      valueType: { "primitive": "LONG" }, 
     30      scope: "non_versioned" 
     31    }, 
     32    { 
     33      name: "sample:booleanfield", 
     34      valueType: { "primitive": "BOOLEAN" }, 
     35      scope: "non_versioned" 
     36    }, 
     37    { 
     38      name: "sample:linkfield", 
     39      valueType: { "primitive": "LINK" }, 
     40      scope: "non_versioned" 
     41    }, 
     42    { 
     43      name: "sample:datefield", 
     44      valueType: { "primitive": "DATE" }, 
     45      scope: "non_versioned" 
     46    }, 
     47    { 
     48      name: "sample:datetimefield", 
     49      valueType: { "primitive": "DATETIME" }, 
     50      scope: "non_versioned" 
    1551    } 
    1652  ], 
    17   "recordTypes": [ 
     53  recordTypes: [ 
    1854    { 
    19       "name": "Book", 
    20       "fields": [ 
    21         {"name": "sample:field1", "mandatory": false }, 
    22         {"name": "sample:field2", "mandatory": false } 
     55      name: "MiscFields", 
     56      fields: [ 
     57        {name: "sample:field1", mandatory: false }, 
     58        {name: "sample:field2", mandatory: false } 
    2359      ] 
    2460    } 
    2561  ], 
    26   "records": [ 
    27     {"type": "Book", "sample:field1": "My first document."}, 
    28     {"type": "Book", "sample:field1": "My second document.", "sample:field2": "some more data"} 
     62  records: [ 
     63    { 
     64      type: "MiscFields", 
     65      "sample:stringfield": "My first document.", 
     66      "sample:multiValueString": ["first", "second", "third"], 
     67      "sample:intfield": 23, 
     68      "sample:longfield": 242, 
     69      "sample:datefield": "2010-07-09", 
     70      "sample:datetimefield": "2010-07-09T14:04:46", 
     71      "sample:booleanfield": true 
     72    }, 
     73    { 
     74      type: "MiscFields", 
     75      id: "zoo", 
     76      "sample:stringfield": "A document with a user-defined ID" 
     77    }, 
     78    { 
     79      type: "MiscFields", 
     80      "sample:stringfield": "A document with a link field", 
     81      "sample:linkfield": "USER.zoo" 
     82    } 
    2983  ] 
    3084} 
  • projects/lily/trunk/tools/import/src/main/java/org/lilycms/tools/import_/DefaultImportListener.java

    r4125 r4130  
    2020    } 
    2121 
    22     public void existsAndEqual(EntityType entityType, String entityName) { 
    23         out.println(String.format("%1$s already exists and is equal: %2$s", toText(entityType), entityName)); 
     22    public void existsAndEqual(EntityType entityType, String entityName, String entityId) { 
     23        out.println(String.format("%1$s already exists and is equal: %2$s", toText(entityType), id(entityName, entityId))); 
    2424    } 
    2525 
    26     public void updated(EntityType entityType, String entityName, String entityId) { 
    27         out.println(String.format("%1$s updated: %2$s", toText(entityType), entityName)); 
     26    public void updated(EntityType entityType, String entityName, String entityId, long version) { 
     27        if (entityType == EntityType.RECORD || entityType == EntityType.RECORD_TYPE) { 
     28            out.println(String.format("%1$s updated: %2$s (version %3$s)", toText(entityType), id(entityName, entityId), version)); 
     29        } else { 
     30            out.println(String.format("%1$s updated: %2$s", toText(entityType), id(entityName, entityId))); 
     31        } 
    2832    } 
    2933 
    3034    public void created(EntityType entityType, String entityName, String entityId) { 
    31         out.println(String.format("%1$s created: %2$s", toText(entityType), entityName));                         
     35        out.println(String.format("%1$s created: %2$s", toText(entityType), id(entityName, entityId))); 
     36    } 
     37 
     38    private String id(String entityName, String entityId) { 
     39        if (entityName != null) { 
     40            return entityName; 
     41        } else { 
     42            return entityId; 
     43        } 
    3244    } 
    3345 
     
    4153                entityTypeName = "Record type"; 
    4254                break; 
     55            case RECORD: 
     56                entityTypeName = "Record"; 
     57                break; 
    4358            default: 
    4459                throw new RuntimeException("Unexpected entity type: " + entityType); 
  • projects/lily/trunk/tools/import/src/main/java/org/lilycms/tools/import_/EntityType.java

    r4125 r4130  
    22 
    33public enum EntityType { 
    4     FIELD_TYPE, RECORD_TYPE 
     4    FIELD_TYPE, RECORD_TYPE, RECORD 
    55} 
  • projects/lily/trunk/tools/import/src/main/java/org/lilycms/tools/import_/ImportListener.java

    r4125 r4130  
    55            throws ImportConflictException; 
    66 
    7     void existsAndEqual(EntityType entityType, String entityName); 
     7    void existsAndEqual(EntityType entityType, String entityName, String entityId); 
    88 
    9     void updated(EntityType entityType, String entityName, String entityId); 
     9    void updated(EntityType entityType, String entityName, String entityId, long version); 
    1010 
    1111    void created(EntityType entityType, String entityName, String entityId);     
  • projects/lily/trunk/tools/import/src/main/java/org/lilycms/tools/import_/ImportTool.java

    r4125 r4130  
    4343 
    4444            // everything equal, skip it 
    45             importListener.existsAndEqual(EntityType.FIELD_TYPE, newFieldType.getName().toString()); 
     45            importListener.existsAndEqual(EntityType.FIELD_TYPE, newFieldType.getName().toString(), null); 
    4646            return oldFieldType; 
    4747        } 
     
    8585            if (updated) { 
    8686                oldRecordType = typeManager.updateRecordType(oldRecordType); 
    87                 importListener.updated(EntityType.RECORD_TYPE, oldRecordType.getId(), null); 
     87                importListener.updated(EntityType.RECORD_TYPE, null, oldRecordType.getId(), oldRecordType.getVersion()); 
    8888            } else { 
    89                 importListener.existsAndEqual(EntityType.RECORD_TYPE, oldRecordType.getId()); 
     89                importListener.existsAndEqual(EntityType.RECORD_TYPE, null, oldRecordType.getId()); 
    9090            } 
    9191            return oldRecordType; 
    9292        } else { 
    9393            RecordType createdRecordType = typeManager.createRecordType(newRecordType); 
    94             importListener.created(EntityType.RECORD_TYPE, createdRecordType.getId(), null); 
     94            importListener.created(EntityType.RECORD_TYPE, null, createdRecordType.getId()); 
    9595            return createdRecordType; 
     96        } 
     97    } 
     98 
     99    public Record importRecord(Record newRecord) throws RepositoryException { 
     100        Record oldRecord = null; 
     101        if (newRecord.getId() != null) { 
     102            try { 
     103                oldRecord = repository.read(newRecord.getId()); 
     104            } catch (RecordNotFoundException e) { 
     105                // ok 
     106            } 
     107        } 
     108 
     109        if (oldRecord != null) { 
     110            if (newRecord.softEquals(oldRecord)) { 
     111                importListener.existsAndEqual(EntityType.RECORD, null, newRecord.getId().toString()); 
     112                return oldRecord; 
     113            } else { 
     114                // Delete fields which are not present in the new record anymore 
     115                for (Map.Entry<QName, Object> field : oldRecord.getFields().entrySet()) { 
     116                    if (!newRecord.hasField(field.getKey())) { 
     117                        newRecord.delete(field.getKey(), true); 
     118                    } 
     119                } 
     120                Record updatedRecord = repository.update(newRecord); 
     121                importListener.updated(EntityType.RECORD, null, updatedRecord.getId().toString(), updatedRecord.getVersion()); 
     122                return updatedRecord; 
     123            } 
     124        } else { 
     125            Record createdRecord = repository.create(newRecord); 
     126            importListener.created(EntityType.RECORD, null, createdRecord.getId().toString()); 
     127            return createdRecord; 
    96128        } 
    97129    } 
  • projects/lily/trunk/tools/import/src/main/java/org/lilycms/tools/import_/JsonImportTool.java

    r4127 r4130  
    66import org.codehaus.jackson.JsonToken; 
    77import org.codehaus.jackson.map.MappingJsonFactory; 
     8import org.joda.time.DateTime; 
     9import org.joda.time.LocalDate; 
    810import org.lilycms.client.Client; 
    911import org.lilycms.repository.api.*; 
     
    6163        namespaces.clear(); 
    6264 
    63         JsonFactory f = new MappingJsonFactory(); 
    64         JsonParser jp = f.createJsonParser(is); 
     65        JsonFactory jsonFactory = new MappingJsonFactory(); 
     66        jsonFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true); 
     67        jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); 
     68        JsonParser jp = jsonFactory.createJsonParser(is); 
    6569 
    6670        JsonToken current; 
     
    166170        Record record = repository.newRecord(); 
    167171 
     172        String id = getString(node, "id", null); 
     173        if (id != null) { 
     174            record.setId(repository.getIdGenerator().newRecordId(id)); 
     175        } 
     176 
    168177        String type = getString(node, "type"); 
    169178        record.setRecordType(type); 
     
    174183            if (name.contains(":")) { 
    175184                QName qname = parseQName(name); 
    176                 String value = getString(node, name); 
     185                ValueType valueType = typeManager.getFieldTypeByName(qname).getValueType(); 
     186                Object value = readMultiValue(getNode(node, name), valueType, name); 
    177187                record.setField(qname, value); 
    178188            } 
    179189        } 
    180190 
    181         record = repository.create(record); 
    182         System.out.println("Created record " + record.getId()); 
     191        importTool.importRecord(record); 
     192    } 
     193 
     194    private Object readMultiValue(JsonNode node, ValueType valueType, String prop) throws ImportException { 
     195        if (valueType.isMultiValue()) { 
     196            if (!node.isArray()) { 
     197                throw new ImportException("Multi-value value should be specified as array in " + prop); 
     198            } 
     199 
     200            List<Object> value = new ArrayList<Object>(); 
     201            for (int i = 0; i < node.size(); i++) { 
     202                value.add(readHierarchical(node.get(i), valueType, prop)); 
     203            } 
     204 
     205            return value; 
     206        } else { 
     207            return readHierarchical(node, valueType, prop); 
     208        } 
     209    } 
     210 
     211    private Object readHierarchical(JsonNode node, ValueType valueType, String prop) throws ImportException { 
     212        if (valueType.isHierarchical()) { 
     213            if (!node.isArray()) { 
     214                throw new ImportException("Hierarchical value should be specified as an array in " + prop); 
     215            } 
     216 
     217            Object[] elements = new Object[node.size()]; 
     218            for (int i = 0; i < node.size(); i++) { 
     219                elements[i] = readPrimitive(node.get(i), valueType, prop); 
     220            } 
     221 
     222            return new HierarchyPath(elements); 
     223        } else { 
     224            return readPrimitive(node, valueType, prop); 
     225        } 
     226    } 
     227 
     228    private Object readPrimitive(JsonNode node, ValueType valueType, String prop) throws ImportException { 
     229        String primitive = valueType.getPrimitive().getName(); 
     230 
     231        if (primitive.equals("STRING")) { 
     232            if (!node.isTextual()) 
     233                throw new ImportException("Expected text value for " + prop); 
     234 
     235            return node.getTextValue(); 
     236        } else if (primitive.equals("INTEGER")) { 
     237            if (!node.isIntegralNumber()) 
     238                throw new ImportException("Expected int value for " + prop); 
     239 
     240            return node.getIntValue(); 
     241        } else if (primitive.equals("LONG")) { 
     242            if (!node.isIntegralNumber()) 
     243                throw new ImportException("Expected long value for " + prop); 
     244 
     245            return node.getLongValue(); 
     246        } else if (primitive.equals("BOOLEAN")) { 
     247            if (!node.isBoolean()) 
     248                throw new ImportException("Expected boolean value for " + prop); 
     249 
     250            return node.getBooleanValue(); 
     251        } else if (primitive.equals("LINK")) { 
     252            if (!node.isTextual()) 
     253                throw new ImportException("Expected text value for " + prop); 
     254             
     255            return Link.fromString(node.getTextValue(), repository.getIdGenerator()); 
     256        } else if (primitive.equals("DATE")) { 
     257            if (!node.isTextual()) 
     258                throw new ImportException("Expected text value for " + prop); 
     259 
     260            return new LocalDate(node.getTextValue()); 
     261        } else if (primitive.equals("DATETIME")) { 
     262            if (!node.isTextual()) 
     263                throw new ImportException("Expected text value for " + prop); 
     264 
     265            return new DateTime(node.getTextValue()); 
     266        } else { 
     267            throw new ImportException("Primitive value type not supported by import tool: " + primitive); 
     268        } 
    183269    } 
    184270 
Note: See TracChangeset for help on using the changeset viewer.