Skip to content

Commit

Permalink
Merge pull request #160 from openworm/development
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
tarelli authored May 13, 2019
2 parents 7590220 + 54729c4 commit 208d4c8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.geppetto</groupId>
<artifactId>core</artifactId>
<name>Geppetto Core Bundle</name>
<version>0.4.2</version>
<version>1.0.0</version>
<packaging>bundle</packaging>
<properties>
<github.global.server>github</github.global.server>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/META-INF/spring/app-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@
<property name="simulatorName" value="Collada Simulator" />
<property name="simulatorID" value="colladaSimulator" />
</bean>
<bean id="localUserConfig" class="org.geppetto.core.beans.LocalUserConfig">
<property name="guestUserPermissions">
<list>
<value>READ_PROJECT</value>
<value>DOWNLOAD</value>
</list>
</property>
</bean>
</beans>
24 changes: 24 additions & 0 deletions src/main/java/org/geppetto/core/beans/LocalUserConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

package org.geppetto.core.beans;

import java.util.List;

/**
* @author Jesus Martinez ([email protected])
*
*/
public class LocalUserConfig
{

private List<String> guestUserPermissions;

public List<String> getGuestUserPermissions()
{
return this.guestUserPermissions;
}

public void setGuestUserPermissions(List<String> guestUserPermissions)
{
this.guestUserPermissions = guestUserPermissions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;

import org.geppetto.core.beans.LocalUserConfig;
import org.geppetto.core.common.GeppettoExecutionException;
import org.geppetto.core.data.model.ExperimentStatus;
import org.geppetto.core.data.model.IAspectConfiguration;
Expand All @@ -43,6 +44,7 @@
import org.geppetto.core.data.model.local.LocalUserGroup;
import org.geppetto.core.data.model.local.LocalView;
import org.geppetto.core.utilities.LocalViewSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;

import com.google.gson.Gson;
Expand All @@ -58,6 +60,9 @@ public class DefaultGeppettoDataManager implements IGeppettoDataManager
private static IUserGroup userGroup = null;

private volatile static int guestId;

@Autowired
private LocalUserConfig localUserConfig;

public DefaultGeppettoDataManager()
{
Expand Down Expand Up @@ -106,8 +111,8 @@ public boolean isDefault()
@Override
public IUser getUserByLogin(String login)
{
List<UserPrivileges> privileges = Arrays.asList(UserPrivileges.READ_PROJECT, UserPrivileges.DOWNLOAD);
IUserGroup group = new LocalUserGroup("guest", privileges, 0, 0);

IUserGroup group = new LocalUserGroup("guest", getUserPrivileges(), 0, 0);
IUser user = new LocalUser(1, login, login, login, login, new ArrayList<LocalGeppettoProject>(), group);

return user;
Expand Down Expand Up @@ -252,8 +257,7 @@ public IUser newUser(String name, String password, boolean persistent, IUserGrou

if(group == null)
{
List<UserPrivileges> privileges = Arrays.asList(UserPrivileges.READ_PROJECT, UserPrivileges.DOWNLOAD);
group = new LocalUserGroup("guest", privileges, 0, 0);
group = new LocalUserGroup("guest", getUserPrivileges(), 0, 0);
}

return new LocalUser(0, name, password, name, name, list, group);
Expand Down Expand Up @@ -467,6 +471,17 @@ private static IUserGroup getUserGroup()
}
return userGroup;
}

private List<UserPrivileges> getUserPrivileges()
{
List<String> permissions = this.localUserConfig.getGuestUserPermissions();
List<UserPrivileges> privileges = new ArrayList<UserPrivileges>();
for(int i=0; i< permissions.size(); i++){
privileges.add(UserPrivileges.valueOf(permissions.get(i)));
}

return privileges;
}

@Override
public void makeGeppettoProjectPublic(long projectId, boolean isPublic) throws GeppettoExecutionException
Expand Down

0 comments on commit 208d4c8

Please sign in to comment.