001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Florent Guillaume 011 */ 012 013package org.nuxeo.ecm.core.query.sql; 014 015/** 016 * This defines the constants for NXQL queries. 017 * 018 * @author Florent Guillaume 019 */ 020public class NXQL { 021 022 // constant utility class 023 private NXQL() { 024 } 025 026 /** The NXQL query type. */ 027 public static final String NXQL = "NXQL"; 028 029 public static final String ECM_PREFIX = "ecm:"; 030 031 public static final String ECM_UUID = "ecm:uuid"; 032 033 public static final String ECM_PATH = "ecm:path"; 034 035 public static final String ECM_NAME = "ecm:name"; 036 037 public static final String ECM_POS = "ecm:pos"; 038 039 public static final String ECM_PARENTID = "ecm:parentId"; 040 041 public static final String ECM_MIXINTYPE = "ecm:mixinType"; 042 043 public static final String ECM_PRIMARYTYPE = "ecm:primaryType"; 044 045 public static final String ECM_ISPROXY = "ecm:isProxy"; 046 047 public static final String ECM_ISVERSION = "ecm:isVersion"; 048 049 /** 050 * @since 5.7.3 051 */ 052 public static final String ECM_ISVERSION_OLD = "ecm:isCheckedInVersion"; 053 054 public static final String ECM_LIFECYCLESTATE = "ecm:currentLifeCycleState"; 055 056 public static final String ECM_VERSIONLABEL = "ecm:versionLabel"; 057 058 public static final String ECM_FULLTEXT = "ecm:fulltext"; 059 060 public static final String ECM_FULLTEXT_JOBID = "ecm:fulltextJobId"; 061 062 /** 063 * @since 6.0 064 */ 065 public static final String ECM_FULLTEXT_SCORE = "ecm:fulltextScore"; 066 067 /** 068 * @deprecated since 5.4.2, use {@link #ECM_LOCK_OWNER} instead 069 */ 070 @Deprecated 071 public static final String ECM_LOCK = "ecm:lock"; 072 073 /** 074 * @since 5.4.2 075 */ 076 public static final String ECM_LOCK_OWNER = "ecm:lockOwner"; 077 078 /** 079 * @since 5.4.2 080 */ 081 public static final String ECM_LOCK_CREATED = "ecm:lockCreated"; 082 083 /** 084 * @since 5.7 085 */ 086 public static final String ECM_TAG = "ecm:tag"; 087 088 /** 089 * @since 5.7 090 */ 091 public static final String ECM_PROXY_TARGETID = "ecm:proxyTargetId"; 092 093 /** 094 * @since 5.7 095 */ 096 public static final String ECM_PROXY_VERSIONABLEID = "ecm:proxyVersionableId"; 097 098 /** 099 * @since 5.7.3 100 */ 101 public static final String ECM_ISCHECKEDIN = "ecm:isCheckedIn"; 102 103 /** 104 * @since 5.7.3 105 */ 106 public static final String ECM_ISLATESTVERSION = "ecm:isLatestVersion"; 107 108 /** 109 * @since 5.7.3 110 */ 111 public static final String ECM_ISLATESTMAJORVERSION = "ecm:isLatestMajorVersion"; 112 113 /** 114 * @since 5.7.3 115 */ 116 public static final String ECM_VERSIONCREATED = "ecm:versionCreated"; 117 118 /** 119 * @since 5.7.3 120 */ 121 public static final String ECM_VERSIONDESCRIPTION = "ecm:versionDescription"; 122 123 /** 124 * @since 5.7.3 125 */ 126 public static final String ECM_VERSION_VERSIONABLEID = "ecm:versionVersionableId"; 127 128 /** 129 * @since 6.0 130 */ 131 public static final String ECM_ANCESTORID = "ecm:ancestorId"; 132 133 /** 134 * @since 6.0-HF06, 7.2 135 */ 136 public static final String ECM_ACL = "ecm:acl"; 137 138 /** 139 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /principal} 140 * 141 * @since 6.0-HF06, 7.2 142 */ 143 public static final String ECM_ACL_PRINCIPAL = "principal"; 144 145 /** 146 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /permission} 147 * 148 * @since 6.0-HF06, 7.2 149 */ 150 public static final String ECM_ACL_PERMISSION = "permission"; 151 152 /** 153 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /grant} 154 * 155 * @since 6.0-HF06, 7.2 156 */ 157 public static final String ECM_ACL_GRANT = "grant"; 158 159 /** 160 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /name} 161 * 162 * @since 6.0-HF06, 7.2 163 */ 164 public static final String ECM_ACL_NAME = "name"; 165 166 /** 167 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /pos} 168 * 169 * @since 6.0-HF06, 7.2 170 */ 171 public static final String ECM_ACL_POS = "pos"; 172 173 /** 174 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /creator} 175 * 176 * @since 7.4 177 */ 178 public static final String ECM_ACL_CREATOR = "creator"; 179 180 /** 181 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /begin} 182 * 183 * @since 7.4 184 */ 185 public static final String ECM_ACL_BEGIN = "begin"; 186 187 /** 188 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /end} 189 * 190 * @since 7.4 191 */ 192 public static final String ECM_ACL_END = "end"; 193 194 /** 195 * Suffix for ecm:acl, like in {@code ecm:acl/}{@code *}{@code /status} 196 * 197 * @since 7.4 198 */ 199 public static final String ECM_ACL_STATUS = "status"; 200 201 /** 202 * Escapes a string into a single-quoted string for NXQL. 203 * <p> 204 * Any single quote or backslash characters are escaped with a backslash. 205 * 206 * @param s the string to escape 207 * @return the escaped string 208 * @since 5.7, 5.6.0-HF08 209 */ 210 public static String escapeString(String s) { 211 return "'" + escapeStringInner(s) + "'"; 212 } 213 214 /** 215 * Escapes a string (assumed to be single quoted) for NXQL. 216 * <p> 217 * Any single quote or backslash characters are escaped with a backslash. 218 * 219 * @param s the string to escape 220 * @return the escaped string, without external quotes 221 * @since 5.7, 5.6.0-HF08 222 */ 223 public static String escapeStringInner(String s) { 224 // backslash -> backslash backslash 225 // quote -> backslash quote 226 // newline -> backslash n 227 return s.replaceAll("\\\\", "\\\\\\\\").replaceAll("'", "\\\\'").replaceAll("\n", "\\\\n"); 228 } 229 230}