Original, pre-4.3 version of this API. Always returns the entire contents of the Portlet
Registry, including uncategorized portlets, to which the user has access. Access is based on
the SUBSCRIBE permission.
163980
@RequestMapping(value = "/portletList", method = RequestMethod.GET)
    public ModelAndView listChannels(
            WebRequest webRequest,
            HttpServletRequest request,
            @RequestParam(value = "type", required = false) String type) {

        if (TYPE_MANAGE.equals(type)) {
            throw new UnsupportedOperationException(
                    "Moved to PortletRESTController under /api/portlets.json");
        }

        final IPerson user = personManager.getPerson(request);
        final Map<String, SortedSet<?>> registry = getRegistryOriginal(webRequest, user);

        // Since type=manage was deprecated channels is always empty but retained for backwards
        // compatibility
        registry.put("channels", new TreeSet<ChannelBean>());

        return new ModelAndView("jsonView", "registry", registry);
    }
82414
def content(self, **args):
		'''
		
		'''
		self.gist_name = ''
		if 'name' in args:
			self.gist_name = args['name']
			self.gist_id = self.getMyID(self.gist_name)
		elif 'id' in args:
			self.gist_id = args['id']
		else:
			raise Exception('Either provide authenticated user\'s Unambigious Gistname or any unique Gistid')


		if self.gist_id:
			r = requests.get(
				'%s'%BASE_URL+'/gists/%s' %self.gist_id,
				headers=self.gist.header
				)
			if (r.status_code == 200):
				r_text = json.loads(r.text)
				if self.gist_name!='':
					content =  r.json()['files'][self.gist_name]['content']
				else:
					for key,value in r.json()['files'].iteritems():
						content = r.json()['files'][value['filename']]['content']
				return content

		raise Exception('No such gist found')
589984
def share_extender(self, share: dict, results_filtered: dict):
        
        # add share administration URL
        creator_id = share.get("_creator").get("_tag")[6:]
        share["admin_url"] = "{}/groups/{}/admin/shares/{}".format(
            self.app_url, creator_id, share.get("_id")
        )
        # check if OpenCatalog is activated
        opencat_url = "{}/s/{}/{}".format(
            self.oc_url, share.get("_id"), share.get("urlToken")
        )
        if requests.head(opencat_url):
            share["oc_url"] = opencat_url
        else:
            pass
        # add metadata ids list
        share["mds_ids"] = (i.get("_id") for i in results_filtered)

        return share
844430
def _get_registry(self, registry_path_or_url):
        ''''''
        if os.path.isfile(registry_path_or_url):
            with open(registry_path_or_url, 'r') as f:
                reader = compat.csv_dict_reader(f.readlines())
        else:
            res = requests.get(registry_path_or_url)
            res.raise_for_status()

            reader = compat.csv_dict_reader(StringIO(res.text))

        return dict([(o['id'], o) for o in reader])
348911
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return IpAddressInstance(
            self._version,
            payload,
            account_sid=self._solution['account_sid'],
            ip_access_control_list_sid=self._solution['ip_access_control_list_sid'],
            sid=self._solution['sid'],
        )
862853
def get_all_permissions(self, user, obj=None):
        
        if user.is_anonymous or obj is not None:
            return set()
        # TODO(gabrielhurley): Integrate policy-driven RBAC
        #                      when supported by Keystone.
        role_perms = {utils.get_role_permission(role['name'])
                      for role in user.roles}

        services = []
        for service in user.service_catalog:
            try:
                service_type = service['type']
            except KeyError:
                continue
            service_regions = [utils.get_endpoint_region(endpoint) for endpoint
                               in service.get('endpoints', [])]
            if user.services_region in service_regions:
                services.append(service_type.lower())
        service_perms = {"openstack.services.%s" % service
                         for service in services}
        return role_perms | service_perms
370806
public function portletsAction()
    {
        $securityContext = $this->get('security.context');

        $data = [];
        foreach ($this->get('phlexible_dashboard.portlets')->all() as $portlet) {
            if ($portlet->hasRole() && !$securityContext->isGranted($portlet->getRole())) {
                continue;
            }

            $data[] = $portlet->toArray();
        }

        return new JsonResponse($data);
    }
