public String uploadContent(String path, String fileName){
String contentUUID = new String();
try{
//Start the session
AuthenticationUtils.startSession("admin", "admin");
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
ParentReference companyHomeParent = new ParentReference(storeRef, null, "/app:company_home", Constants.ASSOC_CONTAINS, null);
RepositoryServiceSoapBindingStub repositoryService =WebServiceFactory.getRepositoryService();
ContentServiceSoapBindingStub contentService =WebServiceFactory.getContentService();
String queryLucene = "+PATH:\""+companyHomeParent.getPath()+"//*\" +@\\{http\\://www.alfresco.org/model/content/1.0\\}name:\"" + fileName + "\"";
query = new Query(Constants.QUERY_LANG_LUCENE, queryLucene);
ResultSet rs = repositoryService.query(storeRef, query, false).getResultSet();
if(rs.getTotalRowCount() > 0){
// Suppression du fichier
}
// Upload du fichier
(…)
ParentReference companyHomeParent = new ParentReference(storeRef, null, "/app:company_home/cm:upload", Constants.ASSOC_CONTAINS, null);
String queryLucene = "+PATH:\""+companyHomeParent.getPath()+"//*\" +@\\{http\\://www.alfresco.org/model/content/1.0\\}name:\"" + fileName + "\"";
Attention,
les requêtes Lucene sont "instable", car l'indexation se fait en arrière plan.
Il se peut donc que si la requête est effectuée juste après la création du noeud, elle ne renvoi rien.
Vous pouvez utiliser le service "get" en spécifiant un "path" dans le predicat pour faire une requête sur le chemin d'un noeud.
Mais si c'est pour vérifier l'existence du noeud créé, il veut encore mieux utiliser directement le "nodeRef".
String queryLucene = "+@sys\\:node-uuid:\"" + uuid + "\"";
Query query = new Query(Constants.QUERY_LANG_LUCENE, queryLucene);
ResultSet rs = repositoryService.query(storeRef, query, false).getResultSet();
par cleseach sur 05 Nov 2008, 12:11
Bonjour,
Avez-vous essayer de jouer votre requête Lucene avec le navigateur de noeuds ?
Cordialement,
Charles Le Seac'h
String queryLucene = "+PATH:\""+companyHomeParent.getPath()+"//*\" +@\\{http\\://www.alfresco.org/model/content/1.0\\}name:\"" + fileName + "\"";
String queryLucene = "+(PATH:\""+companyHomeParent.getPath()+"/*\" PATH:\""+companyHomeParent.getPath()+"/*//*\")\" +@\\{http\\://www.alfresco.org/model/content/1.0\\}name:\"" + fileName + "\"";
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.