use of com.servoy.j2db.persistence.SolutionMetaData in project servoy-client by Servoy.
the class DebugClientHandler method createDebugHeadlessClient.
public synchronized SessionClient createDebugHeadlessClient(ServletRequest req, String userName, String password, String method, Object[] objects, String preferedSolution) throws Exception {
if (debugHeadlessClient != null && !debugHeadlessClient.isShutDown()) {
debugHeadlessClient.shutDown(true);
}
SolutionMetaData solutionMetaData = (currentSolution == null) ? null : currentSolution.getSolutionMetaData();
if (preferedSolution != null && solutionMetaData != null && !preferedSolution.equals(solutionMetaData.getName())) {
Map<String, Solution> modules = new HashMap<String, Solution>();
currentSolution.getReferencedModulesRecursive(modules);
if (modules.containsKey(preferedSolution)) {
solutionMetaData = (SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(preferedSolution, IRepository.SOLUTIONS);
}
}
debugHeadlessClient = new DebugHeadlessClient(req, userName, password, method, objects, solutionMetaData, designerCallback) {
@Override
public void shutDown(boolean force) {
super.shutDown(force);
debugHeadlessClient = null;
}
};
testAndStartDebugger();
return debugHeadlessClient;
}
use of com.servoy.j2db.persistence.SolutionMetaData in project servoy-client by Servoy.
the class WebClientSession method startSessionClient.
@SuppressWarnings("nls")
public IWebClientApplication startSessionClient(RootObjectMetaData sd, String method, StartupArguments argumentsScope) throws Exception {
String firstArgument = argumentsScope.getFirstArgument();
IWebClientApplication webClient = getWebClient();
if (webClient != null) {
boolean solutionLoaded = webClient.getSolution() != null;
if (solutionLoaded && !webClient.closeSolution(false, null)) {
// not allowed to close solution?
return webClient;
}
if (solutionLoaded && isSignedIn() && !Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.allowSolutionBrowsing", "true")) && !sd.getName().equals(keepCredentialsSolutionName)) {
webClient.logout(null);
}
if (!isSignedIn()) {
SolutionMetaData smd = (SolutionMetaData) sd;
IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
Solution sol = (Solution) repository.getActiveRootObject(smd.getName(), IRepository.SOLUTIONS);
if (sol.getLoginSolutionName() == null && sol.getLoginFormID() <= 0 && smd.getMustAuthenticate()) {
// signin first
throw new RestartResponseAtInterceptPageException(SignIn.class);
}
}
keepCredentialsSolutionName = null;
}
if (webClient == null || webClient.isShutDown()) {
HttpServletRequest req = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest();
httpSession = req.getSession();
webClient = createWebClient(req, credentials, method, firstArgument == null ? null : new Object[] { firstArgument, argumentsScope.toJSMap() }, sd.getName());
webClient.handleArguments(new String[] { sd.getName() }, argumentsScope);
if (RequestCycle.get() != null) {
// if this is inside a request cycle set the service provider.
// will be reset by the detach of the RequestCycle.
J2DBGlobals.setServiceProvider(webClient);
}
setAttribute("servoy_webclient", webClient);
} else {
webClient.handleArguments(firstArgument != null ? new String[] { sd.getName(), method, firstArgument } : new String[] { sd.getName(), method }, argumentsScope);
}
// fake first load
webClient.handleClientUserUidChanged(null, "");
if (webClient.getSolution() != null)
getSolutionLastModifiedTime(webClient.getSolution());
else {
if (webClient.getPreferedSolutionNameToLoadOnInit() != null) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("s", webClient.getPreferedSolutionNameToLoadOnInit());
map.put("m", webClient.getPreferedSolutionMethodNameToCall());
if (webClient.getPreferedSolutionMethodArguments() != null && webClient.getPreferedSolutionMethodArguments().length > 0) {
map.put("a", webClient.getPreferedSolutionMethodArguments()[0]);
}
throw new RestartResponseException(SolutionLoader.class, new PageParameters(map));
}
}
return webClient;
}
use of com.servoy.j2db.persistence.SolutionMetaData in project servoy-client by Servoy.
the class SharedMediaResource method getResource.
private ResourceState getResource(final String iconId, final String solutionName) {
return new ResourceState() {
private String contentType;
private int length;
byte[] array = null;
@Override
public Time lastModifiedTime() {
try {
IRootObject solution = ApplicationServerRegistry.get().getLocalRepository().getActiveRootObject(solutionName, IRepository.SOLUTIONS);
if (solution != null)
return Time.valueOf(solution.getLastModifiedTime());
} catch (Exception e) {
Debug.trace(e);
}
return time;
}
@Override
public byte[] getData() {
if (array == null) {
boolean closeFS = false;
try {
final IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
FlattenedSolution fs = null;
try {
if (Session.exists() && ((WebClientSession) Session.get()).getWebClient() != null) {
fs = ((WebClientSession) Session.get()).getWebClient().getFlattenedSolution();
}
if (fs == null) {
SolutionMetaData solutionMetaData = (SolutionMetaData) repository.getRootObjectMetaData(solutionName, IRepository.SOLUTIONS);
if (solutionMetaData == null)
return new byte[0];
closeFS = true;
IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
fs = new FlattenedSolution(solutionMetaData, new AbstractActiveSolutionHandler(as) {
@Override
public IRepository getRepository() {
return repository;
}
});
}
Media m = fs.getMedia(iconId);
if (m == null) {
try {
Integer iIconID = new Integer(iconId);
m = fs.getMedia(iIconID.intValue());
} catch (NumberFormatException ex) {
Debug.error("no media found for: " + iconId);
}
}
if (m != null) {
array = m.getMediaData();
contentType = m.getMimeType();
}
} finally {
if (closeFS && fs != null) {
fs.close(null);
}
}
if (array != null) {
if (contentType == null) {
contentType = MimeTypes.getContentType(array);
}
length = array.length;
}
} catch (Exception ex) {
Debug.error(ex);
}
}
return array == null ? new byte[0] : array;
}
/**
* @see wicket.markup.html.DynamicWebResource.ResourceState#getLength()
*/
@Override
public int getLength() {
return length;
}
@Override
public String getContentType() {
return contentType;
}
};
}
use of com.servoy.j2db.persistence.SolutionMetaData 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.SolutionMetaData in project servoy-client by Servoy.
the class NGClient method loadSolution.
public void loadSolution(String solutionName) throws RepositoryException {
try {
SolutionMetaData solutionMetaData = getApplicationServer().getSolutionDefinition(solutionName, getSolutionTypeFilter());
if (solutionMetaData == null) {
throw new IllegalArgumentException(Messages.getString("servoy.exception.solutionNotFound", new Object[] { solutionName, IApplication.getApplicationTypeAsString(getClientInfo().getApplicationType()), SolutionMetaData.getSolutionNamesByFilter(getSolutionTypeFilter()) }));
}
loadSolution(solutionMetaData);
} catch (RemoteException e) {
throw new RepositoryException(e);
}
}
Aggregations