Obtain collection of profiles

@param model
@return
@throws Exception
973081
@RequestMapping(value = "/api/profile", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getList(Model model) throws Exception {
        logger.info("Using a GET request to list profiles");
        return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles");
    }
258215
public void setProfiles(java.util.Collection<ProfileData> profiles) {
        if (profiles == null) {
            this.profiles = null;
            return;
        }

        this.profiles = new java.util.ArrayList<ProfileData>(profiles);
    }
567836
public Profile[] getProfilesForServerName(String serverName) throws Exception {
        int profileId = -1;
        ArrayList<Profile> returnProfiles = new ArrayList<Profile>();

        PreparedStatement queryStatement = null;
        ResultSet results = null;
        try (Connection sqlConnection = sqlService.getConnection()) {
            queryStatement = sqlConnection.prepareStatement(
                "SELECT " + Constants.GENERIC_PROFILE_ID + " FROM " + Constants.DB_TABLE_SERVERS +
                    " WHERE " + Constants.SERVER_REDIRECT_SRC_URL + " = ? GROUP BY " +
                    Constants.GENERIC_PROFILE_ID
            );
            queryStatement.setString(1, serverName);
            results = queryStatement.executeQuery();

            while (results.next()) {
                profileId = results.getInt(Constants.GENERIC_PROFILE_ID);

                Profile profile = ProfileService.getInstance().findProfile(profileId);

                returnProfiles.add(profile);
            }
        } catch (SQLException e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (queryStatement != null) {
                    queryStatement.close();
                }
            } catch (Exception e) {
            }
        }

        if (returnProfiles.size() == 0) {
            return null;
        }
        return returnProfiles.toArray(new Profile[0]);
    }
154781
public List<Profile> findAllProfiles() throws Exception {
        ArrayList<Profile> allProfiles = new ArrayList<>();
        PreparedStatement statement = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PROFILE);
            results = statement.executeQuery();
            while (results.next()) {
                allProfiles.add(this.getProfileFromResultSet(results));
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
        return allProfiles;
    }
916476
public static Map<BioPAXElement, List<Match>> search(Model model, Pattern pattern)
	{
		return search(model, pattern, null);
	}
875569
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        if (false === $this->enabled) {
            return;
        }

        $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
        $profile->setTime(time());
        $profile->setUrl($request->getUri());
        $profile->setMethod($request->getMethod());
        $profile->setStatusCode($response->getStatusCode());
        try {
            $profile->setIp($request->getClientIp());
        } catch (ConflictingHeadersException $e) {
            $profile->setIp('Unknown');
        }

        if ($prevToken = $response->headers->get('X-Debug-Token')) {
            $response->headers->set('X-Previous-Debug-Token', $prevToken);
        }

        $response->headers->set('X-Debug-Token', $profile->getToken());

        foreach ($this->collectors as $collector) {
            $collector->collect($request, $response, $exception);

            // we need to clone for sub-requests
            $profile->addCollector(clone $collector);
        }

        return $profile;
    }
310649
def _count_model(self, model):
        
        try:
            res = model.objects.all().count()
        except Exception as e:
            self.err(e)
            return
        return res
274727
public static autoscaleprofile[] get(nitro_service service) throws Exception{
		autoscaleprofile obj = new autoscaleprofile();
		autoscaleprofile[] response = (autoscaleprofile[])obj.get_resources(service);
		return response;
	}
1245463
public function actionModel($model = null)
    {
        if (!$model) {
            $model = $this->prompt('Namespaced path to the ngrest model (e.g. "app\models\Users"):');
        }
        $object = Yii::createObject(['class' => $model]);
        
        if (!$object instanceof NgRestModelInterface) {
            throw new Exception("Model must be instance of NgRestModelInterface.");
        }
        
        $reflector = new \ReflectionClass($model);
        $fileName = $reflector->getFileName();
        $path = dirname($fileName);
        $apiEndpoint = $object->ngrestApiEndpoint();
        $i18n = !empty($object->i18n);
        $data = [
            'path' =>  $path,
            'fileName' => basename($fileName),
            'content' => $this->generateModelContent(
                $reflector->getNamespaceName(),
                $reflector->getShortName(),
                $apiEndpoint,
                Yii::$app->db->getTableSchema($object->tableName(), true),
                $i18n
             ),
        ];
        
        $this->generateFile($data);
    }
