Skip to content

Commit

Permalink
Refactoring of authentication and authorization, created API and
Browse files Browse the repository at this point in the history
provided extension points
  • Loading branch information
edgarmueller committed Feb 11, 2015
1 parent 14c7a17 commit 6c54edf
Show file tree
Hide file tree
Showing 93 changed files with 5,707 additions and 4,123 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2012-2013 EclipseSource Muenchen GmbH and others.
*
*
* 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:
* Otto von Wesendonk, Edgar Mueller - initial API and implementation
******************************************************************************/
Expand Down Expand Up @@ -63,7 +63,7 @@

/**
* Represents a remote project that is located on a remote server.
*
*
* @author wesendon
* @author emueller
*/
Expand All @@ -77,7 +77,7 @@ public class ESRemoteProjectImpl implements ESRemoteProject {

/**
* Constructor.
*
*
* @param serverInfo
* the server the remote project is located on
* @param projectInfo
Expand All @@ -89,9 +89,9 @@ public ESRemoteProjectImpl(ServerInfo serverInfo, ProjectInfo projectInfo) {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#getGlobalProjectId()
*/
public ESGlobalProjectId getGlobalProjectId() {
Expand All @@ -103,9 +103,9 @@ public ESGlobalProjectId call() throws Exception {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#getProjectName()
*/
public String getProjectName() {
Expand All @@ -117,9 +117,9 @@ public String call() throws Exception {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#getBranches(org.eclipse.core.runtime.IProgressMonitor)
*/
public List<ESBranchInfo> getBranches(IProgressMonitor monitor) throws ESException {
Expand All @@ -141,9 +141,9 @@ protected List<BranchInfo> run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#getBranches(org.eclipse.emf.emfstore.client.ESUsersession,
* org.eclipse.core.runtime.IProgressMonitor)
*/
Expand All @@ -159,9 +159,9 @@ protected List<BranchInfo> run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#resolveVersionSpec(org.eclipse.emf.emfstore.server.model.versionspec.ESVersionSpec,
* org.eclipse.core.runtime.IProgressMonitor)
*/
Expand All @@ -183,9 +183,9 @@ protected PrimaryVersionSpec run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#resolveVersionSpec(org.eclipse.emf.emfstore.client.ESUsersession,
* org.eclipse.emf.emfstore.server.model.versionspec.ESVersionSpec, org.eclipse.core.runtime.IProgressMonitor)
*/
Expand All @@ -208,19 +208,19 @@ protected PrimaryVersionSpec run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#getHistoryInfos(org.eclipse.emf.emfstore.server.model.query.ESHistoryQuery,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public List<ESHistoryInfo> getHistoryInfos(final ESHistoryQuery<? extends ESHistoryQuery<?>> query,
IProgressMonitor monitor)
throws ESException {
throws ESException {

@SuppressWarnings("unchecked")
final ESHistoryQueryImpl<ESHistoryQuery<? extends ESHistoryQuery<?>>, ?> queryImpl =
(ESHistoryQueryImpl<ESHistoryQuery<? extends ESHistoryQuery<?>>, ?>) query;
(ESHistoryQueryImpl<ESHistoryQuery<? extends ESHistoryQuery<?>>, ?>) query;

return APIUtil.mapToAPI(ESHistoryInfo.class, new ServerCall<List<HistoryInfo>>(getServerInfo(), monitor) {
@Override
Expand All @@ -234,15 +234,15 @@ protected List<HistoryInfo> run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#getHistoryInfos(org.eclipse.emf.emfstore.client.ESUsersession,
* org.eclipse.emf.emfstore.server.model.query.ESHistoryQuery, org.eclipse.core.runtime.IProgressMonitor)
*/
public List<ESHistoryInfo> getHistoryInfos(final ESUsersession session,
final ESHistoryQuery<? extends ESHistoryQuery<?>> query,
final IProgressMonitor monitor) throws ESException {
final IProgressMonitor monitor) throws ESException {

return RunESCommand.WithException.runWithResult(ESException.class, new Callable<List<ESHistoryInfo>>() {
public List<ESHistoryInfo> call() throws Exception {
Expand All @@ -267,16 +267,16 @@ protected List<HistoryInfo> run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#addTag(org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec,
* org.eclipse.emf.emfstore.server.model.versionspec.ESTagVersionSpec,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void addTag(final ESPrimaryVersionSpec primaryVersionSpec, final ESTagVersionSpec tagVersionSpec,
final IProgressMonitor monitor)
throws ESException {
throws ESException {

final ESPrimaryVersionSpecImpl primaryVersionSpecImpl = (ESPrimaryVersionSpecImpl) primaryVersionSpec;
final ESTagVersionSpecImpl tagVersionSpecImpl = (ESTagVersionSpecImpl) tagVersionSpec;
Expand All @@ -299,16 +299,16 @@ protected Void run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESProject#removeTag(org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec,
* org.eclipse.emf.emfstore.server.model.versionspec.ESTagVersionSpec,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void removeTag(final ESPrimaryVersionSpec versionSpec, final ESTagVersionSpec tag,
final IProgressMonitor monitor)
throws ESException {
throws ESException {

final ESPrimaryVersionSpecImpl versionSpecImpl = (ESPrimaryVersionSpecImpl) versionSpec;
final ESTagVersionSpecImpl tagVersionSpecImpl = (ESTagVersionSpecImpl) tag;
Expand All @@ -333,9 +333,9 @@ protected Void run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#checkout(java.lang.String,
* org.eclipse.core.runtime.IProgressMonitor)
*/
Expand All @@ -354,15 +354,15 @@ protected ESLocalProjectImpl run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#checkout(java.lang.String,
* org.eclipse.emf.emfstore.client.ESUsersession, org.eclipse.core.runtime.IProgressMonitor)
*/
public ESLocalProjectImpl checkout(final String name, final ESUsersession usersession,
final IProgressMonitor monitor)
throws ESException {
throws ESException {
return RunESCommand.WithException.runWithResult(ESException.class, new Callable<ESLocalProjectImpl>() {
public ESLocalProjectImpl call() throws Exception {
final ESPrimaryVersionSpec primaryVersionSpec = resolveVersionSpec(usersession, Versions.createHEAD()
Expand All @@ -373,9 +373,9 @@ public ESLocalProjectImpl call() throws Exception {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#fetch(java.lang.String,
* org.eclipse.emf.emfstore.client.ESUsersession,
* org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec,
Expand Down Expand Up @@ -424,21 +424,21 @@ protected Project run() throws ESException {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#checkout(java.lang.String,
* org.eclipse.emf.emfstore.client.ESUsersession,
* org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public ESLocalProjectImpl checkout(final String name, final ESUsersession session,
final ESPrimaryVersionSpec versionSpec, final IProgressMonitor progressMonitor)
throws ESException {
throws ESException {
final ESLocalProjectImpl project = fetch(name, session, versionSpec, progressMonitor);
project.addToWorkspace(progressMonitor);
ESWorkspaceProviderImpl.getObserverBus().notify(ESCheckoutObserver.class)
.checkoutDone(project);
.checkoutDone(project);

return project;
}
Expand Down Expand Up @@ -467,27 +467,27 @@ private ProjectSpace initProjectSpace(final Usersession usersession, final Proje
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#delete(org.eclipse.core.runtime.IProgressMonitor)
*/
public void delete(final IProgressMonitor monitor) throws ESException {
RunESCommand.WithException.run(ESException.class, new Callable<Void>() {
public Void call() throws Exception {
getDeleteProjectServerCall()
.setProgressMonitor(monitor)
.setServer(getServerInfo())
.execute();
.setProgressMonitor(monitor)
.setServer(getServerInfo())
.execute();
return null;
}
});
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#delete(org.eclipse.emf.emfstore.client.ESUsersession,
* org.eclipse.core.runtime.IProgressMonitor)
*/
Expand All @@ -496,18 +496,18 @@ public void delete(ESUsersession session, final IProgressMonitor monitor) throws
RunESCommand.WithException.run(ESException.class, new Callable<Void>() {
public Void call() throws Exception {
getDeleteProjectServerCall()
.setProgressMonitor(monitor)
.setUsersession(usersession)
.execute();
.setProgressMonitor(monitor)
.setUsersession(usersession)
.execute();
return null;
}
});
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#getServer()
*/
public ESServerImpl getServer() {
Expand All @@ -520,9 +520,9 @@ public ESServerImpl call() throws Exception {
}

/**
*
*
* {@inheritDoc}
*
*
* @see org.eclipse.emf.emfstore.client.ESRemoteProject#getHeadVersion(org.eclipse.core.runtime.IProgressMonitor)
*/
public ESPrimaryVersionSpec getHeadVersion(final IProgressMonitor monitor) throws ESException {
Expand All @@ -533,9 +533,10 @@ public ESPrimaryVersionSpec call() throws Exception {
});
}

private boolean canDeleteFiles(ACOrgUnit orgUnit, ProjectId projectId) {
private boolean canDeleteFiles(ACOrgUnit<?> orgUnit, ProjectId projectId) {

for (final Role role : orgUnit.getRoles()) {
final List<Role> roles = orgUnit.getRoles();
for (final Role role : roles) {
if (ServerAdmin.class.isInstance(role)) {
return true;
}
Expand Down Expand Up @@ -564,10 +565,10 @@ public Void run(IProgressMonitor monitor) throws ESException {

if (canDeleteFiles(user, getProjectInfo().getProjectId())) {
getConnectionManager()
.deleteProject(getSessionId(), getProjectInfo().getProjectId(), true);
.deleteProject(getSessionId(), getProjectInfo().getProjectId(), true);
} else {
getConnectionManager()
.deleteProject(getSessionId(), getProjectInfo().getProjectId(), false);
.deleteProject(getSessionId(), getProjectInfo().getProjectId(), false);
}
return null;
}
Expand All @@ -580,7 +581,7 @@ public Void run(IProgressMonitor monitor) throws ESException {

/**
* Returns the project info of this remote project.
*
*
* @return the project info of this remote project
*/
public ProjectInfo getProjectInfo() {
Expand All @@ -589,7 +590,7 @@ public ProjectInfo getProjectInfo() {

/**
* Returns the server info of this remote project.
*
*
* @return the server info of this remote project
*/
public ServerInfo getServerInfo() {
Expand Down
19 changes: 10 additions & 9 deletions bundles/org.eclipse.emf.emfstore.common/.classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/org.apache.commons.lang_2.4.0.v201005080502.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.0.1.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/com.google.guava_15.0.0.v201403281430.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.apache.commons.lang_2.4.0.v201005080502.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.0.1.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Loading

0 comments on commit 6c54edf

Please sign in to comment.