Package com.atlassian.labs.speakeasy.model

Examples of com.atlassian.labs.speakeasy.model.UserExtension


        return buildGlobal(plugin, new Extension(plugin));
    }

    public UserExtension build(Plugin plugin, String userName, Iterable<Plugin> speakeasyPlugins) throws PluginOperationFailedException
    {
        UserExtension extension = buildGlobal(plugin, new UserExtension(plugin));
        boolean canAuthor = permissionManager.canAuthorExtensions(userName);
        List<String> accessList = data.getUsersList(plugin.getKey());

        boolean isAuthor = userName.equals(extension.getAuthor());
        boolean hasFavorited = data.getFavorites(plugin.getKey()).contains(userName);
        boolean pureSpeakeasy = ExtensionValidate.isPureSpeakeasyExtension(bundleContext, plugin);

        if (extension.isAvailable())
        {
            extension.setEnabled(accessList.contains(userName));
            extension.setCanEnable(!extension.isEnabled());
            extension.setCanDisable(extension.isEnabled());
        }

        boolean canEdit = isAuthor && pureSpeakeasy && canAuthor;
        extension.setCanEdit(canEdit);
        extension.setCanUninstall(canEdit);
        extension.setCanFork(!extension.isFork() && pureSpeakeasy && canAuthor);
        extension.setCanFavorite(!hasFavorited);
        extension.setCanDownload(pureSpeakeasy && canAuthor);

        // if the user has already forked this, don't let them fork again
        if (!extension.isFork())
        {
            for (Plugin plug : speakeasyPlugins)
            {
                if (extension.getKey().equals(Extension.getForkedPluginKey(plug.getKey())) && userName.equals(getPluginAuthor(plug)))
                {
                    extension.setCanFork(false);
                }
            }
        }

        // if the user is an admin and admins aren't allowed to enable
        if (!permissionManager.canEnableExtensions(userName))
        {
            extension.setCanEnable(false);
            extension.setCanFork(false);
            extension.setCanEdit(false);
        }

        // global extensions are quite limited
        final boolean isGlobalExtension = data.isGlobalExtension(plugin.getKey());
        if (isGlobalExtension)
        {
            extension.setCanEnable(false);
            extension.setCanDisable(false);
            extension.setEnabled(true);
            extension.setCanEdit(false);
            extension.setCanUninstall(false);
            extension.setCanFork(false);
        }

        // forks of global extensions can't be enabled
        if (data.isGlobalExtension(extension.getForkedPluginKey()))
        {
            extension.setCanEnable(false);
        }

        if (userManager.isAdmin(userName))
        {
            // if already a global extension, allow the admin to disable it
            if (isGlobalExtension)
            {
                extension.setCanDisableGlobally(true);
                extension.setCanEdit(true);
                extension.setCanUninstall(true);
            }
            else
            {
                extension.setCanEnableGlobally(true);
            }
        }
        return extension;
    }
View Full Code Here


    {
        String user = userManager.getRemoteUsername(req);
        String pluginKey = repo.getWorkTree().getName();
        UserProfile userProfile = userManager.getUserProfile(user);

        final UserExtension userExtension = speakeasyService.getRemotePlugin(pluginKey, user);
        if (userExtension != null && !userExtension.isCanEdit())
        {
            throw new ServiceNotAuthorizedException();
        }
        ReceiveCommits rc = new ReceiveCommits(userProfile, userExtension, repo, speakeasyService, gitRepositoryManager);
        return rc.getReceivePack();
View Full Code Here

                    return getUserExtension(from, userName, rawPlugins);
                }
                catch (RuntimeException ex)
                {
                    log.error("Unable to load plugin '" + from.getKey() + "'", ex);
                    UserExtension plugin = new UserExtension(from);
                    plugin.setDescription("Unable to load due to " + ex.getMessage());
                    return plugin;
                }
            }
        });
    }
View Full Code Here

                    return extensionBuilder.build(from, userName, rawPlugins);
                }
                catch (RuntimeException ex)
                {
                    log.error("Unable to load plugin '" + from.getKey() + "'", ex);
                    UserExtension plugin = new UserExtension(from);
                    plugin.setDescription("Unable to load due to " + ex.getMessage());
                    return plugin;
                }
            }
        }));
    }
View Full Code Here

TOP

Related Classes of com.atlassian.labs.speakeasy.model.UserExtension

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.