code: public void setState(final int state) throws RepositoryException
     {
        // Need privileges to manage repository.
        SecurityManager security = System.getSecurityManager();
        if (security != null)
        {
           security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
        }
  
        try
        {
           SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
           {
              public Void run() throws RepositoryException
              {
                 switch (state)
                 {
                    case ManageableRepository.ONLINE :
                       resume();
                       break;
                    case ManageableRepository.OFFLINE :
                       suspend();
                       break;
                    case ManageableRepository.SUSPENDED :
                       suspend();
                       break;
                    default :
                       return null;
                 }
                 return null;
              }
           });
        }
        catch (PrivilegedActionException e)
        {
           Throwable cause = e.getCause();
           if (cause instanceof RepositoryException)
           {
              throw new RepositoryException(cause);
           }
           else
           {
              throw new RuntimeException(cause);
           }
        }
     }
docs: Set new workspace state.
  
  @param state
  @throws RepositoryException