Package org.eclipse.orion.server.core.metastore

Examples of org.eclipse.orion.server.core.metastore.UserInfo


  public void testSiteHostingServiceStart() throws Exception {
    IMetaStore metaStore = getMetaStore();

    SiteHostingService hostingService = new SiteHostingService(SiteHostingConfig.getSiteHostingConfig("https://*.sites.example.org:1234"));

    UserInfo user = new UserInfo();
    user.setUniqueId("A");
    user.setUserName("carlos");
    metaStore.createUser(user);

    SiteInfo site = SiteInfo.newSiteConfiguration(user, "mysite", "myworkspace");
    site.setId("s1");
    site.setName("Some site");
View Full Code Here


  public void testSiteHostingServiceStartHostnameTaken() throws Exception {
    IMetaStore metaStore = getMetaStore();

    SiteHostingService hostingService = new SiteHostingService(SiteHostingConfig.getSiteHostingConfig("https://*.sites.example.org"));

    UserInfo user = new UserInfo();
    user.setUniqueId("A");
    user.setUserName("carlos");
    metaStore.createUser(user);

    SiteInfo site1 = SiteInfo.newSiteConfiguration(user, "site1", "myworkspace");
    site1.setId("s1");
    site1.setName("Site 1");
View Full Code Here

  public void testSiteHostingServiceMatchesVirtualHost() throws Exception {
    IMetaStore metaStore = getMetaStore();

    SiteHostingService hostingService = new SiteHostingService(SiteHostingConfig.getSiteHostingConfig("https://*.sites.example.org:1234"));

    UserInfo user = new UserInfo();
    user.setUniqueId("A");
    user.setUserName("carlos");
    metaStore.createUser(user);

    SiteInfo site = SiteInfo.newSiteConfiguration(user, "mysite", "myworkspace");
    site.setId("s1");
    site.setName("Some site");
View Full Code Here

  }

  @Test
  // Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=382760
  public void testDisallowedSiteAccess() throws SAXException, IOException, JSONException, URISyntaxException, CoreException {
    UserInfo userBObject = createUser("userB", "userB");
    String userB = userBObject.getUniqueId();

    // User "test": create file in test's workspace
    final String filename = "foo.html";
    final String fileContent = "<html><body>This is a test file</body></html>";
    WebResponse createdFile = createFileOnServer("", filename, fileContent);
    URL fileLocation = createdFile.getURL();
    IPath filepath = new Path(fileLocation.getPath());
    filepath = filepath.removeFirstSegments(new Path(FILE_SERVLET_LOCATION).segmentCount()); // chop off leading /file/
    filepath = filepath.removeLastSegments(1); // chop off trailing /foo.html
    filepath = filepath.makeAbsolute();
    filepath = filepath.addTrailingSeparator();
    String parentFolder = filepath.toString();

    // User B: Give access to test's workspace
    String bWorkspaceId = workspaceId;
    AuthorizationService.addUserRight(userBObject.getUniqueId(), "/workspace/" + bWorkspaceId);
    AuthorizationService.addUserRight(userBObject.getUniqueId(), "/workspace/" + bWorkspaceId + "/*");

    // User B: create a site against B's workspace that exposes a file in test's workspace
    final String siteName = "My hosted site";
    final String filePath = parentFolder; //"/" + filename;
    final String mountAt = "/"; //"/file.html";
View Full Code Here

    IPath pathInfo = getPathInfo(req);
    try {
      //bad request
      if (pathInfo.segmentCount() != 1)
        return null;
      UserInfo user = OrionConfiguration.getMetaStore().readUser(userName);
      return SiteInfo.getSite(user, pathInfo.segment(0));
    } catch (CoreException e) {
      //backing store failure
      LogHelper.log(e);
    }
View Full Code Here

  // TODO: allow filtering by hosting state via query parameter?
  private boolean doGetAllSiteConfigurations(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
    String userName = getUserName(req);
    try {
      UserInfo user = OrionConfiguration.getMetaStore().readUser(userName);
      //user info stores an object where key is site id, value is site info, but we just want the values
      URI base = ServletResourceHandler.getURI(req);
      JSONArray configurations = new JSONArray();
      JSONObject sites = SiteInfo.getSites(user);
      final String[] names = JSONObject.getNames(sites);
View Full Code Here

      IMetaStore metaStore = OrionConfiguration.getMetaStore();
      List<String> userids = metaStore.readAllUsers();
      for (String userId : userids) {
        File userRoot = metaStore.getUserHome(userId).toLocalFile(EFS.NONE, null);
        String diskUsage = getFolderSize(userRoot);
        UserInfo userInfo = metaStore.readUser(userId);
        // try to store the disk usage timestamp and value in the user profile
        userInfo.setProperty(UserConstants2.DISK_USAGE, diskUsage);
        userInfo.setProperty(UserConstants2.DISK_USAGE_TIMESTAMP, new Long(System.currentTimeMillis()).toString());
        metaStore.updateUser(userInfo);
      }
      if (logger.isInfoEnabled()) {
        logger.info("Orion disk usage user data updated"); //$NON-NLS-1$
      }
View Full Code Here

  }

  private void createBashrc(String user) {
    try {
      IMetaStore metaStore = OrionConfiguration.getMetaStore();
      UserInfo userInfo = metaStore.readUser(user);
      List<String> workspaceIds = userInfo.getWorkspaceIds();
      if (workspaceIds.isEmpty()) {
        // the user has no workspaces, just return
        return;
      }
      String workspaceId = workspaceIds.get(0);
View Full Code Here

  }

  private String getDockerVolume(String user) {
    try {
      IMetaStore metaStore = OrionConfiguration.getMetaStore();
      UserInfo userInfo = metaStore.readUser(user);
      List<String> workspaceIds = userInfo.getWorkspaceIds();
      if (workspaceIds.isEmpty()) {
        // the user has no workspaces so no projects
        return null;
      }
      String workspaceId = workspaceIds.get(0);
View Full Code Here

    if (!(("/" + SITE_CONFIGURATION_SERVLET_ALIAS).equals(req.getServletPath())))
      return;

    try {
      UserInfo webUser = getWebUser(req);
      if (path.segmentCount() == 0) {
        if ("GET".equals(req.getMethod())) { //$NON-NLS-1$
          // GET /site/ (get all site configs)
          JSONArray siteConfigurations = representation.optJSONArray(SiteConfigurationConstants.KEY_SITE_CONFIGURATIONS);
          if (siteConfigurations != null) {
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.metastore.UserInfo

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.