Publish { @RequestMapping(value = "/{portal}/{lang}/md.publish", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @ResponseBody public PublishReport publish( @PathVariable String lang, HttpServletRequest request, @RequestParam(value = "ids", required = false) String commaSeparatedIds, @RequestParam(value = "skipIntranet", defaultValue = "false") boolean skipIntranet) throws Exception { ConfigurableApplicationContext appContext = ApplicationContextHolder.get(); ServiceManager serviceManager = appContext.getBean(ServiceManager.class); final ServiceContext serviceContext = serviceManager.createServiceContext("md.publish", lang, request); return exec(commaSeparatedIds, true, skipIntranet, serviceContext); }  @RequestMapping(value = "/{portal}/{lang}/md.publish", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @ResponseBody PublishReport publish(
        @PathVariable String lang,
        HttpServletRequest request,
        @RequestParam(value = "ids", required = false) String commaSeparatedIds,
        @RequestParam(value = "skipIntranet", defaultValue = "false") boolean skipIntranet); @RequestMapping(value = "/{portal}/{lang}/md.unpublish", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @ResponseBody PublishReport unpublish(
        @PathVariable String lang,
        HttpServletRequest request,
        @RequestParam(value = "ids", required = false) String commaSeparatedIds,
        @RequestParam(value = "skipIntranet", defaultValue = "false") boolean skipIntranet);  }
@Test public void testPublishSingle() throws Exception { final String metadataId = metadataIds.get(0); allowedRepository.deleteAll(); dataManager.indexMetadata(metadataId, true, null); MockHttpServletRequest request = new MockHttpServletRequest(); request.getSession(); PublishReport report = publishService.publish("eng", request, metadataId, false); assertCorrectReport(report, 1, 0, 0, 0); assertPublishedInIndex(true, metadataId); report = publishService.publish("eng", request, metadataId, false); assertCorrectReport(report, 0, 0, 1, 0); assertPublishedInIndex(true, metadataId); allowedRepository.deleteAll(); dataManager.indexMetadata(metadataId, true, null); assertPublishedInIndex(false, metadataId); SecurityContextHolder.clearContext(); report = publishService.publish("eng", request, metadataId, false); assertCorrectReport(report, 0, 0, 0, 1); assertPublishedInIndex(false, metadataId); int iMetadataId = Integer.parseInt(metadataId); final int downloadId = ReservedOperation.download.getId(); final int allGroupId = ReservedGroup.all.getId(); allowedRepository.save(new OperationAllowed(new OperationAllowedId(iMetadataId, allGroupId, downloadId))); final int featuredId = ReservedOperation.featured.getId(); allowedRepository.save(new OperationAllowed(new OperationAllowedId(iMetadataId, allGroupId, featuredId))); allowedRepository.save(new OperationAllowed(new OperationAllowedId(iMetadataId, sampleGroupId, featuredId))); report = publishService.publish("eng", request, metadataId, false); assertCorrectReport(report, 0, 0, 0, 1); assertEquals(3, allowedRepository.count()); assertNotNull(allowedRepository.findOneById_GroupIdAndId_MetadataIdAndId_OperationId(allGroupId, iMetadataId, downloadId)); assertNotNull(allowedRepository.findOneById_GroupIdAndId_MetadataIdAndId_OperationId(allGroupId, iMetadataId, featuredId)); assertNotNull(allowedRepository.findOneById_GroupIdAndId_MetadataIdAndId_OperationId(sampleGroupId, iMetadataId, featuredId)); }
@Test public void testPublishMultiple() throws Exception { allowedRepository.deleteAll(); MockHttpServletRequest request = new MockHttpServletRequest(); request.getSession(); String ids = Joiner.on(",").join(this.metadataIds); PublishReport report = publishService.publish("eng", request, ids, false); assertCorrectReport(report, 3, 0, 0, 0); report = publishService.publish("eng", request, ids, false); assertCorrectReport(report, 0, 0, 3, 0); allowedRepository.deleteAll(OperationAllowedSpecs.hasMetadataId(this.metadataIds.get(0))); report = publishService.publish("eng", request, ids, false); assertCorrectReport(report, 1, 0, 2, 0); allowedRepository.deleteAll(OperationAllowedSpecs.hasMetadataId(this.metadataIds.get(0))); SecurityContextHolder.clearContext(); report = publishService.publish("eng", request, ids, false); assertCorrectReport(report, 0, 0, 2, 1); }