624617
def api(self):
        
        functions = [x[0]for x in inspect.getmembers(self, predicate=inspect.ismethod)
                     if not x[0].startswith('_')]

        full_api = {
            'doc': u"When posting data you have to use the JSON format.",
            'api': []
        }
        my_daemon_type = "%s" % getattr(self.app, 'type', 'unknown')
        my_address = getattr(self.app, 'host_name', getattr(self.app, 'name', 'unknown'))
        if getattr(self.app, 'address', '127.0.0.1') not in ['127.0.0.1']:
            # If an address is explicitely specified, I must use it!
            my_address = self.app.address
        for fun in functions:
            endpoint = {
                'daemon': my_daemon_type,
                'name': fun,
                'doc': getattr(self, fun).__doc__,
                'uri': '%s://%s:%s/%s' % (getattr(self.app, 'scheme', 'http'),
                                          my_address,
                                          self.app.port, fun),
                'args': {}
            }

            try:
                spec = inspect.getfullargspec(getattr(self, fun))
            except Exception:  # pylint: disable=broad-except
                # pylint: disable=deprecated-method
                spec = inspect.getargspec(getattr(self, fun))
            args = [a for a in spec.args if a not in ('self', 'cls')]
            if spec.defaults:
                a_dict = dict(list(zip(args, spec.defaults)))
            else:
                a_dict = dict(list(zip(args, ("No default value",) * len(args))))

            endpoint["args"] = a_dict
            full_api['api'].append(endpoint)

        return full_api
21508
public void removePortletRegistration(IPerson person, PortletDefinitionForm form) {

        /* TODO:  Service-Layer Security Reboot (great need of refactoring with a community-approved plan in place) */
        // Arguably a check here is redundant since -- in the current
        // portlet-manager webflow -- you can't get to this point in the
        // conversation with out first obtaining a PortletDefinitionForm;  but
        // it makes sense to check permissions here as well since the route(s)
        // to reach this method could evolve in the future.

        // Let's enforce the policy that you may only delete a portlet thet's
        // currently in a lifecycle state you have permission to MANAGE.
        // (They're hierarchical.)
        if (!hasLifecyclePermission(person, form.getLifecycleState(), form.getCategories())) {
            logger.warn(
                    "User '"
                            + person.getUserName()
                            + "' attempted to remove portlet '"
                            + form.getFname()
                            + "' without the proper MANAGE permission");
            throw new SecurityException("Not Authorized");
        }

        IPortletDefinition def = portletDefinitionRegistry.getPortletDefinition(form.getId());
        /*
         * It's very important to remove portlets via the portletPublishingService
         * because that API cleans up details like category memberships and permissions.
         */
        portletPublishingService.removePortletDefinition(def, person);
    }
662273
function() {
      if( StackMob['useRelativePathForAjax'] ){
        // Build "relative path" (also used for OAuth signing)
        return StackMob.apiDomain ? StackMob.apiDomain : (this.getHostname() + (this.getPort() ? ':' + this.getPort() : '')) + '/';
      } else {
        // Use absolute path and operate through CORS
        return StackMob.apiDomain ? StackMob.apiDomain : (StackMob['API_SERVER'] + '/');
      }
    }
584844
@Restricted(NoExternalUse.class)
    public List<User> getImpactedUserList() {
        return User.getAll().stream()
                .filter(user -> {
                    ApiTokenProperty apiTokenProperty = user.getProperty(ApiTokenProperty.class);
                    return (apiTokenProperty != null && apiTokenProperty.hasLegacyToken());
                })
                .collect(Collectors.toList());
    }
1085424
public List<CustomPortletModeType<PortletAppType<T>>> getAllCustomPortletMode()
   {
      List<CustomPortletModeType<PortletAppType<T>>> list = new ArrayList<CustomPortletModeType<PortletAppType<T>>>();
      List<Node> nodeList = childNode.get("custom-portlet-mode");
      for(Node node: nodeList)
      {
         CustomPortletModeType<PortletAppType<T>>  type = new CustomPortletModeTypeImpl<PortletAppType<T>>(this, "custom-portlet-mode", childNode, node);
         list.add(type);
      }
      return list;
   }
