TokenHandler.java revision 6c322ff001f7e73151fee8595cb9406a1b1eb0eb
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2011-2013 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
// TODO: replace use of this class with TokenHandler in org.forgerock.openidm.repo.util
public class TokenHandler {
// The OpenIDM query token is of format ${token-name}
/**
* Replaces a query string with tokens of format ${token-name} with the values from the
* passed in map, where the token-name must be the key in the map
*
* @param queryString the query with tokens
* @param params the parameters to replace the tokens. Values can be String or List.
* @return the query with all tokens replace with their found values
* @throws BadRequestException if token in the query is not in the passed parameters
*/
throws BadRequestException {
// if prefix found
}
// fail with an exception if token not found
} else {
if (replacement instanceof List) {
boolean first = true;
if (!first) {
} else {
first = false;
}
}
}
if (replacement == null) {
replacement = "";
}
// Optional control of representation via prefix
if (tokenPrefix != null) {
// Leave replacement unquoted
// Convert Json Pointer to OrientDB dot notation
} else {
}
}
} else {
// Default is single quoted string replacement
}
}
}
}
/**
* Replaces a query string with tokens of format ${token-name} with the
* token format in OrientDB, which is of the form :token-name.
*
* OrientDB tokens has some limitations, e.g. they can currently only be used
* in the where clause, and hence the returned string is not guaranteed to be
* valid for use in a prepared statement. If the parsing fails the system may
* have to fall back onto non-prepared statements and manual token replacement.
*
* @param queryString the query with OpenIDM format tokens ${token}
* @return the query with all tokens replaced with the OrientDB style tokens :token
* @throws PrepareNotSupported if this method knows a given statement can not be converted into a prepared statement.
* That a statement was not rejected here though does not mean it could not fail during the parsing phase later.
*/
// if prefix found
}
throw new PrepareNotSupported("Prepared query not supported for params with dotnotation conversion");
}
// OrientDB token is of format :token-name
}
}
}
}