Package org.apache.stanbol.cmsadapter.servicesapi.model.web

Examples of org.apache.stanbol.cmsadapter.servicesapi.model.web.ConnectionInfo


    }

    @Test
    public void testGetSession() throws RepositoryAccessException {
        expectedException.expect(UnsupportedOperationException.class);
        offlineAccess.getSession(new ConnectionInfo());
    }
View Full Code Here


     * @param ontModel
     * @return
     */
    public static ConnectionInfo getConnectionInfo(OntModel ontModel) {
        ObjectFactory of = new ObjectFactory();
        ConnectionInfo ci = null;
        Resource ciResource = ontModel.getResource(CMSAdapterVocabulary.CONNECTION_INFO_RES.getURI());

        try {
            ci = of.createConnectionInfo();
            ci.setConnectionType(ciResource.getProperty(CMSAdapterVocabulary.CONNECTION_TYPE_PROP)
                    .getString());
            ci.setPassword(ciResource.getProperty(CMSAdapterVocabulary.CONNECTION_PASSWORD_PROP).getString());
            ci.setUsername(ciResource.getProperty(CMSAdapterVocabulary.CONNECTION_USERNAME_PROP).getString());
            ci.setWorkspaceName(ciResource.getProperty(CMSAdapterVocabulary.CONNECTION_WORKSPACE_PROP)
                    .getString());
            ci.setRepositoryURL(ciResource.getProperty(CMSAdapterVocabulary.CONNECTION_WORKSPACE_URL_PROP)
                    .getString());
        } catch (Exception e) {
            log.warn("Failed to get connection info from ont model");
            return null;
        }
View Full Code Here

     * @param type
     *            The protocol type of the cached session e.g <b>JCR</b>, <b>CMIS</b>.
     * @return a {@link UUID} generated unique identifier.
     */
    public String createSessionKey(Object session, String type) {
        ConnectionInfo cInfo = new ConnectionInfo();
        cInfo.setConnectionType(type);
        return cacheSessionContext(new SessionContext(session, cInfo));
    }
View Full Code Here

                                   String workspaceIdentifier,
                                   String username,
                                   String password,
                                   String connectionType) throws RepositoryAccessException {

        ConnectionInfo connectionInfo = formConnectionInfo(repositoryURL, workspaceIdentifier, username,
            password, connectionType);
        RepositoryAccess repositoryAccess = repositoryAccessManager.getRepositoryAccessor(connectionInfo);

        if (repositoryAccess == null) {
            log.warn(String
View Full Code Here

            if (repositoryAccess != null) {
                boolean validSession = repositoryAccess.isSessionValid(session);
                if (validSession) {
                    return session;
                } else {
                    ConnectionInfo connectionInfo = sessionContext.getConnectionInfo();
                    session = repositoryAccess.getSession(connectionInfo);
                    log.info(String
                            .format(
                                "Session was invalid for the connection info. \n Repository URL: %s\n Workspace identifier: %s\n Username: %s\n Password: %s\n Connection type: %s",
                                connectionInfo.getRepositoryURL(), connectionInfo.getWorkspaceName(),
                                connectionInfo.getUsername(), connectionInfo.getPassword(),
                                connectionInfo.getConnectionType()));
                    log.info("New session is created for the provided key: {}", sessionKey);
                    sessions.put(sessionKey, new SessionContext(session, connectionInfo));
                    return session;
                }
            } else {
                ConnectionInfo connectionInfo = sessionContext.getConnectionInfo();
                log.warn(String
                        .format(
                            "There is no suitable RepositoryAccess instance in the environment. \n Repository URL: %s\n Workspace identifier: %s\n Username: %s\n Password: %s\n Connection type: %s",
                            connectionInfo.getRepositoryURL(), connectionInfo.getWorkspaceName(),
                            connectionInfo.getUsername(), connectionInfo.getPassword(),
                            connectionInfo.getConnectionType()));
                throw new RepositoryAccessException(
                        "There is no suitable RepositoryAccess instance in the environment. Please refer to logs");
            }
        } else {
            log.warn("There is no cached session for the key: {}", sessionKey);
View Full Code Here

        AdapterMode adapterMode = conf.getAdapterMode();
        if (adapterMode == null) {
            adapterMode = AdapterMode.ONLINE;
        }

        ConnectionInfo connectionInfo = conf.getConnectionInfo();
        if (connectionInfo == null) {
            if (!adapterMode.equals(AdapterMode.STRICT_OFFLINE)) {
                connectionInfo = OntologyResourceHelper.getConnectionInfo(this.ontModel);
                if (connectionInfo == null) {
                    logger.warn("Failed to retrieve connection info from ontmodel");
View Full Code Here

    }

    @Test
    public void testGetSession() throws RepositoryAccessException {
        expectedException.expect(UnsupportedOperationException.class);
        offlineAccess.getSession(new ConnectionInfo());
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.cmsadapter.servicesapi.model.web.ConnectionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.