关闭会话 CMIS



我正在尝试访问通过CMIS与Alfresco通信的网络服务。我正在访问此链接:http://localhost:8080/Changes/ChangesPDF?filePath=/Documentos/examplepdf.pdf&ticket=TICKET_1dd4951f5d97c72232db40bdc8dceeb7be70aaed

当我启动Alfresco时,我可以毫无问题地访问Web服务,但是当我关闭Alfresco时 - 它给了我在Web服务中未经授权的权限,即使我进行了登录,也继续给我未经授权的权限。

获取会话的代码:

 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;
    }

错误如下:

请求处理失败;嵌套异常为 org.apache.chemistry.opencmis.commons.exceptions .Cmis未经授权例外:未授权

并在此处输入:

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

如何关闭与Alfresco的旧连接?

您只需

要在票证更改时关闭会话。您可以使用以下方法执行此操作: session.clear(); session=null;

相关内容

  • 没有找到相关文章

最新更新