use of com.servoy.j2db.server.shared.IApplicationServer in project servoy-client by Servoy.
the class AngularIndexPageWriter method getFlattenedSolution.
private static Pair<FlattenedSolution, Boolean> getFlattenedSolution(String solutionName, String clientnr, HttpServletRequest request, HttpServletResponse response) {
INGClientWebsocketSession wsSession = null;
HttpSession httpSession = request.getSession(false);
if (clientnr != null && httpSession != null) {
wsSession = (INGClientWebsocketSession) WebsocketSessionManager.getSession(CLIENT_ENDPOINT, httpSession, Integer.parseInt(clientnr));
}
FlattenedSolution fs = null;
boolean closeFS = false;
if (wsSession != null) {
fs = wsSession.getClient().getFlattenedSolution();
}
if (fs == null) {
try {
closeFS = true;
IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
if (applicationServerUnavailable(response, as)) {
return new Pair<FlattenedSolution, Boolean>(null, Boolean.FALSE);
}
SolutionMetaData solutionMetaData = (SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(solutionName, SOLUTIONS);
if (solutionMissing(response, solutionName, solutionMetaData)) {
return new Pair<FlattenedSolution, Boolean>(null, Boolean.FALSE);
}
fs = new FlattenedSolution(solutionMetaData, new AbstractActiveSolutionHandler(as) {
@Override
public IRepository getRepository() {
return ApplicationServerRegistry.get().getLocalRepository();
}
});
} catch (Exception e) {
Debug.error("error loading solution: " + solutionName + " for clientnr: " + clientnr, e);
}
}
return new Pair<FlattenedSolution, Boolean>(fs, Boolean.valueOf(closeFS));
}
use of com.servoy.j2db.server.shared.IApplicationServer in project servoy-client by Servoy.
the class MediaResourcesServlet method sendFlattenedSolutionBasedMedia.
private boolean sendFlattenedSolutionBasedMedia(HttpServletRequest request, HttpServletResponse response, String rootSolutionName, String mediaName) throws IOException {
FlattenedSolution fs = null;
try {
IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
SolutionMetaData solutionMetaData = (SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(rootSolutionName, IRepository.SOLUTIONS);
if (solutionMetaData == null) {
Debug.error("Solution '" + rootSolutionName + "' was not found when sending media data for '" + mediaName + "'.");
return false;
}
fs = new FlattenedSolution(solutionMetaData, new AbstractActiveSolutionHandler(as) {
@Override
public IRepository getRepository() {
return ApplicationServerRegistry.get().getLocalRepository();
}
});
} catch (RepositoryException e) {
Debug.error(e);
}
try {
return findAndSendMediaData(request, response, mediaName, fs);
} finally {
fs.close(null);
}
}
Aggregations