Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several bug fixes for the admin console (Faces 4.0) #1703

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
* @author <a href="mailto:[email protected]">Andreas Schmitz</a>
* @since 3.4
*/
@Named
@RequestScoped

public class Config implements Comparable<Config>, Serializable {

private static final long serialVersionUID = -175529275940063759L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
public class ConnectionTester implements Serializable {

private Workspace getWorkspace() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
return ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace().getNewWorkspace();
return WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();
}

public void test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ public String save() {

private void create() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
Workspace ws = ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace()
.getNewWorkspace();
Workspace ws = WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();
try {
Map<String, Object> sMap = ctx.getSessionMap();
String newId = (String) sMap.get("newConfigId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public FeatureStoreConfig(ResourceMetadata metadata, ResourceManager resourceMan
}

private Workspace getWorkspace() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
return ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace().getNewWorkspace();
return WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();
}

public boolean getSql() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
import java.util.SortedSet;
import java.util.TreeSet;

import jakarta.el.ELContext;
import jakarta.el.ELResolver;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.application.Application;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
Expand Down Expand Up @@ -133,8 +136,7 @@ public String getFeatureStoreId() {
}

private DeegreeWorkspace getWorkspace() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
return ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace();
return WorkspaceBean.getInstance().getActiveWorkspace();
}

public SortedSet<String> getAvailableJdbcConns() {
Expand Down Expand Up @@ -279,9 +281,7 @@ public String analyzeSchema() throws IOException, ClassNotFoundException, Securi
public String generateConfig() {

try {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
Workspace ws = ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace()
.getNewWorkspace();
Workspace ws = WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();

CRSRef storageCrs = CRSManager.getCRSRef(this.storageCrs);
boolean createBlobMapping = storageMode.equals("hybrid") || storageMode.equals("blob");
Expand Down Expand Up @@ -336,9 +336,7 @@ public String generateConfig() {

public String createTables() throws ClassNotFoundException, SecurityException, NoSuchMethodException,
IllegalArgumentException, IllegalAccessException, InvocationTargetException {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
Workspace ws = ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace()
.getNewWorkspace();
Workspace ws = WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();
FeatureStore fs = ws
.init(new DefaultResourceIdentifier<FeatureStore>(FeatureStoreProvider.class, getFeatureStoreId()), null);
SQLFeatureStore store = (SQLFeatureStore) fs;
Expand Down Expand Up @@ -368,7 +366,7 @@ public Integer getTableNameLength() {
public String activateFS() {
try {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
WorkspaceBean workspaceBean = (WorkspaceBean) ctx.getApplicationMap().get("workspace");
WorkspaceBean workspaceBean = WorkspaceBean.getInstance();
Workspace ws = workspaceBean.getActiveWorkspace().getNewWorkspace();
WorkspaceUtils.reinitializeChain(ws,
new DefaultResourceIdentifier<FeatureStore>(FeatureStoreProvider.class, getFeatureStoreId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import jakarta.faces.application.FacesMessage;
import jakarta.faces.component.html.HtmlCommandButton;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.faces.event.ActionEvent;

Expand All @@ -63,8 +62,7 @@ public MetadataStoreConfig(ResourceMetadata<?> state, ResourceManager<?> resourc
}

private Workspace getWorkspace() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
return ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace().getNewWorkspace();
return WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();
}

public void updateId(ActionEvent evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public class Connection implements Serializable {
private String status = "OK";

private Workspace getWorkspace() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
return ((WorkspaceBean) ctx.getApplicationMap().get("workspace")).getActiveWorkspace().getNewWorkspace();
return WorkspaceBean.getInstance().getActiveWorkspace().getNewWorkspace();
}

public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,17 @@ public String getContent() throws IOException, ClassNotFoundException {
if (content == null) {
LOG.trace("No content set for {}", this.toString());
if (resourceProviderClass == null) {
File file = getFile();
if (fileName != null && file.exists()) {
LOG.trace("Loading content from file: {}", file.getAbsolutePath());
content = FileUtils.readFileToString(file);
LOG.trace("Setting content to: {}", content);
return content;
if (fileName != null) {
File file = getFile();
if (file.exists()) {
LOG.trace("Loading content from file: {}", file.getAbsolutePath());
content = FileUtils.readFileToString(file);
LOG.trace("Setting content to: {}", content);
return content;
}
}
else if (emptyTemplate != null) {

if (emptyTemplate != null) {
// load template content if the requested file did not exists
LOG.trace("Loading template from {}", emptyTemplate);
StringWriter sw = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public List<String> getInternalModules() {
}

public List<String> getWorkspaceModules() {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
WorkspaceBean wsBean = ((WorkspaceBean) ctx.getApplicationMap().get("workspace"));
WorkspaceBean wsBean = WorkspaceBean.getInstance();
if (wsBean == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
import java.util.HashMap;
import java.util.List;

import jakarta.el.ELContext;
import jakarta.el.ELResolver;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.faces.application.Application;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.FacesContext;

Expand Down Expand Up @@ -428,4 +431,14 @@ public void handleFileUpload(FileUploadEvent event) {
LOG.debug("Workspace {} unzipped into workspace root directory", workspaceImportName);
}

public static WorkspaceBean getInstance() {
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();

ELResolver elResolver = application.getELResolver();
ELContext elContext = facesContext.getELContext();

return (WorkspaceBean) elResolver.getValue(elContext, null, "workspace");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@
<legend>
<h:outputText styleClass="titel" value="Setup database" />
</legend>
<pe:codeMirror id="sqlArea" mode="sql" theme="dracular"
value="#{execution.statements}" keyMap="debug" lineNumbers="true"
matchBrackets="true"/>
<h:inputTextarea id="sqlArea" cols="70" rows="21" value="" />
<h:inputTextarea id="sqlArea" cols="70" rows="21" value="#{execution.statements}" />
<h:outputText value="#{execution.message}" />
<br /> <br />
<h:commandButton styleClass="buttonSave" value="#{labels.sql_execute}" action="#{execution.execute}" />
<h:commandButton styleClass="buttonCancel" value="#{labels.sql_back}" action="#{execution.getBackOutcome}" />
<p id="highlighting" style="cursor: pointer;" class="schema" onclick="activateEditor();">Turn on
highlighting</p>
<pe:codeMirror id="xmltextarea" mode="xml" theme="dracular" lineNumbers="true" matchBrackets="true"
value="${xmlEditorBean.content}" />
</fieldset>
</h:form>
</ui:define>
Expand Down