0

I have a requirement where i need to connect to Alfresco Repository using the below atompuburl

https://www.myalfresco.com/alfresco/api/-default-/public/cmis/versions/1.1/atom

where www.myalfresco.com is my aws alfresco url.

I use the below snippet to get a session of alfresco

public Session connectToRepository(String username,String password,String atompuburl)
    {
        // Create session.
        Session session = null;
        try
        {
            // Default factory implementation of client runtime.
            final SessionFactory sessionFactory = SessionFactoryImpl.newInstance();

            // prepare connection parameters
            final Map<String, String> connectionParameters = new HashMap<String, String>();

            // User credentials.
            connectionParameters.put(SessionParameter.USER,username);
            connectionParameters.put(SessionParameter.PASSWORD,password);

            // Connection settings.
            connectionParameters.put(SessionParameter.ATOMPUB_URL,atompuburl);
            connectionParameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
            session = sessionFactory.getRepositories(connectionParameters).get(0).createSession();
        } catch (CmisConnectionException ce){
            System.out.println("CMIS error=========");
            ce.printStackTrace();
        } catch (CmisPermissionDeniedException cmisPermissionDeniedException)
        {

        }

where i use the above mentioned url in the atompul url.

Is there any way to connect to the Alfresco Repository without the ports(as it is not given to me).

Is there any other way than this for Chemistry Cmis.

Kindly help.

This is the exception it gives

org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Cannot access "https://www.myalfresco.com:443/alfresco/api/-default-/public/cmis/versions/1.1/atom": Connection timed out: connect at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:230) at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invokeGET(DefaultHttpInvoker.java:57) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:641) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:808) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:65) at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:90) at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:135) at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:112) at com.ge.test.CMISConnector.connectToRepository(CMISConnector.java:35) at com.ge.test.MyApp.main(MyApp.java:10) connected Caused by: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668) at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264) at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153) at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:205) ... 9 more

user2361591
  • 153
  • 1
  • 14

1 Answers1

1

Looks like your port is 443 because your URL protocol is "https" and you aren't specifying a port, so it must be the default SSL port.

Make sure you can successfully hit that URL via curl or a similar HTTP client. If you can't do that, check the firewall. Also check that your SSL certificate is valid.

Jeff Potts
  • 10,468
  • 17
  • 40
  • I am able to hit the host and also download the atompub file when i hit https://www.myalfresco.com/alfresco/api/-default-/public/cmis/versions/1.1/atom using the browser – user2361591 Oct 18 '16 at 12:57
  • Is it because its using https, its preventing authentication ? do we need to install the necessary certificates in the jvm to access the same ? – user2361591 Oct 18 '16 at 13:11
  • Java has to be able to validate the certificate, so, yes, make sure your JVM knows about your certs. If that were the problem, I wouldn't expect a timeout, I'd expect a different error. Is that "myalfresco.com" your real domain? I noticed its cert was expired. – Jeff Potts Oct 18 '16 at 13:48
  • its only a sample name as the url is confidential. Thanks but ,i'l try with that approach. – user2361591 Oct 19 '16 at 09:10