<xs:element name="accountId" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="screenName" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="userId" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="tenantId" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
*/\r
public class FileTools {\r
\r
+ public static String convertStreamToString(InputStream is) {\r
+ /*\r
+ * To convert the InputStream to String we use the\r
+ * Reader.read(char[] buffer) method. We iterate until the\r
+ * Reader return -1 which means there's no more data to\r
+ * read. We use the StringWriter class to produce the string.\r
+ */\r
+ if (is != null) {\r
+ Writer writer = new StringWriter();\r
+\r
+ char[] buffer = new char[1024];\r
+ try {\r
+ Reader reader = new BufferedReader(\r
+ new InputStreamReader(is, "UTF-8"));\r
+ int n;\r
+ while ((n = reader.read(buffer)) != -1) {\r
+ writer.write(buffer, 0, n);\r
+ }\r
+ } catch (IOException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } finally {\r
+ try {\r
+ is.close();\r
+ } catch (IOException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return writer.toString();\r
+ } else { \r
+ return "";\r
+ }\r
+ }\r
+ \r
public static void forceParentDirectories(String filename) throws IOException {\r
File theFile = new File(filename);\r
String parent = theFile.getParent();\r
/** The tenant id. */\r
String tenantId;\r
\r
+ static public final String getTenantQualifiedDoctype(QueryContext queryContext, String docType) {\r
+// return queryContext.getTenantId() + "_" + docType;\r
+ return docType; //FIXME: Need to use the line above to get a qualified doctype name \r
+\r
+ }\r
+ \r
/**\r
* Instantiates a new query context.\r
*\r
public String getDocType() {\r
return this.docType;\r
}\r
+ \r
+ public final String getTenantQualifiedDoctype() {\r
+ return QueryContext.getTenantQualifiedDoctype(this, docType);\r
+ } \r
\r
/**\r
* Gets the doc type.\r
releaseEntityManagerFactory(emf);
}
}
-
+ /*
+ * Add the currentTenantId to the payload so the client knows the current
+ * tenancy.
+ */
+ AccountValue av = result.getAccounts().get(0);
+ av.setTenantId(AuthN.get().getCurrentTenantId());
return result;
}
*/
static public final String buildNXQLQuery(QueryContext queryContext) throws Exception {
StringBuilder query = new StringBuilder("SELECT * FROM ");
- query.append(queryContext.getDocType());
+ query.append(queryContext.getTenantQualifiedDoctype()); // Nuxeo doctype must be tenant qualified.
appendNXQLWhere(query, queryContext);
appendNXQLOrderBy(query, queryContext);
return query.toString();
}
-
+
/**
* Builds an NXQL SELECT query across multiple document types.
*
* @return an NXQL query
*/
static public final String buildNXQLQuery(List<String> docTypes, QueryContext queryContext) {
- StringBuilder query = new StringBuilder("SELECT * FROM ");
+ StringBuilder query = new StringBuilder("SELECT * FROM ");
boolean fFirst = true;
for (String docType : docTypes) {
if (fFirst) {
} else {
query.append(",");
}
- query.append(docType);
+ String tqDocType = QueryContext.getTenantQualifiedDoctype(queryContext, docType);
+ query.append(tqDocType); // Nuxeo doctype must be tenant qualified.
}
appendNXQLWhere(query, queryContext);
// FIXME add 'order by' clause here, if appropriate