Creates a new RepositorySystemSession.
@param system A RepositorySystem to get a LocalRepositoryManager from.
@return The new instance of a RespositorySystemSession.
341973
protected RepositorySystemSession newSession( RepositorySystem system )
  {
      MavenRepositorySystemSession session = new MavenRepositorySystemSession();

      LocalRepository localRepo = new LocalRepository( localRepository );
      session.setLocalRepositoryManager( system.newLocalRepositoryManager( localRepo ) );

      return session;
  }
564795
Session getStorageSession() throws RepositoryException
   {
      try
      {
         ManageableRepository repository = getWorkingRepository();

         String workspaceName = storageWorkspace;
         if (workspaceName == null)
         {
            workspaceName = repository.getConfiguration().getDefaultWorkspaceName();
         }

         return repository.getSystemSession(workspaceName);
      }
      catch (RepositoryConfigurationException e)
      {
         throw new RepositoryException("Can not get system session", e);
      }
   }
1273019
public static LocalFileResource newResource(String normalizedPath, String repositoryPath, SymbolicRootResource root) {
        return new LocalFileResource(normalizedPath, repositoryPath, root);
    }
326354
@Override
	public synchronized TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException
    {
        checkNotClosed();
        LocalTopicSession session =  new LocalTopicSession(idProvider.createID(),this,engine,transacted,acknowledgeMode);
        registerSession(session);
        return session;
    }
803285
public <T extends SubSystem> T addSystemIfAbsent(T system)
  {
    return addSystemIfAbsent(system.getClass(), system);
  }
500823
private JcrSession openSession() throws ResourceException {
        try {
            Repository repo = mcf.getRepository();
            Session s = repo.login(cri.getCredentials(), cri.getWorkspace());
            return (JcrSession) s;
        } catch (RepositoryException e) {
            throw new ResourceException("Failed to create session: " + e.getMessage(), e);
        }
    }
643217
public Authorizable getOrCreateUser(JackrabbitSession session, UserManager userManager,
                                        String path, boolean systemUser)
            throws RepositoryException {
        String[] pathAndName = pathAndName(path);
        Authorizable user = userManager.getAuthorizable(pathAndName[1]);
        LOG.debug("user.check: " + pathAndName[1] + " - " + user);
        if (user == null) {
            LOG.info("user.create: " + pathAndName[1]);
            Principal principal = new NamePrincipal(pathAndName[1]);
            if (systemUser) {
                try {
                    // using reflection to create systems users for compatibility to older API versions
                    Method createSystemUser = userManager.getClass().getMethod("createSystemUser", String.class, String.class);
                    user = (User) createSystemUser.invoke(userManager, pathAndName[1], pathAndName[0]);
                } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                    LOG.error(ex.toString());
                }
            } else {
                user = userManager.createUser(pathAndName[1], pathAndName[1],
                        principal, pathAndName[0]);
            }
        }
        return user;
    }
325108
@Override
    public JMSContext createContext() throws JMSRuntimeException, JMSSecurityRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createContext");

        JMSContext jmsContext = null;
        try {

            // Pass sessionMode as AUTO_ACKNOWLEDGE. The sessionMode is used to create a session.In simplified
            // API(JMS 2.0), AUTO_ACKNOWLEDGE is the default sessionMode  
            jmsContext = createContext(null, null, JMSContext.AUTO_ACKNOWLEDGE);

        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createContext");
        }
        return jmsContext;
    }
1147006
protected static <E extends SubSystemBase> SystemManager
    preCreate(Class<E> serviceClass)
  {
    SystemManager system = SystemManager.getCurrent();
    if (system == null)
      throw new IllegalStateException(L.l("{0} must be created before {1}",
                                          SystemManager.class.getSimpleName(),
                                          serviceClass.getSimpleName()));
    
    if (system.getSystem(serviceClass) != null)
      throw new IllegalStateException(L.l("{0} was previously created",
                                          serviceClass.getSimpleName()));
    
    return system;
  }
1126809
@SuppressWarnings("unchecked")
  public <T extends SubSystem> T
  addSystemIfAbsent(Class<?> systemApi, T system)
  {
    SubSystem oldService
      = _systemMap.putIfAbsent(systemApi, system);

    if (oldService != null) {
      return (T) oldService;
    }

    _pendingStart.add(system);

    if (_lifecycle.isActive()) {
      startSystems();
    }

    return null;
  }
