Package io.lumify.core.model.workspace

Examples of io.lumify.core.model.workspace.Workspace


    }

    private void switchWorkspace(String authUserId, String workspaceId) {
        if (!workspaceId.equals(userRepository.getCurrentWorkspaceId(authUserId))) {
            User authUser = userRepository.findById(authUserId);
            Workspace workspace = workspaceRepository.findById(workspaceId, authUser);
            userRepository.setCurrentWorkspace(authUserId, workspace.getWorkspaceId());
            workQueueRepository.pushUserCurrentWorkspaceChange(authUser, workspace.getWorkspaceId());

            LOGGER.debug("User %s switched current workspace to %s", authUserId, workspaceId);
        }
    }
View Full Code Here


    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception {
        String workspaceId = getRequiredParameter(request, "workspaceId");

        User user = getUser(request);
        Workspace workspace = this.workspaceRepository.findById(workspaceId, user);
        if (workspace == null) {
            respondWithNotFound(response);
            return;
        }

        Authorizations authorizations = getUserRepository().getAuthorizations(user, UserRepository.VISIBILITY_STRING, WorkspaceRepository.VISIBILITY_STRING, workspace.getWorkspaceId());

        List<String> workspaceEntityIds = toList(getWorkspaceEntityIds(user, workspace));

        // create this array so that we get the relationships from workspace to entities
        ArrayList<String> workspaceEntityIdsAndWorkspaceId = new ArrayList<String>(workspaceEntityIds);
        workspaceEntityIdsAndWorkspaceId.add(workspace.getWorkspaceId());

        Vertex workspaceVertex = this.workspaceRepository.getVertex(workspace.getWorkspaceId(), user);
        Iterable<Vertex> vertices = graph.getVertices(workspaceEntityIds, authorizations);
        Iterable<Edge> edges = graph.getEdges(graph.findRelatedEdges(workspaceEntityIdsAndWorkspaceId, authorizations), authorizations);

        response.addHeader("Content-Disposition", "attachment; filename=" + workspace.getDisplayTitle() + ".lumifyWorkspace");

        OutputStream out = response.getOutputStream();
        try {
            GraphBackup graphBackup = new GraphBackup();
            graphBackup.saveVertex(workspaceVertex, out);
View Full Code Here

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception {
        User user = getUser(request);
        Authorizations authorizations = getAuthorizations(request, user);
        String workspaceId = getActiveWorkspaceId(request);
        Workspace workspace = workspaceRepository.findById(workspaceId, user);

        AnalystsNotebookVersion version = DEFAULT_VERSION;
        String versionParameter = getOptionalParameter(request, VERSION_PARAMETER_NAME);
        if (versionParameter != null) {
            version = AnalystsNotebookVersion.valueOf(versionParameter);
        }

        Locale locale = getLocale(request);
        String timeZone = getTimeZone(request);
        String baseUrl = getBaseUrl(request);
        Chart chart = analystsNotebookExporter.toChart(version, workspace, user, authorizations, locale, timeZone, baseUrl);

        List<String> comments = new ArrayList<String>();
        comments.add(String.format("Lumify Workspace: %s", workspace.getDisplayTitle()));
        comments.add(String.format("%s/#w=%s", baseUrl, workspaceId));
        comments.add(String.format("Exported %1$tF %1$tT %1$tz for Analyst's Notebook version %2$s", new Date(), version.toString()));

        String xml = AnalystsNotebookExporter.toXml(chart, comments);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        response.setContentType(CONTENT_TYPE);
        setMaxAge(response, EXPIRES_1_HOUR);
        String filename = workspace.getDisplayTitle().replaceAll("[^A-Za-z0-9]", "_") + "_" + simpleDateFormat.format(new Date()) + "." + FILE_EXT;
        response.addHeader("Content-Disposition", "attachment; filename=" + filename.replaceAll("_{2,}", "_"));

        InputStream in = new ByteArrayInputStream(xml.getBytes());
        try {
            IOUtils.copy(in, response.getOutputStream());
View Full Code Here

        final String workspaceId = getActiveWorkspaceId(request);
        final String data = getRequiredParameter(request, "data");

        User authUser = getUser(request);

        Workspace workspace = workspaceRepository.findById(workspaceId, authUser);
        if (workspace == null) {
            respondWithNotFound(response);
            return;
        }
View Full Code Here

            final String workspaceId = getAttributeString(request, "workspaceId");

            User user = getUser(request);

            LOGGER.info("Deleting workspace with id: %s", workspaceId);
            Workspace workspace = workspaceRepository.findById(workspaceId, user);
            if (workspace == null) {
                respondWithNotFound(response);
                return;
            }
            ClientApiWorkspace clientApiWorkspaceBeforeDeletion = workspaceRepository.toClientApi(workspace, user, false);
View Full Code Here

            if (workspaceId == null) {
                LOGGER.warn("cannot find configuration parameter: %s", SETTING_WORKSPACE_ID);
                return;
            }

            Workspace workspace = this.workspaceRepository.findById(workspaceId, this.userRepository.getSystemUser());
            if (workspace == null) {
                LOGGER.warn("cannot find workspace: %s", workspaceId);
                return;
            }

            Workspace newWorkspace = this.workspaceRepository.copyTo(workspace, user, this.userRepository.getSystemUser());

            String newWorkspaceTitle = this.configuration.get(SETTING_NEW_WORKSPACE_TITLE, null);
            if (newWorkspaceTitle != null) {
                workspaceRepository.setTitle(newWorkspace, newWorkspaceTitle, user);
            }

            this.userRepository.setCurrentWorkspace(user.getUserId(), newWorkspace.getWorkspaceId());
        } catch (Exception ex) {
            LOGGER.error("Could not share workspace", ex);
        }
    }
View Full Code Here

        double y1 = Double.parseDouble(getRequiredParameter(request, "y1"));
        double y2 = Double.parseDouble(getRequiredParameter(request, "y2"));

        User user = getUser(request);
        String workspaceId = getActiveWorkspaceId(request);
        Workspace workspace = workspaceRepository.findById(workspaceId, user);
        Authorizations authorizations = getAuthorizations(request, user);

        if (!graph.isVisibilityValid(new Visibility(visibilitySource), authorizations)) {
            LOGGER.warn("%s is not a valid visibility for %s user", visibilitySource, user.getDisplayName());
            respondWithBadRequest(response, "visibilitySource", getString(request, "visibility.invalid"));
View Full Code Here

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception {
        final String workspaceId = super.getAttributeString(request, "workspaceId");
        final User authUser = getUser(request);
        LOGGER.info("Attempting to retrieve workspace: %s", workspaceId);
        final Workspace workspace = getWorkspaceRepository().findById(workspaceId, authUser);
        if (workspace == null) {
            LOGGER.warn("Could not find workspace: %s", workspaceId);
            respondWithNotFound(response);
        } else {
            LOGGER.debug("Successfully found workspace");
View Full Code Here

        respondWithClientApiObject(response, handle(conceptType, visibilitySource, user, workspaceId, authorizations));
    }

    private ClientApiElement handle(String conceptType, String visibilitySource, User user, String workspaceId, Authorizations authorizations) {
        Workspace workspace = getWorkspaceRepository().findById(workspaceId, user);

        VisibilityJson visibilityJson = GraphUtil.updateVisibilitySourceAndAddWorkspaceId(null, visibilitySource, workspaceId);
        LumifyVisibility lumifyVisibility = this.visibilityTranslator.toVisibility(visibilityJson);
        Visibility visibility = lumifyVisibility.getVisibility();
View Full Code Here

        List<SqlWorkspaceUser> sqlWorkspaceUsers = getSqlWorkspaceUserLists(workspaceId);

        for (SqlWorkspaceUser sqlWorkspaceUser : sqlWorkspaceUsers) {
            if (!sqlWorkspaceUser.getWorkspaceAccess().equals(WorkspaceAccess.NONE.toString())) {
                String userId = sqlWorkspaceUser.getUser().getUserId();
                Workspace workspace = findById(workspaceId, user);
                boolean isCreator = ((SqlWorkspace) workspace).getWorkspaceCreator().getUserId().equals(userId);
                withAccess.add(new WorkspaceUser(userId, WorkspaceAccess.valueOf(sqlWorkspaceUser.getWorkspaceAccess()), isCreator));
            }
        }
View Full Code Here

TOP

Related Classes of io.lumify.core.model.workspace.Workspace

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.