Skip to content

Commit

Permalink
Workspaces: clean up warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsCharlier committed Jan 20, 2016
1 parent a47cf64 commit 8a9ca54
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 68 deletions.
Expand Up @@ -13,7 +13,7 @@
* Detachable model for a specific namespace
*/
@SuppressWarnings("serial")
public class NamespaceDetachableModel extends LoadableDetachableModel {
public class NamespaceDetachableModel extends LoadableDetachableModel<NamespaceInfo> {

String id;

Expand All @@ -22,7 +22,7 @@ public NamespaceDetachableModel( NamespaceInfo ns ) {
}

@Override
protected Object load() {
protected NamespaceInfo load() {
return GeoServerApplication.get().getCatalog().getNamespace( id );
}

Expand Down
Expand Up @@ -15,24 +15,25 @@
* TODO: go back using LoadatableDetachableModel once we upgrade to Wicket 1.4,
* see http://issues.apache.org/jira/browse/WICKET-27 and http://issues.apache.org/jira/browse/WICKET-2364
*/
@SuppressWarnings("serial")
public class WorkspaceDetachableModel implements IModel {
transient WorkspaceInfo workspace;
public class WorkspaceDetachableModel implements IModel<WorkspaceInfo> {
private static final long serialVersionUID = 7805768164289311051L;

transient WorkspaceInfo workspace;
String id;

public WorkspaceDetachableModel( WorkspaceInfo workspace ) {
setObject(workspace);
}

public Object getObject() {
public WorkspaceInfo getObject() {
if(workspace == null) {
workspace = id != null
? GeoServerApplication.get().getCatalog().getWorkspace( id ) : null;
}
return workspace;
}

public void setObject(Object object) {
public void setObject(WorkspaceInfo object) {
this.workspace = (WorkspaceInfo) object;
this.id = workspace != null ? workspace.getId() : null;
}
Expand Down
Expand Up @@ -46,7 +46,6 @@
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.config.ContactInfo;
import org.geoserver.config.GeoServer;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.config.ServiceInfo;
import org.geoserver.config.SettingsInfo;
import org.geoserver.config.impl.ServiceInfoImpl;
Expand All @@ -71,13 +70,14 @@
/**
* Allows editing a specific workspace
*/
@SuppressWarnings("serial")
public class WorkspaceEditPage extends GeoServerSecuredPage {

private static final Logger LOGGER = Logging.getLogger("org.geoserver.web.data.workspace");
private static final long serialVersionUID = 4341324830412716976L;

private static final Logger LOGGER = Logging.getLogger("org.geoserver.web.data.workspace");

IModel wsModel;
IModel nsModel;
IModel<WorkspaceInfo> wsModel;
IModel<NamespaceInfo> nsModel;
boolean defaultWs;

SettingsPanel settingsPanel;
Expand Down Expand Up @@ -113,8 +113,13 @@ private void init(WorkspaceInfo ws) {
NamespaceInfo ns = getCatalog().getNamespaceByPrefix( ws.getName() );
nsModel = new NamespaceDetachableModel(ns);

Form form = new Form( "form", new CompoundPropertyModel( nsModel ) ) {
protected void onSubmit() {
Form<NamespaceInfo> form = new Form<NamespaceInfo>( "form", new CompoundPropertyModel<NamespaceInfo>( nsModel ) ) {
/**
*
*/
private static final long serialVersionUID = 5140757565172795453L;

protected void onSubmit() {
try {
saveWorkspace();
} catch (RuntimeException e) {
Expand All @@ -128,17 +133,17 @@ protected void onSubmit() {
//check for full admin, we don't allow workspace admins to change all settings
boolean isFullAdmin = isAuthenticatedAsAdmin();

TextField name = new TextField("name", new PropertyModel(wsModel, "name"));
TextField<String> name = new TextField<String>("name", new PropertyModel<String>(wsModel, "name"));
name.setRequired(true);
name.setEnabled(isFullAdmin);

name.add(new XMLNameValidator());
form.add(name);
TextField uri = new TextField("uri", new PropertyModel(nsModel, "uRI"), String.class);
TextField<String> uri = new TextField<String>("uri", new PropertyModel<String>(nsModel, "uRI"), String.class);
uri.setRequired(true);
uri.add(new URIValidator());
form.add(uri);
CheckBox defaultChk = new CheckBox("default", new PropertyModel(this, "defaultWs"));
CheckBox defaultChk = new CheckBox("default", new PropertyModel<Boolean>(this, "defaultWs"));
form.add(defaultChk);
defaultChk.setEnabled(isFullAdmin);

Expand All @@ -159,7 +164,7 @@ protected void onSubmit() {
SubmitLink submit = new SubmitLink("save");
form.add(submit);
form.setDefaultButton(submit);
form.add(new BookmarkablePageLink("cancel", WorkspacePage.class));
form.add(new BookmarkablePageLink<WorkspacePage>("cancel", WorkspacePage.class));
}

private void saveWorkspace() {
Expand Down Expand Up @@ -226,7 +231,9 @@ protected ComponentAuthorizer getPageAuthorizer() {
* Data object to hold onto transient settings, and maintain state of enabled for the workspace.
*/
static class Settings implements Serializable {
/** track selection */
private static final long serialVersionUID = -5855608735160516252L;

/** track selection */
Boolean enabled;

/** created settings, not yet added to configuration */
Expand All @@ -235,7 +242,11 @@ static class Settings implements Serializable {

static class ExistingSettingsModel extends LoadableDetachableModel<SettingsInfo> {

IModel<WorkspaceInfo> wsModel;
/**
*
*/
private static final long serialVersionUID = -8203239697623788188L;
IModel<WorkspaceInfo> wsModel;

ExistingSettingsModel(IModel<WorkspaceInfo> wsModel) {
this.wsModel = wsModel;
Expand All @@ -251,7 +262,11 @@ protected SettingsInfo load() {

static class NewSettingsModel extends Model<SettingsInfo> {

IModel<WorkspaceInfo> wsModel;
/**
*
*/
private static final long serialVersionUID = -4365626821652771933L;
IModel<WorkspaceInfo> wsModel;
SettingsInfo info;

NewSettingsModel(IModel<WorkspaceInfo> wsModel) {
Expand Down Expand Up @@ -281,15 +296,17 @@ public SettingsInfo getObject() {
}
}

class SettingsPanel extends FormComponentPanel {
class SettingsPanel extends FormComponentPanel<WorkspaceInfo> {

WebMarkupContainer settingsContainer;
private static final long serialVersionUID = -1580928887379954134L;

WebMarkupContainer settingsContainer;
ContactPanel contactPanel;
WebMarkupContainer otherSettingsPanel;
Settings set;

public SettingsPanel(String id, IModel<WorkspaceInfo> model) {
super(id, new Model());
super(id, model);

SettingsInfo settings = getGeoServer().getSettings(model.getObject());

Expand All @@ -300,7 +317,9 @@ public SettingsPanel(String id, IModel<WorkspaceInfo> model) {

add(new CheckBox("enabled", new PropertyModel<Boolean>(set, "enabled")).
add(new AjaxFormComponentUpdatingBehavior("click") {
@Override
private static final long serialVersionUID = -7851699665702753119L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
contactPanel.setVisible(set.enabled);
otherSettingsPanel.setVisible(set.enabled);
Expand All @@ -327,16 +346,15 @@ protected void onUpdate(AjaxRequestTarget target) {
otherSettingsPanel.add(new CheckBox("verboseExceptions"));
otherSettingsPanel.add(new CheckBox("localWorkspaceIncludesPrefix"));
otherSettingsPanel.add(new TextField<Integer>("numDecimals").add(RangeValidator.minimum(0)));
otherSettingsPanel.add(new DropDownChoice("charset", GlobalSettingsPage.AVAILABLE_CHARSETS));
otherSettingsPanel.add(new TextField("proxyBaseUrl").add(new UrlValidator()));
otherSettingsPanel.add(new DropDownChoice<String>("charset", GlobalSettingsPage.AVAILABLE_CHARSETS));
otherSettingsPanel.add(new TextField<String>("proxyBaseUrl").add(new UrlValidator()));

// Addition of pluggable extension points
ListView extensions = SettingsPluginPanelInfo.createExtensions("extensions", set.model,
ListView<SettingsPluginPanelInfo> extensions = SettingsPluginPanelInfo.createExtensions("extensions", set.model,
getGeoServerApplication());
otherSettingsPanel.add(extensions);

settingsContainer.add(otherSettingsPanel);

settingsContainer.add(otherSettingsPanel);
}
}

Expand All @@ -345,7 +363,12 @@ protected void onUpdate(AjaxRequestTarget target) {
* the workspace.
*/
static class Service implements Serializable {
/** track selection */
/**
*
*/
private static final long serialVersionUID = 3283857206025172687L;

/** track selection */
Boolean enabled;

/** the admin page for the service */
Expand All @@ -357,7 +380,11 @@ static class Service implements Serializable {

static class NewServiceModel extends Model<ServiceInfo> {

IModel<WorkspaceInfo> wsModel;
/**
*
*/
private static final long serialVersionUID = -3467556623909292282L;
IModel<WorkspaceInfo> wsModel;
Class<ServiceInfo> serviceClass;
ServiceInfo service;

Expand Down Expand Up @@ -394,7 +421,11 @@ ServiceInfo create() {

static class ExistingServiceModel extends LoadableDetachableModel<ServiceInfo> {

IModel<WorkspaceInfo> wsModel;
/**
*
*/
private static final long serialVersionUID = -2170117760214309321L;
IModel<WorkspaceInfo> wsModel;
Class<ServiceInfo> serviceClass;

ExistingServiceModel(IModel<WorkspaceInfo> wsModel, Class<ServiceInfo> serviceClass) {
Expand All @@ -408,22 +439,36 @@ protected ServiceInfo load() {
}
}

class ServicesPanel extends FormComponentPanel {
class ServicesPanel extends FormComponentPanel<WorkspaceInfo> {

List<Service> services;
/**
*
*/
private static final long serialVersionUID = 7375904545106343626L;
List<Service> services;

public ServicesPanel(String id, final IModel<WorkspaceInfo> wsModel) {
super(id, new Model());
super(id, wsModel);

services = services(wsModel);
ListView<Service> serviceList = new ListView<Service>("services", services) {

@Override
/**
*
*/
private static final long serialVersionUID = -4142739871430618450L;

@Override
protected void populateItem(ListItem<Service> item) {
Service service = item.getModelObject();

final Link<Service> link = new Link<Service>("link", new Model(service)) {
@Override
final Link<Service> link = new Link<Service>("link", new Model<Service>(service)) {
/**
*
*/
private static final long serialVersionUID = 1111536301891090436L;

@Override
public void onClick() {
Service s = getModelObject();
Page page = null;
Expand All @@ -449,7 +494,7 @@ public void onClick() {
}

}
((BaseServiceAdminPage)page).setReturnPage(WorkspaceEditPage.this);
((BaseServiceAdminPage<?>)page).setReturnPage(WorkspaceEditPage.this);
setResponsePage(page);
}
};
Expand All @@ -458,7 +503,12 @@ public void onClick() {

AjaxCheckBox enabled =
new AjaxCheckBox("enabled", new PropertyModel<Boolean>(service, "enabled")) {
@Override
/**
*
*/
private static final long serialVersionUID = 6369730006169869310L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
link.setEnabled(getModelObject());
target.add(link);
Expand Down Expand Up @@ -489,7 +539,7 @@ protected void onUpdate(AjaxRequestTarget target) {
}

List<Service> services(IModel<WorkspaceInfo> wsModel) {
List<Service> services = new ArrayList();
List<Service> services = new ArrayList<Service>();

for (ServiceMenuPageInfo page :
getGeoServerApplication().getBeansOfType(ServiceMenuPageInfo.class)) {
Expand All @@ -500,7 +550,8 @@ List<Service> services(IModel<WorkspaceInfo> wsModel) {

//if service is disabled, create a placeholder model to hold a newly created one,
// otherwise create a live model to the existing service
Class<ServiceInfo> serviceClass = (Class<ServiceInfo>) page.getServiceClass();
@SuppressWarnings("unchecked")
Class<ServiceInfo> serviceClass = (Class<ServiceInfo>) page.getServiceClass();
service.model = !service.enabled ? new NewServiceModel(wsModel, serviceClass) :
new ExistingServiceModel(wsModel, serviceClass);
services.add(service);
Expand Down

0 comments on commit 8a9ca54

Please sign in to comment.