AnsweredAssumed Answered

Create a share site with a program

Question asked by anita.platos on Nov 28, 2013
Latest reply on Nov 28, 2013 by yogeshpj
I have created a site with a Java program. It creates OK the site but it is unaccessible.
This is the java program:

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.json.JSONObject;
public class CreateSiteTest
   public static final String HOSTNAME="localhost";
   public static final String USER="admin";
   public static final String PASSWORD=USER;
   public static final Integer PORT=8080;
   public static final String APIURL="http://localhost:8080/alfresco/service/api/sites";
   public static final String SHORTNAME="mysite";
   public static final String VISIBILITY="PUBLIC";
   public static final String SITEPRESET="site-dashboard";
   public static final String CONTENT_TYPE="application/json";
   public void crearNuevoSitio ()
      System.out.println("SHORTNAME= "+ SHORTNAME);
      HttpClient client = new HttpClient();
                     new AuthScope(HOSTNAME, PORT, "Alfresco"),
                     new UsernamePasswordCredentials(USER, PASSWORD));
      String apiurl ="http://localhost:8080/alfresco/service/api/sites";
      PostMethod post = new PostMethod(apiurl);
         JSONObject site=new JSONObject ();
         site.put("description", SHORTNAME);
         site.put("shortName", SHORTNAME);
         site.put("visibility", VISIBILITY);
         site.put("sitePreset", SITEPRESET);
         site.put("title", SHORTNAME);
         site.put("description", SHORTNAME);
         post.setRequestHeader("Content-Type", CONTENT_TYPE);
         post.setRequestEntity(new StringRequestEntity(site.toString(), CONTENT_TYPE, "UTF-8"));
         int status = client.executeMethod(post);
         if (status != HttpStatus.SC_OK)
            System.err.println("Method failed: " + post.getStatusLine());
         String resultString = post.getResponseBodyAsString();
      catch (Exception e)

The problem is that when I try to access to the site in the Share, it appears an error in the explorer interface telling this:

A server error has occured.
There are a number of reasons why this could have happened:
You have attempted to access a page that does not exist - check the URL in the address bar.
You have attempted to access a page that is not accessable to you, such as a private Site dashboard.
A valid page has been requested but the server was unable to render it due to an internal error -  contact your administrator.
Return to your dashboard page
Alfresco Software Inc. © 2005-2012 All rights reserved.

The exception in the log is:

javax.servlet.ServletException: Could not resolve view with name 'site/mysite/dashboard' in servlet with name 'Spring Surf Dispatcher Servlet'
   at org.springframework.web.servlet.DispatcherServlet.render(
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(
   at org.springframework.web.servlet.DispatcherServlet.doService(
   at org.springframework.web.servlet.FrameworkServlet.processRequest(
   at org.springframework.web.servlet.FrameworkServlet.doGet(
   at javax.servlet.http.HttpServlet.service(
   at javax.servlet.http.HttpServlet.service(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.catalina.core.StandardWrapperValve.invoke(
   at org.apache.catalina.core.StandardContextValve.invoke(
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
   at org.apache.catalina.core.StandardHostValve.invoke(
   at org.apache.catalina.valves.ErrorReportValve.invoke(
   at org.apache.catalina.core.StandardEngineValve.invoke(
   at org.apache.catalina.connector.CoyoteAdapter.service(
   at org.apache.coyote.http11.Http11Processor.process(
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

Moreover, in the application console browser I can see that normal sites created in the web interface  contain inside the folder "cm:surf-config", but my site created with the program doesn´t contain it. Somebody knows how can I create a site accessible with a program as I created using the Share inteface?