Java Code Examples for org.springframework.web.bind.annotation.RequestMethod#GET

The following examples show how to use org.springframework.web.bind.annotation.RequestMethod#GET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PublicController.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
@RequestMapping(value = "/findTotalCount", method = RequestMethod.GET)
@ResponseBody
public Map<String, Integer> findTotalCount(final String collectionCode) throws Exception {
	try {
		Collection collection = collectionService.findByCode(collectionCode);
		AidrCollectionTotalDTO dto = convertAidrCollectionToDTO(collection, false);
		if (dto != null) {
			Integer totalCount = collectionLogService.countTotalDownloadedItemsForCollection(dto.getId());
			if (CollectionStatus.RUNNING.equals(dto.getStatus()) || CollectionStatus.RUNNING_WARNING.equals(dto.getStatus())){
				totalCount += dto.getCount();
			}
			dto.setTotalCount(totalCount);
		}
		Map<String, Integer> result = new HashMap<String, Integer>();
		result.put(collectionCode, dto.getTotalCount());
		return result;
	} catch (Exception e) {
		logger.error("Unable to fetch total count of downloaded documents for collection = " + collectionCode, e);
	}
	return null;
}
 
Example 2
Source File: PrivilegeConfigController.java    From springboot-security-wechat with Apache License 2.0 5 votes vote down vote up
/**
 * @name 获取一个权限配置
 * @param i 权限id
 * @param request
 * @return
 */
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/edit")
@ResponseBody
public Response edit(@RequestParam(value = "id", required = true) String i,
                     HttpServletRequest request) {
    Long id = -1L;
    PrivilegeConfig privilegeConfig = null;
    try {
        id = Long.valueOf(i);
        privilegeConfig = privilegeConfigService.findById(id);
    } catch (Exception e) {
        return errorResponse("选择失败:" + e.getMessage(), e.toString());
    }
    return successResponse("选择成功", privilegeConfig);
}
 
Example 3
Source File: AdministrationController.java    From voj with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 加载试题列表页面.
 * @param request - HttpServletRequest对象
 * @param response - HttpServletResponse对象
 * @return 包含提交列表页面信息的ModelAndView对象
 */
@RequestMapping(value="/all-problems", method=RequestMethod.GET)
public ModelAndView allProblemsView(
		@RequestParam(value="keyword", required=false, defaultValue="") String keyword,
		@RequestParam(value="problemCategory", required=false, defaultValue="") String problemCategorySlug,
		@RequestParam(value="problemTag", required=false, defaultValue="") String problemTagSlug,
		@RequestParam(value="page", required=false, defaultValue="1") long pageNumber,
		HttpServletRequest request, HttpServletResponse response) {
	final int NUMBER_OF_PROBLEMS_PER_PAGE = 100;
	List<ProblemCategory> problemCategories = problemService.getProblemCategories();
	long totalProblems = problemService.getNumberOfProblemsUsingFilters(keyword, problemCategorySlug, false);

	long offset = (pageNumber >= 1 ? pageNumber - 1 : 0) * NUMBER_OF_PROBLEMS_PER_PAGE;
	long problemIdLowerBound = problemService.getFirstIndexOfProblems() + offset;
	long problemIdUpperBound = problemIdLowerBound + NUMBER_OF_PROBLEMS_PER_PAGE - 1;

	List<Problem> problems = problemService.getProblemsUsingFilters(problemIdLowerBound, keyword, problemCategorySlug, problemTagSlug, false, NUMBER_OF_PROBLEMS_PER_PAGE);
	Map<Long, List<ProblemCategory>> problemCategoryRelationships =
			problemService.getProblemCategoriesOfProblems(problemIdLowerBound, problemIdUpperBound);
	Map<Long, List<ProblemTag>> problemTagRelationships =
			problemService.getProblemTagsOfProblems(problemIdLowerBound, problemIdUpperBound);

	ModelAndView view = new ModelAndView("administration/all-problems");
	view.addObject("problemCategories", problemCategories);
	view.addObject("selectedProblemCategory", problemCategorySlug);
	view.addObject("keyword", keyword);
	view.addObject("currentPage", pageNumber);
	view.addObject("totalPages", (long) Math.ceil(totalProblems * 1.0 / NUMBER_OF_PROBLEMS_PER_PAGE));
	view.addObject("problems", problems);
	view.addObject("problemCategoryRelationships", problemCategoryRelationships);
	view.addObject("problemTagRelationships", problemTagRelationships);
	return view;
}
 
