use of com.servoy.j2db.persistence.SolutionMetaData in project servoy-client by Servoy.
the class DebugWebClient method checkForChanges.
public synchronized boolean checkForChanges() {
if (getClientInfo() == null)
return false;
boolean changed = false;
SolutionMetaData mainSolutionMetaData = getFlattenedSolution().getMainSolutionMetaData();
if ((mainSolutionMetaData == null && solution != null) || (mainSolutionMetaData != null && !mainSolutionMetaData.getName().equals(solution.getName()))) {
try {
loadSolution(solution);
changed = true;
} catch (Exception e) {
Debug.error(e);
}
}
if (!changed) {
changed = performRefresh();
}
if (getSolution() != null && form != null) {
getFormManager().showFormInMainPanel(form.getName());
form = null;
changed = true;
}
return changed;
}
use of com.servoy.j2db.persistence.SolutionMetaData in project servoy-client by Servoy.
the class NGClientEntryFilter method doFilter.
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
try {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
if ("GET".equalsIgnoreCase(request.getMethod())) {
if (request.getCharacterEncoding() == null)
request.setCharacterEncoding("UTF8");
String uri = request.getRequestURI();
if (handleShortSolutionRequest(request, response)) {
return;
}
if (handleDeeplink(request, response)) {
return;
}
if (handleRecording(request, response)) {
return;
}
if (uri != null && (uri.endsWith(".html") || uri.endsWith(".js"))) {
String solutionName = getSolutionNameFromURI(uri);
if (solutionName != null) {
String clientnr = AngularIndexPageWriter.getClientNr(uri, request);
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 (AngularIndexPageWriter.applicationServerUnavailable(response, as)) {
return;
}
SolutionMetaData solutionMetaData = (SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(solutionName, SOLUTIONS);
if (AngularIndexPageWriter.solutionMissing(response, solutionName, solutionMetaData)) {
return;
}
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);
}
}
if (fs != null) {
try {
if (handleMainJs(request, response, fs)) {
return;
}
if (handleForm(request, response, wsSession, fs)) {
return;
}
if (AngularIndexPageWriter.handleMaintenanceMode(request, response, wsSession)) {
return;
}
// prepare for possible index.html lookup
Map<String, Object> variableSubstitution = getSubstitutions(request, solutionName, clientnr, fs);
List<String> extraMeta = new ArrayList<String>();
addManifest(fs, extraMeta);
addHeadIndexContributions(fs, extraMeta);
ContentSecurityPolicyConfig contentSecurityPolicyConfig = addcontentSecurityPolicyHeader(request, response, true);
super.doFilter(servletRequest, servletResponse, filterChain, asList(SERVOY_CSS), new ArrayList<String>(getFormScriptReferences(fs)), extraMeta, variableSubstitution, contentSecurityPolicyConfig == null ? null : contentSecurityPolicyConfig.getNonce());
return;
} finally {
if (closeFS) {
fs.close(null);
}
}
}
}
}
if (!uri.contains(ModifiablePropertiesGenerator.PUSH_TO_SERVER_BINDINGS_LIST))
Debug.log("No solution found for this request, calling the default filter: " + uri);
}
super.doFilter(servletRequest, servletResponse, filterChain, null, null, null, null, null);
} catch (RuntimeException | Error e) {
Debug.error(e);
throw e;
}
}
use of com.servoy.j2db.persistence.SolutionMetaData 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.persistence.SolutionMetaData in project servoy-client by Servoy.
the class SelectNGSolutionFilter method doFilter.
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
if (Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.allowSolutionBrowsing", "true"))) {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String uri = request.getServletPath();
if (uri != null) {
if (uri.equals("/servoy-ngclient")) {
// html contents
((HttpServletResponse) servletResponse).setContentType("text/html");
PrintWriter w = servletResponse.getWriter();
addNeededJSAndCSS(getClass().getResource("solution_list.html"), w);
w.flush();
return;
} else if (uri.equals("/servoy-ngclient/solutions.js")) {
HTTPUtils.setNoCacheHeaders((HttpServletResponse) servletResponse);
IApplicationServerSingleton as = ApplicationServerRegistry.get();
// js contents giving the actual solutions list
List<Solution> ngCompatibleSolutions = new ArrayList<Solution>();
if (as.isDeveloperStartup()) {
Solution active = as.getDebugClientHandler().getDebugSmartClient().getCurrent();
if ((((SolutionMetaData) active.getMetaData()).getSolutionType() & (SolutionMetaData.SOLUTION | SolutionMetaData.NG_CLIENT_ONLY)) != 0)
ngCompatibleSolutions.add(active);
} else {
try {
RootObjectMetaData[] smds = as.getLocalRepository().getRootObjectMetaDatasForType(IRepository.SOLUTIONS);
int solutionType;
for (RootObjectMetaData element : smds) {
solutionType = ((SolutionMetaData) element).getSolutionType();
if ((solutionType & (SolutionMetaData.SOLUTION | SolutionMetaData.NG_CLIENT_ONLY)) > 0) {
Solution solution = (Solution) as.getLocalRepository().getActiveRootObject(element.getRootObjectId());
if (solution != null) {
ngCompatibleSolutions.add(solution);
}
}
}
} catch (RepositoryException e) {
Debug.error(e);
}
}
// now generate the js containing these solutions
((HttpServletResponse) servletResponse).setContentType("text/javascript");
PrintWriter w = servletResponse.getWriter();
w.println("angular.module('solutionsListModule', []).value('$solutionsList', {");
w.println(" ngSolutions: [");
boolean putComma = false;
for (Solution s : ngCompatibleSolutions) {
if (putComma)
w.println(",");
else
putComma = true;
String titleText = (s.getTitleText() != null ? "'" + s.getTitleText() + "'" : null);
// it wouldn't look nice in the list of solutions to pick + client can't convert those
if (titleText != null && (titleText.contains("#") || titleText.startsWith("i18n:")))
titleText = null;
w.print(" { name : '" + s.getName() + "', titleText : " + titleText + ", requiresAuth : " + s.requireAuthentication() + " }");
}
if (putComma)
w.println("");
w.println(" ]");
w.println("});");
w.flush();
return;
}
}
}
filterChain.doFilter(servletRequest, servletResponse);
}
use of com.servoy.j2db.persistence.SolutionMetaData 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