520981
public static Connection createTempConnection(StorageService storageService, final DataSource dataSource) throws RepositoryException {    	
    	
    	if (DataSource.JNDI_VENDOR.equals(dataSource.getVendor())) {
			return getJNDIConnection(storageService, dataSource);
		}
    	
		final String driver = dataSource.getDriver();

		try {
			Class.forName(driver);
		} catch (Exception e) {
            e.printStackTrace();
            LOG.error(e.getMessage(), e);
            throw new RepositoryException("Driver '" + driver + "' not found.", e);
		}

		final String url = dataSource.getUrl();
		final String username = dataSource.getUsername();
		final String password = dataSource.getPassword();
		Settings settings = storageService.getSettings();
		int connectionTimeout = settings.getConnectionTimeout();				
		
		if (connectionTimeout <= 0) {
			// wait as long as driver manager (not deterministic)
			try {
				if (driver.equals(CSVDialect.DRIVER_CLASS)) {
					return DriverManager.getConnection(url, convertListToProperties(dataSource.getProperties()));
				} else {
					return DriverManager.getConnection(url, username, password);
				}
			} catch (Exception e) {
				e.printStackTrace();
				LOG.error(e.getMessage(), e);
				Locale locale = LanguageManager.getInstance().getLocale(storageService.getSettings().getLanguage());
				ResourceBundle bundle = ResourceBundle.getBundle("ro.nextreports.server.web.NextServerApplication", locale);			
				throw new RepositoryException(bundle.getString("Connection.failed") + " '" + dataSource.getPath() + "'", e);
			}
		} else {
			// wait just the number of seconds configured (deterministic)
			Connection connection;                
	        FutureTask<Connection> createConnectionTask = null;
	        try {
	        	createConnectionTask = new FutureTask<Connection>(new Callable<Connection>() {
	        		
	        		public Connection call() throws Exception {   
	        			if (driver.equals(CSVDialect.DRIVER_CLASS)) {
	    					return DriverManager.getConnection(url, convertListToProperties(dataSource.getProperties()));
	    				} else {
	    					return DriverManager.getConnection(url, username, password);
	    				}
	        		}
	        		
	        	});
	        	new Thread(createConnectionTask).start();
	        	connection = createConnectionTask.get(connectionTimeout, TimeUnit.SECONDS);        	
			} catch (Exception e) {
				Locale locale = LanguageManager.getInstance().getLocale(storageService.getSettings().getLanguage());
				ResourceBundle bundle = ResourceBundle.getBundle("ro.nextreports.server.web.NextServerApplication", locale);		
				throw new RepositoryException(bundle.getString("Connection.failed") + " '" + dataSource.getPath() + "'", e);
			}		
			return connection;
		}
	}
267991
@Override
    public ISession createSession(String id, boolean newId) {
        // assert (id!=null);
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINER)) {
            StringBuffer sb = new StringBuffer("{").append(id).append(",").append(newId).append("} ").append(appNameForLogging);
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CREATE_SESSION], sb.toString());
        }
        MemorySession sess = null;

        // need to test on a different language
        // try creating a temporary logger with the old resource bundle, and then
        // changing the environment to French or something
        if (inProcessOfStopping) {
            throwException("SessionContext.createWhenStop");
        }
        if ((!_smc.getEnableOverflow()) && (_sessions.size() >= _smc.getInMemorySize())) {
            // if we know we're in an overflow situation, don't bother
            // creating a new session
            if (_sessionStatistics != null) {
                _sessionStatistics.incNoRoomForNewSession();
            }
            sess = overflowSession;
        }
        // We expect the second part of check below - _sessions.get(id) == null --
        // to pass unless
        // the id generator generates a dup. This really should never happen.
        // The synchronization in SessionManager.createISession will prevent
        // multiple threads
        // with the same incoming id from both getting into this code. We're no
        // longer using
        // the newId parm...it could be removed, but its now part of the IStore
        // interface.
        if ((sess == null) && (_sessions.get(id) == null)) {
            if(!_removeAttrOnInvalidate)
                sess = new MemorySession(this, id, _storeCallback);
            else{
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[CREATE_SESSION], "Create MemorySession with _removeAttrOnInvalidate -->" + _removeAttrOnInvalidate );
                }
                sess = new MemorySession(this, id, _storeCallback, _removeAttrOnInvalidate);
            }
            sess.setUserName(ANONYMOUS_USER);
            // since this was a newly created session, we need to update the
            // lastAccessTime to the create time
            sess.updateLastAccessTime(sess.getCreationTime());
            try {
                _sessions.put(id, sess);
            } catch (TooManySessionsException tmse) {
                // could catch this exception if multiple threads get past the
                // first overflow check and then attempt to do the sessions.put
                sess = overflowSession;
            }
        }

        // Returns a new session if everything is good
        // Returns an overflowSession is overflow is not allowed and we've already
        // hit the maximum number in memory
        // Returns null if there was an existing session with this key - should
        // never happen

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CREATE_SESSION], sess);
        }
        return sess;
    }
962546
public SessionProvider getSystemSessionProvider(Object key)
   {
      if (systemProviders.containsKey(key))
      {
         return systemProviders.get(key);
      }
      else
      {
         final SessionProvider ssp = SessionProvider.createSystemProvider();
         systemProviders.put(key, ssp);
         return ssp;
      }
   }
417364
public static Repository newRepository() {
        try {
            MapRepositoryBuilder builder = new MapRepositoryBuilder();
            return builder.build();
        } catch (RepositoryException e) {
            // Not expected.
            throw new RuntimeException(e);
        }
    }
858559
@Override
    public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
        return new AudioMediaSession(payloadType, remote, local, null,null);
    }
58334
@Override
    public ProducerSession createSystemProducerSession(SIDestinationAddress destAddress,
                                                       String discriminator,
                                                       DestinationType destFilter,
                                                       OrderingContext context,
                                                       String alternateUser)
                    throws SIConnectionUnavailableException, SIConnectionDroppedException,
                    SIResourceException, SIConnectionLostException, SILimitExceededException,
                    SIErrorException,
                    SINotAuthorizedException,
                    SINotPossibleInCurrentConfigurationException,
                    SIIncorrectCallException
    {
        return createSystemProducerSession(destAddress,
                                           discriminator,
                                           destFilter,
                                           context,
                                           alternateUser,
                                           true);
    }
386589
@SuppressWarnings("unchecked")
    public static Set<Repository> toRepositoryList(Vector<Object> repositoriesParams)
    {
        Set<Repository> repositories = new TreeSet<Repository>();
        for(Object repositoryParams : repositoriesParams)
        {
            repositories.add(toRepository((Vector<Object>)repositoryParams));
        }
        
        return repositories;
    }