You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by pd...@apache.org on 2016/03/17 02:13:09 UTC
[05/23] incubator-openaz git commit: Revert "Ported original att
source to openaz"
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java
deleted file mode 100644
index 80d33b8..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.data.util.filter.SimpleStringFilter;
-import com.vaadin.data.util.sqlcontainer.SQLContainer;
-import com.vaadin.event.FieldEvents.TextChangeEvent;
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class FunctionSelectionWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private Button buttonSave;
- @AutoGenerated
- private Table tableFunctions;
- @AutoGenerated
- private TextField textFieldFilter;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static Log logger = LogFactory.getLog(FunctionSelectionWindow.class);
- private final FunctionSelectionWindow self = this;
- private final String defaultFunctionID;
- private String selectedFunction = null;
- private boolean isSaved = false;
- private static SQLContainer highOrderFunctions = ((XacmlAdminUI) UI.getCurrent()).getHigherOrderBagContainer();
- /*
- * Seems that when this view is created it may or may not be upper case.
- */
- private static String PROPERTY_SHORTNAME = "shortname";
- private static String PROPERTY_XACMLID = "xacmlid";
-
- static {
- for (Object prop : FunctionSelectionWindow.highOrderFunctions.getContainerPropertyIds()) {
- logger.info("SQL Container Property Id: " + prop.toString());
- if (prop.toString().equalsIgnoreCase(PROPERTY_SHORTNAME)) {
- PROPERTY_SHORTNAME = prop.toString();
- } else if (prop.toString().equalsIgnoreCase(PROPERTY_XACMLID)) {
- PROPERTY_XACMLID = prop.toString();
- }
- }
-
- }
-
-
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public FunctionSelectionWindow(String defaultFunction) {
- buildMainLayout();
- //setCompositionRoot(mainLayout);
- setContent(mainLayout);
- //
- // Save
- //
- this.defaultFunctionID = defaultFunction;
- //
- // Close shortcut
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- //
- // Initialize GUI
- //
- this.initializeTextField();
- this.initializeFunctions();
- this.initializeButtons();
- //
- // Set our focus
- //
- this.tableFunctions.focus();
- }
-
- protected void initializeTextField() {
- //
- // Initialize GUI settings
- //
- this.textFieldFilter.setImmediate(true);
- //
- // Respond to the text change events
- //
- this.textFieldFilter.addTextChangeListener(new TextChangeListener() {
- private static final long serialVersionUID = 1L;
- SimpleStringFilter currentFilter = null;
-
- @Override
- public void textChange(TextChangeEvent event) {
- //
- // Remove current filter
- //
- if (this.currentFilter != null) {
- FunctionSelectionWindow.highOrderFunctions.removeContainerFilter(this.currentFilter);
- this.currentFilter = null;
- }
- //
- // Get the text
- //
- String value = event.getText();
- if (value != null && value.length() > 0) {
- //
- // Add the new filter
- //
- this.currentFilter = new SimpleStringFilter(PROPERTY_SHORTNAME, value, true, false);
- FunctionSelectionWindow.highOrderFunctions.addContainerFilter(this.currentFilter);
- }
- }
- });
- }
- protected void initializeFunctions() {
- //
- // Setup data source. Make sure there are no current filters
- //
- FunctionSelectionWindow.highOrderFunctions.removeAllContainerFilters();
- this.tableFunctions.setContainerDataSource(FunctionSelectionWindow.highOrderFunctions);
- //
- // Initialize GUI properties
- //
- this.tableFunctions.setImmediate(true);
- this.tableFunctions.setNullSelectionAllowed(false);
- this.tableFunctions.setRequired(true);
- this.tableFunctions.setRequiredError("Please select a function.");
- this.tableFunctions.setSelectable(true);
- this.tableFunctions.setPageLength(15);
- this.tableFunctions.setVisibleColumns(new Object[] {PROPERTY_SHORTNAME, PROPERTY_XACMLID});
- this.tableFunctions.setColumnHeaders(new String[] {"Short Function Name", "Xacml ID"});
- //
- // Respond to selection events
- //
- this.tableFunctions.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- Object id = self.tableFunctions.getValue();
- if (id != null) {
- Item item = FunctionSelectionWindow.highOrderFunctions.getItem(id);
- if (item == null) {
- return;
- }
- Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
- if (property == null) {
- return;
- }
- selectedFunction = property.getValue().toString();
- self.buttonSave.setEnabled(true);
- } else {
- self.buttonSave.setEnabled(false);
- }
- }
- });
- //
- // Respond to double-click events
- //
- this.tableFunctions.addItemClickListener(new ItemClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void itemClick(ItemClickEvent event) {
- if (event.isDoubleClick()) {
- self.doSave();
- }
- }
- });
- //
- // Setup the default selection
- //
- this.buttonSave.setEnabled(false);
- if (this.defaultFunctionID != null) {
- for (Object id : FunctionSelectionWindow.highOrderFunctions.getItemIds()) {
- Item item = FunctionSelectionWindow.highOrderFunctions.getItem(id);
- if (item != null) {
- Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
- if (property != null && property.getValue().toString().equals(this.defaultFunctionID)) {
- this.tableFunctions.select(id);
- break;
- }
- }
- }
- }
- }
-
- protected void initializeButtons() {
- this.buttonSave.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- self.doSave();
- }
- });
- }
-
- protected void doSave() {
- try {
- //
- // Commit changes
- //
- self.tableFunctions.commit();
- //
- // We are saved
- //
- self.isSaved = true;
- //
- // Close the window
- //
- self.close();
- } catch (SourceException | InvalidValueException e) { //NOPMD
- //
- // Nothing to do, Vaadin highlights
- //
- }
- }
-
- public boolean isSaved() {
- return this.isSaved;
- }
-
- public String getSelectedFunction() {
- return this.selectedFunction;
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textFieldFilter
- textFieldFilter = new TextField();
- textFieldFilter.setCaption("Filter");
- textFieldFilter.setImmediate(false);
- textFieldFilter.setWidth("-1px");
- textFieldFilter.setHeight("-1px");
- mainLayout.addComponent(textFieldFilter);
-
- // tableFunctions
- tableFunctions = new Table();
- tableFunctions.setImmediate(false);
- tableFunctions.setDescription("Functions To Select From");
- tableFunctions.setWidth("100.0%");
- tableFunctions.setHeight("-1px");
- mainLayout.addComponent(tableFunctions);
- mainLayout.setExpandRatio(tableFunctions, 1.0f);
-
- // buttonSave
- buttonSave = new Button();
- buttonSave.setCaption("Save");
- buttonSave.setImmediate(true);
- buttonSave.setWidth("-1px");
- buttonSave.setHeight("-1px");
- mainLayout.addComponent(buttonSave);
- mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java
deleted file mode 100644
index cd75c07..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.VerticalLayout;
-
-public class GitConflictResolver extends CustomComponent {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public GitConflictResolver() {
- buildMainLayout();
- setCompositionRoot(mainLayout);
-
- // TODO add user code here
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(false);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java
deleted file mode 100644
index 492d8b9..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.dircache.DirCache;
-import org.eclipse.jgit.dircache.DirCacheEntry;
-import org.eclipse.jgit.errors.NoWorkTreeException;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import org.apache.openaz.xacml.admin.model.GitStatusContainer;
-import org.apache.openaz.xacml.admin.model.GitStatusContainer.GitEntry;
-import org.apache.openaz.xacml.admin.model.GitStatusContainer.StatusItem;
-import org.apache.openaz.xacml.admin.util.AdminNotification;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Item;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.event.FieldEvents.TextChangeEvent;
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Table.ColumnGenerator;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class GitPushWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private Button buttonPush;
- @AutoGenerated
- private Table tableChanges;
- @AutoGenerated
- private TextArea textAreaComments;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Log logger = LogFactory.getLog(GitPushWindow.class);
- private final GitPushWindow self = this;
- private final GitStatusContainer container;
- private final Git git;
- private final File target;
- private boolean isSaved = false;
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- * @param git
- * @param status
- */
- public GitPushWindow(Git git, File target, Status status) {
- buildMainLayout();
- //setCompositionRoot(mainLayout);
- setContent(mainLayout);
- //
- // Save data
- //
- this.git = git;
- this.target = target;
- this.container = new GitStatusContainer(status);
- //
- // Set our shortcuts
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- //
- // Initialize GUI
- //
- this.initializeText();
- this.initializeTable(status);
- this.initializeButtons();
- //
- // Focus
- //
- this.textAreaComments.focus();
- }
-
- protected void initializeText() {
- this.textAreaComments.setImmediate(true);
- this.textAreaComments.addTextChangeListener(new TextChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void textChange(TextChangeEvent event) {
- if (event.getText().isEmpty()) {
- self.buttonPush.setEnabled(false);
- } else {
- if (self.container.getConflictCount() == 0) {
- self.buttonPush.setEnabled(true);
- } else {
- self.buttonPush.setEnabled(false);
- }
- }
- }
- });
- }
-
- protected void initializeTable(Status status) {
- //
- // Setup the table
- //
- this.tableChanges.setContainerDataSource(this.container);
- this.tableChanges.setPageLength(this.container.size());
- this.tableChanges.setImmediate(true);
- //
- // Generate column
- //
- this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Object generateCell(Table source, Object itemId, Object columnId) {
- Item item = self.container.getItem(itemId);
- assert item != null;
- if (item instanceof StatusItem) {
- return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
- }
- assert item instanceof StatusItem;
- return null;
- }
- });
- }
-
- protected Object generateGitEntryComponent(final GitEntry entry) {
- //
- // If its conflicting, take care of it
- //
- if (entry.isConflicting()) {
- return this.generateConflictingEntry(entry);
- }
- if (entry.isUntracked()) {
- return this.generateUntrackedEntry(entry);
- }
- /*
- if (entry.isChanged() ||
- entry.isModified() ||
- entry.isUncommitted()) {
- return this.generateUncommittedEntry(entry);
- }
- */
- return null;
- }
-
- protected Object generateConflictingEntry(final GitEntry entry) {
- Button resolve = new Button("Resolve");
- resolve.setImmediate(true);
- resolve.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
-
- }
- });
- return resolve;
- }
-
- protected Object generateUntrackedEntry(final GitEntry entry) {
- Button add = new Button("Add");
- add.setImmediate(true);
- add.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- DirCache cache = self.git.add().addFilepattern(entry.getName()).call();
- DirCacheEntry cacheEntry = cache.getEntry(entry.getName());
- assert cacheEntry != null;
- if (cacheEntry == null) {
- return;
- }
- if (cacheEntry.isMerged()) {
- self.refreshStatus();
- }
- } catch (GitAPIException e) {
- String error = "Failed to add: " + e.getLocalizedMessage();
- logger.error(error);
- AdminNotification.error(error);
- }
- }
- });
- return add;
- }
-
- protected Object generateUncommittedEntry(final GitEntry entry) {
- Button commit = new Button("Commit");
- commit.setImmediate(true);
- commit.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- }
- });
- return commit;
- }
-
- protected void initializeButtons() {
- this.buttonPush.setEnabled(false);
- this.buttonPush.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- //
- // Commit
- //
- self.textAreaComments.commit();
- //
- // Mark as saved
- //
- self.isSaved = true;
- //
- // Close the window
- //
- self.close();
- } catch(SourceException | InvalidValueException idontcare) { //NOPMD
- //
- // Vaadin will highlight the failed requirement or validation
- //
- }
- }
- });
- }
-
- protected void refreshStatus() {
- try {
- //
- // Grab our working repository
- //
- Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
- final Git git = Git.open(repoPath.toFile());
- //
- // Get our status
- //
- final String base;
- Status status;
- if (target == null) {
- base = ".";
- } else {
- Path relativePath = repoPath.relativize(Paths.get(target.getPath()));
- base = relativePath.toString();
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Status on base: " + base);
- }
- status = git.status().addPath(base).call();
- //
- // Pass it to our container
- //
- this.container.refreshStatus(status);
- this.tableChanges.refreshRowCache();
- } catch (NoWorkTreeException | IOException | GitAPIException e) {
- String error = "Failed to refresh status: " + e.getLocalizedMessage();
- logger.error(error);
- }
- }
-
- public boolean isSaved() {
- return this.isSaved;
- }
-
- public String getComment() {
- return this.textAreaComments.getValue();
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textAreaComments
- textAreaComments = new TextArea();
- textAreaComments.setCaption("Add Comments");
- textAreaComments.setImmediate(false);
- textAreaComments
- .setDescription("Enter comments that reflect the changes you have made to the repository domains and/or policy files.");
- textAreaComments.setWidth("400px");
- textAreaComments.setHeight("-1px");
- textAreaComments.setInvalidAllowed(false);
- textAreaComments.setRequired(true);
- textAreaComments
- .setInputPrompt("Eg. Add new rule for employees in marketing department.");
- mainLayout.addComponent(textAreaComments);
-
- // tableChanges
- tableChanges = new Table();
- tableChanges.setCaption("Changes To Be Pushed");
- tableChanges.setImmediate(false);
- tableChanges.setWidth("100.0%");
- tableChanges.setHeight("-1px");
- mainLayout.addComponent(tableChanges);
- mainLayout.setExpandRatio(tableChanges, 1.0f);
-
- // buttonPush
- buttonPush = new Button();
- buttonPush.setCaption("Push Changes");
- buttonPush.setImmediate(true);
- buttonPush.setWidth("-1px");
- buttonPush.setHeight("-1px");
- mainLayout.addComponent(buttonPush);
- mainLayout.setComponentAlignment(buttonPush, new Alignment(48));
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java
deleted file mode 100644
index da2edf7..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import java.io.IOException;
-import java.nio.file.Path;
-
-import org.eclipse.jgit.api.Git;
-// import org.eclipse.jgit.api.MergeResult;
-import org.eclipse.jgit.api.PullResult;
-// import org.eclipse.jgit.api.RebaseResult;
-import org.eclipse.jgit.api.errors.GitAPIException;
-// import org.eclipse.jgit.transport.FetchResult;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class GitSynchronizeWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private Button buttonSynchronize;
- @AutoGenerated
- private TextArea textAreaResults;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final GitSynchronizeWindow self = this;
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public GitSynchronizeWindow() {
- buildMainLayout();
- //setCompositionRoot(mainLayout);
- setContent(mainLayout);
- //
- // Set our shortcuts
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- //
- //
- //
- this.initializeButtons();
- }
-
- protected void initializeButtons() {
- this.buttonSynchronize.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- if (self.buttonSynchronize.getCaption().equals("Synchronize")) {
- self.synchronize();
- } else {
- self.close();
- }
- }
- });
- }
-
- protected void synchronize() {
- //
- // Grab our working repository
- //
- Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
- try {
- final Git git = Git.open(repoPath.toFile());
-
- PullResult result = git.pull().call();
- // FetchResult fetch = result.getFetchResult();
- // MergeResult merge = result.getMergeResult();
- // RebaseResult rebase = result.getRebaseResult();
- if (result.isSuccessful()) {
- //
- // TODO add more notification
- //
- this.textAreaResults.setValue("Successful!");
- } else {
- //
- // TODO
- //
- this.textAreaResults.setValue("Failed.");
- }
- } catch (IOException | GitAPIException e) {
- e.printStackTrace();
- }
- this.buttonSynchronize.setCaption("Ok");
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textAreaResults
- textAreaResults = new TextArea();
- textAreaResults.setCaption("Synch Results");
- textAreaResults.setImmediate(false);
- textAreaResults.setWidth("462px");
- textAreaResults.setHeight("222px");
- mainLayout.addComponent(textAreaResults);
-
- // buttonSynchronize
- buttonSynchronize = new Button();
- buttonSynchronize.setCaption("Synchronize");
- buttonSynchronize.setImmediate(true);
- buttonSynchronize.setWidth("-1px");
- buttonSynchronize.setHeight("-1px");
- mainLayout.addComponent(buttonSynchronize);
- mainLayout.setComponentAlignment(buttonSynchronize, new Alignment(24));
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java
deleted file mode 100644
index eafb7e0..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import org.apache.openaz.xacml.admin.jpa.Attribute;
-import org.apache.openaz.xacml.admin.jpa.Datatype;
-import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.data.util.filter.Compare;
-import com.vaadin.data.util.sqlcontainer.SQLContainer;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class MatchEditorWindow extends Window implements AttributeChangedEventListener {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private Button buttonSave;
- @AutoGenerated
- private Table tableFunctions;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static Log logger = LogFactory.getLog(MatchEditorWindow.class);
- private final MatchEditorWindow self = this;
- private final MatchType match;
- private final Datatype datatype;
- private boolean isSaved = false;
- private static SQLContainer matchFunctions = ((XacmlAdminUI) UI.getCurrent()).getMatchFunctionContainer();
-
- private static String PROPERTY_SHORTNAME = "shortname";
- private static String PROPERTY_XACMLID = "xacmlid";
- private static String PROPERTY_ARG2_DATATYPE = "arg2_datatype";
-
- static {
- //
- // H2 seems to insist on capitalizing, even with the no uppercase switch.
- //
- for (Object prop : MatchEditorWindow.matchFunctions.getContainerPropertyIds()) {
- logger.info("SQL Container Property Id: " + prop.toString());
- if (prop.toString().equalsIgnoreCase(PROPERTY_SHORTNAME)) {
- PROPERTY_SHORTNAME = prop.toString();
- } else if (prop.toString().equalsIgnoreCase(PROPERTY_XACMLID)) {
- PROPERTY_XACMLID = prop.toString();
- } else if (prop.toString().equalsIgnoreCase(PROPERTY_ARG2_DATATYPE)) {
- PROPERTY_ARG2_DATATYPE = prop.toString();
- }
- }
-
- }
-
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public MatchEditorWindow(MatchType match, Datatype datatype) {
- buildMainLayout();
- //setCompositionRoot(mainLayout);
- setContent(mainLayout);
- //
- // Save our data
- //
- this.match = match;
- this.datatype = datatype;
- //
- // Close shortcut
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- //
- // Initialize GUI
- //
- this.initializeFunctions();
- this.initializeButtons();
- //
- // Set our focus
- //
- this.tableFunctions.focus();
- }
-
- protected void initializeFunctions() {
- //
- // Setup datasource and GUI properties
- //
- this.tableFunctions.setContainerDataSource(MatchEditorWindow.matchFunctions);
- this.tableFunctions.setImmediate(true);
- this.tableFunctions.setNullSelectionAllowed(false);
- this.tableFunctions.setRequired(true);
- this.tableFunctions.setRequiredError("Please select a function.");
- this.tableFunctions.setSelectable(true);
- this.tableFunctions.setPageLength(15);
- this.tableFunctions.setVisibleColumns(PROPERTY_SHORTNAME, PROPERTY_XACMLID);
- this.tableFunctions.setColumnHeaders(new String[] {"Short Function Name", "Xacml ID"});
- //
- // Filter out functions where ARG2 is the given datatype. NOTE: The
- // AttributeDesignator/AttributeSelector is the 2nd argument.
- //
- MatchEditorWindow.matchFunctions.removeAllContainerFilters();
- MatchEditorWindow.matchFunctions.addContainerFilter(new Compare.Equal(PROPERTY_ARG2_DATATYPE, this.datatype.getId()));
- //
- // Respond to selection events
- //
- this.tableFunctions.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- Object id = self.tableFunctions.getValue();
- if (id != null) {
- Item item = MatchEditorWindow.matchFunctions.getItem(id);
- if (item == null) {
- return;
- }
- Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
- if (property == null) {
- return;
- }
- self.match.setMatchId(property.getValue().toString());
- self.buttonSave.setEnabled(true);
- } else {
- self.buttonSave.setEnabled(false);
- }
- }
- });
- //
- // Respond to double-click events
- //
- this.tableFunctions.addItemClickListener(new ItemClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void itemClick(ItemClickEvent event) {
- if (event.isDoubleClick()) {
- self.doSave();
- }
- }
- });
- //
- // Default selection
- //
- this.buttonSave.setEnabled(false);
- if (this.match.getMatchId() != null) {
- for (Object id : MatchEditorWindow.matchFunctions.getItemIds()) {
- Item item = MatchEditorWindow.matchFunctions.getItem(id);
- if (item != null) {
- Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
- if (property != null && property.getValue().toString().equals(this.match.getMatchId())) {
- this.tableFunctions.select(id);
- break;
- }
- }
- }
- }
- }
-
- protected void initializeButtons() {
- this.buttonSave.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- self.doSave();
- }
- });
- }
-
- protected void doSave() {
- try {
- //
- // Commit changes
- //
- self.tableFunctions.commit();
- //
- // We are saved
- //
- self.isSaved = true;
- //
- // Close the window
- //
- self.close();
- } catch (SourceException | InvalidValueException e) {
- return;
- }
- }
-
- @Override
- public void attributeChanged(Attribute attribute) {
- if (logger.isDebugEnabled()) {
- logger.debug("attributeChanged: " + attribute);
- }
- //
- // Remove all filters.
- //
- MatchEditorWindow.matchFunctions.removeAllContainerFilters();
- if (attribute == null) {
- return;
- }
- //
- // Get the datatype for the attribute
- //
- Datatype datatype = attribute.getDatatypeBean();
- if (logger.isDebugEnabled()) {
- logger.debug("datatype: " + datatype.getId());
- }
- //
- // Filter out functions where ARG2 is the datatype. The
- // AttributeDesignator/AttributeSelector is the 2nd arg.
- //
- MatchEditorWindow.matchFunctions.addContainerFilter(new Compare.Equal(PROPERTY_ARG2_DATATYPE, datatype.getId()));
- }
-
- public boolean isSaved() {
- return this.isSaved;
- }
-
- public MatchType getMatch() {
- return this.match;
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // tableFunctions
- tableFunctions = new Table();
- tableFunctions.setCaption("Function");
- tableFunctions.setImmediate(true);
- tableFunctions
- .setDescription("Select a function for matching the attribute.");
- tableFunctions.setWidth("100.0%");
- tableFunctions.setHeight("-1px");
- tableFunctions.setInvalidAllowed(false);
- tableFunctions.setRequired(true);
- mainLayout.addComponent(tableFunctions);
- mainLayout.setExpandRatio(tableFunctions, 1.0f);
-
- // buttonSave
- buttonSave = new Button();
- buttonSave.setCaption("Save");
- buttonSave.setImmediate(true);
- buttonSave.setWidth("-1px");
- buttonSave.setHeight("-1px");
- mainLayout.addComponent(buttonSave);
- mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java
deleted file mode 100644
index 960a2b7..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import org.apache.openaz.xacml.admin.jpa.Obadvice;
-import org.apache.openaz.xacml.admin.view.fields.OaExpressionsField;
-import com.vaadin.addon.jpacontainer.EntityItem;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.fieldgroup.FieldGroup;
-import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
-import com.vaadin.data.fieldgroup.PropertyId;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.OptionGroup;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class ObadviceEditorWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- private static final long serialVersionUID = 1L;
- private ObadviceEditorWindow self = this;
-
- private FormLayout mainLayout = new FormLayout();
-
- @PropertyId("type")
- OptionGroup typeOption = new OptionGroup("Type");
-
- @PropertyId("xacmlId")
- TextField xacmlID = new TextField("Obligation Id");
-
- @PropertyId("description")
- TextArea descriptionField = new TextArea("Description");
-
- @PropertyId("fulfillOn")
- OptionGroup fulfillOption = new OptionGroup("Fullfill On");
-
- @PropertyId("obadviceExpressions")
- OaExpressionsField expressionsField;
- //Table tableExpressions = new Table("Attribute Assignments");
-
- Button saveButton = new Button("Save");
-
- private FieldGroup fieldGroup = null;
- private final EntityItem<Obadvice> obad;
- private boolean isSaved = false;
-
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- * @param caption
- */
- public ObadviceEditorWindow(EntityItem<Obadvice> obad) {
- this.setContent(mainLayout);
- //
- // Save
- //
- this.obad = obad;
- //
- // Initialize main layout
- //
- this.mainLayout.setMargin(true);
- this.mainLayout.setWidth("-1px");
- //
- // Initialize components
- //
- this.typeOption.setNullSelectionAllowed(false);
- this.typeOption.setImmediate(true);
- this.typeOption.setDescription("Select whether this is an obligation or advice");
- this.typeOption.addItem("Obligation");
- this.typeOption.addItem("Advice");
-
- this.fulfillOption.setNullSelectionAllowed(true);
- this.fulfillOption.setDescription("Optionally restrict the use of the obligation/advice to a Permit or a Deny");
- this.fulfillOption.addItem("Permit");
- this.fulfillOption.addItem("Deny");
-
- this.descriptionField.setNullRepresentation("");
-
- this.expressionsField = new OaExpressionsField(this.obad);
- //
- // Add our form components
- //
- this.mainLayout.addComponent(this.typeOption);
- this.mainLayout.addComponent(this.fulfillOption);
- this.mainLayout.addComponent(this.xacmlID);
- this.mainLayout.addComponent(this.descriptionField);
- this.mainLayout.addComponent(this.expressionsField);
-// this.mainLayout.addComponent(this.tableExpressions);
- this.mainLayout.addComponent(this.saveButton);
- //
- // Now bind those fields to the data
- //
- this.fieldGroup = new FieldGroup(obad);
- this.fieldGroup.bindMemberFields(this);
- //
- // Finish setting up
- //
- this.initializeButtons();
- this.initializeOptions();
- //
- // Set focus
- //
- this.xacmlID.focus();
- }
-
- private void initializeButtons() {
- this.saveButton.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- fieldGroup.commit();
- self.isSaved = true;
- self.close();
- } catch (CommitException e) {
- e.printStackTrace();
- }
- }
-
- });
- }
-
- private void initializeOptions() {
- self.setIDCaption();
- this.typeOption.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.setIDCaption();
- }
-
- });
- }
-
- private void setIDCaption() {
- String value = (String) self.typeOption.getValue();
- if (value.equals("Obligation")) {
- self.xacmlID.setCaption("Obligation Id");
- } else {
- self.xacmlID.setCaption("Advice Id");
- }
- }
-
- public boolean isSaved() {
- return this.isSaved;
- }
-
- public void discard() {
- //
- // May be discarded automatically??
- //
- this.fieldGroup.discard();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java
deleted file mode 100644
index 21c2d45..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java
+++ /dev/null
@@ -1,817 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import java.util.Map;
-
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.admin.model.ObligationAdviceContainer;
-import org.apache.openaz.xacml.util.XACMLObjectCopy;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.TreeTable;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class ObligationAdviceEditorWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private Button buttonSave;
- @AutoGenerated
- private TreeTable tableExpressions;
- @AutoGenerated
- private HorizontalLayout horizontalLayout_1;
- @AutoGenerated
- private Button buttonClear;
- @AutoGenerated
- private Button buttonRemove;
- @AutoGenerated
- private Button buttonAdd;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static Log logger = LogFactory.getLog(ObligationAdviceEditorWindow.class);
- private final ObligationAdviceEditorWindow self = this;
- private final Object root;
- private final Map<VariableDefinitionType, PolicyType> variables;
- private ObligationAdviceContainer container;
- private boolean isSaved = false;
-
- private static final Action ADD_OBLIGATION = new Action ("Add Obligation");
- private static final Action ADD_ADVICE = new Action ("Add Advice");
- private static final Action ADD_EXPRESSION = new Action ("Add Expression");
- private static final Action ADD_ATTRIBUTE = new Action ("Add Attribute");
- private static final Action EDIT_OBLIGATION = new Action ("Edit Obligation");
- private static final Action EDIT_ADVICE = new Action ("Edit Advice");
- private static final Action EDIT_EXPRESSION = new Action ("Edit Expression");
- private static final Action EDIT_ATTRIBUTE = new Action ("Edit Attribute");
- private static final Action REMOVE_OBLIGATION = new Action ("Remove Obligation");
- private static final Action REMOVE_ADVICE = new Action ("Remove Advice");
- private static final Action REMOVE_EXPRESSION = new Action ("Remove Expression");
- private static final Action REMOVE_ATTRIBUTE = new Action ("Remove Attribute");
-
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public ObligationAdviceEditorWindow(Object root, Map<VariableDefinitionType, PolicyType> variables) {
- buildMainLayout();
- //setCompositionRoot(mainLayout);
- setContent(mainLayout);
- //
- // Save
- //
- if (! (root instanceof ObligationExpressionsType) &&
- ! (root instanceof AdviceExpressionsType) ) {
- throw new IllegalArgumentException("This window supports Obligation or Advice Expressions only.");
- }
- this.root = root;
- this.variables = variables;
- this.container = new ObligationAdviceContainer(this.root);
- //
- // Set our shortcuts
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- //
- // Initialize GUI
- //
- this.initializeTable();
- this.initializeButtons();
- this.setupButtons();
- //
- // Focus
- //
- this.tableExpressions.focus();
- }
-
- protected void initializeTable() {
- //
- // GUI properties
- //
- this.tableExpressions.setImmediate(true);
- //
- // Set the container
- //
- this.tableExpressions.setContainerDataSource(this.container);
- this.tableExpressions.setVisibleColumns(new Object[] {ObligationAdviceContainer.PROPERTY_NAME,
- ObligationAdviceContainer.PROPERTY_ID_SHORT,
- ObligationAdviceContainer.PROPERTY_EFFECT,
- ObligationAdviceContainer.PROPERTY_CATEGORY_SHORT,
- ObligationAdviceContainer.PROPERTY_DATATYPE_SHORT});
- this.tableExpressions.setColumnHeaders(new String[] {"Name", "ID or Value", (this.root instanceof ObligationExpressionsType ? "Effect" : "Applies"), "Category", "Data Type"});
- //this.tableExpressions.setColumnExpandRatio(ObligationAdviceContainer.PROPERTY_NAME, 1.0f);
- //this.tableExpressions.setColumnExpandRatio(ObligationAdviceContainer.PROPERTY_ID_SHORT, 1.0f);
- //this.tableExpressions.setColumnWi
- this.tableExpressions.setSelectable(true);
- //
- // Expand it out
- //
- for (Object item : this.tableExpressions.getItemIds()) {
- this.tableExpressions.setCollapsed(item, false);
- for (Object child : this.tableExpressions.getChildren(item)) {
- this.tableExpressions.setCollapsed(child, false);
- }
- }
- this.tableExpressions.setPageLength(this.container.size() + 3);
- //
- // Respond to events
- //
- this.tableExpressions.addActionHandler(new Handler() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Action[] getActions(Object target, Object sender) {
- if (target == null) {
- if (self.root instanceof ObligationExpressionsType) {
- return new Action[] {ADD_OBLIGATION};
- }
- if (self.root instanceof AdviceExpressionsType) {
- return new Action[] {ADD_ADVICE};
- }
- }
- if (target instanceof ObligationExpressionType) {
- return new Action[] {EDIT_OBLIGATION, REMOVE_OBLIGATION, ADD_EXPRESSION};
- }
- if (target instanceof AdviceExpressionType) {
- return new Action[] {EDIT_ADVICE, REMOVE_ADVICE, ADD_EXPRESSION};
- }
- if (target instanceof AttributeAssignmentExpressionType) {
- return new Action[] {EDIT_EXPRESSION, REMOVE_EXPRESSION, ADD_ATTRIBUTE};
- }
- if (target instanceof AttributeValueType ||
- target instanceof AttributeDesignatorType ||
- target instanceof AttributeSelectorType ||
- target instanceof ApplyType) {
- return new Action[] {EDIT_ATTRIBUTE, REMOVE_ATTRIBUTE};
- }
- return null;
- }
-
- @Override
- public void handleAction(Action action, Object sender, Object target) {
- if (action == ADD_OBLIGATION) {
- self.editObligation(null);
- return;
- }
- if (action == EDIT_OBLIGATION) {
- assert target instanceof ObligationExpressionType;
- self.editObligation((ObligationExpressionType) target);
- return;
- }
- if (action == REMOVE_OBLIGATION) {
- assert target instanceof ObligationExpressionType;
- if (self.container.removeItem(target) == false) {
- logger.error("Failed to remove obligation");
- assert false;
- }
- return;
- }
- if (action == ADD_ADVICE) {
- self.editAdvice(null);
- return;
- }
- if (action == EDIT_ADVICE) {
- assert target instanceof AdviceExpressionType;
- self.editAdvice((AdviceExpressionType) target);
- return;
- }
- if (action == REMOVE_ADVICE) {
- assert target instanceof AdviceExpressionType;
- if (self.container.removeItem(target) == false) {
- logger.error("Failed to remove advice");
- assert false;
- }
- return;
- }
- if (action == ADD_EXPRESSION) {
- assert target instanceof ObligationExpressionType || target instanceof AdviceExpressionType;
- self.editExpression(null, target);
- return;
- }
- if (action == EDIT_EXPRESSION) {
- assert target instanceof AttributeAssignmentExpressionType;
- self.editExpression((AttributeAssignmentExpressionType) target, self.container.getParent(target));
- return;
- }
- if (action == REMOVE_EXPRESSION) {
- assert target instanceof AttributeAssignmentExpressionType;
- if (self.container.removeItem(target) == false) {
- logger.error("Failed to remove expression");
- assert false;
- }
- return;
- }
- if (action == ADD_ATTRIBUTE) {
- assert target instanceof AttributeAssignmentExpressionType;
- self.editAttribute(null, (AttributeAssignmentExpressionType) target);
- return;
- }
- if (action == EDIT_ATTRIBUTE) {
- assert target instanceof AttributeValueType ||
- target instanceof AttributeDesignatorType ||
- target instanceof AttributeSelectorType ||
- target instanceof ApplyType;
- self.editAttribute(target, (AttributeAssignmentExpressionType) self.container.getParent(target));
- return;
- }
- if (action == REMOVE_ATTRIBUTE) {
- assert target instanceof AttributeValueType ||
- target instanceof AttributeDesignatorType ||
- target instanceof AttributeSelectorType ||
- target instanceof ApplyType;
- if (self.container.removeItem(target) == false) {
- logger.error("Failed to remove attribute");
- assert false;
- }
- return;
- }
- }
- });
- //
- // Respond to selections
- //
- this.tableExpressions.addValueChangeListener(new ValueChangeListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- self.setupButtons();
- }
- });
- this.tableExpressions.addItemClickListener(new ItemClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void itemClick(ItemClickEvent event) {
- if (event.isDoubleClick()) {
- if (event.getSource() instanceof AdviceExpressionType) {
- self.editAdvice((AdviceExpressionType) event.getSource());
- } else if (event.getSource() instanceof ObligationExpressionType) {
- self.editObligation((ObligationExpressionType) event.getSource());
- } else if (event.getSource() instanceof AttributeAssignmentExpressionType) {
- self.editExpression((AttributeAssignmentExpressionType) event.getSource(), self.container.getParent(event.getSource()));
- } else {
- self.editAttribute(event.getSource(), (AttributeAssignmentExpressionType) self.container.getParent(event.getSource()));
- }
- }
- }
- });
- //
- // Implement a description generator, to display the full XACML ID.
- //
- this.tableExpressions.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String generateDescription(Component source, Object itemId, Object propertyId) {
- if (propertyId == ObligationAdviceContainer.PROPERTY_ID_SHORT) {
- if (itemId instanceof AdviceExpressionType) {
- return ((AdviceExpressionType) itemId).getAdviceId();
- }
- if (itemId instanceof ObligationExpressionType) {
- return ((ObligationExpressionType) itemId).getObligationId();
- }
- if (itemId instanceof AttributeAssignmentExpressionType) {
- return ((AttributeAssignmentExpressionType) itemId).getAttributeId();
- }
- if (itemId instanceof AttributeDesignatorType) {
- return ((AttributeDesignatorType) itemId).getAttributeId();
- }
- if (itemId instanceof AttributeSelectorType) {
- return ((AttributeSelectorType) itemId).getContextSelectorId();
- }
- if (itemId instanceof ApplyType) {
- return ((ApplyType) itemId).getDescription();
- }
- }
- if (propertyId == ObligationAdviceContainer.PROPERTY_CATEGORY_SHORT) {
- if (itemId instanceof AttributeAssignmentExpressionType) {
- return ((AttributeAssignmentExpressionType) itemId).getCategory();
- }
- if (itemId instanceof AttributeDesignatorType) {
- return ((AttributeDesignatorType) itemId).getCategory();
- }
- if (itemId instanceof AttributeSelectorType) {
- return ((AttributeSelectorType) itemId).getCategory();
- }
- if (itemId instanceof ApplyType) {
- return null;
- }
- }
- if (propertyId == ObligationAdviceContainer.PROPERTY_DATATYPE_SHORT) {
- if (itemId instanceof AttributeValueType) {
- return ((AttributeValueType) itemId).getDataType();
- }
- if (itemId instanceof AttributeDesignatorType) {
- return ((AttributeDesignatorType) itemId).getDataType();
- }
- if (itemId instanceof AttributeSelectorType) {
- return ((AttributeSelectorType) itemId).getDataType();
- }
- /*
- if (itemId instanceof ApplyType) {
- //
- // TODO - get the datatype for the function
- //
- }
- */
- }
- return null;
- }
- });
- }
-
- protected void initializeButtons() {
- this.buttonAdd.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- if (self.tableExpressions.getValue() == null) {
- //
- // Add new root advice or obligation
- //
- if (self.root instanceof AdviceExpressionsType) {
- self.editAdvice(null);
- } else {
- self.editObligation(null);
- }
- } else {
- //
- // Add new assignment expression
- //
- self.editExpression(null, self.tableExpressions.getValue());
- }
- }
- });
-
- this.buttonRemove.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- Object object = self.tableExpressions.getValue();
- if (object != null) {
- if (object instanceof AttributeValueType ||
- object instanceof AttributeDesignatorType ||
- object instanceof AttributeSelectorType ||
- object instanceof ApplyType) {
- if (self.container.removeItem(self.container.getParent(object)) == false) {
- logger.error("Failed to remove attribute value/des/sel/apply");
- assert false;
- }
- } else {
- if (self.container.removeItem(object) == false) {
- logger.error("Failed to remove object");
- assert false;
- }
- }
- } else {
- logger.error("This code should never get executed if the button was properly disabled.");
- }
- }
- });
-
- this.buttonClear.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- Object object = self.tableExpressions.getValue();
- if (object == null) {
- if (self.container.removeAllItems() == false) {
- logger.error("Failed to remove all items");
- assert false;
- }
- } else {
- if (self.container.removeAllAssignments() == false) {
- logger.error("Failed to remove all assignments");
- assert false;
- }
- }
- }
- });
-
- this.buttonSave.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- //
- // Mark ourselves as saved
- //
- self.isSaved = true;
- //
- // Close the window
- //
- self.close();
- }
- });
- }
-
- protected void setupButtons() {
- Object target = this.tableExpressions.getValue();
- if (target == null) {
- if (this.root instanceof AdviceExpressionsType) {
- this.buttonAdd.setVisible(true);
- this.buttonAdd.setCaption("Add Advice");
- this.buttonRemove.setCaption("Remove Advice");
- this.buttonClear.setCaption("Clear All Advice");
- this.buttonClear.setVisible(true);
- } else {
- this.buttonAdd.setVisible(true);
- this.buttonAdd.setCaption("Add Obligation");
- this.buttonRemove.setCaption("Remove Obligation");
- this.buttonClear.setCaption("Clear All Obligations");
- this.buttonClear.setVisible(true);
- }
- this.buttonRemove.setEnabled(false);
- } else {
- if (target instanceof AdviceExpressionType ||
- target instanceof ObligationExpressionType) {
- this.buttonAdd.setVisible(true);
- this.buttonAdd.setCaption("Add Assignment");
- if (target instanceof AdviceExpressionType) {
- this.buttonRemove.setCaption("Remove Advice");
- } else {
- this.buttonRemove.setCaption("Remove Obligation");
- }
- this.buttonClear.setCaption("Clear All Assignments");
- this.buttonClear.setVisible(true);
- } else {
- this.buttonAdd.setVisible(false);
- this.buttonRemove.setCaption("Remove Assignment");
- this.buttonClear.setVisible(false);
- }
- this.buttonRemove.setEnabled(true);
- }
- if (this.tableExpressions.size() == 0) {
- this.buttonClear.setEnabled(false);
- } else {
- this.buttonClear.setEnabled(true);
- }
- }
-
- protected void editAttribute(Object target, final AttributeAssignmentExpressionType parent) {
- //
- // Make a copy
- //
- final AttributeAssignmentExpressionType copyAssignment = (parent == null ? new AttributeAssignmentExpressionType() : XACMLObjectCopy.copy(parent));
- //
- // Prompt user for attribute right away
- //
- final ExpressionBuilderComponent builder = new ExpressionBuilderComponent(copyAssignment, copyAssignment.getExpression() != null ? copyAssignment.getExpression().getValue() : null, null, self.variables);
- builder.setCaption("Define Assignment Attribute");
- builder.setModal(true);
- builder.addCloseListener(new CloseListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void windowClose(CloseEvent e) {
- //
- // Did the user save?
- //
- if (builder.isSaved() == false) {
- return;
- }
- //
- // Yes - update it
- //
- parent.setExpression(copyAssignment.getExpression());
- if (parent.getExpression() != null) {
- self.container.removeItem(parent.getExpression().getValue());
- }
- self.container.addItem(copyAssignment.getExpression().getValue(), parent);
- //
- // Set the table size
- //
- self.tableExpressions.setPageLength(self.container.size() + 1);
- }
- });
- builder.center();
- UI.getCurrent().addWindow(builder);
- }
-
- protected void editExpression(final AttributeAssignmentExpressionType assignment, final Object parent) {
- //
- // Copy
- //
- final AttributeAssignmentExpressionType copyAssignment = (assignment == null ? new AttributeAssignmentExpressionType() : XACMLObjectCopy.copy(assignment));
- //
- // Create the window
- //
- final AttributeAssignmentExpressionEditorWindow window = new AttributeAssignmentExpressionEditorWindow(copyAssignment);
- window.setCaption(assignment == null ? "Create Attribute Assignment" : "Edit Attribute Assignment");
- window.setModal(true);
- window.addCloseListener(new CloseListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void windowClose(CloseEvent e) {
- //
- // Did the user click save?
- //
- if (window.isSaved() == false) {
- return;
- }
- //
- // Was this a new assignment?
- //
- if (assignment == null) {
- //
- // Prompt user for attribute right away
- //
- final ExpressionBuilderComponent builder = new ExpressionBuilderComponent(copyAssignment, null, null, self.variables);
- builder.setCaption("Define Assignment Attribute");
- builder.setModal(true);
- builder.addCloseListener(new CloseListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void windowClose(CloseEvent e) {
- //
- // Did the user save?
- //
- if (builder.isSaved() == false) {
- return;
- }
- //
- // Yes - add it to the container
- //
- if (self.container.addItem(copyAssignment, parent) == null) {
- logger.error("Failed to add copy assignment");
- assert false;
- }
- //
- // Set the table size
- //
- self.tableExpressions.setPageLength(self.container.size() + 1);
- }
- });
- builder.center();
- UI.getCurrent().addWindow(builder);
- } else {
- //
- // No - copy back the data
- //
- assignment.setAttributeId(copyAssignment.getAttributeId());
- assignment.setIssuer(assignment.getIssuer());
- assignment.setCategory(copyAssignment.getCategory());
- //
- // Update the container
- //
- self.container.updateItem(assignment);
- }
- }
- });
- window.center();
- UI.getCurrent().addWindow(window);
- }
-
- protected void editAdvice(final AdviceExpressionType advice) {
- //
- // Copy the advice
- //
- final AdviceExpressionType copyAdvice = (advice == null ? new AdviceExpressionType() : XACMLObjectCopy.copy(advice));
- //
- // Setup the window
- //
- final AdviceEditorWindow window = new AdviceEditorWindow(copyAdvice);
- window.setCaption("Edit Advice");
- window.setModal(true);
- window.addCloseListener(new CloseListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void windowClose(CloseEvent e) {
- //
- // Is it saved?
- //
- if (window.isSaved() == false) {
- return;
- }
- //
- // Was this a new object?
- //
- if (advice == null) {
- //
- // New - add it to the container
- //
- if (self.container.addItem(copyAdvice) == null) {
- logger.error("failed to add advice");
- assert false;
- }
- //
- // Set the table size
- //
- self.tableExpressions.setPageLength(self.container.size() + 1);
- } else {
- //
- // No - copy it back
- //
- advice.setAdviceId(copyAdvice.getAdviceId());
- advice.setAppliesTo(copyAdvice.getAppliesTo());
- //
- // Update
- //
- self.container.updateItem(advice);
- }
- }
- });
- window.center();
- UI.getCurrent().addWindow(window);
- }
-
- protected void editObligation(final ObligationExpressionType obligation) {
- //
- // Copy the advice
- //
- final ObligationExpressionType copyObligation = (obligation == null ? new ObligationExpressionType() : XACMLObjectCopy.copy(obligation));
- //
- // Setup the window
- //
- final ObligationEditorWindow window = new ObligationEditorWindow(copyObligation);
- window.setCaption("Edit Obligation");
- window.setModal(true);
- window.addCloseListener(new CloseListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void windowClose(CloseEvent e) {
- //
- // Is it saved?
- //
- if (window.isSaved() == false) {
- return;
- }
- //
- // Was this a new object?
- //
- if (obligation == null) {
- //
- // New - add it to the container
- //
- if (self.container.addItem(copyObligation) == null) {
- logger.error("Failed to add obligation");
- assert false;
- }
- //
- // Set the table size
- //
- self.tableExpressions.setPageLength(self.container.size() + 1);
- } else {
- //
- // No - copy it back
- //
- obligation.setObligationId(copyObligation.getObligationId());
- obligation.setFulfillOn(copyObligation.getFulfillOn());
- //
- // Update
- //
- self.container.updateItem(obligation);
- }
- }
- });
- window.center();
- UI.getCurrent().addWindow(window);
- }
-
- public boolean isSaved() {
- return this.isSaved;
- }
-
- public Object getRootObject() {
- return this.root;
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("100%");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // horizontalLayout_1
- horizontalLayout_1 = buildHorizontalLayout_1();
- mainLayout.addComponent(horizontalLayout_1);
-
- // tableExpressions
- tableExpressions = new TreeTable();
- tableExpressions.setCaption("Expressions");
- tableExpressions.setImmediate(false);
- tableExpressions.setWidth("100%");
- tableExpressions.setHeight("-1px");
- mainLayout.addComponent(tableExpressions);
- mainLayout.setExpandRatio(tableExpressions, 1.0f);
-
- // buttonSave
- buttonSave = new Button();
- buttonSave.setCaption("Save");
- buttonSave.setImmediate(false);
- buttonSave.setWidth("-1px");
- buttonSave.setHeight("-1px");
- mainLayout.addComponent(buttonSave);
- mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
-
- return mainLayout;
- }
-
- @AutoGenerated
- private HorizontalLayout buildHorizontalLayout_1() {
- // common part: create layout
- horizontalLayout_1 = new HorizontalLayout();
- horizontalLayout_1.setImmediate(false);
- horizontalLayout_1.setWidth("-1px");
- horizontalLayout_1.setHeight("-1px");
- horizontalLayout_1.setMargin(false);
- horizontalLayout_1.setSpacing(true);
-
- // buttonAdd
- buttonAdd = new Button();
- buttonAdd.setCaption("Add Expression");
- buttonAdd.setImmediate(false);
- buttonAdd.setWidth("-1px");
- buttonAdd.setHeight("-1px");
- horizontalLayout_1.addComponent(buttonAdd);
-
- // buttonRemove
- buttonRemove = new Button();
- buttonRemove.setCaption("Remove Expression");
- buttonRemove.setImmediate(false);
- buttonRemove.setWidth("-1px");
- buttonRemove.setHeight("-1px");
- horizontalLayout_1.addComponent(buttonRemove);
-
- // buttonClear
- buttonClear = new Button();
- buttonClear.setCaption("Clear Expressions");
- buttonClear.setImmediate(false);
- buttonClear.setWidth("-1px");
- buttonClear.setHeight("-1px");
- horizontalLayout_1.addComponent(buttonClear);
-
- return horizontalLayout_1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java
deleted file mode 100644
index dac4eda..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
-
-import org.apache.openaz.xacml.admin.XacmlAdminUI;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.data.Buffered.SourceException;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.OptionGroup;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class ObligationEditorWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
- @AutoGenerated
- private Button buttonSave;
- @AutoGenerated
- private OptionGroup optionGroupFullfillOn;
- @AutoGenerated
- private TextField textFieldObligationID;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final ObligationEditorWindow self = this;
- private final ObligationExpressionType obligation;
- private boolean isSaved = false;
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public ObligationEditorWindow(ObligationExpressionType obligation) {
- buildMainLayout();
- //setCompositionRoot(mainLayout);
- setContent(mainLayout);
- //
- // Save
- //
- this.obligation = obligation;
- //
- // Set our shortcuts
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- //
- // Initialize GUI
- //
- this.initialize();
- this.initializeButton();
- //
- // Focus
- //
- this.textFieldObligationID.focus();
- }
-
- protected void initialize() {
- //
- // The text field for the advice ID
- //
- this.textFieldObligationID.setNullRepresentation("");
- if (this.obligation.getObligationId() == null) {
- this.textFieldObligationID.setValue(XacmlAdminUI.getDomain());
- } else {
- this.textFieldObligationID.setValue(obligation.getObligationId());
- }
- this.textFieldObligationID.setRequiredError("You must have an ID for the obligation");
- //
- // The option
- //
- this.optionGroupFullfillOn.setRequiredError("You must select Permit or Deny for the obligation");
- this.optionGroupFullfillOn.addItem(EffectType.PERMIT);
- this.optionGroupFullfillOn.addItem(EffectType.DENY);
- if (this.obligation.getFulfillOn() == null) {
- this.optionGroupFullfillOn.select(EffectType.PERMIT);
- } else {
- if (this.obligation.getFulfillOn().equals(EffectType.PERMIT)) {
- this.optionGroupFullfillOn.select(EffectType.PERMIT);
- } else {
- this.optionGroupFullfillOn.select(EffectType.DENY);
- }
- }
- }
-
- protected void initializeButton() {
- this.buttonSave.setImmediate(true);
- this.buttonSave.setClickShortcut(KeyCode.ENTER);
- this.buttonSave.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- //
- // Commit
- //
- self.textFieldObligationID.commit();
- self.optionGroupFullfillOn.commit();
- //
- // all good, save everything
- //
- self.obligation.setObligationId(self.textFieldObligationID.getValue());
- self.obligation.setFulfillOn((EffectType) self.optionGroupFullfillOn.getValue());
- //
- // Set ourselves as saved
- //
- self.isSaved = true;
- //
- // Close the window
- //
- self.close();
- } catch (SourceException | InvalidValueException e) { //NOPMD
- //
- // Vaadin displays the error
- //
- }
- }
- });
- }
-
- public boolean isSaved() {
- return this.isSaved;
- }
-
- public ObligationExpressionType getAdvice() {
- return this.obligation;
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("-1px");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // textFieldObligationID
- textFieldObligationID = new TextField();
- textFieldObligationID.setCaption("Obligation ID");
- textFieldObligationID.setImmediate(false);
- textFieldObligationID.setWidth("-1px");
- textFieldObligationID.setHeight("-1px");
- textFieldObligationID.setInvalidAllowed(false);
- textFieldObligationID.setRequired(true);
- textFieldObligationID.setInputPrompt("Eg. urn:com:foo:obligation:sample");
- mainLayout.addComponent(textFieldObligationID);
-
- // optionGroupFullfillOn
- optionGroupFullfillOn = new OptionGroup();
- optionGroupFullfillOn.setCaption("Fulfill On");
- optionGroupFullfillOn.setImmediate(false);
- optionGroupFullfillOn.setWidth("-1px");
- optionGroupFullfillOn.setHeight("-1px");
- optionGroupFullfillOn.setInvalidAllowed(false);
- optionGroupFullfillOn.setRequired(true);
- mainLayout.addComponent(optionGroupFullfillOn);
-
- // buttonSave
- buttonSave = new Button();
- buttonSave.setCaption("Save");
- buttonSave.setImmediate(true);
- buttonSave.setWidth("-1px");
- buttonSave.setHeight("-1px");
- mainLayout.addComponent(buttonSave);
- mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
-
- return mainLayout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/c68f98c5/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java
deleted file mode 100644
index de279a3..0000000
--- a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.openaz.xacml.admin.view.windows;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
-import org.apache.openaz.xacml.api.pap.PDPPolicy;
-import org.apache.openaz.xacml.api.pap.PDPStatus;
-import com.vaadin.annotations.AutoGenerated;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class PDPStatusWindow extends Window {
-
- /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
-
- @AutoGenerated
- private VerticalLayout mainLayout;
-
-
- @AutoGenerated
- private Button buttonOK;
-
-
- @AutoGenerated
- private Table table;
-
-
- private PDPStatus status;
-
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Log logger = LogFactory.getLog(PDPStatusWindow.class);
- private final PDPStatusWindow self = this;
-
- /**
- * The constructor should first build the main layout, set the
- * composition root and then do any custom initialization.
- *
- * The constructor will not be automatically regenerated by the
- * visual editor.
- */
- public PDPStatusWindow(PDPStatus status) {
- buildMainLayout();
- setContent(mainLayout);
- //setCompositionRoot(mainLayout);
- //
- // Save
- //
- this.status = status;
- //
- // Setup shortcuts
- //
- this.setCloseShortcut(KeyCode.ESCAPE);
- this.buttonOK.setClickShortcut(KeyCode.ENTER);
- //
- // Initialize
- //
- try {
- this.initialize();
- this.initializeButton();
- } catch (Exception e) {
- logger.error("Initialize exception: " + e);
- }
- //
- // Focus
- //
- this.buttonOK.focus();
- }
-
- protected void initialize() {
- //
- // Setup the table - real simple
- //
- this.table.addContainerProperty("Property", Label.class, null);
- this.table.addContainerProperty("Value", TextArea.class, null);
- //
- // Set the status
- //
- StringBuilder builder;
- int rows;
- Integer id = 1;
- this.table.addItem(new Object[] {new Label("Status"), this.createTextArea(this.status.getStatus().toString(), 1)}, id++);
- //
- // Setup Errors
- //
- builder = new StringBuilder();
- rows = 0;
- for (String error : this.status.getLoadErrors()) {
- builder.append(error);
- builder.append(System.lineSeparator());
- rows++;
- }
- if (rows == 0) {
- rows = 1;
- }
- this.table.addItem(new Object[] {new Label("Errors"), this.createTextArea(builder.toString(), rows)}, id++);
- //
- // Setup Errors
- //
- builder = new StringBuilder();
- rows = 0;
- for (String error : this.status.getLoadWarnings()) {
- builder.append(error);
- builder.append(System.lineSeparator());
- rows++;
- }
- if (rows == 0) {
- rows = 1;
- }
- this.table.addItem(new Object[] {new Label("Warnings"), this.createTextArea(builder.toString(), rows)}, id++);
- //
- // Setup the loaded policy table
- //
- builder = new StringBuilder();
- rows = 0;
- for (PDPPolicy policy : this.status.getLoadedPolicies()) {
- builder.append(policy.getName());
- builder.append(System.lineSeparator());
- rows++;
- }
- if (rows == 0) {
- rows = 1;
- }
- this.table.addItem(new Object[] {new Label("Policies Loaded"), this.createTextArea(builder.toString(), rows)}, id++);
- //
- // Setup the Failed policy table
- //
- builder = new StringBuilder();
- rows = 0;
- for (PDPPolicy policy : this.status.getFailedPolicies()) {
- builder.append(policy.getName());
- builder.append(System.lineSeparator());
- rows++;
- }
- if (rows == 0) {
- rows = 1;
- }
- this.table.addItem(new Object[] {new Label("Policies Failed To Load"), this.createTextArea(builder.toString(), rows)}, id++);
- //
- // Setup the Loaded PIP configuration table
- //
- builder = new StringBuilder();
- rows = 0;
- for (PDPPIPConfig config : this.status.getLoadedPipConfigs()) {
- builder.append(config.getName());
- builder.append(System.lineSeparator());
- rows++;
- }
- if (rows == 0) {
- rows = 1;
- }
- this.table.addItem(new Object[] {new Label("Loaded PIP Configurations"), this.createTextArea(builder.toString(), rows)}, id++);
- //
- // Setup the Failed PIP configuration table
- //
- builder = new StringBuilder();
- rows = 0;
- for (PDPPIPConfig config : this.status.getFailedPipConfigs()) {
- builder.append(config.getName());
- builder.append(System.lineSeparator());
- rows++;
- }
- if (rows == 0) {
- rows = 1;
- }
- this.table.addItem(new Object[] {new Label("Failed PIP Configurations"), this.createTextArea(builder.toString(), rows)}, id++);
- //
- // Set the length
- //
- table.setPageLength(id - 1);
- table.setReadOnly(true);
- table.setSizeFull();
- }
-
- protected TextArea createTextArea(String value, int lines) {
- TextArea area = new TextArea();
- area.setValue(value);
- area.setNullRepresentation("");
- area.setSizeFull();
- area.setReadOnly(true);
- area.setRows(lines);
- return area;
- }
-
- protected void initializeButton() {
- this.buttonOK.addClickListener(new ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- self.close();
- }
- });
- }
-
- @AutoGenerated
- private VerticalLayout buildMainLayout() {
- // common part: create layout
- mainLayout = new VerticalLayout();
- mainLayout.setImmediate(false);
- mainLayout.setWidth("100.0%");
- mainLayout.setHeight("-1px");
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
-
- // top-level component properties
- setWidth("-1px");
- setHeight("-1px");
-
- // table
- table = new Table();
- table.setCaption("Status");
- table.setImmediate(false);
- table.setWidth("100.0%");
- table.setHeight("-1px");
- mainLayout.addComponent(table);
-
- // buttonOK
- buttonOK = new Button();
- buttonOK.setCaption("Ok");
- buttonOK.setImmediate(true);
- buttonOK.setWidth("-1px");
- buttonOK.setHeight("-1px");
- mainLayout.addComponent(buttonOK);
- mainLayout.setComponentAlignment(buttonOK, new Alignment(48));
-
- return mainLayout;
- }
-
-
-
-}