/** * Constructs a new error object by pushing the given context on top of the * current context */ public static Error get(String ctx, String errorCode, String msg) { push(ctx); try { return new Error(THREAD_CONTEXT.get(), errorCode, msg); } finally { pop(); } }
/** * Constructs a new error object by pushing the given context on top of the * current context */ public static Error get(String ctx, String errorCode, String msg) { push(ctx); try { return new Error(THREAD_CONTEXT.get(), errorCode, msg); } finally { pop(); } }
/** * Constructs a new error object by pushing the given context on top of the * current context */ public static Error get(String ctx, String errorCode, String msg) { push(ctx); try { Error x = new Error(THREAD_CONTEXT.get(), errorCode, msg); return x; } finally { pop(); } }
public void convertPropertyParser(T object, Map<String, Object> properties) { Error.push("convertPropertyParser"); try { for (Entry entry : properties.entrySet()) { String key = (String) entry.getKey(); PropertyParser p = extensions.getPropertyParser(key); if (p != null) { p.convert(this, object, entry.getValue()); } } } finally { Error.pop(); } }
public FieldTreeNode resolve(Path p) { Error.push(name); try { return fields.resolve(p); } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
public void validateDocs(List<? extends JsonDoc> docList) { currentDocList = docList; currentDoc = null; LOGGER.debug("validateDocs() enter with {} docs", docList.size()); Error.push("validateDocs"); try { for (JsonDoc doc : docList) { validateDoc(doc); } } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(CrudConstants.ERR_CRUD, e.getMessage()); } finally { Error.pop(); } LOGGER.debug("validateDocs() complete"); }
public FieldTreeNode resolve(Path p) { Error.push(name); try { return fields.resolve(p); } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
public FieldTreeNode resolve(Path p) { Error.push(name); try { return fields.resolve(p); } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
public void validateDocs(List<? extends JsonDoc> docList) { currentDocList = docList; currentDoc = null; LOGGER.debug("validateDocs() enter with {} docs", docList.size()); Error.push("validateDocs"); try { for (JsonDoc doc : docList) { validateDoc(doc); } } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(CrudConstants.ERR_CRUD, e.getMessage()); } finally { Error.pop(); } LOGGER.debug("validateDocs() complete"); }
/** * Builds a composite metadata rooted at the given entity metadata. */ public static CompositeMetadata buildCompositeMetadata(EntityMetadata root, GetMetadata gmd) { LOGGER.debug("enter buildCompositeMetadata"); Error.push("compositeMetadata"); try { CompositeMetadata cmd = buildCompositeMetadata(root, gmd, new Path(), null, new MutablePath()); return cmd; } finally { LOGGER.debug("end buildCompositeMetadata"); Error.pop(); } }
/** * Builds a composite metadata rooted at the given entity metadata. */ public static CompositeMetadata buildCompositeMetadata(EntityMetadata root, GetMetadata gmd) { LOGGER.debug("enter buildCompositeMetadata"); Error.push("compositeMetadata"); try { CompositeMetadata cmd = buildCompositeMetadata(root, gmd, new Path(), null, new MutablePath()); return cmd; } finally { LOGGER.debug("end buildCompositeMetadata"); Error.pop(); } }
@Override public EntityInfo getEntityInfo(String entityName) { if (entityName == null || entityName.length() == 0) { throw new IllegalArgumentException(LITERAL_ENTITY_NAME); } Error.push("getEntityInfo(" + entityName + ")"); try { BasicDBObject query = new BasicDBObject(LITERAL_ID, entityName + BSONParser.DELIMITER_ID); DBObject ei = collection.findOne(query); if (ei != null) { return mdParser.parseEntityInfo(ei); } else { return null; } } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { throw analyzeException(e, MetadataConstants.ERR_ILL_FORMED_METADATA); } finally { Error.pop(); } }
/** * Translates a query to Mongo query * * @param md Entity metadata * @param query The query expression */ public DBObject translate(EntityMetadata md, QueryExpression query) { Error.push("translateQuery"); FieldTreeNode mdRoot = md.getFieldTreeRoot(); try { return translate(mdRoot, query); } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MongoCrudConstants.ERR_INVALID_OBJECT, e.getMessage()); } finally { Error.pop(); } }
/** * Override to set _id appropriately. */ @Override public BSONObject convert(EntityInfo info) { Error.push("convert[info|bson]"); try { BSONObject doc = (BSONObject) super.convert(info); // entityInfo._id = {entityInfo.name}| putValue(doc, "_id", getStringProperty(doc, "name") + DELIMITER_ID); return doc; } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
/** * Override to set _id appropriately. */ @Override public BSONObject convert(EntityInfo info) { Error.push("convert[info|bson]"); try { BSONObject doc = super.convert(info); // entityInfo._id = {entityInfo.name}| putValue(doc, "_id", getStringProperty(doc, "name") + DELIMITER_ID); return doc; } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
public void parsePropertyParser(T object, Map<String, Object> properties) { Error.push("parsePropertyParser"); try { Set<String> propertyFields = findFieldsNotIn(object, ENTITY_INFO_FIELDS); for (String property : propertyFields) { PropertyParser p = extensions.getPropertyParser(property); if (p != null) { p.parseProperty(this, property, properties, getObjectProperty(object, property)); } } } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
/** * Override to set _id appropriately. */ @Override public BSONObject convert(EntitySchema schema) { Error.push("convert[info|bson]"); try { BSONObject doc = super.convert(schema); putValue(doc, "_id", getStringProperty(doc, "name") + DELIMITER_ID + getStringProperty(getObjectProperty(doc, "version"), "value")); return doc; } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
/** * Override to set _id appropriately. */ @Override public BSONObject convert(EntitySchema schema) { Error.push("convert[info|bson]"); try { BSONObject doc = (BSONObject) super.convert(schema); putValue(doc, "_id", getStringProperty(doc, "name") + DELIMITER_ID + getRequiredStringProperty(getRequiredObjectProperty(doc, "version"), "value")); return doc; } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }
/** * Translates the source to a {@link JsonDoc}. * @param source - Object containing the source data. * @return {@link JsonDoc} */ public JsonDoc translate(S source){ Error.push("translating to json"); try{ FieldCursor cursor = entityMetadata.getFieldCursor(); if (cursor.firstChild()) { ObjectNode node = factory.objectNode(); iterateOverNodes(source, node, cursor); return new JsonDoc(node); } } finally{ Error.pop(); } //TODO: What to do in case of a null value here? return null; }
/** * Converts the entity metadata to T */ public T convert(EntityMetadata md) { Error.push("convert[metadata]"); try { T ret = newNode(); putObject(ret, STR_ENTITY_INFO, convert(md.getEntityInfo())); putObject(ret, STR_SCHEMA, convert(md.getEntitySchema())); convertProperties(md, ret); return ret; } catch (Error e) { // rethrow lightblue error throw e; } catch (Exception e) { // throw new Error (preserves current error context) LOGGER.error(e.getMessage(), e); throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage()); } finally { Error.pop(); } }