0

I'm trying to access a web service that communicates with Alfresco through CMIS. I'm accessing this link: http://localhost:8080/Changes/ChangesPDF?filePath=/Documentos/examplepdf.pdf&ticket=TICKET_1dd4951f5d97c72232db40bdc8dceeb7be70aaed

When I start Alfresco, I can access the web service without problems, but when I shutdown Alfresco - it gives me unauthorized in the webservice, and even if I made login, continues to give me unauthorized.

Code to get session:

 public Session getSession(
            String connectionName, String token) {
        Session session = connections.get(connectionName);
        if (session == null) {
            logger.info("Not connected, creating new connection to" +
                    " Alfresco with the connection id (" + connectionName +
                    ")");
// No connection to Alfresco available, create a new one
            SessionFactory sessionFactory =
                    SessionFactoryImpl.newInstance();
            Map<String, String> parameters = new HashMap<>();
            parameters.put(SessionParameter.USER, "");
            parameters.put(SessionParameter.PASSWORD, token);
            parameters.put(SessionParameter.ATOMPUB_URL,
                    "http://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/atom");
            parameters.put(SessionParameter.BINDING_TYPE,
                    BindingType.ATOMPUB.value());
            parameters.put(SessionParameter.COMPRESSION, "true");
            parameters.put(SessionParameter.CACHE_TTL_OBJECTS, "0");
// If there is only one repository exposed (e.g. Alfresco),
// these lines will help detect it and its ID
            List<Repository> repositories =
                    sessionFactory.getRepositories(parameters);
            Repository alfrescoRepository = null;
            if (repositories != null && repositories.size() > 0) {
                logger.info("Found (" + repositories.size() +
                        ") Alfresco repositories");
                alfrescoRepository = repositories.get(0);
                logger.info("Info about the first Alfresco repo [ID=" +
                        alfrescoRepository.getId() + "][name=" +
                        alfrescoRepository.getName() + "][CMIS ver supported=" +
                        alfrescoRepository.getCmisVersionSupported() + "]");
            } else {
                throw new CmisConnectionException(
                        "Could not connect to the Alfresco Server, " +
                                "no repository found!");
            }
// Create a new session with the Alfresco repository
            session = alfrescoRepository.createSession();
// Save connection for reuse
            connections.put(connectionName, session);
        } else {
            logger.info("Already connected to Alfresco with the " +
                    "connection id (" + connectionName + ")");
        }
        return session;
    }

Error below:

Request processing failed; nested exception is org.apache.chemistry.opencmis.commons.exceptions .CmisUnauthorizedException: Unauthorized

And enter here:

"Already connected to Alfresco with the " +
                    "connection id (" + connectionName + ")"7

How can I close the older connection with Alfresco?

PRVS
  • 1,612
  • 4
  • 38
  • 75
  • Sounds like user1 is lacking access required by the service itself. As in, maybe the user doesn't have permission on a space that service is accessing? – DocWatson Feb 24 '16 at 16:28
  • But if I logout admin and login admin I lost the connection too. @ConsultStan – PRVS Feb 24 '16 at 16:57
  • Try the CMIS workbench with the token and show us the results – Tahir Malik Feb 25 '16 at 11:21
  • But with the URL of the webservice? @TahirMalik – PRVS Feb 25 '16 at 14:04
  • I tried http://localhost:8080/share/proxy/alfresco/auth/get-ticket and it gives me error: `Exception: CmisUnauthorizedException Unauthorized The provide credentials are invalid. Check your credentials.` but my credentials are correct. I don't know if it is the suppose that I have to make on CMIS workbench. @TahirMalik – PRVS Feb 25 '16 at 14:06
  • And with this: `http://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/atom` I can make the connection. – PRVS Feb 25 '16 at 14:08
  • With web service: `Exception: CmisConnectionException Cannot access WSDL: http://localhost:8080/Changes/ChangesPDF?filePath=/Teste/latexexemplo.pdf&ticket=TICKET_9df294d47c4613812cd0d80202be909d6ea4ae39 Check the URL, the binding, and the credentials.` – PRVS Feb 25 '16 at 14:17

1 Answers1

2

you just need to close the session when the ticket change. You can do this with: session.clear(); session=null;

JMR
  • 765
  • 1
  • 8
  • 31