AnsweredAssumed Answered

Admin password is deleted from db after calling a webscript

Question asked by nicola.peluchetti on Mar 16, 2011
Hi,

i've got a strange behaviour in an alfresco installetion (3.2 community edition). I have a procedure in php that calls a webscript to create a folder in alfresco.

Fact is, after creating 2 or thre folders i have this error in the logs:
12:19:55,179  ERROR [lucene.index.IndexInfo] Index is missing 1fdd78eb-6714-4903-9d27-5543983a4ea4
12:19:55,181  ERROR [lucene.index.IndexInfo] Index is missing 45a519f9-ea04-4a00-bab4-4a1edfc96a23
12:19:55,517  ERROR [web.scripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 02168903 Login failed
org.alfresco.web.scripts.WebScriptException: 02168903 Login failed
   at org.alfresco.repo.web.scripts.bean.AbstractLoginBean.login(AbstractLoginBean.java:81)
   at org.alfresco.repo.web.scripts.bean.Login.executeImpl(Login.java:64)
   at org.alfresco.web.scripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:223)
   at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:70)
   at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:372)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:327)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:422)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:439)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:262)
   at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:306)
   at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:183)
   at org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)

It's clear that the login has failed, and the reason is that in the alfresco db the user "admin" has no password anymore! (i can't login to the back-end and i checked  with the sql command found here http://wiki.alfresco.com/wiki/Security_and_Authentication#Alfresco_Version_3.1sp1 that returns no result).

Here is the code of the webservice
package it.fondazionepolitecnico.astra.webscripts;

import it.fondazionepolitecnico.astra.util.Validator;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.io.Serializable;


import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.web.scripts.AbstractWebScript;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptResponse;

import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.json.JSONException;
import org.json.JSONObject;


public class CreaNdgWebScript extends AbstractWebScript {

   
   private SearchService searchService;
      
   public void setSearchService(SearchService searchService) {
      this.searchService = searchService;
   }

   private NodeService nodeService;
   
   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }

   @Override
   public void execute(WebScriptRequest req, WebScriptResponse res)
         throws IOException, DuplicateChildNodeNameException {

      /*
       * Ricavo dalla req l'identificativo che voglio assegnare all'NDG
       * Ricavo il nodeRef parent, cioè la superfolder NDG
       * faccio un node figlio creando un cm:folder a cui assegno id pari al parametro ricevuto
       * Restituisco nella response una stringa di conferma
       */
      
      String ndg = req.getParameter(AstraWebscript.NDG_PARAMETER);
      JSONObject response = new JSONObject();
            
      if (Validator.isNotNull(ndg)){

         String basePath="+PATH:\"/app:company_home/cm:Astra/cm:NDG\"";
         String ndgCercata = "+PATH:\"/app:company_home/cm:Astra/cm:NDG/cm:"+org.alfresco.util.ISO9075.encode(ndg)+"\"";
         // trovo il nodeRef del nodo radice NDG         
         ResultSet result = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,SearchService.LANGUAGE_LUCENE, basePath);
         NodeRef ndgRadice = result.getNodeRef(0);   
   
         //verifico se esiste già un NDG figlio con il nome inserito      
         ResultSet resultNdgFiglio = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,SearchService.LANGUAGE_LUCENE, ndgCercata);
         if (resultNdgFiglio.length()==0){
         
            Map<QName,Serializable> ndgParameters = new HashMap<QName,Serializable>(2);
            ndgParameters.put(ContentModel.PROP_NAME, ndg);
            ndgParameters.put(ContentModel.PROP_TITLE, ndg);
      
         /*
          * Definizione dei parametri usati nella funzione createNode():
          * il 1° è il nodeRef del nodo padre,
          * il 2° è il tipo di associazione (ASSOC_CONTAINS se si vuol creare un nodo TYPE_FOLDER)
          * il 3° è il nome dell'associazione, che viene riportato come valore terminale del Primary Path (cm:ndg)
          * il 4° è il tipo di contenuto da creare
          * il 5° è una mappa di properties da assegnare al nuovo nodo
          */         
            NodeRef ndgNodeRef = nodeService.createNode(ndgRadice, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,ndg), ContentModel.TYPE_FOLDER, ndgParameters).getChildRef();
            try {
               response.put(AstraWebscript.ESITO, AstraWebscript.OK);
               response.put(AstraWebscript.NDG_PARAMETER, ndgNodeRef);
            } catch (JSONException e) {
               e.printStackTrace();
            }         
         }
         else{
            try {
               response.put(AstraWebscript.ESITO, AstraWebscript.KO);
               response.put(AstraWebscript.MOTIVAZIONE, "NDG esistente");
            } catch (JSONException e) {
               e.printStackTrace();
            }
         }
      }
      
      else{
         try {
            response.put(AstraWebscript.ESITO, AstraWebscript.KO);
            response.put(AstraWebscript.MOTIVAZIONE, "NDG non valido");
         } catch (JSONException e) {
            e.printStackTrace();
         }
      }
      
      // creo la stringa JSON finale e la restituisco nella response
      String jsonString = response.toString();
       res.getWriter().write(jsonString);
   }

}

the thing that it's making me mad is that i have this problem only on a particular installation of Alfresco, other testing machines don't have the problem.

Has anyone experienced something similar?

Outcomes