Index: oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+>/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.apache.jackrabbit.oak.kernel;\n\nimport java.util.HashMap;\nimport java.util.Locale;\nimport java.util.Map;\n\nimport javax.jcr.PropertyType;\n\nimport static com.google.common.base.Preconditions.checkNotNull;\n\n/**\n * TypeCodes maps between {@code Type} and the code used to prefix\n * its json serialisation.\n */\npublic class TypeCodes {\n private static final Map TYPE2CODE = new HashMap();\n private static final Map CODE2TYPE = new HashMap();\n\n static {\n for (int type = PropertyType.UNDEFINED; type <= PropertyType.DECIMAL; type++) {\n String code = PropertyType.nameFromValue(type).substring(0, 3).toLowerCase(Locale.ENGLISH);\n TYPE2CODE.put(type, code);\n CODE2TYPE.put(code, type);\n }\n }\n\n private TypeCodes() { }\n\n /**\n * Encodes the given {@code propertyName} of the given {@code propertyType} into\n * a json string, which is prefixed with a type code.\n * @param propertyType type of the property\n * @param propertyName name of the property\n * @return type code prefixed json string\n */\n public static String encode(int propertyType, String propertyName) {\n String typeCode = checkNotNull(TYPE2CODE.get(propertyType));\n return typeCode + ':' + propertyName;\n }\n\n /**\n * Splits a {@code jsonString}, which is prefixed with a type code\n * at the location where the prefix ends.\n * @param jsonString json string to split\n * @return the location where the prefix ends or -1 if no prefix is present\n */\n public static int split(String jsonString) {\n if (jsonString.length() >= 4 && jsonString.charAt(3) == ':') {\n return 3;\n }\n else {\n return -1;\n }\n }\n\n /**\n * Decode the type encoded into {@code jsonString} given its split.\n * @param split split of the json string\n * @param jsonString json string\n * @return decoded type. {@code PropertyType.UNDEFINED} if none or split is not within {@code jsonString}.\n */\n public static int decodeType(int split, String jsonString) {\n if (split == -1 || split > jsonString.length()) {\n return PropertyType.UNDEFINED;\n }\n else {\n Integer type = CODE2TYPE.get(jsonString.substring(0, split));\n return type == null\n ? PropertyType.UNDEFINED\n : type;\n }\n }\n\n /**\n * Decode the property name encoded into a {@code jsonString} given its split.\n * @param split split of the json string\n * @param jsonString json string\n * @return decoded property name. Or {@code jsonString} if split is not with {@code jsonString}.\n */\n public static String decodeName(int split, String jsonString) {\n if (split == -1 || split >= jsonString.length()) {\n return jsonString;\n }\n else {\n return jsonString.substring(split + 1);\n }\n }\n\n} =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java (revision 21a5cab020bae805ce21da05d06a4d3cbadd53fb) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TypeCodes.java (revision ) @@ -34,7 +34,9 @@ static { for (int type = PropertyType.UNDEFINED; type <= PropertyType.DECIMAL; type++) { - String code = PropertyType.nameFromValue(type).substring(0, 3).toLowerCase(Locale.ENGLISH); + String code = type == PropertyType.BINARY + ? ":blobId" // See class comment for MicroKernel and OAK-428 + : PropertyType.nameFromValue(type).substring(0, 3).toLowerCase(Locale.ENGLISH); TYPE2CODE.put(type, code); CODE2TYPE.put(code, type); } @@ -61,7 +63,10 @@ * @return the location where the prefix ends or -1 if no prefix is present */ public static int split(String jsonString) { - if (jsonString.length() >= 4 && jsonString.charAt(3) == ':') { + if (jsonString.startsWith(":blobId:")) { // See OAK-428 + return 7; + } + else if (jsonString.length() >= 4 && jsonString.charAt(3) == ':') { return 3; } else { @@ -82,8 +87,8 @@ else { Integer type = CODE2TYPE.get(jsonString.substring(0, split)); return type == null - ? PropertyType.UNDEFINED - : type; + ? PropertyType.UNDEFINED + : type; } } \ No newline at end of file