protected void delay(BindingSession session) { session.writeLock(); try { int delayTime = session.get(DELAY_TIME, -1); if (delayTime < 0) { if (LOG.isInfoEnabled()) { LOG.info("No delay time configured."); } return; } Object lastExcution = session.get(LAST_EXECUTION); if (lastExcution instanceof Long) { long lastExcutionLong = (Long) lastExcution; long now = System.currentTimeMillis(); if (now - lastExcutionLong < delayTime) { try { Thread.sleep(delayTime - (now - lastExcutionLong)); } catch (InterruptedException e) { if (LOG.isDebugEnabled()) { LOG.debug("Interrupted sleep", e); } } } } session.put(LAST_EXECUTION, System.currentTimeMillis()); } finally { session.writeUnlock(); } }
@Override public String getSessionId() { return session.getSessionId(); }
@Override public void clearAllCaches() { session.remove(SpiSessionParameter.LINK_CACHE); }
/** * Returns the authentication provider from the session or <code>null</code> * if no authentication provider is set. */ public static AuthenticationProvider getAuthenticationProvider(BindingSession session) { assert session != null; return (AuthenticationProvider) session.get(AUTHENTICATION_PROVIDER_OBJECT); }
LOG.debug("Session {}: {} {}", session.getSessionId(), method, url); (String) session.get(SessionParameter.USER_AGENT, ClientVersion.OPENCMIS_USER_AGENT)); int connectTimeout = session.get(SessionParameter.CONNECT_TIMEOUT, -1); if (connectTimeout >= 0) { conn.setConnectTimeout(connectTimeout); int readTimeout = session.get(SessionParameter.READ_TIMEOUT, -1); if (readTimeout >= 0) { conn.setReadTimeout(readTimeout); Object compression = session.get(SessionParameter.COMPRESSION); if (compression != null && Boolean.parseBoolean(compression.toString())) { conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); if (session.get(CmisBindingsHelper.ACCEPT_LANGUAGE) instanceof String) { conn.setRequestProperty("Accept-Language", session.get(CmisBindingsHelper.ACCEPT_LANGUAGE).toString()); Object clientCompression = session.get(SessionParameter.CLIENT_COMPRESSION); if ((clientCompression != null) && Boolean.parseBoolean(clientCompression.toString())) { conn.setRequestProperty("Content-Encoding", "gzip"); LOG.trace("Session {}: {} {} > Headers: {}", session.getSessionId(), method, url, conn.getHeaderFields().toString());
/** * Returns the repository URL cache or creates a new cache if it doesn't * exist. */ protected RepositoryUrlCache getRepositoryUrlCache() { RepositoryUrlCache repositoryUrlCache = (RepositoryUrlCache) getSession().get( SpiSessionParameter.REPOSITORY_URL_CACHE); if (repositoryUrlCache == null) { repositoryUrlCache = new RepositoryUrlCache(); getSession().put(SpiSessionParameter.REPOSITORY_URL_CACHE, repositoryUrlCache); } return repositoryUrlCache; }
@Override public void clearRepositoryCache(String repositoryId) { checkSession(); if (repositoryId == null) { return; } session.writeLock(); try { RepositoryInfoCache repInfoCache = (RepositoryInfoCache) session .get(CmisBindingsHelper.REPOSITORY_INFO_CACHE); repInfoCache.remove(repositoryId); TypeDefinitionCache typeDefCache = CmisBindingsHelper.getTypeDefinitionCache(session); typeDefCache.remove(repositoryId); CmisSpi spi = CmisBindingsHelper.getSPI(session); spi.clearRepositoryCache(repositoryId); } finally { session.writeUnlock(); } }
LOG.debug("Session {}: Initializing local SPI...", session.getSessionId()); String serviceFactoryClassname = (String) session.get(SessionParameter.LOCAL_FACTORY); if (serviceFactoryClassname == null) { throw new CmisConnectionException("Factory class not set!"); for (String key : session.getKeys()) { Object value = session.get(key); if (value instanceof String) { parameters.put(key, (String) value);
@Override public void clearAllCaches() { checkSession(); session.writeLock(); try { session.put(CmisBindingsHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(session)); TypeDefinitionCache typeDefCache = CmisBindingsHelper.getTypeDefinitionCache(session); typeDefCache.removeAll(); CmisSpi spi = CmisBindingsHelper.getSPI(session); spi.clearAllCaches(); } finally { session.writeUnlock(); } }
@Override public void close() { checkSession(); session.writeLock(); try { CmisSpi spi = CmisBindingsHelper.getSPI(session); spi.close(); } finally { session.writeUnlock(); session = null; } }
session.put(entry.getKey(), entry.getValue()); session.put(CmisBindingsHelper.ACCEPT_LANGUAGE, acceptLanguage); if (forceCmisVersion != null) { try { session.put(CmisBindingsHelper.FORCE_CMIS_VERSION, CmisVersion.fromValue(forceCmisVersion)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid CMIS version value: " + forceCmisVersion, e); session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, typeDefCache); typeDefCache.initialize(session); session.put(CmisBindingsHelper.AUTHENTICATION_PROVIDER_OBJECT, authenticationProvider); if (authenticationProvider instanceof SessionAwareAuthenticationProvider) { ((SessionAwareAuthenticationProvider) authenticationProvider).setSession(session);
/** * Returns the service document URL of this session. */ protected String getServiceDocURL() { Object url = session.get(SessionParameter.ATOMPUB_URL); if (url instanceof String) { return (String) url; } return null; }
LOG.debug("Session {}: {} {}", session.getSessionId(), method, url); (String) session.get(SessionParameter.USER_AGENT, ClientVersion.OPENCMIS_USER_AGENT)); int connectTimeout = session.get(SessionParameter.CONNECT_TIMEOUT, -1); if (connectTimeout >= 0) { conn.setConnectTimeout(connectTimeout); int readTimeout = session.get(SessionParameter.READ_TIMEOUT, -1); if (readTimeout >= 0) { conn.setReadTimeout(readTimeout); Object compression = session.get(SessionParameter.COMPRESSION); if (compression != null && Boolean.parseBoolean(compression.toString())) { conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); if (session.get(CmisBindingsHelper.ACCEPT_LANGUAGE) instanceof String) { conn.setRequestProperty("Accept-Language", session.get(CmisBindingsHelper.ACCEPT_LANGUAGE).toString()); Object clientCompression = session.get(SessionParameter.CLIENT_COMPRESSION); if ((clientCompression != null) && Boolean.parseBoolean(clientCompression.toString())) { conn.setRequestProperty("Content-Encoding", "gzip"); LOG.trace("Session {}: {} {} > Headers: {}", session.getSessionId(), method, url, conn.getHeaderFields().toString());
/** * Returns the repository URL cache or creates a new cache if it doesn't * exist. */ protected RepositoryUrlCache getRepositoryUrlCache() { RepositoryUrlCache repositoryUrlCache = (RepositoryUrlCache) getSession().get( SpiSessionParameter.REPOSITORY_URL_CACHE); if (repositoryUrlCache == null) { repositoryUrlCache = new RepositoryUrlCache(); getSession().put(SpiSessionParameter.REPOSITORY_URL_CACHE, repositoryUrlCache); } return repositoryUrlCache; }
@Override public void clearRepositoryCache(String repositoryId) { checkSession(); if (repositoryId == null) { return; } session.writeLock(); try { RepositoryInfoCache repInfoCache = (RepositoryInfoCache) session .get(CmisBindingsHelper.REPOSITORY_INFO_CACHE); repInfoCache.remove(repositoryId); TypeDefinitionCache typeDefCache = CmisBindingsHelper.getTypeDefinitionCache(session); typeDefCache.remove(repositoryId); CmisSpi spi = CmisBindingsHelper.getSPI(session); spi.clearRepositoryCache(repositoryId); } finally { session.writeUnlock(); } }
@Override public void clearAllCaches() { checkSession(); session.writeLock(); try { session.put(CmisBindingsHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(session)); TypeDefinitionCache typeDefCache = CmisBindingsHelper.getTypeDefinitionCache(session); typeDefCache.removeAll(); CmisSpi spi = CmisBindingsHelper.getSPI(session); spi.clearAllCaches(); } finally { session.writeUnlock(); } }
@Override public void close() { checkSession(); session.writeLock(); try { CmisSpi spi = CmisBindingsHelper.getSPI(session); spi.close(); } finally { session.writeUnlock(); session = null; } }
session.put(entry.getKey(), entry.getValue()); session.put(CmisBindingsHelper.ACCEPT_LANGUAGE, acceptLanguage); if (forceCmisVersion != null) { try { session.put(CmisBindingsHelper.FORCE_CMIS_VERSION, CmisVersion.fromValue(forceCmisVersion)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid CMIS version value: " + forceCmisVersion, e); session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, typeDefCache); typeDefCache.initialize(session); session.put(CmisBindingsHelper.AUTHENTICATION_PROVIDER_OBJECT, authenticationProvider); if (authenticationProvider instanceof SessionAwareAuthenticationProvider) { ((SessionAwareAuthenticationProvider) authenticationProvider).setSession(session);
assert session != null; HttpInvoker invoker = (HttpInvoker) session.get(HTTP_INVOKER_OBJECT); session.writeLock(); try { invoker = (HttpInvoker) session.get(HTTP_INVOKER_OBJECT); if (invoker != null) { return invoker; String invokerName = (String) session.get(SessionParameter.HTTP_INVOKER_CLASS); invoker = (HttpInvoker) ClassLoaderUtil.loadClass(invokerName).newInstance(); } catch (CmisBaseException e) { session.put(HTTP_INVOKER_OBJECT, invoker, true); } finally { session.writeUnlock();
/** * Returns the repository info cache from the session. */ public static RepositoryInfoCache getRepositoryInfoCache(BindingSession session) { assert session != null; return (RepositoryInfoCache) session.get(REPOSITORY_INFO_CACHE); }