582999
def getResourceSubscription(self,ep,res):
		'''
		
		'''
		result = asyncResult()
		result.endpoint = ep
		result.resource = res
		data = self._getURL("/subscriptions/"+ep+res)
		if data.status_code == 200: #immediate success
			result.error = False
			result.is_done = True
			result.result = data.content
		else:
			result.error = response_codes("unsubscribe",data.status_code)
			result.is_done = True
		result.raw_data = data.content
		result.status_code = data.status_code
		return result
643761
IndexedContainer getPermissionContainer(CmsPermissionSet permissions) {

        IndexedContainer result = new IndexedContainer();
        result.addContainerProperty(PROPERTY_LABEL, String.class, "");
        result.addContainerProperty(PROPERTY_VALUE, Integer.class, null);
        result.addContainerProperty(PROPERTY_ALLOWED, Boolean.class, Boolean.FALSE);
        result.addContainerProperty(PROPERTY_DISPLAY_ALLOWED, Label.class, null);
        result.addContainerProperty(PROPERTY_DENIED, Boolean.class, Boolean.FALSE);
        result.addContainerProperty(PROPERTY_DISPLAY_DENIED, Label.class, null);
        for (String key : CmsPermissionSet.getPermissionKeys()) {
            int flag = CmsPermissionSet.getPermissionValue(key);
            Item entry = result.addItem(key);
            entry.getItemProperty(PROPERTY_LABEL).setValue(CmsVaadinUtils.getMessageText(key));
            entry.getItemProperty(PROPERTY_ALLOWED).setValue(isAllowed(permissions, flag));
            entry.getItemProperty(PROPERTY_DISPLAY_ALLOWED).setValue(getCheckBoxLabel(isAllowed(permissions, flag)));
            entry.getItemProperty(PROPERTY_DENIED).setValue(isDenied(permissions, flag));
            entry.getItemProperty(PROPERTY_DISPLAY_DENIED).setValue(getCheckBoxLabel(isDenied(permissions, flag)));
            entry.getItemProperty(PROPERTY_VALUE).setValue(Integer.valueOf(flag));
        }

        return result;
    }
618184
def current_access(self):
        
        return self.access_for(actor=current_auth.actor, anchors=current_auth.anchors)
571399
function downloadRegistry() {
        if (pendingDownloadRegistry) {
            return pendingDownloadRegistry.promise();
        }

        pendingDownloadRegistry = new $.Deferred();

        $.ajax({
            url: brackets.config.extension_registry,
            dataType: "json",
            cache: false
        })
            .done(function (data) {
                exports.hasDownloadedRegistry = true;
                Object.keys(data).forEach(function (id) {
                    if (!extensions[id]) {
                        extensions[id] = {};
                    }
                    extensions[id].registryInfo = data[id];
                    synchronizeEntry(id);
                });
                exports.trigger("registryDownload");
                pendingDownloadRegistry.resolve();
            })
            .fail(function () {
                pendingDownloadRegistry.reject();
            })
            .always(function () {
                // Make sure to clean up the pending registry so that new requests can be made.
                pendingDownloadRegistry = null;
            });

        return pendingDownloadRegistry.promise();
    }
850773
@RequestMapping(value = "/portlet/{fname}.json", method = RequestMethod.GET)
    public ModelAndView getPortlet(
            HttpServletRequest request, HttpServletResponse response, @PathVariable String fname)
            throws Exception {
        IAuthorizationPrincipal ap = getAuthorizationPrincipal(request);
        IPortletDefinition portletDef =
                portletDefinitionRegistry.getPortletDefinitionByFname(fname);
        if (portletDef != null && ap.canRender(portletDef.getPortletDefinitionId().getStringId())) {
            LayoutPortlet portlet = new LayoutPortlet(portletDef);
            return new ModelAndView("json", "portlet", portlet);
        } else {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            return new ModelAndView("json");
        }
    }