use of org.bimserver.interfaces.objects.SProfileDescriptor in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllLocalProfiles.
@Override
public List<SProfileDescriptor> getAllLocalProfiles(String serviceIdentifier) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
try {
SUser currentUser = getCurrentUser();
Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Token(), new StringLiteral(currentUser.getToken()));
User user = session.querySingle(condition, User.class, OldQuery.getDefault());
if (user != null) {
for (InternalServicePluginConfiguration internalServicePluginConfiguration : user.getUserSettings().getServices()) {
if (serviceIdentifier.equals("" + internalServicePluginConfiguration.getOid())) {
SProfileDescriptor sProfileDescriptor = new SProfileDescriptor();
descriptors.add(sProfileDescriptor);
sProfileDescriptor.setIdentifier("" + internalServicePluginConfiguration.getOid());
sProfileDescriptor.setName(internalServicePluginConfiguration.getName());
sProfileDescriptor.setDescription(internalServicePluginConfiguration.getDescription());
sProfileDescriptor.setPublicProfile(false);
}
}
}
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return descriptors;
}
use of org.bimserver.interfaces.objects.SProfileDescriptor in project BIMserver by opensourceBIM.
the class RemoteServiceImpl method getPrivateProfiles.
@Override
public List<SProfileDescriptor> getPrivateProfiles(String serviceIdentifier, String token) throws UserException, ServerException {
DatabaseSession session = getServiceMap().getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
try {
Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Token(), new StringLiteral(token));
User user = session.querySingle(condition, User.class, OldQuery.getDefault());
if (user != null) {
for (InternalServicePluginConfiguration internalServicePluginConfiguration : user.getUserSettings().getServices()) {
if (internalServicePluginConfiguration.getPluginDescriptor().getPluginClassName().equals(serviceIdentifier)) {
SProfileDescriptor sProfileDescriptor = new SProfileDescriptor();
descriptors.add(sProfileDescriptor);
sProfileDescriptor.setIdentifier("" + internalServicePluginConfiguration.getOid());
sProfileDescriptor.setName(internalServicePluginConfiguration.getName());
sProfileDescriptor.setDescription(internalServicePluginConfiguration.getDescription());
sProfileDescriptor.setPublicProfile(false);
}
}
}
} catch (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
return descriptors;
}
use of org.bimserver.interfaces.objects.SProfileDescriptor in project BIMserver by opensourceBIM.
the class RemoteServiceImpl method getPublicProfiles.
@Override
public List<SProfileDescriptor> getPublicProfiles(String serviceIdentifier) throws UserException, ServerException {
DatabaseSession session = getServiceMap().getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
try {
IfcModelInterface modelInterface = session.getAllOfType(StorePackage.eINSTANCE.getInternalServicePluginConfiguration(), OldQuery.getDefault());
for (InternalServicePluginConfiguration internalServicePluginConfiguration : modelInterface.getAll(InternalServicePluginConfiguration.class)) {
if (internalServicePluginConfiguration.isPublicProfile()) {
if (serviceIdentifier.equals("" + internalServicePluginConfiguration.getOid())) {
SProfileDescriptor sProfileDescriptor = new SProfileDescriptor();
descriptors.add(sProfileDescriptor);
sProfileDescriptor.setIdentifier("" + internalServicePluginConfiguration.getOid());
sProfileDescriptor.setName(internalServicePluginConfiguration.getName());
sProfileDescriptor.setDescription(internalServicePluginConfiguration.getDescription());
sProfileDescriptor.setPublicProfile(false);
}
}
}
} catch (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
return descriptors;
}
Aggregations