public void simpleAddContentSourcesToRepo(Subject subject, int repoId, int[] contentSourceIds) throws Exception { Repo repo = entityManager.find(Repo.class, repoId); if (repo == null) { throw new Exception("There is no repo with an ID [" + repoId + "]"); } for (int id : contentSourceIds) { ContentSource cs = entityManager.find(ContentSource.class, id); if (cs == null) { throw new Exception("There is no content source with id [" + id + "]"); } RepoContentSource ccsmapping = repo.addContentSource(cs); entityManager.persist(ccsmapping); } }
/** * Directly assign a repo to this repogroup. * * @param repo * * @return the mapping that was added */ public RepoRepoGroup addRepo(Repo repo) { if (this.repoRepoGroups == null) { this.repoRepoGroups = new HashSet<RepoRepoGroup>(); } RepoRepoGroup mapping = new RepoRepoGroup(repo, this); this.repoRepoGroups.add(mapping); repo.addRepoGroup(this); return mapping; }
if (!authzManager.canViewRepo(subject, repo.getId())) { throw new PermissionException("User [" + subject + "] cannot access a repo with id " + repo.getId()); ResourceRepo mapping = repo.addResource(resource); entityManager.persist(mapping);
private void validateFields(Repo repo) throws RepoException { if (repo.getName() == null || repo.getName().trim().equals("")) { throw new RepoException("Repo name is required"); } if (repo.getSyncSchedule() != null) { try { CronExpression ce = new CronExpression(repo.getSyncSchedule()); } catch (ParseException e) { throw new RepoException("Repo sync schedule is not a vaild format."); } } }
/** * Removes the repo from this repogroup, if it exists. If it does exist, the mapping that was removed is * returned; if the given repo did not did not belong to this repo group, <code>null</code> is * returned. * * @param repo the repo to remove from this repo group * * @return the mapping that was removed or <code>null</code> if the repo did not belong to this repo group */ public RepoRepoGroup removeRepo(Repo repo) { if ((this.repoRepoGroups == null) || (repo == null)) { return null; } RepoRepoGroup doomed = null; for (RepoRepoGroup rrg : this.repoRepoGroups) { if (repo.equals(rrg.getRepoRepoGroupPK().getRepo())) { doomed = rrg; repo.removeRepoGroup(this); break; } } if (doomed != null) { this.repoRepoGroups.remove(doomed); } return doomed; }
/** * Removes the repo from this content source, if it exists. If it does exist, the mapping that was removed is * returned; if the given repo did not exist as one that this content source is a member of, <code>null</code> is * returned. * * @param repo the repo to remove from this content source * * @return the mapping that was removed or <code>null</code> if the repo was not mapped to this content source */ public RepoContentSource removeRepo(Repo repo) { if ((this.repoContentSources == null) || (repo == null)) { return null; } RepoContentSource doomed = null; for (RepoContentSource ccs : this.repoContentSources) { if (repo.equals(ccs.getRepoContentSourcePK().getRepo())) { doomed = ccs; repo.removeContentSource(this); break; } } if (doomed != null) { this.repoContentSources.remove(doomed); } return doomed; }
public List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId) { if (!authzManager.canViewResource(subject, resourceId)) { throw new PermissionException("User [" + subject + "] can't view resource with id " + resourceId); } List<SubscribedRepo> list = new ArrayList<SubscribedRepo>(); PageControl pc = new PageControl(); for (RepoComposite repoComposite : findResourceSubscriptions(subject, resourceId, pc)) { Repo repo = repoComposite.getRepo(); SubscribedRepo summary = new SubscribedRepo(repo.getId(), repo.getName()); list.add(summary); } return list; }
addContentSourcesToRepo(overlord, existingRepo.getId(), new int[] { contentSourceId }); Repo addMe = new Repo(name); addMe.setCandidate(!autoImport); addMe.setDescription(createMe.getDescription()); addMe.addRepoGroup(group); addContentSourcesToRepo(overlord, addMe.getId(), new int[] { contentSourceId }); } else { Repo parent = parentList.get(0); addRepoRelationship(overlord, addMe.getId(), parent.getId(), PARENT_RELATIONSHIP_NAME);
@SuppressWarnings("unchecked") @RequiredPermission(Permission.MANAGE_REPOSITORIES) public void deleteCandidatesWithOnlyContentSource(Subject subject, int contentSourceId) { Query query = entityManager.createNamedQuery(Repo.QUERY_FIND_CANDIDATES_WITH_ONLY_CONTENT_SOURCE); query.setParameter("contentSourceId", contentSourceId); List<Repo> repoList = query.getResultList(); for (Repo deleteMe : repoList) { deleteRepo(subject, deleteMe.getId()); } }
repo.setLastModifiedDate(System.currentTimeMillis()); Set<ContentSource> alreadyAssociatedContentSources = repo.getContentSources(); RepoContentSource repoContentSourceMapping = repo.addContentSource(contentSource); entityManager.persist(repoContentSourceMapping); repo.getPackageVersions());
private void removeRepoFromList(String repoName, List<Repo> repoList) { Repo deleteMe = null; for (Repo checkMe : repoList) { if (checkMe.getName().equals(repoName)) { deleteMe = checkMe; break; } } if (deleteMe != null) { repoList.remove(deleteMe); } }
progress.append("Start synchronization of Repository [").append(repo.getName()).append("]\n"); progress.append(new Date()).append(": "); progress.append("Getting currently known list of content source packages...\n"); log.info("Repository [" + repo.getName() + "] is already currently being synchronized - this sync request will be ignored."); return false; for (ContentSource source : repo.getContentSources()) { try { ContentProvider provider = getIsolatedContentProvider(source.getId()); for (ContentSource source : repo.getContentSources()) { ContentProvider provider = getIsolatedContentProvider(source.getId()); SyncProgressWeight sw = provider.getSyncProgressWeight(); for (ContentSource source : repo.getContentSources()) { for (ContentSource source : repo.getContentSources()) { try { ContentProvider provider = getIsolatedContentProvider(source.getId()); for (ContentSource source : repo.getContentSources()) { try { ContentProvider provider = getIsolatedContentProvider(source.getId()); for (ContentSource source : repo.getContentSources()) { try {
return false; } else if (!repo.equals(other.repo)) { return false;
/** * Unsubscribes the resource from a repo, if it exists. If it was already subscribed, the mapping that was * removed is returned; if not, <code>null</code> is returned. * * @param repo the repo to unsubscribe from * * @return the mapping that was removed or <code>null</code> if the resource was not subscribed to the repo */ public ResourceRepo removeRepo(Repo repo) { if ((this.resourceRepos == null) || (repo == null)) { return null; } ResourceRepo doomed = null; for (ResourceRepo rc : this.resourceRepos) { if (repo.equals(rc.getResourceRepoPK().getRepo())) { doomed = rc; repo.removeResource(this); break; } } if (doomed != null) { this.resourceRepos.remove(doomed); } if (this.resourceRepos.isEmpty()) { this.resourceRepos = null; } return doomed; }
public Repo updateRepo(Subject subject, Repo repo) throws RepoException { validateFields(repo); if (!authzManager.hasGlobalPermission(subject, Permission.MANAGE_REPOSITORIES)) { if (!authzManager.canUpdateRepo(subject, repo.getId())) { throw new PermissionException("User [" + subject + "] can't update repo with id " + repo.getId()); } //only the repo manager can update the owner of a repo. //make sure that's the case. repo.setOwner(subject); } // HHH-2864 - Leave this in until we move to hibernate > 3.2.r14201-2 getRepo(subject, repo.getId()); // should we check non-null repo relationships and warn that we aren't changing them? log.debug("User [" + subject + "] is updating [" + repo + "]..."); repo = entityManager.merge(repo); log.debug("User [" + subject + "] updated [" + repo + "]."); try { ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer(); pc.unscheduleRepoSyncJob(repo); pc.scheduleRepoSyncJob(repo); } catch (Exception e) { log.warn("Failed to reschedule repository synchronization job for [" + repo + "].", e); } return repo; }
@RequiredPermission(Permission.MANAGE_REPOSITORIES) public void mergeRepoImportResults(List<RepoDetails> repos) { Subject overlord = subjectManager.getOverlord(); for (RepoDetails createMe : repos) { String repoName = createMe.getName(); // Make sure the repo doesn't already exist. If we add twice, currently we'll get an exception List<Repo> existingRepo = repoManager.getRepoByName(repoName); if (existingRepo != null) { continue; } Repo repo = new Repo(repoName); repo.setCandidate(false); repo.setDescription(createMe.getDescription()); try { repoManager.createRepo(overlord, repo); } catch (RepoException e) { log.error("Error creating repo [" + repo + "]", e); } } }
Repo repo = new Repo(name); repo.setCandidate(false); repo.setSyncSchedule(null);
/** * Directly subscribe the resource to a repo. * * @param repo * * @return the mapping that was added */ public ResourceRepo addRepo(Repo repo) { if (this.resourceRepos == null) { this.resourceRepos = new HashSet<ResourceRepo>(1); } ResourceRepo mapping = new ResourceRepo(this, repo); this.resourceRepos.add(mapping); repo.addResource(this); return mapping; }
/** * Removes the repo as one that this package version is related to. The mapping that was removed is returned; if * the given package version was not a member of the repo, <code>null</code> is returned. * * @param repo * * @return the mapping that was removed or <code>null</code> if this package version was not mapped to the given * repo */ public RepoPackageVersion removeRepo(Repo repo) { if ((this.repoPackageVersions == null) || (repo == null)) { return null; } RepoPackageVersion doomed = null; for (RepoPackageVersion cpv : this.repoPackageVersions) { if (repo.equals(cpv.getRepoPackageVersionPK().getRepo())) { doomed = cpv; repo.removePackageVersion(this); break; } } if (doomed != null) { this.repoPackageVersions.remove(doomed); } return doomed; }
ResourceRepo mapping = repo.removeResource(resource); entityManager.remove(mapping);