@Override public void computeAccess( IAccessContextId contextId, Collection<Object> objectsToCheck, AccessData accessData) throws OseeCoreException { Conditions.checkNotNull(contextId, "contextId"); Conditions.checkNotNull(objectsToCheck, "objectsToCheck"); Conditions.checkNotNull(accessData, "accessData"); OseeDsl oseeDsl = dslProvider.getDsl(); Conditions.checkNotNull(oseeDsl, "oseeDsl", "dsl provider returned null"); Collection<AccessContext> contexts = oseeDsl.getAccessDeclarations(); AccessContext context = interpreter.getContext(contexts, contextId); Conditions.checkNotNull( context, "interpreted accessContext", "No matching access context was found in access dsl for [%s]", contextId); for (Object objectToCheck : objectsToCheck) { List<AccessDetail<?>> accessDetail = new LinkedList<AccessDetail<?>>(); AccessDetailCollector collector = new AccessDataCollector(accessDetail); interpreter.computeAccessDetails(collector, context, objectToCheck); accessData.addAll(objectToCheck, accessDetail); } }
@Override public AccessContext getContext(Collection<AccessContext> contexts, IAccessContextId contextId) throws OseeCoreException { Conditions.checkNotNull(contexts, "accessContext collection"); Conditions.checkNotNull(contextId, "accessContextId"); AccessContext toReturn = null; for (AccessContext accessContext : contexts) { if (contextId.getGuid().equals(Strings.unquote(accessContext.getGuid()))) { toReturn = accessContext; } } return toReturn; }
@Override public void run() throws OseeCoreException { Conditions.checkNotNull(configuration, "DbInitConfiguration Info"); OseeClientProperties.setInDbInit(true); createOseeDatastore(); Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.skynet.core"); int state = bundle.getState(); if (state != Bundle.ACTIVE) { try { bundle.start(); } catch (BundleException ex) { throw new OseeCoreException(ex); } } IOseeCachingService service = DatabaseInitActivator.getInstance().getCachingService(); service.clearAll(); IOseeDatabaseService databaseService = DatabaseInitActivator.getInstance().getDatabaseService(); databaseService.getSequence().clear(); IdentityService identityService = DatabaseInitActivator.getInstance().getIdentityService(); identityService.clear(); Branch systemRoot = BranchManager.getSystemRootBranch(); Conditions.checkNotNull(systemRoot, "System root was not created - "); ClientSessionManager.releaseSession(); ClientSessionManager.authenticate( new BaseCredentialProvider() { @Override public OseeCredential getCredential() { OseeCredential credential = super.getCredential(); credential.setUserName(SystemUser.BootStrap.getName()); return credential; } }); List<String> oseeTypes = configuration.getOseeTypeExtensionIds(); Conditions.checkExpressionFailOnTrue(oseeTypes.isEmpty(), "osee types cannot be empty"); OseeTypesSetup oseeTypesSetup = new OseeTypesSetup(); oseeTypesSetup.execute(oseeTypes); service.clearAll(); }
@Override public void removeSupportedVersion(String version) throws OseeCoreException { Conditions.checkNotNull(version, "Osee Version"); Conditions.checkExpressionFailOnTrue( defaultVersions.contains(version), "Unable to remove default Osee version [%s]", version); OseeServerInfoMutable info = getApplicationServerInfo(); refreshData(info); Set<String> versions = info.getVersionSet(); boolean wasRemoved = versions.remove(version); if (wasRemoved) { info.setVersions(versions); dataStore.update(Collections.singleton(info)); } else { throw new OseeStateException("Not part of the supported version [%s]", version); } }
@Override public void addSupportedVersion(String version) throws OseeCoreException { Conditions.checkNotNull(version, "Osee Version"); OseeServerInfoMutable info = getApplicationServerInfo(); refreshData(info); info.addVersion(version); dataStore.update(Collections.singleton(info)); }
@Override public void computeAccessDetails( AccessDetailCollector collector, AccessContext context, Object objectToCheck) throws OseeCoreException { Conditions.checkNotNull(collector, "accessDetailCollector"); Conditions.checkNotNull(context, "accessContext"); Conditions.checkNotNull(objectToCheck, "objectToCheck"); if (provider.isApplicable(objectToCheck)) { ArtifactProxy data = provider.asCastedObject(objectToCheck); Conditions.checkNotNull( data, "artifactData", "artifact data provider returned null - provider has an isApplicable error"); collectApplicable(collector, context, data); } }
@Override protected ReadableBranch innerCall() throws Exception { Conditions.checkNotNull(branchToken, "branch"); Conditions.checkNotNull(branchType, "branchType"); Branch branch = cache.get(branchToken); Conditions.checkNotNull(branch, "branch"); BranchType original = branch.getBranchType(); try { branch.setBranchType(branchType); cache.storeItems(branch); } catch (Exception ex) { branch.setBranchType(original); throw ex; } finally { // TODO Event ? } return branch; }
/** * Overwrite current relations of type side with new atsObject artifact. Artifacts must already * exist in system for this method to work. Persist must be done outside this method * * @return collection of artifacts that were related */ protected Collection<Artifact> setRelationsOfType( AtsArtifactConfigCache cache, Artifact artifact, Collection<? extends IAtsObject> atsObjects, IRelationTypeSide side) throws OseeCoreException { Conditions.checkNotNull(artifact, "artifact"); List<Artifact> newArts = new ArrayList<Artifact>(); for (IAtsObject version : atsObjects) { Artifact verArt = cache.getSoleArtifact(version); newArts.add(verArt); } artifact.setRelations(side, newArts); return newArts; }
public void start() throws Exception { defaultVersions.clear(); String[] userSpecifiedVersion = OseeServerProperties.getOseeVersion(); if (Conditions.hasValues(userSpecifiedVersion)) { for (String version : userSpecifiedVersion) { defaultVersions.add(version); } } else { defaultVersions.add(OseeCodeVersion.getVersion()); } dataStore = new ApplicationServerDataStore(getLogger(), getDatabaseService()); serverInfo = createOseeServerInfo(getLogger(), dataStore, defaultVersions); timer = new Timer(); timer.schedule( new TimerTask() { @Override public void run() { if (isDbInitialized()) { try { boolean wasRegistered = executeLookupRegistration(); setServletRequestsAllowed(wasRegistered); } catch (Exception ex) { getLogger().error(ex, "Error during lookup registration"); } finally { timer.cancel(); } } else { setServletRequestsAllowedNoDbUpdate(true); } } private boolean isDbInitialized() { boolean result = false; try { String id = OseeInfo.getDatabaseGuid(); if (Strings.isValid(id)) { result = true; } } catch (Exception ex) { // Do nothing - no need to log exception } return result; } }, 5 * 1000); }
@Override protected void doWork(IProgressMonitor monitor) throws Exception { Branch startBranch = uiData.getTxDelta().getStartTx().getBranch(); Branch otherBranch = branchProvider.getBranch(monitor); checkForCancelledStatus(monitor); Conditions.checkNotNull(otherBranch, "other branch to compare to"); TransactionRecord startTx = TransactionManager.getHeadTransaction(startBranch); TransactionRecord endTx = TransactionManager.getHeadTransaction(otherBranch); TransactionDelta txDelta = new TransactionDelta(startTx, endTx); uiData.setTxDelta(txDelta); Branch mergeBranch = BranchManager.getMergeBranch(startBranch, otherBranch, true); uiData.setMergeBranch(mergeBranch); if (otherBranch.equals(startBranch.getParentBranch())) { uiData.setCompareType(CompareType.COMPARE_CURRENTS_AGAINST_PARENT); } else { uiData.setCompareType(CompareType.COMPARE_CURRENTS_AGAINST_OTHER_BRANCH); } }