Example 4
Source File: SetupApplication.java    From Insights with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public String loadConfig(){
	JsonParser parser = new JsonParser();
	JsonElement data = parser.parse(ApplicationConfigCache.readConfigFile());
	return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(data);
}
 
Example 5
Source File: MobileOrganisationUnitController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/all" )
@ResponseBody
public MobileModel getAllDataForOrgUnit2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
{
    MobileModel mobileModel = new MobileModel();
    mobileModel.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
    OrganisationUnit unit = getUnit( id );
    mobileModel.setDatasets( facilityReportingService.getMobileDataSetsForUnit( unit, locale ) );
    mobileModel.setServerCurrentDate( new Date() );
    mobileModel.setLocales( getLocalStrings( localeService.getAllLocales() ) );
    return mobileModel;
}
 
Example 6
Source File: TextUnitWS.java    From mojito with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = "/api/textunits/count")
@ResponseStatus(HttpStatus.OK)
public TextUnitAndWordCount getTextUnitsCount(
        @RequestParam(value = "repositoryIds[]", required = false) ArrayList<Long> repositoryIds,
        @RequestParam(value = "repositoryNames[]", required = false) ArrayList<String> repositoryNames,
        @RequestParam(value = "tmTextUnitIds[]", required = false) ArrayList<Long> tmTextUnitIds,
        @RequestParam(value = "name", required = false) String name,
        @RequestParam(value = "source", required = false) String source,
        @RequestParam(value = "target", required = false) String target,
        @RequestParam(value = "assetPath", required = false) String assetPath,
        @RequestParam(value = "pluralFormOther", required = false) String pluralFormOther,
        @RequestParam(value = "pluralFormFiltered", required = false, defaultValue = "true") boolean pluralFormFiltered,
        @RequestParam(value = "pluralFormExcluded", required = false, defaultValue = "false") boolean pluralFormExcluded,
        @RequestParam(value = "searchType", required = false, defaultValue = "EXACT") SearchType searchType,
        @RequestParam(value = "localeTags[]", required = false) ArrayList<String> localeTags,
        @RequestParam(value = "usedFilter", required = false) UsedFilter usedFilter,
        @RequestParam(value = "statusFilter", required = false) StatusFilter statusFilter,
        @RequestParam(value = "doNotTranslateFilter", required = false) Boolean doNotTranslateFilter,
        @RequestParam(value = "tmTextUnitCreatedBefore", required = false) DateTime tmTextUnitCreatedBefore,
        @RequestParam(value = "tmTextUnitCreatedAfter", required = false) DateTime tmTextUnitCreatedAfter,
        @RequestParam(value = "branchId", required = false) Long branchId) throws InvalidTextUnitSearchParameterException {

    TextUnitSearcherParameters textUnitSearcherParameters = queryParamsToTextUnitSearcherParameters(
            repositoryIds, repositoryNames, tmTextUnitIds, name, source, target,
            assetPath, pluralFormOther, pluralFormFiltered, pluralFormExcluded,
            localeTags, usedFilter, statusFilter, doNotTranslateFilter, tmTextUnitCreatedBefore,
            tmTextUnitCreatedAfter, branchId, searchType
    );

    TextUnitAndWordCount countTextUnitAndWordCount = textUnitSearcher.countTextUnitAndWordCount(textUnitSearcherParameters);
    return countTextUnitAndWordCount;
}
 
Example 7
Source File: JwSystemLogoTitleController.java    From jeewx-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 编辑
 * @return
 */
