use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class AbstractSolutionTest method buildSolution.
@Before
public void buildSolution() throws Exception {
TestNGClient.initSettings();
Types.getTypesInstance().registerTypes();
final File f = new File(NGClient.class.getProtectionDomain().getCodeSource().getLocation().getPath());
IPackageReader[] servicesReaders = null;
IPackageReader[] componentsReaders = null;
InMemPackageReader inMemPackageReader = getTestComponents();
if (f.isFile() && f.getName().startsWith("servoy_ngclient") && f.getName().endsWith(".jar")) {
// it is running from bundles/jars
ZipFile zipFile = new ZipFile(f);
componentsReaders = inMemPackageReader != null ? new IPackageReader[] { new ZipPackageReader(zipFile, "war/servoycore/"), new ZipPackageReader(zipFile, "war/servoydefault/"), inMemPackageReader } : new IPackageReader[] { new ZipPackageReader(zipFile, "war/servoycore/"), new ZipPackageReader(zipFile, "war/servoydefault/") };
servicesReaders = new IPackageReader[] { new ZipPackageReader(zipFile, "war/servoyservices/") };
} else {
// it is running from sources/projects
File ngClientProjDir = f;
if (!new File(ngClientProjDir, "/war/servoycore/").exists()) {
ngClientProjDir = ngClientProjDir.getParentFile();
}
componentsReaders = getReaders(new File[] { new File(ngClientProjDir.getAbsoluteFile() + "/war/servoycore/"), new File(ngClientProjDir.getAbsoluteFile() + "/war/servoydefault/") }, // in eclipse we .. out of bin, in jenkins we .. out of @dot
inMemPackageReader);
servicesReaders = getReaders(new File[] { new File(ngClientProjDir.getAbsoluteFile(), "/war/servoyservices/") }, null);
}
WebComponentSpecProvider.init(componentsReaders, DefaultComponentPropertiesProvider.instance);
WebServiceSpecProvider.init(servicesReaders);
final TestRepository tr = new TestRepository();
try {
ApplicationServerRegistry.setApplicationServerSingleton(new TestApplicationServer(tr));
UUID uuid = UUID.randomUUID();
final RootObjectMetaData metadata = tr.createRootObjectMetaData(tr.getElementIdForUUID(uuid), uuid, "Test", IRepository.SOLUTIONS, 1, 1);
solution = (Solution) tr.createRootObject(metadata);
tr.cacheRootObject(solution);
solution.setChangeHandler(new ChangeHandler(tr));
fillTestSolution();
HttpSession testHttpsession = new TestHttpsession();
endpoint = new NGClientEndpoint() {
// for testing onstart of the NGClientEndpoint should not run
@Override
public void onStart() {
}
@Override
protected HttpSession getHttpSession(Session session) {
return testHttpsession;
}
};
NGClientWebsocketSession session = new NGClientWebsocketSession(new WebsocketSessionKey(testHttpsession.getId(), 1)) {
@Override
public void init(Map<String, List<String>> requestParams) throws Exception {
// override default init, shouldnt make another client.
}
@Override
protected IEventDispatcher createEventDispatcher() {
return new TestNGEventDispatcher(endpoint);
}
};
WebsocketSessionManager.addSession(session);
NGClientWebsocketSessionWindows windows = new NGClientWebsocketSessionWindows(session);
CurrentWindow.set(windows);
client = new TestNGClient(tr, session) {
@Override
public boolean loadSolutionsAndModules(SolutionMetaData solutionMetaData) {
boolean b = super.loadSolutionsAndModules(solutionMetaData);
IPersistIndex index = PersistIndexCache.getCachedIndex(solution);
solution.getChangeHandler().addIPersistListener((IItemChangeListener<IPersist>) index);
try {
setupData();
} catch (ServoyException e) {
e.printStackTrace();
}
return b;
}
};
J2DBGlobals.setServiceProvider(client);
client.setUseLoginSolution(false);
endpoint.start(new TestSession(), String.valueOf(session.getSessionKey().getClientnr()), "null", "42");
CurrentWindow.set(session.getWindows().iterator().next());
} catch (RepositoryException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class FlattenedSolution method getDataproviderLookup.
public IDataProviderLookup getDataproviderLookup(IFoundSetManagerInternal foundSetManager, final IPersist p) {
IDataProviderLookup retval = null;
synchronized (this) {
if (dataProviderLookups == null)
dataProviderLookups = new HashMap<IPersist, IDataProviderLookup>();
retval = dataProviderLookups.get(p);
if (retval != null)
return retval;
}
if (p instanceof Form) {
ITable t = null;
try {
if (foundSetManager == null) {
t = getTable(((Form) p).getDataSource());
} else {
t = foundSetManager.getTable(((Form) p).getDataSource());
}
} catch (RepositoryException e) {
Debug.error(e);
}
retval = new FormAndTableDataProviderLookup(this, (Form) p, t);
} else if (p instanceof Portal) {
ITable t = null;
Relation[] relations = getRelationSequence(((Portal) p).getRelationName());
if (relations == null) {
return null;
}
t = getTable(relations[relations.length - 1].getForeignDataSource());
retval = new FormAndTableDataProviderLookup(this, (Form) p.getParent(), t);
} else // solution
{
retval = new IDataProviderLookup() {
public IDataProvider getDataProvider(String id) throws RepositoryException {
return getGlobalDataProvider(id);
}
public Table getTable() throws RepositoryException {
return null;
}
};
}
synchronized (this) {
dataProviderLookups.put(p, retval);
}
return retval;
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class FlattenedSolution method setSolution.
public void setSolution(SolutionMetaData sol, boolean loadLoginSolution, boolean loadMainSolution, IActiveSolutionHandler activeSolutionHandler) throws RepositoryException, RemoteException {
// $NON-NLS-1$
if (sol == null)
throw new IllegalArgumentException("use close method!");
isLoadingSolution = true;
try {
copySolution = null;
persistFactory = null;
mainSolution = null;
user_created_styles = null;
all_styles = null;
if (index != null) {
index.destroy();
index = null;
}
mainSolutionMetaData = sol;
if (loadLoginSolution) {
// get login solution
Solution[] loginSolutionAndModules = activeSolutionHandler.loadLoginSolutionAndModules(mainSolutionMetaData);
if (loginSolutionAndModules != null && loginSolutionAndModules.length > 0) {
if (loginFlattenedSolution == null) {
loginFlattenedSolution = new ExtendsConfiguratingFlattenedSolution();
}
loginFlattenedSolution.setSolutionAndModules(loginSolutionAndModules[0].getName(), loginSolutionAndModules);
loginFlattenedSolution.setParentSolution(this);
}
}
// get regular solution if available
if (// local or already access to repository
loadMainSolution && activeSolutionHandler.haveRepositoryAccess()) {
// Note: referencedModules includes main solution
List<RootObjectReference> referencedModules = activeSolutionHandler.getRepository().getActiveSolutionModuleMetaDatas(mainSolutionMetaData.getRootObjectId());
if (referencedModules != null && referencedModules.size() != 0) {
List<RootObjectMetaData> solutionAndModuleMetaDatas = new ArrayList<RootObjectMetaData>();
for (RootObjectReference moduleReference : referencedModules) {
RootObjectMetaData moduleMetaData = moduleReference.getMetaData();
if (moduleMetaData == null) {
// $NON-NLS-1$
throw new RepositoryException(Messages.getString("servoy.client.module.notfound", new Object[] { moduleReference.toString() }));
}
solutionAndModuleMetaDatas.add(moduleMetaData);
}
Solution[] mods = activeSolutionHandler.loadActiveSolutions(solutionAndModuleMetaDatas.toArray(new RootObjectMetaData[solutionAndModuleMetaDatas.size()]));
setSolutionAndModules(mainSolutionMetaData.getName(), mods);
}
}
} finally {
isLoadingSolution = false;
}
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class ClientState method selectSolutionToLoad.
protected SolutionMetaData selectSolutionToLoad() throws RepositoryException {
// get a list from the server to choose from
int solutionTypeFilter = getSolutionTypeFilter();
if (getPreferedSolutionNameToLoadOnInit() != null) {
try {
SolutionMetaData startSolution = applicationServer.getSolutionDefinition(getPreferedSolutionNameToLoadOnInit(), solutionTypeFilter);
if (startSolution != null)
return startSolution;
} catch (RemoteException e) {
throw new RepositoryException(e);
}
}
SolutionMetaData[] solutions;
try {
solutions = applicationServer.getSolutionDefinitions(solutionTypeFilter);
} catch (RemoteException e) {
throw new RepositoryException(e);
}
if (solutions == null || solutions.length == 0) {
if (!Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.allowSolutionBrowsing", "true"))) {
if (argumentsScope != null) {
try {
SolutionMetaData smd = applicationServer.getSolutionDefinition(argumentsScope.getSolutionName(), solutionTypeFilter);
if (smd != null)
return smd;
} catch (RemoteException e) {
throw new RepositoryException(e);
}
}
}
// $NON-NLS-1$
throw new RuntimeException(Messages.getString("servoy.client.error.opensolution"));
}
if (solutions.length == 1) {
return solutions[0];
}
// show a dialog
return showSolutionSelection(solutions);
}
use of com.servoy.j2db.persistence.RepositoryException in project servoy-client by Servoy.
the class ClientState method authenticate.
public Object authenticate(String authenticator_solution, String method, Object[] credentials) throws RepositoryException {
String jscredentials;
JSONConverter jsonConverter;
try {
jsonConverter = new JSONConverter(foundSetManager);
jscredentials = jsonConverter.convertToJSON(credentials);
} catch (Exception e) {
// $NON-NLS-1$
Debug.error("Could not convert credentials object to json", e);
return null;
}
String jsReturn = authenticate(new Credentials(clientInfo.getClientId(), authenticator_solution, method, jscredentials));
try {
return jsonConverter.convertFromJSON(jsReturn);
} catch (Exception e) {
// $NON-NLS-1$
Debug.error("Could not convert authentication json result to object", e);
return null;
}
}
Aggregations