1171208
@RequestMapping(value = "/pathname/{profileId}/{pathId}", method = RequestMethod.GET)
    public String editPathname(Model model,
                               @PathVariable int pathId, @PathVariable int profileId) throws Exception {
        model.addAttribute("profile_id", profileId);
        model.addAttribute("profile_name", ProfileService.getInstance().getNamefromId(profileId));
        model.addAttribute("endpoint", pathOverrideService.getPath(pathId));
        model.addAttribute("groups_in_path", pathOverrideService.getGroupsInPathProfile(profileId, pathId));
        model.addAttribute("groups_not_in_path", pathOverrideService.getGroupsNotInPathProfile(profileId, pathId));
        return "editPathname";
    }
71082
private List<String> loadProfiles(List<Locale> locales) throws Exception {

        List<String> profiles = new ArrayList<String>();
        List<String> languagesAdded = new ArrayList<String>();
        for (Locale locale : locales) {
            try {
                String lang = locale.getLanguage();
                // make sure not to add a profile twice
                if (!languagesAdded.contains(lang)) {
                    languagesAdded.add(lang);
                    String profileFile = "profiles" + "/" + lang;
                    InputStream is = getClass().getClassLoader().getResourceAsStream(profileFile);
                    if (is != null) {
                        String profile = IOUtils.toString(is, "UTF-8");
                        if ((profile != null) && (profile.length() > 0)) {
                            profiles.add(profile);
                        }
                        is.close();
                    } else {
                        LOG.warn(
                            Messages.get().getBundle().key(
                                Messages.INIT_I18N_LAND_DETECT_PROFILE_NOT_AVAILABLE_1,
                                locale));
                    }
                }
            } catch (Exception e) {
                LOG.error(
                    Messages.get().getBundle().key(Messages.INIT_I18N_LAND_DETECT_LOADING_PROFILE_FAILED_1, locale),
                    e);
            }
        }
        return profiles;
    }
774871
@RequestMapping(value = "/api/profile", method = RequestMethod.DELETE)
    public
    @ResponseBody
    HashMap<String, Object> deleteProfile(Model model, int id) throws Exception {
        profileService.remove(id);
        return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles");
    }
31861
public static Profile getProfile(HttpServletRequest request) {
        Authentication auth = getAuthentication(request);
        if (auth != null) {
            return auth.getProfile();
        } else {
            return null;
        }
    }
1070911
@RequestMapping(value = "/pathname/{profileId}/{pathId}/addGroups", method = RequestMethod.POST)
    @ResponseBody
    public String addGroups(Model model, @PathVariable int profileId, @PathVariable int pathId, int[] group_ids) {
        for (int i = 0; i < group_ids.length; i++)
            pathOverrideService.AddGroupByNumber(profileId, pathId, group_ids[i]);
        return null;
    }
729029
public static final synchronized ProfileManager getInstance(Object context) {
		
		return (instance == null)? 
				(instance = new ProfileService(ContextUtils.asApplication(context))) :instance;
	}
569892
public static nshttpprofile[] get(nitro_service service) throws Exception{
		nshttpprofile obj = new nshttpprofile();
		nshttpprofile[] response = (nshttpprofile[])obj.get_resources(service);
		return response;
	}
511603
public static appfwprofile[] get(nitro_service service) throws Exception{
		appfwprofile obj = new appfwprofile();
		appfwprofile[] response = (appfwprofile[])obj.get_resources(service);
		return response;
	}