@RequestMapping(value = "/doEdit",method ={RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public AjaxJson doEdit(@ModelAttribute JwSystemLogoTitle jwSystemLogoTitle){
	AjaxJson j = new AjaxJson();
	try {
		jwSystemLogoTitleService.doEdit(jwSystemLogoTitle);
		j.setMsg("编辑成功");
	} catch (Exception e) {
		j.setSuccess(false);
		j.setMsg("编辑失败");
	}
	return j;
}
 
Example 8
Source File: StudentController.java    From SA47 with The Unlicense 5 votes vote down vote up
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ModelAndView listAll() {
	ModelAndView mav = new ModelAndView("StudentCRUD");
	ArrayList<Student> students = sService.findAllStudents();
	mav.addObject("students", students);
	return mav;
}
 
Example 9
Source File: TopicController.java    From kafka-eagle with Apache License 2.0 5 votes vote down vote up
/** Topic message manager. */
@RequiresPermissions("/topic/manager")
@RequestMapping(value = "/topic/manager", method = RequestMethod.GET)
public ModelAndView topicManagerView(HttpSession session) {
	ModelAndView mav = new ModelAndView();
	mav.setViewName("/topic/manager");
	return mav;
}
 
Example 10
Source File: EventChartController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping( value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET )
public void getChart(
    @PathVariable( "uid" ) String uid,
    @RequestParam( value = "date", required = false ) Date date,
    @RequestParam( value = "ou", required = false ) String ou,
    @RequestParam( value = "width", defaultValue = "800", required = false ) int width,
    @RequestParam( value = "height", defaultValue = "500", required = false ) int height,
    @RequestParam( value = "attachment", required = false ) boolean attachment,
    HttpServletResponse response ) throws IOException, WebMessageException
{
    EventChart chart = eventChartService.getEventChart( uid ); // TODO no acl?

    if ( chart == null )
    {
        throw new WebMessageException( WebMessageUtils.notFound( "Event chart does not exist: " + uid ) );
    }

    OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;

    JFreeChart jFreeChart = chartService.getJFreeChart( chart, date, unit, i18nManager.getI18nFormat() );

    String filename = CodecUtils.filenameEncode( chart.getName() ) + ".png";

    contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, attachment );

    ChartUtils.writeChartAsPNG( response.getOutputStream(), jFreeChart, width, height );
}
 
Example 11
Source File: ModuleController.java    From oneplatform with Apache License 2.0 4 votes vote down vote up
@ApiOperation(value = "按id查询")
@RequestMapping(value = "{id}", method = RequestMethod.GET)
   public @ResponseBody WrapperResponse<ModuleEntity> getById(@PathVariable("id") int id) {
	ModuleEntity entity = moduleService.getmoduleDetails(id);
	return new WrapperResponse<>(entity);
}
 
Example 12
Source File: ChartFacadeController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@RequestMapping( value = "/{uid}/{property}/{itemId}", method = RequestMethod.GET )
public @ResponseBody RootNode getCollectionItem(
    @PathVariable( "uid" ) String pvUid,
    @PathVariable( "property" ) String pvProperty,
    @PathVariable( "itemId" ) String pvItemId,
    @RequestParam Map<String, String> parameters,
    TranslateParams translateParams,
    HttpServletRequest request, HttpServletResponse response ) throws Exception
{
    User user = currentUserService.getCurrentUser();
    setUserContext( user, translateParams );

    try
    {
        if ( !aclService.canRead( user, getEntityClass() ) )
        {
            throw new ReadAccessDeniedException( "You don't have the proper permissions to read objects of this type." );
        }

        RootNode rootNode = getObjectInternal( pvUid, parameters, Lists.newArrayList(), Lists.newArrayList( pvProperty + "[:all]" ), user );

        // TODO optimize this using field filter (collection filtering)
        if ( !rootNode.getChildren().isEmpty() && rootNode.getChildren().get( 0 ).isCollection() )
        {
            rootNode.getChildren().get( 0 ).getChildren().stream().filter( Node::isComplex ).forEach( node ->
            {
                node.getChildren().stream()
                    .filter( child -> child.isSimple() && child.getName().equals( "id" ) && !((SimpleNode) child).getValue().equals( pvItemId ) )
                    .forEach( child -> rootNode.getChildren().get( 0 ).removeChild( node ) );
            } );
        }

        if ( rootNode.getChildren().isEmpty() || rootNode.getChildren().get( 0 ).getChildren().isEmpty() )
        {
            throw new WebMessageException( WebMessageUtils.notFound( pvProperty + " with ID " + pvItemId + " could not be found." ) );
        }

        response.setHeader( ContextUtils.HEADER_CACHE_CONTROL, CacheControl.noCache().cachePrivate().getHeaderValue() );

        return rootNode;
    }
    finally
    {
        UserContext.reset();
    }
}
 
Example 13
Source File: TestController.java    From java-course-ee with MIT License 4 votes vote down vote up
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(Model model) {
    return "login";

}
 
Example 14
Source File: UserController.java    From VideoMeeting with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/test3", method = RequestMethod.GET)
@ResponseStatus(reason = "未授权", value = HttpStatus.UNAUTHORIZED)
@ResponseBody
public void test3(HttpServletRequest request, HttpServletResponse response) {
}
 
Example 15
Source File: AnkushRegisterCluster.java    From ankush with GNU Lesser General Public License v3.0 4 votes vote down vote up
@RequestMapping(value = "/gangliaNodes", method = RequestMethod.GET)
public String gangliaNodes(ModelMap model) {
	logger.info("Inside gangliaNodes view");
	model.addAttribute("title", "gangliaNodes");
	return "registerCluster/gangliaNodes";
}
 
Example 16
Source File: OauthController.java    From java-platform with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/authorization/{oauthPluginId}", method = RequestMethod.GET)
public String redirectUsersToRequestAccess(@PathVariable("oauthPluginId") String oauthPluginId, RedirectAttributes redirectAttributes) {
	OauthPlugin oauthPlugin = oauthService.getOauthPlugin(oauthPluginId);
	redirectAttributes.addAllAttributes(oauthPlugin.getAuthorizationParameterMap());
	return "redirect:" + oauthPlugin.getAuthorizationUrl();
}
 
Example 17
Source File: ObservableSseEmitterTest.java    From Java-programming-methodology-Rxjava-articles with Apache License 2.0 4 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = "/messages" ,produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public ObservableSseEmitter<String> messages() {
    return new ObservableSseEmitter<>(Observable.just("message 1", "message 2", "message 3"));
}
 
Example 18
Source File: FileVaultEndpointController.java    From yes-cart with Apache License 2.0 4 votes vote down vote up
/**
 * Download given file as bytes.
 * @param fileName file name
 */
@ApiOperation(value = "Download file from system file vault")
@Secured({"ROLE_SMADMIN","ROLE_SMSHOPADMIN","ROLE_SMSHOPUSER"})
@RequestMapping(value = "/sysfiles/{type}", method = RequestMethod.GET)
void downloadSysFile(@ApiParam(value = "Type", allowableValues = "shop,system") @PathVariable("type") String type, @ApiParam(value = "File name") @RequestParam("fileName") String fileName, HttpServletResponse response) throws IOException;
 
Example 19
Source File: TokenController.java    From spring-security-oauth with MIT License 4 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = "/tokens")
@ResponseBody
public List<String> getTokens() {
    Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId("sampleClientId");
    return Optional.ofNullable(tokens).orElse(Collections.emptyList()).stream().map(OAuth2AccessToken::getValue).collect(Collectors.toList());
}
 
Example 20
Source File: LegendGraphicController.java    From geomajas-project-server with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Gets a legend graphic for a layer with a default style and rule. Assumes REST url style:
 * /legendgraphic/{layerId}.{format}
 * 
 * @param layerId
 *            the layer id
 * @param styleName
 *            the style name
 * @param format
 *            the image format ('png','jpg','gif')
 * @param width
 *            the graphic's width
 * @param height
 *            the graphic's height
 * @param scale
 *            the scale denominator (not supported yet)
 * @param request
 *            the servlet request object
 * @return the model and view
 * @throws GeomajasException
 *             when a style or rule does not exist or is not renderable
 */
@RequestMapping(value = "/legendgraphic/{layerId}.{format}", method = RequestMethod.GET)
public ModelAndView getLayerGraphic(@PathVariable("layerId") String layerId, @PathVariable("format") String format,
		@RequestParam(value = "width", required = false) Integer width,
		@RequestParam(value = "height", required = false) Integer height,
		@RequestParam(value = "scale", required = false) Double scale, HttpServletRequest request)
		throws GeomajasException {
	return getGraphic(layerId, null, null, format, width, height, scale, false, request);
}