diff options
author | Angel Avila | 2015-03-19 21:41:20 +0000 |
---|---|---|
committer | Angel Avila | 2015-03-19 21:41:20 +0000 |
commit | a27232fef83da17dab042d101efcf5f2d5f52859 (patch) | |
tree | 51695070608f78c6c5224c3162552d92ec2a10d4 /plugins/org.eclipse.osee.orcs.account.admin | |
parent | e964ad8eaf2706ee3436f6d76c58ec51741eba20 (diff) | |
download | org.eclipse.osee-a27232fef83da17dab042d101efcf5f2d5f52859.tar.gz org.eclipse.osee-a27232fef83da17dab042d101efcf5f2d5f52859.tar.xz org.eclipse.osee-a27232fef83da17dab042d101efcf5f2d5f52859.zip |
feature[ats_ATS179688]: Provide Anonymous Principal through JAX-RS
Change-Id: I7f0fd465e59a723b188641c7443a15c680c1d13f
Signed-off-by: Angel Avila <angel.avila2@boeing.com>
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.account.admin')
3 files changed, 103 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java index 32d078677fe..a7f0159f736 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java @@ -15,6 +15,7 @@ import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.ApplicationContext; +import org.eclipse.osee.orcs.OrcsAdmin; import org.eclipse.osee.orcs.OrcsApi; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.search.QueryBuilder; @@ -97,4 +98,9 @@ public abstract class AbstractOrcsStorage { return transactionFactory.createTransaction(getBranch(), getSystemUser(), comment); } + protected boolean isInitialized() { + OrcsAdmin adminOps = orcsApi.getAdminOps(context); + return adminOps.isDataStoreInitialized(); + } + } diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java new file mode 100644 index 00000000000..ad974bb355b --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2015 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.orcs.account.admin.internal; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import org.eclipse.osee.account.admin.Account; +import org.eclipse.osee.account.admin.AccountPreferences; +import org.eclipse.osee.framework.core.enums.SystemUser; +import org.eclipse.osee.framework.jdk.core.type.BaseIdentity; + +/** + * @author Roberto E. Escobar + */ +public class BootstrapAccount extends BaseIdentity<String> implements Account, AccountPreferences { + + public BootstrapAccount() { + super(SystemUser.BootStrap.getGuid()); + } + + @Override + public long getId() { + return -1L; + } + + @Override + public boolean isActive() { + return SystemUser.BootStrap.isActive(); + } + + @Override + public String getName() { + return SystemUser.BootStrap.getName(); + } + + @Override + public String getUserName() { + return SystemUser.BootStrap.getUserId(); + } + + @Override + public String getEmail() { + return SystemUser.BootStrap.getEmail(); + } + + @Override + public AccountPreferences getPreferences() { + return this; + } + + @Override + public Map<String, String> asMap() { + return Collections.emptyMap(); + } + + @Override + public Set<String> getKeys() { + return Collections.emptySet(); + } + + @Override + public String get(String key) { + return ""; + } + + @Override + public boolean getBoolean(String key) { + return false; + } + +} diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java index c3f47d62cdb..bc82b485627 100644 --- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java +++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java @@ -21,11 +21,13 @@ import org.eclipse.osee.account.admin.CreateAccountRequest; import org.eclipse.osee.account.admin.ds.AccountStorage; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.jdk.core.type.Identifiable; import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.framework.jdk.core.type.ResultSet; +import org.eclipse.osee.framework.jdk.core.type.ResultSets; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.jdbc.JdbcService; import org.eclipse.osee.orcs.data.ArtifactId; @@ -40,6 +42,7 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt private JdbcService jdbcService; private AccountSessionStorage sessionStore; + private Account bootstrapAccount; public void setJdbcService(JdbcService jdbcService) { this.jdbcService = jdbcService; @@ -50,6 +53,7 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt super.start(); JdbcClient jdbcClient = jdbcService.getClient(); sessionStore = new AccountSessionDatabaseStore(getLogger(), jdbcClient, getFactory()); + bootstrapAccount = new BootstrapAccount(); } @Override @@ -229,4 +233,17 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt } } + @Override + public ResultSet<Account> getAnonymousAccount() { + ResultSet<Account> toReturn; + if (isInitialized()) { + ResultSet<ArtifactReadable> results = + newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(SystemUser.Anonymous.getGuid()).getResults(); + toReturn = getFactory().newAccountResultSet(results); + } else { + toReturn = ResultSets.singleton(bootstrapAccount); + } + return toReturn; + } + } |