本文整理汇总了Java中org.apache.jackrabbit.util.ISO9075类的典型用法代码示例。如果您正苦于以下问题:Java ISO9075类的具体用法?Java ISO9075怎么用?Java ISO9075使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISO9075类属于org.apache.jackrabbit.util包,在下文中一共展示了ISO9075类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getName
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
/**
* Validate that the given value can be converted to a JCR name, and
* return the name.
*
* @param v the value
* @return name value, or {@code null} if the value can not be converted
*/
private String getName(PropertyValue v) {
// TODO correctly validate JCR names - see JCR 2.0 spec 3.2.4 Naming Restrictions
switch (v.getType().tag()) {
case PropertyType.DATE:
case PropertyType.DECIMAL:
case PropertyType.DOUBLE:
case PropertyType.LONG:
case PropertyType.BOOLEAN:
return null;
}
String name = v.getValue(Type.NAME);
// Name escaping (convert _x0020_ to space)
name = ISO9075.decode(name);
// normalize paths (./name > name)
name = PropertyValues.getOakPath(name, query.getNamePathMapper());
if (name.startsWith("[") && !name.endsWith("]")) {
return null;
} else if (!JcrNameParser.validate(name)) {
return null;
}
return name;
}
示例2: getGroupNodeByName
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
/**
* Gets the Node for the specified name. If no node with the specified name exists, null is returned.
*
* @param groupName the name of the Group to return
* @return the Node with name groupName
*/
public Node getGroupNodeByName(final String groupName) {
final String escapedGroupName = Text.escapeIllegalJcr10Chars(ISO9075.encode(NodeNameCodec.encode(groupName, true)));
final String queryString = QUERY_GROUP.replace("{}", escapedGroupName);
try {
@SuppressWarnings("deprecation") final Query query = getQueryManager().createQuery(queryString, Query.SQL);
final QueryResult queryResult = query.execute();
final NodeIterator iterator = queryResult.getNodes();
if (!iterator.hasNext()) {
return null;
}
final Node node = iterator.nextNode();
return node;
} catch (RepositoryException e) {
log.error("Unable to check if group '{}' exists, returning true", groupName, e);
return null;
}
}
示例3: internalRemove
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
@Override
protected void internalRemove(String key) throws MessagingException {
try {
Session session = login();
try {
String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
QueryManager manager = session.getWorkspace().getQueryManager();
Query query = manager.createQuery("/jcr:root/" + MAIL_PATH + "//element(" + name + ",james:mail)", Query.XPATH);
NodeIterator nodes = query.execute().getNodes();
if (nodes.hasNext()) {
while (nodes.hasNext()) {
nodes.nextNode().remove();
}
session.save();
logger.info("Mail " + key + " removed from repository");
} else {
logger.warn("Mail " + key + " not found");
}
} finally {
session.logout();
}
} catch (RepositoryException e) {
throw new MessagingException("Unable to remove message: " + key, e);
}
}
示例4: getEntitiesByClassNameForRange
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
public Entity[] getEntitiesByClassNameForRange(String path, String className, DateRange range)
throws NotFoundException {
// xpath xs:dateTime function has a specific format (see
// getFormattedDate)
// characters that must remain unchanged must be between '' in
// SimpleDateFormat
// SimpleDateFormat format = new
// SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
// this format does not put semicolon in time zone (
// 2012-01-04T23:59:59.999+0200 instead of
// 2012-01-04T23:59:59.999+02:00)
// so we will use getFormattedDate method instead of formatting with a
// SimpleDateFormat
checkPath(path);
StringBuilder sb = new StringBuilder();
sb.append("/jcr:root").append(ISO9075.encodePath(path)).append("//*[@className='").append(className).append("'")
.append(" and @createdDate <= xs:dateTime('").append(getFormattedDate(range.getEndDate())).append("')")
.append(" and @createdDate >= xs:dateTime('").append(getFormattedDate(range.getStartDate()))
.append("')]");
return getEntities(sb.toString());
}
示例5: clearUserWidgetData
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
public void clearUserWidgetData(String widgetId) {
try {
String className = "ro.nextreports.server.domain.UserWidgetParameters";
String xpath = "/jcr:root" + ISO9075.encodePath(StorageConstants.USERS_DATA_ROOT) + "//*[@className='"
+ className + "']";
NodeIterator nodes = getTemplate().query(xpath).getNodes();
while (nodes.hasNext()) {
Node node = nodes.nextNode();
if (node.getName().equals(widgetId)) {
node.remove();
}
}
getTemplate().save();
} catch (RepositoryException e) {
throw convertJcrAccessException(e);
}
}
示例6: modifyDashboardState
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private void modifyDashboardState() throws RepositoryException {
LOG.info("Modify dashboard state - add columnCount property");
String path = StorageConstants.DASHBOARDS_ROOT;
String className = "ro.nextreports.server.domain.DashboardState";
String statement = "/jcr:root" + ISO9075.encodePath(path) + "//*[@className='" + className + "']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " dashboard state nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
node.setProperty("columnCount", 2);
}
getTemplate().save();
}
示例7: addRuntimeNameProperty
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private void addRuntimeNameProperty() throws RepositoryException {
String statement =
"/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) +
"//*[@className='ro.nextreports.server.domain.Report']" +
"//*[fn:name()='parametersValues']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("RuntimeHistory : Found " + nodes.getSize() + " parameterValues nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
NodeIterator childrenIt = node.getNodes();
while (childrenIt.hasNext()) {
Node child = childrenIt.nextNode();
child.setProperty("runtimeName", child.getName());
}
}
getTemplate().save();
}
示例8: updateTemplateNodes
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private void updateTemplateNodes() throws RepositoryException {
// add shortcutType node to all report templates nodes
String statement =
"/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) +
"//*[@className='ro.nextreports.server.domain.Report']/templates";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Add shortcutType node to all report templates nodes : Found " + nodes.getSize() + " report nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
NodeIterator templatesForReport = node.getNodes();
while (templatesForReport.hasNext()) {
Node template = templatesForReport.nextNode();
Node shortcutTypeNode = template.addNode("shortcutType");
shortcutTypeNode.setProperty("type", 0);
shortcutTypeNode.setProperty("timeType", 0);
shortcutTypeNode.setProperty("timeUnits", 0);
}
}
getTemplate().save();
}
示例9: addAnalystUserProfile
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private void addAnalystUserProfile() throws RepositoryException {
LOG.info("User profile analyst");
String path = StorageConstants.USERS_ROOT ;
String className = "ro.nextreports.server.domain.User";
String statement = "/jcr:root" + ISO9075.encodePath(path) + "//*[@className='" + className + "']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
node.setProperty("profile", "analyst");
}
getTemplate().save();
}
示例10: updateInternalSettings
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private void updateInternalSettings() throws RepositoryException {
// find all internalSettings nodes from DASHBOARDS and change chartId property in entityId
String statement = "/jcr:root" + ISO9075.encodePath(StorageConstants.DASHBOARDS_ROOT) + "//*[fn:name()='internalSettings']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " internalSettings nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
try {
Property prop = node.getProperty("chartId");
node.setProperty("entityId", prop.getValue());
prop.remove();
} catch (PathNotFoundException ex) {
// if property not found we have nothing to do
}
}
}
示例11: renameChartWidgetClassName
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private void renameChartWidgetClassName() throws RepositoryException {
LOG.info("Rename chart widget class name");
String path = StorageConstants.DASHBOARDS_ROOT;
String className = "ro.nextreports.server.web.chart.ChartWidget";
String newClassName = "ro.nextreports.server.web.dashboard.chart.ChartWidget";
String statement = "/jcr:root" + ISO9075.encodePath(path) + "//*[@widgetClassName='" + className + "']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
node.setProperty("widgetClassName", newClassName);
}
getTemplate().save();
}
示例12: escapeXpath
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
public static String escapeXpath(String xpath) {
final Matcher matcher = XPATH.matcher(xpath);
if (matcher.find()) {
final String path = ISO9075.encodePath(matcher.group(1));
final String props = matcher.group(2);
return String.format("/jcr:root%s//%s", path, props);
}
return xpath;
}
示例13: searchAces
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
@Nonnull
private static Result searchAces(@Nonnull Set<Principal> principals, @Nonnull Root root) throws RepositoryException {
StringBuilder stmt = new StringBuilder("/jcr:root");
stmt.append("//element(*,");
stmt.append(NT_REP_ACE);
stmt.append(")[");
int i = 0;
for (Principal principal : principals) {
if (i > 0) {
stmt.append(" or ");
}
stmt.append('@');
stmt.append(ISO9075.encode(REP_PRINCIPAL_NAME));
stmt.append("='");
stmt.append(principal.getName().replaceAll("'", "''"));
stmt.append('\'');
i++;
}
stmt.append(']');
stmt.append(" order by jcr:path");
try {
QueryEngine queryEngine = root.getQueryEngine();
return queryEngine.executeQuery(
stmt.toString(), Query.XPATH, Long.MAX_VALUE, 0,
QueryEngine.NO_BINDINGS, QueryEngine.NO_MAPPINGS);
} catch (ParseException e) {
String msg = "Error while collecting effective policies.";
log.error(msg, e.getMessage());
throw new RepositoryException(msg, e);
}
}
示例14: getUserNodeByName
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
private Node getUserNodeByName(final String username) throws RepositoryException {
Node userNode = null;
final String queryString = QUERY_USER.replace("{}", Text.escapeIllegalJcr10Chars(ISO9075.encode(NodeNameCodec.encode(username))));
final Query query = getQueryManager().createQuery(queryString, Query.SQL);
final NodeIterator nodes = query.execute().getNodes();
if (nodes.hasNext()) {
userNode = nodes.nextNode();
}
return userNode;
}
示例15: userExists
import org.apache.jackrabbit.util.ISO9075; //导入依赖的package包/类
/**
* Checks if the user with username exists.
*
* @param username the name of the user to check
* @return true if the user exists, false otherwise
*/
public boolean userExists(final String username) {
final String queryString = QUERY_USER.replace("{}", Text.escapeIllegalJcr10Chars(ISO9075.encode(NodeNameCodec.encode(username))));
try {
final Query query = getQueryManager().createQuery(queryString, Query.SQL);
return query.execute().getNodes().hasNext();
} catch (RepositoryException e) {
log.error("Unable to check if user '{}' exists, returning true", username, e);
return true;
}
}