/** * Saves persistently a download performed by a user. * * @param size download size. * @param start_date date downloading start. * @param user associate user to download. */ @Transactional @Caching (evict = { @CacheEvict (value = "network_download_count", key = "#user.getUUID ()", condition = "#user != null"), @CacheEvict (value = "network_download_size", key = "#user.getUUID ()", condition = "#user != null") }) public void createDownloadUsage (final Long size, final Date start_date, final User user) { if (size == null || size < 0 || start_date == null || user == null) { throw new IllegalArgumentException ("Invalid parameters"); } NetworkUsage download_usage = new NetworkUsage (); download_usage.setSize (size); download_usage.setDate (start_date); download_usage.setUser (user); download_usage.setIsDownload (true); networkUsageDao.create (download_usage); }
@Transactional (readOnly=false, propagation=Propagation.REQUIRED) @Caching (evict = { @CacheEvict(value = "user", allEntries = true), @CacheEvict(value = "userByName", allEntries = true)}) public void resetPassword(String code, String new_password) throws RootNotModifiableException, RequiredFieldMissingException, EmailNotSentException { User u = userDao.getUserFromUserCode (code); if (u == null) { throw new UserNotExistingException (); } checkRoot (u); u.setPassword (new_password); checkRequiredFields (u); userDao.update (u); }
/** * Update given User, after checking required fields. * * @param user * @throws RootNotModifiableException * @throws RequiredFieldMissingException */ @PreAuthorize ("isAuthenticated ()") @Transactional (readOnly=false, propagation=Propagation.REQUIRED) @Caching (evict = { @CacheEvict(value = "user", key = "#user.getUUID ()"), @CacheEvict(value = "userByName", key = "#user.username.toLowerCase()")}) public void selfUpdateUser (User user) throws RootNotModifiableException, RequiredFieldMissingException, EmailNotSentException { User u = userDao.read (user.getUUID ()); checkRoot (u); u.setEmail (user.getEmail ()); u.setFirstname (user.getFirstname ()); u.setLastname (user.getLastname ()); u.setAddress (user.getAddress ()); u.setPhone (user.getPhone ()); u.setCountry (user.getCountry ()); u.setUsage (user.getUsage ()); u.setSubUsage (user.getSubUsage ()); u.setDomain (user.getDomain ()); u.setSubDomain (user.getSubDomain ()); checkRequiredFields (u); userDao.update (u); }
@Override @Transactional(rollbackFor = Exception.class) @Caching(evict = { @CacheEvict(value = "getOneArticleById", key = "#root.target.oneArticleKey + #article.id"), @CacheEvict(value = "getArticlesCount", key = "#root.target.articleCountKey + #username") }) public long insertOneArticle(Article article) { long articleId = idWorker.nextId(); article.setId(articleId); article.setCreatedTime(new Date()); // add the created time article.setModifiedTime(new Date()); // add the modified time articleMapper.insertOneArticle(article); logger.info(article.getUsername() + " insert article " + article.getId() + " successfully"); deleteAllPagesCache(article.getUsername()); return articleId; }
@Caching(evict = { @CacheEvict(value = CACHE_POST, key = "#post.id.toString()"), @CacheEvict(value = CACHE_COUNT_USER_TAG_POSTS, key = "#post.user.id.toString().concat('_tags_posts_count')", allEntries = true), @CacheEvict(value = TagService.CACHE_COUNT_USER, key = "#post.user.id.toString().concat('_posts_count')") }) @Transactional public void deletePost(Post post) { PostStatus status = post.getStatus(); postRepository.delete(post.getId()); if (status == PostStatus.PUBLIC) { Set<Tag> tags = tagRepository.findPostTags(post.getId()); hotPostService.removeHotPost(post); hotPostService.removeTaggedPost(post, tags); newPostsService.remove(post.getId()); newPostsService.removeTaggedPost(post.getId(), tags); countingService.decPublicPostsCount(); tags.forEach(tagService::decreasePostCountByOne); // 标签文章统计需要减一 } PostSearchService.deleteIndex(post.getId()); countingService.decPostsCount(); }
@Override @Caching( evict = { @CacheEvict(key="#object.id"), @CacheEvict(cacheResolver="secondaryCacheResolver", allEntries=true) } ) public T delete(T object) throws DataAccessException { if (logger.isDebugEnabled()) logger.debug("type {} delete", type); try { mongoOperations.remove(object); return object; } catch (Exception e) { throw new DataAccessException(e); } }
@SuppressWarnings("rawtypes") @Caching(evict = { @CacheEvict(value = "entornsUsuariActual", allEntries=true), @CacheEvict(value = "consultaCache", allEntries=true)}) public void deletePermissions( String recipient, boolean principal, Set<Permission> permissions, Serializable id, Class clazz, boolean granting) { for (Permission permission: permissions) { if (principal) { aclServiceDao.revocarPermisUsuari( recipient, clazz, (Long)id, permission); } else { aclServiceDao.revocarPermisRol( recipient, clazz, (Long)id, permission); } } }
@Override @Caching(evict = { @CacheEvict(key = "'id:'+#result"), @CacheEvict(key = "'auth:persion-id'+#result"), @CacheEvict(key = "'auth-bind'+#result"), @CacheEvict(key = "'person-name'+#authBindEntity.name") }) public String insert(PersonAuthBindEntity authBindEntity) { authBindEntity.setStatus(DataStatus.STATUS_ENABLED); if (authBindEntity.getPersonUser() != null) { syncUserInfo(authBindEntity); } String id = this.insert(((PersonEntity) authBindEntity)); if (authBindEntity.getPositionIds() != null) { syncPositionInfo(id, authBindEntity.getPositionIds()); } return id; }
@Override @Caching(evict = { @CacheEvict(key = "'id:'+#authBindEntity.id"), @CacheEvict(key = "'auth:persion-id'+#authBindEntity.id"), @CacheEvict(key = "'auth-bind'+#authBindEntity.id"), @CacheEvict(key = "'person-name'+#authBindEntity.name") }) public int updateByPk(PersonAuthBindEntity authBindEntity) { if (authBindEntity.getPositionIds() != null) { personPositionDao.deleteByPersonId(authBindEntity.getId()); syncPositionInfo(authBindEntity.getId(), authBindEntity.getPositionIds()); } if (authBindEntity.getPersonUser() != null) { syncUserInfo(authBindEntity); } return this.updateByPk(((PersonEntity) authBindEntity)); }
@Override @Caching( put = @CachePut(cacheNames = "oauth2-user-token", key = "'a-t:'+#tokenInfo.accessToken"), evict = @CacheEvict(cacheNames = "oauth2-user-token-list", key = "'s-g-t:'+#result.serverId+':'+#result.grantType") ) @Transactional(propagation = Propagation.NOT_SUPPORTED) public AccessTokenInfo insert(AccessTokenInfo tokenInfo) { if (tokenInfo.getId() == null) { tokenInfo.setId(getIDGenerator().generate()); } OAuth2UserTokenEntity entity = entityTokenInfoMapping().apply(tokenInfo); entity.setCreateTime(tokenInfo.getCreateTime()); entity.setUpdateTime(tokenInfo.getUpdateTime()); insert(entity); return tokenInfo; }
@Caching(cacheable = {@Cacheable(value = "member", key = "\"Member.memberId:\" + #member.memberId")}, put = { @CachePut(value = "member", key = "\"Member.memberName:\" + #result.memberName", condition = "#result != null"), @CachePut(value = "member", key = "\"Member.email:\" + #result.email", condition = "#result != null")}) // 将 memberName,email 作为 key 加入到缓存,以便于 findByMemberName,findByEmail 可以使用缓存 public Member findByMemberId(final Member member) { System.out.println("cache miss, invoke find by memberId, memberId:" + member.getMemberId()); for (Member item : members) { if (item.getMemberId().equals(member.getMemberId())) { return item; } } return null; }
/** {@inheritDoc} */ @Override @Caching(evict = { @CacheEvict(value = "users", allEntries = true) }, put = { @CachePut(value = "user", key = "#id") }) public User updateUser(User user, String id) throws SecuredAppException { User persistedUser = getUserById(id); if (persistedUser == null) { throw new SecuredAppException("User " + user.getId() + " doesn't exist"); } // List<Role> updatedRoles = new ArrayList<>(); List<Role> updatedRoles = user.getRoleList().stream().parallel() .filter(role -> role.getId() != null) .map(role -> getRoleById(role.getId())) .collect(Collectors.toCollection(ArrayList::new)); /* * if(roles != null){ for (Role role : roles) { if(role.getId() != null) * { updatedRoles.add(getRoleById(role.getId())); } } } */ persistedUser.setRoleList(updatedRoles); return userRepository.save(persistedUser); }
@Caching(evict = { @CacheEvict(value = CACHES_NAME, allEntries = true), @CacheEvict(value = CACHE_NAME, key = "#one.id") }) public Tag update(Tag one, TagForm tagForm) { Category category = categoryService.findOne(tagForm.getCategoryId()); if (category == null) { return null; } one.setCode(tagForm.getCode()); one.setTitle(tagForm.getTitle()); one.setCategory(category); tagRepository.save(one); return one; }
@Override @Caching(evict = { @CacheEvict(value = SDK_CACHE, allEntries = true), @CacheEvict(value = FILE_CACHE, allEntries = true) }) public void flushAllCaches() throws SandboxServiceException { final AdminClient client = clientProvider.getClient(); client.login(tenantDeveloperUser, tenantDeveloperPassword); try { retryRestCall(new RestCall() { @Override public void executeRestCall() throws Exception { client.flushSdkCache(); } }, 3, 5000, HttpStatus.UNAUTHORIZED); } catch (Exception e) { throw Utils.handleException(e); } LOG.info("All caches have been completely flushed."); }
@Transactional (readOnly=false, propagation=Propagation.REQUIRED) @IncrementCache (name = "product_count", key = "all", value = -1) @Caching(evict = { @CacheEvict (value = "indexes", key = "#pid"), @CacheEvict (value = "product", key = "#pid"), @CacheEvict (value = "products", allEntries = true)}) public void systemDeleteProduct (Long pid) { Product product = productDao.read (pid); if (product == null) { throw new DataStoreException ("Product #" + pid + " not found in the system."); } systemDeleteProduct (product, Destination.TRASH); }
@Transactional (readOnly = false, propagation = Propagation.REQUIRED) @Caching (evict = { @CacheEvict (value = "product", allEntries = true), @CacheEvict (value = "products", allEntries = true) }) @IncrementCache (name = "product_count", key = "all", value = 1) public Product addProduct (Product product) throws IllegalArgumentException { URL path = product.getPath (); String origin = product.getOrigin (); if (path == null || origin == null || origin.isEmpty ()) { throw new IllegalArgumentException ("product must have a path and an origin"); } // FIXME do I have to check every field? isn't it done by hibernate based on column constraints? Product final_product = this.productDao.create (product); return final_product; }
@Transactional (readOnly=false, propagation=Propagation.REQUIRED) @Caching (evict = { @CacheEvict(value = "user", allEntries = true), @CacheEvict(value = "userByName", allEntries = true), @CacheEvict(value = "json_user", allEntries = true)}) public void resetPassword(String code, String new_password) throws RootNotModifiableException, RequiredFieldMissingException, EmailNotSentException { User u = userDao.getUserFromUserCode (code); if (u == null) { throw new UserNotExistingException (); } checkRoot (u); u.setPassword (new_password); checkRequiredFields (u); userDao.update (u); }
/** * Update given User, after checking required fields. * * @param user * @throws RootNotModifiableException * @throws RequiredFieldMissingException */ @PreAuthorize ("isAuthenticated ()") @Transactional (readOnly=false, propagation=Propagation.REQUIRED) @Caching (evict = { @CacheEvict(value = "user", key = "#user.getUUID ()"), @CacheEvict(value = "userByName", key = "#user.username.toLowerCase()"), @CacheEvict(value = "json_user", key = "#user")}) public void selfUpdateUser (User user) throws RootNotModifiableException, RequiredFieldMissingException, EmailNotSentException { User u = userDao.read (user.getUUID ()); checkRoot (u); u.setEmail (user.getEmail ()); u.setFirstname (user.getFirstname ()); u.setLastname (user.getLastname ()); u.setAddress (user.getAddress ()); u.setPhone (user.getPhone ()); u.setCountry (user.getCountry ()); u.setUsage (user.getUsage ()); u.setSubUsage (user.getSubUsage ()); u.setDomain (user.getDomain ()); u.setSubDomain (user.getSubDomain ()); checkRequiredFields (u); userDao.update (u); }
@RequestMapping(value = "", method = RequestMethod.POST) @Interceptors({ ProjectMemberRequired.class }) @ResponseBody @Caching(evict = { @CacheEvict(value = GET_STORIES_CACHE, key = "#projectId + '*'") }) public StoryDTO newStory(@PathVariable("companyId") int companyId, @PathVariable("projectId") int projectId, @Valid @RequestBody StoryForm storyForm) { storyForm.setProjectId(projectId); storyForm.setCompanyId(companyId); storyForm.setCreatorId(sessionService.getCurrentUser().getId()); storyForm.setCreatorName(sessionService.getCurrentUser().getName()); Story story = storyService.create(storyForm); StoryDTO storyDTO = StoryTransform.storyToStoryDTO(story); fillStoryDTO(storyDTO); return storyDTO; }
@RequestMapping(value = "/{storyId}", method = RequestMethod.PUT) @Interceptors({ ProjectMemberRequired.class }) @ResponseBody @Caching(evict = { @CacheEvict(value = GET_STORIES_CACHE, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'") }) public StoryDTO updateStory(@PathVariable("companyId") int companyId, @PathVariable("projectId") int projectId, @PathVariable("storyId") int storyId, @Valid @RequestBody StoryForm form) { Story story = storyService.getStoryByIdWithoutChilds(storyId); form.setId(storyId); if (form.getParentStoryId() != null && form.getParentStoryId() != story.getParentStoryId()) { boolean succeed = storyService.changeStoryParentStoryId(storyId, form.getParentStoryId()); if (!succeed) { throw new BadRequestException(); } } storyService.updateStoryWithoutChangingParent(form); Story updatedStory = storyService.getById(story.getId()); StoryDTO storyDTO = StoryTransform.storyToStoryDTO(updatedStory); fillStoryDTO(storyDTO); return storyDTO; }
@RequestMapping(value = "/{storyId}/complete", method = RequestMethod.PUT) @Interceptors({ ProjectMemberRequired.class }) @ResponseStatus(HttpStatus.OK) @Caching(evict = { @CacheEvict(value = GET_STORIES_CACHE, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'") }) public void completeStory(@PathVariable("companyId") int companyId, @PathVariable("projectId") int projectId, @PathVariable("storyId") int storyId) { Story story = storyService.getById(storyId); if (!story.getCompletable()) { throw new NoPermissionException("user cannot complete an uncompletable story!"); } Story newStory = new Story(); newStory.setId(storyId); newStory.setCompleted(true); storyService.updateStoryWithoutChangingParent(newStory); }
@RequestMapping(value = "", method = RequestMethod.POST) @Interceptors({ ProjectMemberRequired.class }) @ResponseBody @Caching(evict = { @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'"), @CacheEvict(value = StoryApiController.GET_STORIES_CACHE, key = "#projectId + '*'") }) public StepDTO newStep(@RequestBody Step step, @PathVariable int projectId) { step.setCreatorId(sessionService.getCurrentUser().getId()); step.setCreatorName(sessionService.getCurrentUser().getName()); step.setStatus(IterationItemStatus.TODO.getValue()); step = stepService.create(step); if (step.getAssigneeId() != null) { step.setAssignee(userService.getById(step.getAssigneeId())); } return StepTransform.stepToStepDTO(step); }
@RequestMapping(value = "", method = RequestMethod.POST) @Interceptors({ ProjectMemberRequired.class }) @Caching(evict = { @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'") }) @ResponseBody public BugDTO createBug(@PathVariable int companyId, @PathVariable int projectId, @RequestBody BugDTO bugDTO) { Bug bug = BugTransForm.bugDTOToBug(bugDTO); bug.setCompanyId(companyId); bug.setProjectId(projectId); bug.setCreatorId(sessionService.getCurrentUser().getId()); bug.setCreatorName(sessionService.getCurrentUser().getName()); bug.setDeleted(false); bug.setCreatedTime(new Date()); bug.setDueTime(bugDTO.getDueTime()); bugService.create(bug); return BugTransForm.bugToBugDTO(bug); }
@RequestMapping(value = "", method = RequestMethod.POST) @Interceptors({ ProjectMemberRequired.class, ProjectNotArchivedRequired.class }) @ResponseBody @Caching(evict = { @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + #iterationAttach.iterationId + '*'"), @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'") }) public void createIterationAttach(@RequestBody IterationAttach iterationAttach, @PathVariable int projectId) { iterationService.addIterable(iterationAttach); if (iterationAttach.getObjectType().equals(new Story().getType())) { Story story = storyService.getById(iterationAttach.getObjectId()); for (Step step : story.getSteps()) { if (!step.getCompleted()) { iterationService.addIterable(step); } } } }
@RequestMapping(value = "", method = RequestMethod.DELETE) @Interceptors({ ProjectMemberRequired.class, ProjectNotArchivedRequired.class }) @ResponseStatus(HttpStatus.OK) @Caching(evict = { @CacheEvict(value = IterationApiController.ITERATION_CACHE_NAME, key = "#projectId + '*'"), @CacheEvict(value = IterationApiController.ITERATIONS_CACHE_NAME, key = "#projectId + '*'") }) public void deleteIterationById(@PathVariable int projectId, @RequestParam(value = "iterationId", required = true) Integer iterationId, @RequestParam(value = "attachType", required = true) String attachType, @RequestParam(value = "attachId", required = true) Integer attachId) { IterationAttach iterationAttach = new IterationAttach(); iterationAttach.setIterationId(iterationId); iterationAttach.setObjectId(attachId); iterationAttach.setObjectType(attachType); if (iterationAttach.getObjectType().equals(new Story().getType())) { Story story = storyService.getById(iterationAttach.getObjectId()); for (Step step : story.getSteps()) { if (!step.getCompleted()) { iterationService.removeIterable(step, iterationId); } } } iterationService.removeIterable(iterationAttach); }
@Override @Transactional @Caching(cacheable = {@Cacheable(value = SETTINGS_CACHE_NAME, key = "#root.methodName") }) public MotechSettings getPlatformSettings() { if (settingsDataService == null) { return null; } SettingsRecord settings = getSettings(); SettingsRecord merged = new SettingsRecord(); merged.setPlatformInitialized(settings.isPlatformInitialized()); merged.setLastRun(settings.getLastRun()); merged.setFilePath(settings.getFilePath()); merged.setConfigFileChecksum(settings.getConfigFileChecksum()); merged.setPlatformSettings(settings.getPlatformSettings()); merged.mergeWithDefaults(defaultConfig); return merged; }
@Override @Caching(evict = { @CacheEvict(value = "ShopDetailView", key = "#shopDetail.userName") }) public boolean updateShop(String userId, ShopDetail shopDetail, Integer status) { boolean result = true; try { if (ShopStatusEnum.REJECT.value().equals(status) || ShopStatusEnum.CLOSE.value().equals(status)) { // 拒绝开店 commonUtil.removeAdminRight(userId); } else if (ShopStatusEnum.ONLINE.value().equals(status)) { commonUtil.saveAdminRight(userId); } shopDetail.setStatus(status); shopDetail.setModifyDate(new Date()); EventHome.publishEvent(new FireEvent(shopDetail, OperationTypeEnum.UPDATE_STATUS)); saveOrUpdateShopDetail(shopDetail); } catch (Exception e) { log.error("auditShop ", e); result = false; } return result; }
/** * Stop all jobs belonging to this cube and clean out all segments * * @param cube * @return * @throws IOException * @throws CubeIntegrityException * @throws JobException */ @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'OPERATION') or hasPermission(#cube, 'MANAGEMENT')") @Caching(evict = {@CacheEvict(value = QueryController.SUCCESS_QUERY_CACHE, allEntries = true), @CacheEvict(value = QueryController.EXCEPTION_QUERY_CACHE, allEntries = true)}) public CubeInstance purgeCube(CubeInstance cube) throws IOException, JobException { String cubeName = cube.getName(); RealizationStatusEnum ostatus = cube.getStatus(); if (null != ostatus && !RealizationStatusEnum.DISABLED.equals(ostatus)) { throw new InternalErrorException("Only disabled cube can be purged, status of " + cubeName + " is " + ostatus); } try { this.releaseAllSegments(cube); return cube; } catch (IOException e) { throw e; } }
/** * Update a cube status from ready to disabled. * * @return * @throws CubeIntegrityException * @throws IOException * @throws JobException */ @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'OPERATION') or hasPermission(#cube, 'MANAGEMENT')") @Caching(evict = {@CacheEvict(value = QueryController.SUCCESS_QUERY_CACHE, allEntries = true), @CacheEvict(value = QueryController.EXCEPTION_QUERY_CACHE, allEntries = true)}) public CubeInstance disableCube(CubeInstance cube) throws IOException, JobException { String cubeName = cube.getName(); RealizationStatusEnum ostatus = cube.getStatus(); if (null != ostatus && !RealizationStatusEnum.READY.equals(ostatus)) { throw new InternalErrorException("Only ready cube can be disabled, status of " + cubeName + " is " + ostatus); } cube.setStatus(RealizationStatusEnum.DISABLED); try { return getCubeManager().updateCube(cube); } catch (IOException e) { cube.setStatus(ostatus); throw e; } }
/** * Apply dataset publication flag. * * @param id * @param published */ @Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") }) public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) { StudyDataset dataset = findById(id); helper.evictCache(dataset); if(published) { checkIsPublishable(dataset); Iterable<DatasetVariable> variables = wrappedGetDatasetVariables(dataset); publishState(id); prepareForIndex(dataset); eventBus.post(new DatasetPublishedEvent(dataset, variables, getCurrentUsername(), cascadingScope)); //helper.asyncBuildDatasetVariablesCache(dataset, variables); } else { unPublishState(id); eventBus.post(new DatasetUnpublishedEvent(dataset)); } }
/** * Apply dataset publication flag. * * @param id * @param published */ @Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") }) public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) { HarmonizationDataset dataset = findById(id); helper.evictCache(dataset); if(published) { checkIsPublishable(dataset); publishState(id); Map<String, List<DatasetVariable>> harmonizationVariables = populateHarmonizedVariablesMap(dataset); eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), harmonizationVariables, getCurrentUsername(), cascadingScope)); //helper.asyncBuildDatasetVariablesCache(dataset, harmonizationVariables); } else { unPublishState(id); eventBus.post(new DatasetUnpublishedEvent(dataset)); } }
@Caching(evict = {@CacheEvict(value = "aggregations-metadata", allEntries = true), @CacheEvict(value = {"studies-draft", "studies-published"}, key = "#id")}) public void delete(@NotNull String id) { T study = getRepository().findOne(id); if (study == null) { throw NoSuchEntityException.withId(getType(), id); } checkStudyConstraints(study); fileSystemService.delete(FileUtils.getEntityPath(study)); getEntityStateRepository().delete(id); ((DBRefAwareRepository<T>)getRepository()).deleteWithReferences(study); gitService.deleteGitRepository(study); eventBus.post(new StudyDeletedEvent(study)); }
@Override @Caching(evict = {@CacheEvict(value = "contentlists", key = "#sessionId"), @CacheEvict(value = "lecturecontentlists", key = "#sessionId", condition = "#content.getQuestionVariant().equals('lecture')"), @CacheEvict(value = "preparationcontentlists", key = "#sessionId", condition = "#content.getQuestionVariant().equals('preparation')"), @CacheEvict(value = "flashcardcontentlists", key = "#sessionId", condition = "#content.getQuestionVariant().equals('flashcard')") }, put = {@CachePut(value = "contents", key = "#content.id")}) public Content save(final String sessionId, final Content content) { content.setSessionId(sessionId); try { contentRepository.save(content); return content; } catch (final IllegalArgumentException e) { logger.error("Could not save content {}.", content, e); } return null; }
@PreAuthorize("hasPermission(#session, 'owner')") @Caching(evict = { @CacheEvict(value = "contents", allEntries = true), @CacheEvict(value = "contentlists", key = "#session.getId()"), @CacheEvict(value = "lecturecontentlists", key = "#session.getId()", condition = "'lecture'.equals(#variant)"), @CacheEvict(value = "preparationcontentlists", key = "#session.getId()", condition = "'preparation'.equals(#variant)"), @CacheEvict(value = "flashcardcontentlists", key = "#session.getId()", condition = "'flashcard'.equals(#variant)") }) private void deleteBySessionAndVariant(final Session session, final String variant) { final List<String> contentIds; if ("all".equals(variant)) { contentIds = contentRepository.findIdsBySessionId(session.getId()); } else { contentIds = contentRepository.findIdsBySessionIdAndVariant(session.getId(), variant); } final int answerCount = answerRepository.deleteByContentIds(contentIds); final int contentCount = contentRepository.deleteBySessionId(session.getId()); dbLogger.log("delete", "type", "question", "questionCount", contentCount); dbLogger.log("delete", "type", "answer", "answerCount", answerCount); final DeleteAllQuestionsEvent event = new DeleteAllQuestionsEvent(this, session); this.publisher.publishEvent(event); }
@Override @PreAuthorize("isAuthenticated()") @Caching(evict = { @CacheEvict(value = "contents", allEntries = true), @CacheEvict(value = "contentlists", key = "#sessionId"), @CacheEvict(value = "lecturecontentlists", key = "#sessionId"), @CacheEvict(value = "preparationcontentlists", key = "#sessionId"), @CacheEvict(value = "flashcardcontentlists", key = "#sessionId") }) public void setVotingAdmissions(final String sessionkey, final boolean disableVoting, List<Content> contents) { final User user = getCurrentUser(); final Session session = getSession(sessionkey); if (!session.isCreator(user)) { throw new UnauthorizedException(); } for (final Content q : contents) { if (!"flashcard".equals(q.getQuestionType())) { q.setVotingDisabled(disableVoting); } } ArsnovaEvent event; if (disableVoting) { event = new LockVotesEvent(this, session, contents); } else { event = new UnlockVotesEvent(this, session, contents); } this.publisher.publishEvent(event); }
@Override @PreAuthorize("isAuthenticated()") @Caching(evict = { @CacheEvict(value = "contents", allEntries = true), @CacheEvict(value = "contentlists", key = "#sessionId"), @CacheEvict(value = "lecturecontentlists", key = "#sessionId"), @CacheEvict(value = "preparationcontentlists", key = "#sessionId"), @CacheEvict(value = "flashcardcontentlists", key = "#sessionId") }) public void publishQuestions(final String sessionkey, final boolean publish, List<Content> contents) { final User user = getCurrentUser(); final Session session = getSession(sessionkey); if (!session.isCreator(user)) { throw new UnauthorizedException(); } for (final Content content : contents) { content.setActive(publish); } contentRepository.save(contents); ArsnovaEvent event; if (publish) { event = new UnlockQuestionsEvent(this, session, contents); } else { event = new LockQuestionsEvent(this, session, contents); } this.publisher.publishEvent(event); }