use of org.bimserver.interfaces.objects.SServiceDescriptor in project BIMserver by opensourceBIM.
the class ServiceImpl method sort.
@SuppressWarnings("unchecked")
private List<SServiceDescriptor> sort(List<SServiceDescriptor> sServiceDescriptors) {
ComparatorChain comparatorChain = new ComparatorChain();
comparatorChain.addComparator(new Comparator<SServiceDescriptor>() {
@Override
public int compare(SServiceDescriptor o1, SServiceDescriptor o2) {
return o1.getProviderName().compareTo(o2.getProviderName());
}
});
comparatorChain.addComparator(new Comparator<SServiceDescriptor>() {
@Override
public int compare(SServiceDescriptor o1, SServiceDescriptor o2) {
return o1.getName().compareTo(o2.getName());
}
});
Collections.sort(sServiceDescriptors, comparatorChain);
return sServiceDescriptors;
}
use of org.bimserver.interfaces.objects.SServiceDescriptor in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllServiceDescriptors.
@Override
public List<SServiceDescriptor> getAllServiceDescriptors() throws ServerException, UserException {
requireRealUserAuthentication();
try {
List<SServiceDescriptor> sServiceDescriptors = new ArrayList<SServiceDescriptor>();
URL url = new URL(getServiceMap().get(SettingsInterface.class).getServiceRepositoryUrl() + "/services.json");
String content = NetUtils.getContent(url, 5000);
JSONObject root = new JSONObject(new JSONTokener(content));
JSONArray services = root.getJSONArray("services");
for (int i = 0; i < services.length(); i++) {
JSONObject service = services.getJSONObject(i);
SServiceDescriptor sServiceDescriptor = new SServiceDescriptor();
sServiceDescriptor.setName(service.getString("name"));
sServiceDescriptor.setIdentifier(service.getString("identifier"));
sServiceDescriptor.setDescription(service.getString("description"));
sServiceDescriptor.setNotificationProtocol(SAccessMethod.valueOf(service.getString("notificationProtocol")));
sServiceDescriptor.setTrigger(STrigger.valueOf(service.getString("trigger")));
sServiceDescriptor.setUrl(service.getString("url"));
sServiceDescriptor.setCompanyUrl(service.getString("companyUrl"));
sServiceDescriptor.setTokenUrl(service.getString("tokenUrl"));
sServiceDescriptor.setNewProfileUrl(service.getString("newProfileUrl"));
sServiceDescriptor.setProviderName(service.getString("providerName"));
sServiceDescriptor.setRegisterUrl(service.getString("registerUrl"));
sServiceDescriptor.setAuthorizeUrl(service.getString("authorizeUrl"));
JSONObject rights = service.getJSONObject("rights");
sServiceDescriptor.setReadRevision(rights.has("readRevision") && rights.getBoolean("readRevision"));
sServiceDescriptor.setReadExtendedData(rights.has("readExtendedData") ? rights.getString("readExtendedData") : null);
sServiceDescriptor.setWriteRevision(rights.has("writeRevision") && rights.getBoolean("writeRevision"));
sServiceDescriptor.setWriteExtendedData(rights.has("writeExtendedData") ? rights.getString("writeExtendedData") : null);
sServiceDescriptors.add(sServiceDescriptor);
}
sort(sServiceDescriptors);
return sServiceDescriptors;
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.interfaces.objects.SServiceDescriptor in project BIMserver by opensourceBIM.
the class ServiceImpl method getServiceDescriptor.
@Override
public SServiceDescriptor getServiceDescriptor(String baseUrl, String serviceIdentifier) throws ServerException, UserException {
requireRealUserAuthentication();
try {
try (BimServerClientFactory factory = new JsonBimServerClientFactory(baseUrl, getBimServer().getServicesMap(), getBimServer().getJsonSocketReflectorFactory(), getBimServer().getReflectorFactory(), getBimServer().getMetaDataManager())) {
BimServerClientInterface client = factory.create();
SServiceDescriptor service = client.getRemoteServiceInterface().getService(serviceIdentifier);
if (service == null) {
throw new UserException("No service found with identifier " + serviceIdentifier);
}
service.setUrl(baseUrl);
return service;
}
} catch (Exception e) {
return handleException(e);
}
}
Aggregations