11-28-2013 06:23 AM
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();
client.getState().setCredentials(
new AuthScope(HOSTNAME, PORT, "Alfresco"),
new UsernamePasswordCredentials(USER, PASSWORD));
String apiurl ="http://localhost:8080/alfresco/service/api/sites";
PostMethod post = new PostMethod(apiurl);
try
{
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);
System.out.println(site.toString());
post.setDoAuthentication(true);
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();
System.out.println(resultString);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
post.releaseConnection();
}
}//void
}//class
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.
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(DispatcherServlet.java:1029)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:74)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:355)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
11-28-2013 10:12 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.