diff options
Diffstat (limited to 'bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst')
461 files changed, 41356 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/Action.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/Action.java new file mode 100644 index 000000000..b7f8e1211 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/Action.java @@ -0,0 +1,130 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.CurrentNodeSelectionTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.*; +import javax.servlet.http.*; + +// Abstract action class used for both Link and Form actions. +public abstract class Action +{ + protected Controller controller_; + protected Hashtable propertyTable_; + protected Vector removedProperties_; + + public Action() + { + this(null); + } + + public Action(Controller controller) + { + controller_ = controller; + propertyTable_ = new Hashtable(); + removedProperties_ = new Vector(); + } + + public final Controller getController() + { + return controller_; + } + + /** + * Read properties from an HttpServletRequest and add them to the property table. + * @param HttpServletRequest The HttpServletRequest containing the embedded parameters. + * @return boolean Whether or not the operation was successful. + */ + public abstract boolean populatePropertyTable(HttpServletRequest request); + + /** + * Get the property table. + * @return Hashtable A hashtable containing the properties for this action. + */ + public final Hashtable getPropertyTable() + { + return propertyTable_; + } + + /** + * Set the property table. + * @return void + */ + public void setPropertyTable(Hashtable propertyTable) + { + propertyTable_ = propertyTable; + } + + /** + * Add a property to the property table. + * @param void + */ + public final void addProperty(Object key, Object value) + { + propertyTable_.put(key, value); + } + + /** + * Remove a property from the property table. Track the deletions. + * @param Object The key of the property being removed. + */ + public final void removeProperty(Object key) + { + propertyTable_.remove(key); + removedProperties_.addElement(key); + } + + public final String[] getPropertyAsStringArray(Object key) + { + Object object = propertyTable_.get(key); + if (object instanceof String[]) + return (String[])object; + else if (object != null) + return new String[] {object.toString()}; + else + return new String[0]; + } + + public final boolean execute() + { + return execute(true); + } + + public final boolean execute(boolean useActionEngine) + { + if (useActionEngine) + return controller_.getActionEngine().executeAction(this); + else + return run(); + } + + // Abstract method for running this action. + public abstract boolean run(); + + /** + * Return the transformers used to normalize the input/output parameters for this action + * @return ITransformer[] + */ + public ITransformer[] getTransformers() + { + return new ITransformer[] {new CurrentNodeSelectionTransformer(controller_)}; + } + + protected void handleUnexpectedException(Perspective perspective,MessageQueue messageQueue,String exceptionName,Throwable t) + { + messageQueue.addMessage(perspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage(exceptionName); + messageQueue.addMessage(t.getMessage()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/CheckWorkbenchFileReadOnlyAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/CheckWorkbenchFileReadOnlyAction.java new file mode 100644 index 000000000..0cfceec6d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/CheckWorkbenchFileReadOnlyAction.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import javax.servlet.http.*; + +public class CheckWorkbenchFileReadOnlyAction extends Action +{ + public static final String getActionLink() + { + return "actions/CheckWorkbenchFileReadOnlyActionJSP.jsp"; + } + + public boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ClearNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ClearNodeAction.java new file mode 100644 index 000000000..65d3db43b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ClearNodeAction.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public abstract class ClearNodeAction extends NodeAction +{ + public ClearNodeAction(Controller controller,NodeManager nodeManager) + { + super(controller,nodeManager); + } + + public boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + if (!isStaleNode(nodeId)) + { + Node node = nodeManager_.getNode(nodeId); + TreeElement element = node.getTreeElement(); + element.disconnectAll(); + // Do not add this to the history. + MessageQueue messageQueue = controller_.getCurrentPerspective().getMessageQueue(); + messageQueue.addMessage(controller_.getMessage("MSG_INFO_NODE_CLEARED",node.getNodeName())); + return true; + } + return false; + } + + public final String getActionLinkForHistory() + { + return null; + } + + // Deleting a node from the tree results in changes to the treeview and status contents. + public abstract String getTreeContentVar(); + public abstract String getTreeContentPage(); + public abstract String getPropertiesContainerVar(); + public abstract String getPropertiesContainerPage(); + public abstract String getStatusContentVar(); + public abstract String getStatusContentPage(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ClearViewElementAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ClearViewElementAction.java new file mode 100644 index 000000000..90614e073 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ClearViewElementAction.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.http.*; + +// Abstract action class used for both Link and Form actions. +public abstract class ClearViewElementAction extends LinkAction +{ + private String listManagerRel_; + private NodeManager nodeManager_; + public ClearViewElementAction(Controller controller,NodeManager nodeManager,String listManagerRel) + { + super(controller); + nodeManager_ = nodeManager; + listManagerRel_ = listManagerRel; + } + + // ...jsp?viewId=... + protected final boolean processLinkParameters(HttpServletRequest request) + { + String viewIdString = request.getParameter(ActionInputs.VIEWID); + // Perform data validation. + try + { + int viewId = Integer.parseInt(viewIdString); + } + catch (NumberFormatException e) + { + // Validation failed! + return false; + } + propertyTable_.put(ActionInputs.VIEWID,viewIdString); + return true; + } + + public final boolean run() + { + int viewId = Integer.parseInt((String)propertyTable_.get(ActionInputs.VIEWID)); + Node selectedNode = nodeManager_.getSelectedNode(); + ViewTool viewTool = (ViewTool)selectedNode.getToolManager().getSelectedTool(); + if (viewTool.getToolManager(viewId) == null) + { + // Stale view. + return false; + } + TreeElement element = selectedNode.getTreeElement(); + ListManager listManager = (ListManager)element.getPropertyAsObject(listManagerRel_); + listManager.removeElementWithViewId(viewId); + viewTool.clearViewToolManager(viewId); + selectedNode.setViewId(ActionInputs.VIEWID_DEFAULT); + // Do not add this to the history. + return true; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public abstract String getPropertiesContainerVar(); + public abstract String getPropertiesContainerPage(); + public abstract String getStatusContentVar(); + public abstract String getStatusContentPage(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/FormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/FormAction.java new file mode 100644 index 000000000..d87965205 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/FormAction.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import javax.servlet.http.*; +import java.util.Hashtable; +import java.util.Iterator; + +public abstract class FormAction extends Action +{ + public FormAction(Controller controller) + { + super(controller); + } + + protected abstract boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException; + + public final boolean populatePropertyTable(HttpServletRequest request) + { + try + { + MultipartFormDataParser parser = new MultipartFormDataParser(); + parser.parseRequest(request,HTMLUtils.UTF8_ENCODING); + getSelectedFormTool().clearErrors(); + boolean result = processParsedResults(parser); + removedProperties_.removeAllElements(); + return result; + } + catch (MultipartFormDataException e) + { + } + return false; + } + + public void setPropertyTable(Hashtable propertyTable) + { + try + { + processParsedResults(new MultipartFormDataParser(propertyTable)); + } + catch (MultipartFormDataException mfde) + { + } + for (Iterator it = propertyTable.keySet().iterator(); it.hasNext();) + { + Object key = it.next(); + Hashtable thisPropertyTable = getPropertyTable(); + if (!thisPropertyTable.containsKey(key)) + addProperty(key, propertyTable.get(key)); + } + } + + protected final void addToHistory(int perspectiveId,String url) + { + controller_.addToHistory(perspectiveId,url); + } + + public abstract FormTool getSelectedFormTool(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/FormInputException.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/FormInputException.java new file mode 100644 index 000000000..0f94a9920 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/FormInputException.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +// A class for reporting form input exceptions. +public class FormInputException extends Exception +{ + /** + * Comment for <code>serialVersionUID</code> + */ + private static final long serialVersionUID = 3257846601685938742L; + +public FormInputException(String msg) + { + super(msg); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ImportToFileSystemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ImportToFileSystemAction.java new file mode 100644 index 000000000..cefc21128 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ImportToFileSystemAction.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.wsdl.internal.impl.wsdl4j.WSDLFactoryImpl; +import javax.wsdl.Definition; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLWriter; +import java.io.OutputStreamWriter; +import java.io.OutputStream; +import javax.servlet.http.*; +import org.apache.wsil.WSILDocument; + +public abstract class ImportToFileSystemAction extends LinkAction +{ + public ImportToFileSystemAction(Controller controller) + { + super(controller); + } + + // os is the OutputStream of the file in the file system + public abstract boolean write(OutputStream os); + + // the default name for the file + public abstract String getDefaultFileName(); + + public boolean writeWSDLDefinition(OutputStream os, Definition definition) + { + try + { + WSDLFactory wsdlFactory = new WSDLFactoryImpl(); + WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter(); + wsdlWriter.writeWSDL(definition, os); + return true; + } + catch (Throwable t) + { + return false; + } + } + + public boolean writeWSILDocument(OutputStream os, WSILDocument wsilDoc) + { + OutputStreamWriter osw = null; + try + { + osw = new OutputStreamWriter(os); + wsilDoc.write(osw); + return true; + } + catch (Exception e) + { + return false; + } + finally + { + try + { + if (osw != null) + osw.close(); + } + catch (Exception e) + { + } + } + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID, String jspPage) + { + StringBuffer actionLink = new StringBuffer(jspPage); + actionLink.append('?'); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + protected boolean processLinkParameters(HttpServletRequest request) + { + String nodeID = request.getParameter(ActionInputs.NODEID); + String toolID = request.getParameter(ActionInputs.TOOLID); + String viewID = request.getParameter(ActionInputs.VIEWID); + String viewToolID = request.getParameter(ActionInputs.VIEWTOOLID); + try + { + Integer.parseInt(nodeID); + Integer.parseInt(toolID); + Integer.parseInt(viewID); + Integer.parseInt(viewToolID); + propertyTable_.put(ActionInputs.NODEID, nodeID); + propertyTable_.put(ActionInputs.TOOLID, toolID); + propertyTable_.put(ActionInputs.VIEWID, viewID); + propertyTable_.put(ActionInputs.VIEWTOOLID, viewToolID); + } + catch (Exception e) + { + return false; + } + return true; + } + + public abstract String getStatusContentVar(); + + public abstract String getStatusContentPage(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ImportToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ImportToWorkbenchAction.java new file mode 100644 index 000000000..9f766037b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ImportToWorkbenchAction.java @@ -0,0 +1,217 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageQueue; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.wsil.AddWSDLToWSILCommand; +import org.eclipse.wst.command.internal.env.ui.eclipse.EclipseEnvironment; + +public abstract class ImportToWorkbenchAction extends FormAction { + private IWorkspaceRoot iWorkspaceRoot_; + private IProject iProject_; + private IResource targetFileResource_; + + public ImportToWorkbenchAction(Controller controller) { + super(controller); + iWorkspaceRoot_ = ResourcesPlugin.getWorkspace().getRoot(); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException { + FormTool formTool = getSelectedFormTool(); + MessageQueue msgQueue = controller_.getCurrentPerspective().getMessageQueue(); + boolean inputsValid = true; + String workbenchProjectName = parser.getParameter(ActionInputs.WORKBENCH_PROJECT_NAME); + if (workbenchProjectName == null || workbenchProjectName.length() <= 0) { + msgQueue.addMessage(controller_.getMessage("MSG_ERROR_INVALID_WORKBENCH_PROJECT")); + inputsValid = false; + } + else + { + iProject_ = iWorkspaceRoot_.getProject(workbenchProjectName); + propertyTable_.put(ActionInputs.WORKBENCH_PROJECT_NAME, workbenchProjectName); + } + String importFile = parser.getParameter(ActionInputs.IMPORT_FILE); + if (importFile != null) + { + propertyTable_.put(ActionInputs.IMPORT_FILE, ActionInputs.IMPORT_FILE); + String importedFileName = parser.getParameter(ActionInputs.IMPORTED_FILE_NAME); + if (importedFileName == null || importedFileName.length() <= 0) + { + msgQueue.addMessage(controller_.getMessage("MSG_ERROR_INVALID_FILE_NAME")); + inputsValid = false; + } + else + propertyTable_.put(ActionInputs.IMPORTED_FILE_NAME, importedFileName); + } + String importToWSIL = parser.getParameter(ActionInputs.IMPORT_TO_WSIL); + if (importToWSIL != null) + { + propertyTable_.put(ActionInputs.IMPORT_TO_WSIL, ActionInputs.IMPORT_TO_WSIL); + propertyTable_.put(ActionInputs.IMPORTED_WSDL_URL, parser.getParameter(ActionInputs.IMPORTED_WSDL_URL)); + String wsilFileName = parser.getParameter(ActionInputs.WSIL_FILE_NAME); + if (wsilFileName == null || wsilFileName.length() <= 0) + { + msgQueue.addMessage(controller_.getMessage("MSG_ERROR_INVALID_WSIL_FILE_NAME")); + inputsValid = false; + } + else + propertyTable_.put(ActionInputs.WSIL_FILE_NAME, wsilFileName); + } + if (importFile == null && importToWSIL == null) + { + msgQueue.addMessage(controller_.getMessage("MSG_ERROR_NO_IMPORT_OPTION_SELECTED")); + inputsValid = false; + } + return inputsValid; + } + + private OutputStream getOutputStream(String defaultFileName) throws FileNotFoundException { + File file = new File(controller_.getServletEngineStateLocation() + defaultFileName); + FileOutputStream fos = new FileOutputStream(file); + return fos; + } + + private boolean importTempFileToWebProject(String defaultFileName) throws FileNotFoundException, CoreException + { + if (targetFileResource_ != null && targetFileResource_.getType() == IResource.FILE) + targetFileResource_.delete(true,new NullProgressMonitor()); + + String importedFileName = (String)propertyTable_.get(ActionInputs.IMPORTED_FILE_NAME); + File file = new File(controller_.getServletEngineStateLocation()+defaultFileName); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); + + IFile iFile = iProject_.getFile("/"+importedFileName); + iFile.create(bis,true,new NullProgressMonitor()); + + // Remove the temporary file + file.delete(); + return true; + } + + public boolean fileExists() + { + String importedFileName = (String)propertyTable_.get(ActionInputs.IMPORTED_FILE_NAME); + if (importedFileName != null) + { + targetFileResource_ = iProject_.findMember(importedFileName); + return (targetFileResource_ != null && targetFileResource_.getType() == IResource.FILE); + } + else + return false; + } + + public boolean isTargetFileResourceReadOnly() + { + return targetFileResource_.getResourceAttributes().isReadOnly(); + } + + // TODO: ResourceContext need to move to org.eclipse.wst.ws. + public boolean isCheckoutFilesEnabled() + { + return true; +// return WebServicePlugin.getInstance().getResourceContext().isCheckoutFilesEnabled(); + } + + public String getWebServicePluginFileMessage(String messageId) + { + String importedFileName = (String)propertyTable_.get(ActionInputs.IMPORTED_FILE_NAME); + return controller_.getMessage(messageId,new String[]{iProject_.getFullPath().toString(),importedFileName}); + } + + // TODO: ResourceContext need to move to org.eclipse.wst.ws. + public boolean isOverwriteFilesEnabled() + { + return true; +// return WebServicePlugin.getInstance().getResourceContext().isOverwriteFilesEnabled(); + } + + public boolean validateEdit() + { + IFile[] files = new IFile[1]; + files[0] = (IFile)targetFileResource_; + IStatus status = ResourcesPlugin.getWorkspace().validateEdit(files,null); + MessageQueue messageQueue = controller_.getCurrentPerspective().getMessageQueue(); + messageQueue.addMessage(status.getMessage()); + return status.isOK(); + } + + public boolean run() { + MessageQueue msgQueue = controller_.getCurrentPerspective().getMessageQueue(); + if (propertyTable_.get(ActionInputs.IMPORT_FILE) != null) + { + try { + ImportToFileSystemAction action = newImportToFileSystemAction(); + action.run(); + String defaultFileName = action.getDefaultFileName(); + if (!action.write(getOutputStream(defaultFileName))) { + msgQueue.addMessage(controller_.getMessage("MSG_ERROR_WRITING_TEMP_FILE_TO_FS")); + return false; + } + importTempFileToWebProject(defaultFileName); + String importedFileName = (String)propertyTable_.get(ActionInputs.IMPORTED_FILE_NAME); + msgQueue.addMessage(controller_.getMessage("MSG_INFO_IMPORT_TO_WORKBENCH_SUCCESSFUL", importedFileName)); + } + catch (FileNotFoundException fnfe) { + msgQueue.addMessage(fnfe.getMessage()); + return false; + } + catch (CoreException ce) { + msgQueue.addMessage(ce.getMessage()); + return false; + } + } + if (propertyTable_.get(ActionInputs.IMPORT_TO_WSIL) != null) + { + String projectName = (String)propertyTable_.get(ActionInputs.WORKBENCH_PROJECT_NAME); + String importedWSILFileName = (String)propertyTable_.get(ActionInputs.WSIL_FILE_NAME); + String wsdlURL = (String)propertyTable_.get(ActionInputs.IMPORTED_WSDL_URL); + StringBuffer wsilPlatformURL = new StringBuffer("platform:/resource/"); + wsilPlatformURL.append(projectName); + wsilPlatformURL.append('/'); + wsilPlatformURL.append(importedWSILFileName); + AddWSDLToWSILCommand command = new AddWSDLToWSILCommand(); + String[] args = new String[5]; + args[0] = AddWSDLToWSILCommand.ARG_WSIL; + args[1] = wsilPlatformURL.toString(); + args[2] = AddWSDLToWSILCommand.ARG_WSDL; + args[3] = wsdlURL; + args[4] = AddWSDLToWSILCommand.ARG_RESOLVE_WSDL; + command.setArguments(args); + command.execute(new EclipseEnvironment(null, null, null, null)); + msgQueue.addMessage(controller_.getMessage("MSG_INFO_IMPORT_SERVICE_REF_TO_WSIL_SUCCESSFUL", importedWSILFileName)); + } + return true; + } + + public abstract String getStatusContentVar(); + public abstract String getStatusContentPage(); + public abstract ImportToFileSystemAction newImportToFileSystemAction(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/LaunchWebServiceWizardAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/LaunchWebServiceWizardAction.java new file mode 100644 index 000000000..1370dde4e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/LaunchWebServiceWizardAction.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; + +public abstract class LaunchWebServiceWizardAction extends FormAction +{ + public LaunchWebServiceWizardAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String wizardID = parser.getParameter(ActionInputs.WEB_SERVICE_WIZARD); + propertyTable_.put(ActionInputs.WEB_SERVICE_WIZARD, wizardID); + return true; + } + + public boolean launchWizard(String wsdlURL) + { + LaunchWizardTask task = LaunchWizardTask.getInstance(); + if (task.getIsExecuting()) + { + controller_.getCurrentPerspective().getMessageQueue().addMessage(controller_.getMessage("MSG_ERROR_WIZARD_ALREADY_RUNNING")); + return false; + } + int wizardID = Integer.parseInt((String)propertyTable_.get(ActionInputs.WEB_SERVICE_WIZARD)); + LaunchWizardRunnable runnable; + if (wizardID == ActionInputs.WEB_SERVICE_CLIENT_WIZARD) + runnable = new LaunchWizardRunnable("org.eclipse.jst.ws.internal.consumption.ui.wizard.client.clientwizard", wsdlURL); + else if (wizardID == ActionInputs.WEB_SERVICE_SKELETON_WIZARD) + runnable = new LaunchWizardRunnable("org.eclipse.jst.ws.creation.ui.wizard.serverwizard", wsdlURL); + else + return false; + task.checkAndAsyncExec(runnable); + return true; + } + + public abstract String getStatusContentVar(); + + public abstract String getStatusContentPage(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/LinkAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/LinkAction.java new file mode 100644 index 000000000..223b155c3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/LinkAction.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.http.*; + +// Abstract class representing the action of clicking a link. These actions +// may change the history list. +public abstract class LinkAction extends Action +{ + private boolean isAddedToHistory_; + private boolean isStaleBreadCrumb_; + + public LinkAction(Controller controller) + { + super(controller); + isAddedToHistory_ = false; + isStaleBreadCrumb_ = false; + } + + // Determine if the action was successfully added to this history list. + // This should be called after the run() method. + public final boolean isAddedToHistory() + { + return isAddedToHistory_; + } + + protected abstract boolean processLinkParameters(HttpServletRequest request); + + public final boolean populatePropertyTable(HttpServletRequest request) + { + String isHistoryString = request.getParameter(ActionInputs.ISHISTORY); + if (isHistoryString != null) + propertyTable_.put(ActionInputs.ISHISTORY,isHistoryString); + return processLinkParameters(request); + } + + // Add the action's URL to the controller's history list. + protected final void addToHistory(int perspectiveId,String url) + { + if (!isHistoryAction()) + isAddedToHistory_ = controller_.addToHistory(perspectiveId,url); + } + + public final boolean isHistoryAction() + { + return (propertyTable_.get(ActionInputs.ISHISTORY) != null); + } + + public final void setStaleBreadCrumb() + { + if (isHistoryAction()) + { + isStaleBreadCrumb_ = true; + controller_.processStaleBreadCrumb(); + } + } + + public final boolean isStaleBreadCrumb() + { + return isStaleBreadCrumb_; + } + + // Call this when a stale breadcrumb is encountered while traversing history chain. + public final String getNextHistoryActionLink() + { + return RetrieveHistoryAction.getActionLink(controller_.getHistoryDirection()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/NodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/NodeAction.java new file mode 100644 index 000000000..aec33b30c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/NodeAction.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.http.*; + +public abstract class NodeAction extends LinkAction +{ + protected NodeManager nodeManager_; + private boolean requiresTreeViewRefresh_; + private boolean requiresNodeSelection_; + private boolean requiresViewSelection_; + private boolean requiresStatusUpdate_; + + public NodeAction(Controller controller,NodeManager nodeManager) + { + super(controller); + nodeManager_ = nodeManager; + requiresTreeViewRefresh_ = false; + requiresNodeSelection_ = false; + requiresViewSelection_ = false; + requiresStatusUpdate_ = false; + } + + // ...jsp?nodeId=...<&isHistory=1> + protected boolean processLinkParameters(HttpServletRequest request) + { + String nodeIdString = request.getParameter(ActionInputs.NODEID); + // Perform data validation. + try + { + int nodeId = Integer.parseInt(nodeIdString); + } + catch (NumberFormatException e) + { + // Validation failed! + return false; + } + propertyTable_.put(ActionInputs.NODEID,nodeIdString); + return true; + } + + protected final boolean isStaleNode(int nodeId) + { + return (nodeManager_.getNode(nodeId) == null); + } + + /** + * Make a node visible. A node is visible when all of its ancestors are expanded. + * @param Node The node to be made visible. + * @return boolean Indicator for whether or not the tree structure was changed (i.e. expanded to show the node in question). + */ + protected final boolean makeNodeVisible(Node node) + { + requiresTreeViewRefresh_ = node.getNodeManager().makeNodeVisible(node); + return requiresTreeViewRefresh_; + } + + /** + * Select a node with id nodeId. + * @param int The id of the node to be selected. + */ + protected final void setSelectedNodeId(int nodeId) + { + if (nodeManager_.getSelectedNodeId() != nodeId) + { + requiresNodeSelection_ = true; + nodeManager_.setSelectedNodeId(nodeId); + } + } + + protected final void setSelectedViewId(int viewId) + { + Node selectedNode = nodeManager_.getSelectedNode(); + if (selectedNode.getViewId() != viewId) + { + requiresViewSelection_ = true; + selectedNode.setViewId(viewId); + } + } + + // Determine whether or not the treeview requires reloading as a result of this action. + // Reloading is required when branches are added/removed. + public boolean requiresTreeViewRefresh() + { + return requiresTreeViewRefresh_; + } + + // Determine whether or not a new node has been selected as a result of the action. + public boolean requiresNodeSelection() + { + return requiresNodeSelection_; + } + + // Determine if a new view element is selected. + public boolean requiresViewSelection() + { + return requiresViewSelection_; + } + + // Determine if any status messages arose from this action. + public boolean requiresStatusUpdate() + { + return requiresStatusUpdate_; + } + + protected abstract String getActionLinkForHistory(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/OpenCalendarBrowserAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/OpenCalendarBrowserAction.java new file mode 100644 index 000000000..f9136ec40 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/OpenCalendarBrowserAction.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +import javax.servlet.http.*; + +public class OpenCalendarBrowserAction extends Action +{ + public OpenCalendarBrowserAction() + { + } + + // calendar_browser.jsp?sessionId=...&calendarType=... + public static final String getActionLink(String sessionId,int calendarType) + { + StringBuffer actionLink = new StringBuffer("calendar_browser.jsp?"); + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId); + actionLink.append('&').append(ActionInputs.CALENDAR_TYPE).append('=').append(calendarType); + return actionLink.toString(); + } + + public static final String getActionLinkForDate(String sessionId) + { + return getActionLink(sessionId,ActionInputs.CALENDAR_TYPE_DATE); + } + + public static final String getActionLinkForDateTime(String sessionId) + { + return getActionLink(sessionId,ActionInputs.CALENDAR_TYPE_DATETIME); + } + + public static final String getActionLinkForGYearMonth(String sessionId) + { + return getActionLink(sessionId,ActionInputs.CALENDAR_TYPE_GYEARMONTH); + } + + public static final String getActionLinkForGDay(String sessionId) + { + return getActionLink(sessionId,ActionInputs.CALENDAR_TYPE_GDAY); + } + + public static final String getActionLinkForGMonthDay(String sessionId) + { + return getActionLink(sessionId,ActionInputs.CALENDAR_TYPE_GMONTHDAY); + } + + public final boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public final boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/OpenWSDLBrowserAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/OpenWSDLBrowserAction.java new file mode 100644 index 000000000..f29974991 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/OpenWSDLBrowserAction.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +import javax.servlet.http.*; + +public class OpenWSDLBrowserAction extends Action +{ + public OpenWSDLBrowserAction() + { + } + + public static final String getActionLink(String sessionId,int wsdlType) + { + StringBuffer actionLink = new StringBuffer("wsdl_browser.jsp?"); + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId); + actionLink.append('&').append(ActionInputs.WSDL_TYPE).append('=').append(wsdlType); + return actionLink.toString(); + } + + public static final String getActionLinkForService(String sessionId) + { + return getActionLink(sessionId,ActionInputs.WSDL_TYPE_SERVICE); + } + + public static final String getActionLinkForServiceInterface(String sessionId) + { + return getActionLink(sessionId,ActionInputs.WSDL_TYPE_SERVICE_INTERFACE); + } + + public final boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public final boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ProxyLoadPageAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ProxyLoadPageAction.java new file mode 100644 index 000000000..01a5e40b2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ProxyLoadPageAction.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +import javax.servlet.http.*; + +public class ProxyLoadPageAction extends Action +{ + // Get the action given a relative targetPage URL. e.g. "forms/LongLoadingForm.jsp" + public static final String getActionLink(String targetPage) + { + return getActionLink(null,targetPage); + } + + // Get the action given a sessionId and a relative targetPage URL. + public static final String getActionLink(String sessionId,String targetPage) + { + StringBuffer actionLink = new StringBuffer("forms/ProxyLoadPage.jsp?"); + if (sessionId != null) + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId).append('&'); + actionLink.append(ActionInputs.TARGET_PAGE).append('=').append(targetPage); + return actionLink.toString(); + } + + public boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ResizeFramesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ResizeFramesAction.java new file mode 100644 index 000000000..87d94cec9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ResizeFramesAction.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import javax.servlet.http.*; + +public abstract class ResizeFramesAction extends Action +{ + protected Controller controller_; + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String frameName = parser.getParameter(ActionInputs.FRAME_NAME); + if (frameName != null) + propertyTable_.put(ActionInputs.FRAME_NAME,frameName); + else + return false; + return processOthers(parser); + } + + protected abstract boolean processOthers(MultipartFormDataParser parser) throws MultipartFormDataException; + + public ResizeFramesAction(Controller controller) + { + controller_ = controller; + } + + public final boolean populatePropertyTable(HttpServletRequest request) + { + try + { + MultipartFormDataParser parser = new MultipartFormDataParser(); + parser.parseRequest(request,HTMLUtils.UTF8_ENCODING); + boolean result = processParsedResults(parser); + return result; + } + catch (MultipartFormDataException e) + { + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/RetrieveHistoryAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/RetrieveHistoryAction.java new file mode 100644 index 000000000..add1e2406 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/RetrieveHistoryAction.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.http.*; + +public class RetrieveHistoryAction extends LinkAction +{ + private BreadCrumb breadCrumb_; + + public RetrieveHistoryAction(Controller controller) + { + super(controller); + breadCrumb_ = null; + } + + // actions/RetrieveHistoryAction.jsp?jump=1 - forward (ActionInputs.JUMP_FORWARD) + // actions/RetrieveHistoryAction.jsp?jump=-1 - backward (ActionInputs.JUMP_BACK) + public final static String getActionLink(int jump) + { + StringBuffer actionLink = new StringBuffer("actions/RetrieveHistoryActionJSP.jsp?"); + actionLink.append(ActionInputs.JUMP).append('=').append(jump); + return actionLink.toString(); + } + + protected final boolean processLinkParameters(HttpServletRequest request) + { + String jumpString = request.getParameter(ActionInputs.JUMP); + // Perform data validation. + try + { + int jump = Integer.parseInt(jumpString); + } + catch (NumberFormatException e) + { + // Validation failed! + return false; + } + propertyTable_.put(ActionInputs.JUMP,jumpString); + return true; + } + + public final boolean run() + { + int jump = Integer.parseInt((String)propertyTable_.get(ActionInputs.JUMP)); + switch (jump) + { + case ActionInputs.JUMP_FORWARD: + breadCrumb_ = controller_.forward(); + return true; + case ActionInputs.JUMP_BACK: + breadCrumb_ = controller_.back(); + return true; + } + return false; + } + + public final BreadCrumb getBreadCrumb() + { + return breadCrumb_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/SelectNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/SelectNodeAction.java new file mode 100644 index 000000000..494444b6c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/SelectNodeAction.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.NodeSelectionTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public abstract class SelectNodeAction extends NodeAction +{ + protected Node selectedNode_; + + public SelectNodeAction(Controller controller,NodeManager nodeManager) + { + super(controller,nodeManager); + selectedNode_ = null; + } + + public final void performBaseAction(int nodeId) + { + setSelectedNodeId(nodeId); + selectedNode_ = nodeManager_.getSelectedNode(); + } + + public boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + if (!isStaleNode(nodeId)) + { + // Ensure that the node is visible. + makeNodeVisible(nodeManager_.getNode(nodeId)); + performBaseAction(nodeId); + addToHistory(getPerspectiveId(),getActionLinkForHistory()); + return true; + } + setStaleBreadCrumb(); + return false; + } + + public final Node getSelectedNode() + { + return selectedNode_; + } + + public ITransformer[] getTransformers() + { + return new ITransformer[] {new NodeSelectionTransformer(controller_)}; + } + + // Selecting a node changes the treeview content and the properties container. + public abstract String getTreeContentVar(); + public abstract String getTreeContentPage(); + public abstract String getPropertiesContainerVar(); + public abstract String getPropertiesContainerPage(); + public abstract int getPerspectiveId(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/SelectNodeToolAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/SelectNodeToolAction.java new file mode 100644 index 000000000..25bdb456e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/SelectNodeToolAction.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.CurrentNodeSelectionTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.http.*; + +public abstract class SelectNodeToolAction extends SelectNodeAction +{ + protected NodeManager nodeManager_; + protected Tool selectedTool_; + + public SelectNodeToolAction(Controller controller,NodeManager nodeManager) + { + super(controller,nodeManager); + nodeManager_ = nodeManager; + selectedTool_ = null; + } + + public final NodeManager getNodeManager() + { + return nodeManager_; + } + + // ...jsp?nodeId=...&toolId=...<&viewId=...&viewToolId=...><&isHistory=1> + protected boolean processLinkParameters(HttpServletRequest request) + { + boolean result = super.processLinkParameters(request); + String toolIdString = request.getParameter(ActionInputs.TOOLID); + String viewIdString = request.getParameter(ActionInputs.VIEWID); + String viewToolIdString = request.getParameter(ActionInputs.VIEWTOOLID); + + // Perform data validation. + try + { + int toolId = Integer.parseInt(toolIdString); + } + catch (NumberFormatException e) + { + // Validation failed. + return false; + } + propertyTable_.put(ActionInputs.TOOLID,toolIdString); + + // Optional properties + try + { + int viewId = Integer.parseInt(viewIdString); + propertyTable_.put(ActionInputs.VIEWID,viewIdString); + if (viewId != ActionInputs.VIEWID_DEFAULT) + { + int viewToolId = Integer.parseInt(viewToolIdString); + propertyTable_.put(ActionInputs.VIEWTOOLID,viewToolIdString); + } + } + catch (NumberFormatException e) + { + } + return result; + } + + public boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + if (!isStaleNode(nodeId)) + { + // Ensure that the node is visible. + makeNodeVisible(nodeManager_.getNode(nodeId)); + setSelectedNodeId(nodeId); + selectedNode_ = nodeManager_.getSelectedNode(); + int toolId = Integer.parseInt((String)propertyTable_.get(ActionInputs.TOOLID)); + ToolManager toolManager = selectedNode_.getToolManager(); + toolManager.setSelectedToolId(toolId); + selectedTool_ = toolManager.getSelectedTool(); + String viewIdString = ((String)propertyTable_.get(ActionInputs.VIEWID)); + if (viewIdString != null) + { + int viewId = Integer.parseInt(viewIdString); + setSelectedViewId(viewId); + if (viewId != ActionInputs.VIEWID_DEFAULT) + { + String viewToolIdString = ((String)propertyTable_.get(ActionInputs.VIEWTOOLID)); + ViewTool viewTool = (ViewTool)selectedTool_; + if (viewToolIdString != null) + { + int viewToolId = Integer.parseInt(viewToolIdString); + ToolManager viewToolManager = selectedNode_.getViewToolManager(); + if (viewToolManager == null) + { + if (!isHistoryAction()) + { + viewToolManager = viewTool.createToolManager(viewId); + viewToolId = viewToolManager.getSelectedToolId(); + } + else + { + setStaleBreadCrumb(); + return false; + } + } + viewToolManager.setSelectedToolId(viewToolId); + } + } + } + else + setSelectedViewId(ActionInputs.VIEWID_DEFAULT); + addToHistory(getPerspectiveId(),getActionLinkForHistory()); + return true; + } + setStaleBreadCrumb(); + return false; + } + + public ITransformer[] getTransformers() + { + return new ITransformer[] {new CurrentNodeSelectionTransformer(controller_)}; + } + + public final Tool getSelectedViewTool() + { + if (propertyTable_.get(ActionInputs.VIEWID) != null) + return selectedNode_.getViewToolManager().getSelectedTool(); + return null; + } + + public final Tool getSelectedTool() + { + return selectedTool_; + } + + // Selecting a node tool updates the properties content. Also, in the event + // of a history switch, nodes may need to be selected resulting in changes to + // both the treeview content and the properties container. These requirements are + // covered through the base class. + public abstract String getPropertiesContentVar(); + public abstract String getPropertiesContentPage(); + public String getStatusContentVar() + { + return null; + } + + public String getStatusContentPage() + { + return null; + } + + public abstract int getPerspectiveId(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ShowPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ShowPerspectiveAction.java new file mode 100644 index 000000000..05e144f72 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ShowPerspectiveAction.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import javax.servlet.http.*; + +public class ShowPerspectiveAction extends LinkAction +{ + public ShowPerspectiveAction(Controller controller) + { + super(controller); + } + + // actions/show_perspective.jsp?perspective=0<&isHistory=1> - UDDI (ActionInputs.PERSPECTIVE_UDDI) + // actions/show_perspective.jsp?perspective=1<&isHistory=1> - WSIL (ActionInputs.PERSPECTIVE_WSIL) + // actions/show_perspective.jsp?perspective=2<&isHistory=1> - WSDL (ActionInputs.PERSPECTIVE_WSDL) + // actions/show_perspective.jsp?perspective=3<&isHistory=1> - Favorites (ActionInputs.PERSPECTIVE_FAVORITES) + public final static String getActionLink(int newPerspective,boolean forHistory) + { + StringBuffer actionLink = new StringBuffer("actions/ShowPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.PERSPECTIVE).append('=').append(newPerspective); + if (forHistory) + actionLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return actionLink.toString(); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + return true; + } + + protected final boolean processLinkParameters(HttpServletRequest request) + { + boolean result = false; + String perspectiveString = request.getParameter(ActionInputs.PERSPECTIVE); + // Perform data validation. + try + { + int perspective = Integer.parseInt(perspectiveString); + propertyTable_.put(ActionInputs.PERSPECTIVE,perspectiveString); + MultipartFormDataParser parser = new MultipartFormDataParser(); + parser.parseRequest(request,HTMLUtils.UTF8_ENCODING); + result = processParsedResults(parser); + removedProperties_.removeAllElements(); + } + catch (NumberFormatException e) + { + // Validation failed! - This should not happen. + } + catch (MultipartFormDataException e) + { + } + return result; + } + + public boolean run() + { + int perspective = Integer.parseInt((String)propertyTable_.get(ActionInputs.PERSPECTIVE)); + controller_.setCurrentPerspective(perspective); + addToHistory(perspective,getActionLink(perspective,true)); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ToggleNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ToggleNodeAction.java new file mode 100644 index 000000000..bd35d8ec4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ToggleNodeAction.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.NodeIdTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public abstract class ToggleNodeAction extends NodeAction +{ + protected Node toggledNode_; + public ToggleNodeAction(Controller controller,NodeManager nodeManager) + { + super(controller,nodeManager); + toggledNode_ = null; + } + + // Toggle the current node and update the selection iff the currently selected + // is a related descendant of a collapsed node. + /** + * Toggle the current node and update the selection iff the currently selected + * node is a related descendant of the current node and the current node is + * now collapsed as a result of this action. + * + * @param int The node ID of the node for which this action applies to. + * @return boolean Indicator of whether or not a selection change was necessary. + */ + public final boolean performBaseAction(int nodeId) + { + toggledNode_ = nodeManager_.getNode(nodeId); + nodeManager_.setFocusedNodeId(nodeId); + toggledNode_.setVisibilityOfChildren(!toggledNode_.isOpen()); + Node selectedNode = nodeManager_.getSelectedNode(); + if (selectedNode != null) + { + if (!selectedNode.isVisible()) + { + setSelectedNodeId(nodeId); + return true; + } + } + return false; + } + + public boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + if (!isStaleNode(nodeId)) + { + if (performBaseAction(nodeId)) + { + // Save the selection of the toggle link in the history. + addToHistory(getPerspectiveId(),getActionLinkForHistory()); + } + // Do not save the toggle in history. + return true; + } + setStaleBreadCrumb(); + return false; + } + + public final Node getToggledNode() + { + return toggledNode_; + } + + public ITransformer[] getTransformers() + { + return new ITransformer[] {new NodeIdTransformer(controller_)}; + } + + public abstract String getTreeContentVar(); + public abstract String getTreeContentPage(); + public abstract String getPropertiesContainerVar(); + public abstract String getPropertiesContainerPage(); + public abstract int getPerspectiveId(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ValidateEditAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ValidateEditAction.java new file mode 100644 index 000000000..ea7184d63 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/ValidateEditAction.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import javax.servlet.http.*; + +public class ValidateEditAction extends Action +{ + public static final String getActionLink() + { + return "actions/ValidateEditActionJSP.jsp"; + } + + public boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/WSDLFileNameHelper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/WSDLFileNameHelper.java new file mode 100644 index 000000000..2471ea164 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/WSDLFileNameHelper.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +public class WSDLFileNameHelper +{ + private static final String default_ = "temp.wsdl"; + + /** + * Given a wsdl path (file, URL etc.), guess at the file name by looking for the .wsdl extension at the end of the + * path and the file that it belongs to. If this is not possible, return the default defined in this class. + * @param String The path (file, URL etc.) of this WSDL file. + * @return String The WSDL file name determined by this routine. + */ + public static final String getWSDLFileName(String wsdlPathname) + { + if (wsdlPathname != null) + { + if (wsdlPathname.endsWith(".wsdl")) + { + int lastSeparatorPos = Math.max(wsdlPathname.lastIndexOf("/"),wsdlPathname.lastIndexOf("\\")); + if (lastSeparatorPos > 0) + return wsdlPathname.substring(lastSeparatorPos+1,wsdlPathname.length()); + } + } + return default_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/WriteWSDLToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/WriteWSDLToWorkbenchAction.java new file mode 100644 index 000000000..dfcf6a356 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/actions/WriteWSDLToWorkbenchAction.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.actions; + +import javax.servlet.http.*; + +public class WriteWSDLToWorkbenchAction extends Action +{ + public static final String getActionLink() + { + return "actions/WriteWSDLToWorkbenchActionJSP.jsp"; + } + + public boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ActionInputs.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ActionInputs.java new file mode 100644 index 000000000..0bfeac353 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ActionInputs.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.constants; + +public class ActionInputs +{ + // URL parm for all actions which are in the history list. + public static final String ISHISTORY = "isHistory"; + + // Utility constant for tree node identification. + public static final String NODEID = "nodeId"; + + // Utility constant for tool identification. + public static final String TOOLID = "toolId"; + + // Utility constant for view identification. + public static final String VIEWID = "viewId"; + public static final int VIEWID_DEFAULT = -1; + + // Utility constant for view tool identification. + public static final String VIEWTOOLID = "viewToolId"; + public static final int VIEWTOOLID_DEFAULT = -1; + + // Utility constants for transport classes + public static final String TRANSPORT_CLASS_NAME = "org.uddi4j.TransportClassName"; + public static final String TRASPORT_CLASS = "org.uddi4j.transport.ApacheAxisTransport"; + //public static final String AXIS_TRANSPORT_CLASS = "org.uddi4j.transport.ApacheAxisTransport"; + //public static final String SOAP_TRANSPORT_CLASS = "org.uddi4j.transport.ApacheSOAPTransport"; + + // ToggleNodeAction and its derivatives. + public static final String OPEN = "open"; + public static final int OPEN_NODE = 1; + public static final int CLOSE_NODE = 0; + + // ShowPerspectiveAction + public static final String PERSPECTIVE = "perspective"; + public static final int PERSPECTIVE_UDDI = 0; + public static final int PERSPECTIVE_WSIL = 1; + public static final int PERSPECTIVE_WSDL = 2; + public static final int PERSPECTIVE_FAVORITES = 3; + + // RetrieveHistoryAction + public static final String JUMP = "jump"; + public static final int JUMP_FORWARD = 1; + public static final int JUMP_BACK = -1; + + // LaunchWebServiceWizardAction + public final static String WEB_SERVICE_WIZARD = "webServiceWizard"; + public final static int WEB_SERVICE_CLIENT_WIZARD = 0; + public final static int WEB_SERVICE_SKELETON_WIZARD = 1; + + // ImportToWorkbenchAction + public final static String WORKBENCH_PROJECT_NAME = "workbenchProjectName"; + public final static String IMPORT_FILE = "importWSDL"; + public final static String IMPORTED_FILE_NAME = "importedFileName"; + public final static String IMPORT_TO_WSIL = "importToWSIL"; + public final static String WSIL_FILE_NAME = "WSILFileName"; + public final static String IMPORTED_WSDL_URL = "importedWsdlUrl"; + public final static String IMPORT_ACTION = "importAction"; + + // ProxyLoadAction + public final static String TARGET_PAGE = "targetPage"; + + // Session ID for pop ups whose browsers choose to ignore the session. + public final static String SESSIONID = "sId"; + + // WSDL Browser + public static final String PROJECT = "project"; + public static final String WSDL_TYPE = "wsdlType"; + public static final int WSDL_TYPE_SERVICE_INTERFACE = 0; + public static final int WSDL_TYPE_SERVICE = 1; + public static final String QUERY_INPUT_WEBPROJECT_WSDL_URL = "webProjectWSDLURL"; + public static final String QUERY_INPUT_FAVORITE_WSDL_URL = "favoriteWSDLURL"; + public static final String QUERY_INPUT_WSDL_URL = "wsdlURL"; + + // Calendar Browser + public static final String CALENDAR_TYPE = "calendarType"; + public static final int CALENDAR_TYPE_DATE = 0; + public static final int CALENDAR_TYPE_DATETIME = 1; + public static final int CALENDAR_TYPE_GYEARMONTH = 2; + public static final int CALENDAR_TYPE_GDAY = 3; + public static final int CALENDAR_TYPE_GMONTHDAY = 4; + + // ResizeFrameAction + public static final String FRAME_NAME = "frameName"; + + // Other Actions + public static final String CURRENT_TOOL_MANAGER = "currentToolManager"; + + // Action Engine + public static final String ACTION_ENGINE_SCENARIO = "actionEngineScenario"; + public static final String ACTION_ENGINE_MODE = "actionEngineMode"; + + // MultipartFormDataParser + public static final String MULTIPART_FORM_DATA_PARSER = "multipartFormDataParser"; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/FrameNames.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/FrameNames.java new file mode 100644 index 000000000..eb71f5fd1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/FrameNames.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.constants; + +public class FrameNames +{ + // wsexplorer.jsp + public final static String WINDOW_NAME_WSEXPLORER_JSP = "wsexplorer.jsp"; + public final static String PERSPECTIVE_WORKAREA = "perspective_workarea"; + public final static String PERSPECTIVE_TOOLBAR = "perspective_toolbar"; + public final static String PERSPECTIVE_CONTENT = "perspective_content"; + + // WSDL Browser + public final static String WSDL_TOOLBAR = "wsdl_toolbar"; + public final static String WSDL_CONTENT = "wsdl_content"; + + // Calendar Browser + public final static String CALENDAR_TOOLBAR = "calendar_toolbar"; + public final static String CALENDAR_CONTENT = "calendar_content"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ModelConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ModelConstants.java new file mode 100644 index 000000000..dd55527ba --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ModelConstants.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.constants; + +public class ModelConstants +{ + public static final String REL_ID = "relationshipId"; + public static final String REL_LOCALNAME_SEPARATOR = "#"; + public static final String REL_OWNER = "owner"; + public static final String REL_CHILDREN = "children"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ToolTypes.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ToolTypes.java new file mode 100644 index 000000000..b27134cd1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/constants/ToolTypes.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.constants; + +public class ToolTypes +{ + public static final byte FORM = 0; + public static final byte ACTION = 1; + public static final byte VIEW = 2; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/ListElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/ListElement.java new file mode 100644 index 000000000..8829f7df9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/ListElement.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.datamodel; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +public class ListElement +{ + private int viewId_; + private Object object_; + // For search parameters: info on the Node and ViewTool holding this element. + private int targetNodeId_; + private int targetToolId_; + private int targetViewId_; + + public ListElement(Object object) + { + object_ = object; + viewId_ = ActionInputs.VIEWID_DEFAULT; + targetNodeId_ = -1; + targetToolId_ = -1; + targetViewId_ = ActionInputs.VIEWID_DEFAULT; + } + + public final Object getObject() + { + return object_; + } + + public final void setViewId(int viewId) + { + viewId_ = viewId; + } + + public final int getViewId() + { + return viewId_; + } + + public final void setTargetViewToolInfo(int nodeId,int toolId,int viewId) + { + targetNodeId_ = nodeId; + targetToolId_ = toolId; + targetViewId_ = viewId; + } + + public final int getTargetNodeId() + { + return targetNodeId_; + } + + public final int getTargetToolId() + { + return targetToolId_; + } + + public final int getTargetViewId() + { + return targetViewId_; + } + + public final String toString() { + return getObject().toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/ListManager.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/ListManager.java new file mode 100644 index 000000000..79c44b18e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/ListManager.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.datamodel; + +import java.util.*; + +public class ListManager +{ + private int nextViewId_; + private Vector itemsList_; + private Hashtable itemsTable_; + + public ListManager() + { + nextViewId_ = 0; + itemsList_ = new Vector(); + itemsTable_ = new Hashtable(); + } + + private final void updateManager(ListElement element) + { + itemsTable_.put(String.valueOf(nextViewId_),element); + element.setViewId(nextViewId_); + nextViewId_++; + } + + public final void add(ListElement element) + { + itemsList_.addElement(element); + updateManager(element); + } + + public final void addWithCurrentViewId(ListElement element) + { + itemsList_.addElement(element); + itemsTable_.put(String.valueOf(element.getViewId()),element); + } + + public final ListElement elementAt(int index) + { + return (ListElement)itemsList_.elementAt(index); + } + + public final ListElement getElementWithViewId(int viewId) + { + return (ListElement)itemsTable_.get(String.valueOf(viewId)); + } + + public final void removeElementWithViewId(int viewId) + { + itemsTable_.remove(String.valueOf(viewId)); + for (int i=0;i<itemsList_.size();i++) + { + ListElement listElement = elementAt(i); + if (listElement.getViewId() == viewId) + { + itemsList_.removeElementAt(i); + break; + } + } + } + + public final void removeElementAt(int index) + { + ListElement listElement = (ListElement)elementAt(index); + itemsList_.removeElementAt(index); + itemsTable_.remove(String.valueOf(listElement.getViewId())); + } + + public final void insertElementAt(ListElement element,int index) + { + itemsList_.insertElementAt(element,index); + updateManager(element); + } + + public final Enumeration getListElements() + { + return itemsList_.elements(); + } + + public final void clear() + { + itemsList_.removeAllElements(); + itemsTable_.clear(); + } + + public final ListManager copy(ListManager newListManager) + { + newListManager.clear(); + for (int i=0;i<itemsList_.size();i++) + { + ListElement listElement = (ListElement)elementAt(i); + ListElement newListElement = new ListElement(listElement.getObject()); + newListElement.setViewId(listElement.getViewId()); + newListElement.setTargetViewToolInfo(listElement.getTargetNodeId(),listElement.getTargetToolId(),listElement.getTargetViewId()); + newListManager.addWithCurrentViewId(newListElement); + } + newListManager.setNextViewId(nextViewId_); + return newListManager; + } + + public final void setNextViewId(int nextViewId) + { + nextViewId_ = nextViewId; + } + + public final int getNextViewId() + { + return nextViewId_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/TreeElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/TreeElement.java new file mode 100644 index 000000000..2d2da7445 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/datamodel/TreeElement.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; + +public class TreeElement extends BasicElement +{ + private String key_; + + public TreeElement(String name,Model model) + { + super(name,model); + key_ = name; + } + + public void setKey(String key) + { + key_ = key; + } + + public String getKey() + { + return key_; + } + + public boolean equals(TreeElement element) + { + if (key_ == null) + return false; + return key_.equals(element.getKey()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/ActionDataParser.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/ActionDataParser.java new file mode 100644 index 000000000..13fce578b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/ActionDataParser.java @@ -0,0 +1,231 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine; + +import org.eclipse.wst.ws.internal.explorer.platform.engine.constants.ActionDataConstants; +import org.eclipse.wst.ws.internal.explorer.platform.engine.data.ActionDescriptor; +import org.eclipse.wst.ws.internal.explorer.platform.engine.data.ScenarioDescriptor; +import org.eclipse.wst.ws.internal.explorer.platform.engine.data.TransactionDescriptor; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.CDATASection; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; + +public class ActionDataParser +{ + private Document doc; + + public ScenarioDescriptor parseScenario(Element e) + { + ScenarioDescriptor scenarioDescriptor = new ScenarioDescriptor(); + NodeList transactions = e.getElementsByTagName(ActionDataConstants.ELEMENT_TRANSACTION); + TransactionDescriptor[] transactionDescriptors = new TransactionDescriptor[transactions.getLength()]; + for (int i = 0; i < transactionDescriptors.length; i++) + transactionDescriptors[i] = parseTransaction((Element) transactions.item(i)); + scenarioDescriptor.setTransactionDescriptors(transactionDescriptors); + return scenarioDescriptor; + } + + public TransactionDescriptor parseTransaction(Element e) + { + TransactionDescriptor transactionDescriptor = new TransactionDescriptor(); + NodeList actions = e.getElementsByTagName(ActionDataConstants.ELEMENT_ACTION); + ActionDescriptor[] actionDescriptors = new ActionDescriptor[actions.getLength()]; + for (int i = 0; i < actionDescriptors.length; i++) + actionDescriptors[i] = parseAction((Element) actions.item(i)); + transactionDescriptor.setActionDescriptors(actionDescriptors); + return transactionDescriptor; + } + + public ActionDescriptor parseAction(Element e) + { + ActionDescriptor actionDescriptor = new ActionDescriptor(); + actionDescriptor.setId(e.getAttribute(ActionDataConstants.ATTR_ID)); + try + { + actionDescriptor.setAttempts(Integer.parseInt(e.getAttribute(ActionDataConstants.ATTR_ATTEMPTS))); + } + catch (Throwable t) + { + actionDescriptor.setAttempts(1); + } + actionDescriptor.setStatusId(e.getAttribute(ActionDataConstants.ATTR_STATUS_ID)); + Hashtable propertiesTable = new Hashtable(); + NodeList properties = e.getElementsByTagName(ActionDataConstants.ELEMENT_PROPERTY); + for (int i = 0; i < properties.getLength(); i++) + { + Element property = (Element) properties.item(i); + String name = property.getAttribute(ActionDataConstants.ATTR_NAME); + NodeList valueList = property.getElementsByTagName(ActionDataConstants.ELEMENT_VALUE); + if (valueList.getLength() > 1) + { + String[] values = new String[valueList.getLength()]; + for (int j = 0; j < values.length; j++) + { + Element value = (Element) valueList.item(j); + Node textNode = value.getFirstChild(); + values[j] = (textNode != null) ? textNode.getNodeValue().trim() : ""; + } + propertiesTable.put(name, values); + } + else + { + Node textNode = ((Element) valueList.item(0)).getFirstChild(); + propertiesTable.put(name, (textNode != null) ? textNode.getNodeValue().trim() : ""); + } + } + actionDescriptor.setProperties(propertiesTable); + NodeList statusList = e.getElementsByTagName(ActionDataConstants.ELEMENT_STATUS); + for (int i = 0; i < statusList.getLength(); i++) + { + Element status = (Element)statusList.item(i); + CDATASection cData = (CDATASection)status.getFirstChild(); + actionDescriptor.addStatus(cData.getData()); + } + return actionDescriptor; + } + + public Element toElement(ScenarioDescriptor scenarioDescriptor) + { + try + { + Document document = getDocument(); + Element scenarioElement = document.createElement(ActionDataConstants.ELEMENT_SCENARIO); + TransactionDescriptor[] transactionDescriptors = scenarioDescriptor.getTransactionDescriptors(); + for (int i = 0; i < transactionDescriptors.length; i++) + { + Element transactionElement = toElement(transactionDescriptors[i]); + if (transactionElement != null) + scenarioElement.appendChild(transactionElement); + } + return scenarioElement; + } + catch (DOMException dome) + { + return null; + } + } + + public Element toElement(TransactionDescriptor transactionDescriptor) + { + try + { + Document document = getDocument(); + Element transactionElement = document.createElement(ActionDataConstants.ELEMENT_TRANSACTION); + ActionDescriptor[] actionDescriptors = transactionDescriptor.getActionDescriptors(); + for (int i = 0; i < actionDescriptors.length; i++) + { + Element actionElement = toElement(actionDescriptors[i]); + if (actionElement != null) + transactionElement.appendChild(actionElement); + } + return transactionElement; + } + catch (DOMException dome) + { + return null; + } + } + + public Element toElement(ActionDescriptor actionDescriptor) + { + try + { + Document document = getDocument(); + Element actionElement = document.createElement(ActionDataConstants.ELEMENT_ACTION); + actionElement.setAttribute(ActionDataConstants.ATTR_ID, actionDescriptor.getId()); + actionElement.setAttribute(ActionDataConstants.ATTR_ATTEMPTS, String.valueOf(actionDescriptor.getAttempts())); + String statusId = actionDescriptor.getStatusId(); + if (statusId != null) + actionElement.setAttribute(ActionDataConstants.ATTR_STATUS_ID, statusId); + Hashtable properties = actionDescriptor.getProperties(); + if (properties != null) + { + for (Iterator it = properties.keySet().iterator(); it.hasNext();) + { + Object key = it.next(); + Object value = properties.get(key); + Object[] values; + if (value.getClass().isArray()) + values = (Object[])value; + else if (value instanceof List) + values = ((List)value).toArray(); + else + values = new Object[] {value}; + boolean isAdded = false; + Element propertyElement = document.createElement(ActionDataConstants.ELEMENT_PROPERTY); + propertyElement.setAttribute(ActionDataConstants.ATTR_NAME, key.toString()); + for (int i = 0; i < values.length; i++) + { + if (values[i] instanceof String) + { + Element valueElement = document.createElement(ActionDataConstants.ELEMENT_VALUE); + valueElement.appendChild(document.createTextNode(values[i].toString())); + propertyElement.appendChild(valueElement); + isAdded = true; + } + } + if (isAdded) + actionElement.appendChild(propertyElement); + } + } + List status = actionDescriptor.getStatus(); + if (status != null) + { + for (Iterator it = status.iterator(); it.hasNext();) + { + Element statusElement = document.createElement(ActionDataConstants.ELEMENT_STATUS); + CDATASection cData = document.createCDATASection(it.next().toString()); + statusElement.appendChild(cData); + actionElement.appendChild(statusElement); + } + } + return actionElement; + } + catch (DOMException dome) + { + return null; + } + } + + private Document getDocument() + { + try + { + if (doc == null) + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + doc = builder.newDocument(); + } + return doc; + } + catch (FactoryConfigurationError fce) + { + return null; + } + catch (ParserConfigurationException pce) + { + return null; + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/ActionEngine.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/ActionEngine.java new file mode 100644 index 000000000..e33e3284b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/ActionEngine.java @@ -0,0 +1,234 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.util.Hashtable; +import java.util.Vector; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.Action; +import org.eclipse.wst.ws.internal.explorer.platform.actions.ShowPerspectiveAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.engine.constants.ActionDataConstants; +import org.eclipse.wst.ws.internal.explorer.platform.engine.data.ActionDescriptor; +import org.eclipse.wst.ws.internal.explorer.platform.engine.data.ScenarioDescriptor; +import org.eclipse.wst.ws.internal.explorer.platform.engine.data.TransactionDescriptor; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; + +public class ActionEngine +{ + public static final byte MODE_DISABLED = 0x0; + public static final byte MODE_STOP = 0x1; + public static final byte MODE_RECORD = 0x2; + public static final byte MODE_PLAY = 0x3; + + private Controller controller; + private byte mode; + private Vector actionDescriptors; + + public ActionEngine(Controller controller) + { + this.controller = controller; + mode = MODE_DISABLED; + actionDescriptors = new Vector(); + } + + public void executeScenario(ScenarioDescriptor scenarioDescriptor) + { + TransactionDescriptor[] transactionDescriptors = scenarioDescriptor.getTransactionDescriptors(); + for (int i = 0; i < transactionDescriptors.length; i++) + executeTransaction(transactionDescriptors[i]); + } + + public boolean executeTransaction(TransactionDescriptor transactionDescriptor) + { + boolean result = true; + ActionDescriptor[] actionDescriptors = transactionDescriptor.getActionDescriptors(); + for (int i = 0; i < actionDescriptors.length; i++) + { + if (result) + { + if (!executeAction(actionDescriptors[i])) + result = false; + } + else + actionDescriptors[i].setStatusId(ActionDataConstants.VALUE_STATUS_ID_UNATTEMPTED); + } + return result; + } + + public boolean executeAction(ActionDescriptor actionDescriptor) + { + int attempts = actionDescriptor.getAttempts(); + for (int i = 0; i < attempts; i++) + { + try + { + Class classAction = Class.forName(actionDescriptor.getId()); + if (Action.class.isAssignableFrom(classAction)) + { + Action action = (Action) newInstance(classAction); + if (action != null) + { + Hashtable properties = actionDescriptor.getProperties(); + ITransformer[] transformers = action.getTransformers(); + for (int j = 0; j < transformers.length; j++) + properties = transformers[j].deNormalize(properties); + action.setPropertyTable(properties); + boolean actionResult = action.run(); + // TODO actionDescriptor.addStatus(action.getStatus()); + if (actionResult) + { + actionDescriptor.setStatusId(ActionDataConstants.VALUE_STATUS_ID_PASSED); + return true; + } + } + else + throw new ClassNotFoundException(actionDescriptor.getId()); + } + } + catch (ClassNotFoundException cnfe) + { + cnfe.printStackTrace(); + StringWriter sw = new StringWriter(); + cnfe.printStackTrace(new PrintWriter(sw)); + actionDescriptor.addStatus(sw.getBuffer().toString()); + } + catch (Throwable t) + { + t.printStackTrace(); + StringWriter sw = new StringWriter(); + t.printStackTrace(new PrintWriter(sw)); + actionDescriptor.addStatus(sw.getBuffer().toString()); + } + } + actionDescriptor.setStatusId(ActionDataConstants.VALUE_STATUS_ID_FAILED); + return false; + } + + private ScenarioDescriptor newScenarioDescriptor() + { + return new ScenarioDescriptor(); + } + + private TransactionDescriptor newTransactionDescriptor() + { + return new TransactionDescriptor(); + } + + private ActionDescriptor newActionDescriptor(Action action) + { + ActionDescriptor actionDescriptor = new ActionDescriptor(); + actionDescriptor.setId(action.getClass().getName()); + Hashtable properties = new Hashtable(action.getPropertyTable()); + ITransformer[] transformers = action.getTransformers(); + for (int i = 0; i < transformers.length; i++) + properties = transformers[i].normalize(properties); + actionDescriptor.setProperties(properties); + return actionDescriptor; + } + + private Object newInstance(Class c) + { + try + { + // instantiates the action using the constructor that takes in a + // controller object + Constructor constructor = c.getConstructor(new Class[]{Controller.class}); + return constructor.newInstance(new Object[]{controller}); + } + catch (NoSuchMethodException nsme) + { + } + catch (InstantiationException ie) + { + } + catch (IllegalAccessException iae) + { + } + catch (InvocationTargetException ite) + { + } + catch (Throwable t) + { + } + Object instance = null; + try + { + // instantiates the action using the default constructor + Constructor constructor = c.getConstructor(new Class[0]); + instance = constructor.newInstance(new Object[0]); + Method method = c.getMethod("setController", new Class[]{Controller.class}); + method.invoke(instance, new Object[]{controller}); + } + catch (NoSuchMethodException nsme) + { + } + catch (InstantiationException ie) + { + } + catch (IllegalAccessException iae) + { + } + catch (IllegalArgumentException iae) + { + } + catch (InvocationTargetException ite) + { + } + catch (Throwable t) + { + } + return instance; + } + + public byte getMode() + { + return mode; + } + + public void setMode(byte mode) + { + this.mode = mode; + if (mode == MODE_RECORD) + { + actionDescriptors = new Vector(); + ShowPerspectiveAction showPerspectiveAction = new ShowPerspectiveAction(controller); + showPerspectiveAction.addProperty(ActionInputs.PERSPECTIVE, String.valueOf(controller.getCurrentPerspective().getPerspectiveId())); + actionDescriptors.add(newActionDescriptor(showPerspectiveAction)); + } + } + + public boolean executeAction(Action action) + { + if (mode == MODE_RECORD) + { + ActionDescriptor actionDescriptor = newActionDescriptor(action); + actionDescriptors.add(actionDescriptor); + } + return action.run(); + } + + public ScenarioDescriptor getScenario() + { + ScenarioDescriptor scenarioDescriptor = newScenarioDescriptor(); + TransactionDescriptor transactionDescriptor = newTransactionDescriptor(); + ActionDescriptor[] actionDescriptorArray = (ActionDescriptor[])actionDescriptors.toArray(new ActionDescriptor[0]); + transactionDescriptor.setActionDescriptors(actionDescriptorArray); + scenarioDescriptor.setTransactionDescriptors(new TransactionDescriptor[] {transactionDescriptor}); + return scenarioDescriptor; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/constants/ActionDataConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/constants/ActionDataConstants.java new file mode 100644 index 000000000..7d53ee26b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/constants/ActionDataConstants.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.constants; + +public class ActionDataConstants +{ + public static final String ATTR_ID = "id"; + public static final String ATTR_NAME = "name"; + public static final String ATTR_ATTEMPTS = "attempts"; + public static final String ATTR_STATUS_ID = "statusId"; + + public static final String ELEMENT_SCENARIO = "scenario"; + public static final String ELEMENT_TRANSACTION = "transaction"; + public static final String ELEMENT_ACTION = "action"; + public static final String ELEMENT_PROPERTY = "property"; + public static final String ELEMENT_VALUE = "value"; + public static final String ELEMENT_STATUS = "status"; + + public static final String VALUE_STATUS_ID_UNATTEMPTED = "unattempted"; + public static final String VALUE_STATUS_ID_PASSED = "passed"; + public static final String VALUE_STATUS_ID_FAILED = "failed"; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/ActionDescriptor.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/ActionDescriptor.java new file mode 100644 index 000000000..85bb5b7da --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/ActionDescriptor.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.data; + +import java.util.Hashtable; +import java.util.List; +import java.util.Vector; + +public class ActionDescriptor +{ + private String id; + private Hashtable properties; + private int attempts; + private String statusId; + private List statusList; + + public ActionDescriptor() + { + attempts = 1; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public Hashtable getProperties() + { + return properties; + } + + public void setProperties(Hashtable properties) + { + this.properties = properties; + } + + public int getAttempts() + { + return attempts; + } + + public void setAttempts(int attempts) + { + this.attempts = attempts; + } + + public String getStatusId() + { + return statusId; + } + + public void setStatusId(String statusId) + { + this.statusId = statusId; + } + + public void addStatus(Object status) + { + if (status != null) + { + if (statusList == null) + statusList = new Vector(); + statusList.add(status); + } + } + + public boolean removeStatus(Object status) + { + if (status != null && statusList != null) + return statusList.remove(status); + else + return false; + } + + public List getStatus() + { + return statusList; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/ScenarioDescriptor.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/ScenarioDescriptor.java new file mode 100644 index 000000000..41a3f90fe --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/ScenarioDescriptor.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.data; + +public class ScenarioDescriptor +{ + private TransactionDescriptor[] transactionDescriptors; + + public TransactionDescriptor[] getTransactionDescriptors() + { + return transactionDescriptors; + } + + public void setTransactionDescriptors(TransactionDescriptor[] transactionDescriptors) + { + this.transactionDescriptors = transactionDescriptors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/TransactionDescriptor.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/TransactionDescriptor.java new file mode 100644 index 000000000..3ef67b972 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/data/TransactionDescriptor.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.data; + +public class TransactionDescriptor +{ + private ActionDescriptor[] actionDescriptors; + + public ActionDescriptor[] getActionDescriptors() + { + return actionDescriptors; + } + + public void setActionDescriptors(ActionDescriptor[] actionDescriptors) + { + this.actionDescriptors = actionDescriptors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/CurrentNodeSelectionTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/CurrentNodeSelectionTransformer.java new file mode 100644 index 000000000..5bf3299f4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/CurrentNodeSelectionTransformer.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Hashtable; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; + +public class CurrentNodeSelectionTransformer implements ITransformer +{ + protected Controller controller; + protected String key; + + public CurrentNodeSelectionTransformer(Controller controller) + { + this(controller, ActionInputs.NODEID); + } + + public CurrentNodeSelectionTransformer(Controller controller, String key) + { + this.controller = controller; + this.key = key; + } + + public Hashtable normalize(Hashtable properties) + { + return properties; + } + + public Hashtable deNormalize(Hashtable properties) + { + Node currNode = controller.getCurrentPerspective().getNodeManager().getSelectedNode(); + if (currNode != null) + properties.put(key, String.valueOf(currNode.getNodeId())); + return properties; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/ITransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/ITransformer.java new file mode 100644 index 000000000..4755ffe85 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/ITransformer.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Hashtable; + +public interface ITransformer +{ + public Hashtable normalize(Hashtable properties); + public Hashtable deNormalize(Hashtable properties); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/MassNodeIdTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/MassNodeIdTransformer.java new file mode 100644 index 000000000..81ac34fb9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/MassNodeIdTransformer.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Hashtable; +import java.util.Vector; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; + +public class MassNodeIdTransformer extends NodeIdTransformer +{ + protected String massNodeIdKey; + + public MassNodeIdTransformer(Controller controller, String massNodeIdKey) + { + super(controller); + this.massNodeIdKey = massNodeIdKey; + } + + public Hashtable normalize(Hashtable properties) + { + if (!properties.containsKey(massNodeIdKey)) + return super.normalize(properties); + Object origNodeId = properties.get(ActionInputs.NODEID); + String[] massNodeIds = getValueAsStringArray(properties, massNodeIdKey); + for (int i = 0; i < massNodeIds.length; i++) + { + properties.put(ActionInputs.NODEID, massNodeIds[i]); + properties = super.normalize(properties); + String[] rels = getValueAsStringArray(properties, ModelConstants.REL_ID); + if (rels.length > 0) + { + StringBuffer sb = new StringBuffer(ModelConstants.REL_ID); + sb.append(ModelConstants.REL_LOCALNAME_SEPARATOR); + sb.append(massNodeIds[i]); + properties.put(sb.toString(), rels); + } + properties.remove(ActionInputs.NODEID); + properties.remove(ModelConstants.REL_ID); + } + if (origNodeId != null) + properties.put(ActionInputs.NODEID, origNodeId); + return properties; + } + + public Hashtable deNormalize(Hashtable properties) + { + if (!properties.containsKey(massNodeIdKey)) + return super.deNormalize(properties); + Vector massNodeIdVector = new Vector(); + Object origNodeId = properties.get(ActionInputs.NODEID); + properties.remove(ActionInputs.NODEID); + String[] massNodeIds = getValueAsStringArray(properties, massNodeIdKey); + for (int i = 0; i < massNodeIds.length; i++) + { + StringBuffer sb = new StringBuffer(ModelConstants.REL_ID); + sb.append(ModelConstants.REL_LOCALNAME_SEPARATOR); + sb.append(massNodeIds[i]); + Object rels = properties.get(sb.toString()); + if (rels != null) + { + properties.put(ModelConstants.REL_ID, rels); + properties = super.deNormalize(properties); + Object nodeId = properties.get(ActionInputs.NODEID); + if (nodeId != null) + { + massNodeIdVector.add(nodeId); + properties.remove(ActionInputs.NODEID); + } + properties.remove(ModelConstants.REL_ID); + } + } + if (origNodeId != null) + properties.put(ActionInputs.NODEID, origNodeId); + int size = massNodeIdVector.size(); + if (size == 1) + properties.put(massNodeIdKey, massNodeIdVector.get(0)); + else if (size > 1) + properties.put(massNodeIdKey, massNodeIdVector.toArray(new String[0])); + else + properties.remove(massNodeIdKey); + return properties; + } + + private String[] getValueAsStringArray(Hashtable properties, String key) + { + Object values = properties.get(key); + if (values == null) + return new String[0]; + else if (values instanceof String[]) + return (String[])values; + else + return new String[] {values.toString()}; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/MultipartFormDataParserTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/MultipartFormDataParserTransformer.java new file mode 100644 index 000000000..b4f0a2c68 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/MultipartFormDataParserTransformer.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Hashtable; +import java.util.Enumeration; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; + +public class MultipartFormDataParserTransformer implements ITransformer +{ + protected Controller controller; + + public MultipartFormDataParserTransformer(Controller controller) + { + this.controller = controller; + } + + public Hashtable normalize(Hashtable properties) + { + MultipartFormDataParser parser = (MultipartFormDataParser)properties.get(ActionInputs.MULTIPART_FORM_DATA_PARSER); + String[] keys; + try + { + keys = parser.getParameterNames(); + } + catch (Throwable t) + { + keys = new String[0]; + } + for (int i = 0; i < keys.length; i++) + { + StringBuffer newKey = new StringBuffer(ActionInputs.MULTIPART_FORM_DATA_PARSER); + newKey.append(keys[i]); + try + { + properties.put(newKey.toString(), parser.getParameterValues(keys[i])); + } + catch (Throwable t) + { + } + } + return properties; + } + + public Hashtable deNormalize(Hashtable properties) + { + Enumeration e = properties.keys(); + while (e.hasMoreElements()) + { + Object key = e.nextElement(); + if (key instanceof String) + { + if (((String)key).startsWith(ActionInputs.MULTIPART_FORM_DATA_PARSER)) + { + String realKey = ((String)key).substring(ActionInputs.MULTIPART_FORM_DATA_PARSER.length()); + if (!properties.containsKey(realKey)) + { + Object value = properties.remove(key); + properties.put(realKey, value); + } + } + } + } + return properties; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/NodeIdTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/NodeIdTransformer.java new file mode 100644 index 000000000..d2af98b5b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/NodeIdTransformer.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Hashtable; +import java.util.Vector; +import java.util.Enumeration; +import org.eclipse.wst.ws.internal.datamodel.Element; +import org.eclipse.wst.ws.internal.datamodel.Rel; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class NodeIdTransformer implements ITransformer +{ + protected Controller controller; + + public NodeIdTransformer(Controller controller) + { + this.controller = controller; + } + + public Hashtable normalize(Hashtable properties) + { + Vector rels = new Vector(); + try + { + int nodeId = Integer.parseInt((String)properties.get(ActionInputs.NODEID)); + NodeManager nodeManager = controller.getCurrentPerspective().getNodeManager(); + Node rootNode = nodeManager.getRootNode(); + Node node = nodeManager.getNode(nodeId); + int depth = 0; + if (node != null) + depth = node.getNodeDepth(); + while (rels.size() < depth && node != null && node != rootNode) + { + Node parentNode = node.getParent(); + Element element = node.getTreeElement(); + Rel rel = getRel(parentNode.getTreeElement(), element); + StringBuffer relValue = new StringBuffer(rel.getName()); + relValue.append(ModelConstants.REL_LOCALNAME_SEPARATOR); + relValue.append(element.getName()); + rels.insertElementAt(relValue.toString(), 0); + node = parentNode; + } + } + catch (NumberFormatException nfe) + { + } + int numRelationships = rels.size(); + if (numRelationships == 1) + properties.put(ModelConstants.REL_ID, rels.get(0).toString()); + else if (numRelationships > 1) + properties.put(ModelConstants.REL_ID, (String[])rels.toArray(new String[0])); + return properties; + } + + private Rel getRel(Element sourceElement, Element targetElement) + { + Enumeration rels = sourceElement.getRels(); + while (rels.hasMoreElements()) + { + Rel rel = (Rel)rels.nextElement(); + Enumeration targetElements = rel.getTargetElements(); + while (targetElements.hasMoreElements()) + { + if (targetElements.nextElement() == targetElement) + return rel; + } + } + return null; + } + + public Hashtable deNormalize(Hashtable properties) + { + NodeManager nodeManager = controller.getCurrentPerspective().getNodeManager(); + Node node = nodeManager.getRootNode(); + Object value = properties.get(ModelConstants.REL_ID); + String[] relationships = null; + if (value instanceof String[]) + relationships = (String[])value; + else if (value != null) + relationships = new String[] {value.toString()}; + if (relationships != null) + { + for (int i = 0; i < relationships.length; i++) + { + int index = relationships[i].indexOf(ModelConstants.REL_LOCALNAME_SEPARATOR); + if (index == -1) + return deNormalizeAsSelectedNode(properties); + String rel = (index != -1) ? relationships[i].substring(0, index) : relationships[i]; + String localname = (index != -1) ? relationships[i].substring(index + 1, relationships[i].length()) : null; + if (localname == null) + return deNormalizeAsSelectedNode(properties); + node = getNode(node, rel, localname); + if (node == null) + return deNormalizeAsSelectedNode(properties); + } + properties.put(ActionInputs.NODEID, String.valueOf(node.getNodeId())); + return properties; + } + else + return deNormalizeAsSelectedNode(properties); + } + + private Hashtable deNormalizeAsSelectedNode(Hashtable properties) + { + return (new CurrentNodeSelectionTransformer(controller)).deNormalize(properties); + } + + private Node getNode(Node parent, String rel, String localname) + { + Element parentElement = parent.getTreeElement(); + Enumeration e = parentElement.getElements(rel); + while (e.hasMoreElements()) + { + Element element = (Element)e.nextElement(); + if (localname.equals(element.getName())) + return parent.getChildNode((TreeElement)element); + } + return null; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/NodeSelectionTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/NodeSelectionTransformer.java new file mode 100644 index 000000000..175dc03d0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/NodeSelectionTransformer.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; +import org.eclipse.wst.ws.internal.datamodel.Element; +import org.eclipse.wst.ws.internal.datamodel.Rel; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class NodeSelectionTransformer implements ITransformer +{ + protected Controller controller; + + public NodeSelectionTransformer(Controller controller) + { + this.controller = controller; + } + + public Hashtable normalize(Hashtable properties) + { + try + { + NodeManager nodeManager = controller.getCurrentPerspective().getNodeManager(); + Node nextNode = nodeManager.getNode(Integer.parseInt((String) properties.get(ActionInputs.NODEID))); + Node currNode = nodeManager.getSelectedNode(); + if (currNode == null) + currNode = nodeManager.getRootNode(); + Vector nextRels = new Vector(); + Vector currRels = new Vector(); + while (nextNode != null && currNode != null && (!isRootElement(nextNode.getTreeElement()) || !isRootElement(currNode.getTreeElement())) && nextNode != currNode) + { + if (nextNode.getNodeDepth() >= currNode.getNodeDepth()) + { + Node parentNode = nextNode.getParent(); + Element nextElement = nextNode.getTreeElement(); + Rel rel = getRel(parentNode.getTreeElement(), nextElement); + StringBuffer relValue = new StringBuffer(rel.getName()); + relValue.append(ModelConstants.REL_LOCALNAME_SEPARATOR); + relValue.append(nextElement.getName()); + nextRels.insertElementAt(relValue.toString(), 0); + nextNode = parentNode; + } + else + { + Node parentNode = currNode.getParent(); + Element parentElement = parentNode.getTreeElement(); + Rel rel = getRel(currNode.getTreeElement(), parentElement); + StringBuffer relValue = new StringBuffer(rel.getName()); + relValue.append(ModelConstants.REL_LOCALNAME_SEPARATOR); + relValue.append(parentElement.getName()); + currRels.add(relValue.toString()); + currNode = parentNode; + } + } + currRels.addAll(nextRels); + int numRelationships = currRels.size(); + if (numRelationships == 1) + properties.put(ModelConstants.REL_ID, currRels.get(0).toString()); + else if (numRelationships > 1) + properties.put(ModelConstants.REL_ID, (String[]) currRels.toArray(new String[0])); + } + catch (NumberFormatException nfe) + { + } + return properties; + } + + private boolean isRootElement(Element e) + { + return e.getModel().getRootElement() == e; + } + + private Rel getRel(Element sourceElement, Element targetElement) + { + Enumeration rels = sourceElement.getRels(); + while (rels.hasMoreElements()) + { + Rel rel = (Rel) rels.nextElement(); + Enumeration targetElements = rel.getTargetElements(); + while (targetElements.hasMoreElements()) + { + if (targetElements.nextElement() == targetElement) + return rel; + } + } + return null; + } + + public Hashtable deNormalize(Hashtable properties) + { + NodeManager nodeManager = controller.getCurrentPerspective().getNodeManager(); + Node rootNode = nodeManager.getRootNode(); + Node currNode = nodeManager.getSelectedNode(); + if (currNode == null) + currNode = rootNode; + Object value = properties.get(ModelConstants.REL_ID); + String[] relationships = null; + if (value instanceof String[]) + relationships = (String[]) value; + else if (value != null) + relationships = new String[]{value.toString()}; + if (relationships != null) + { + Element currElement = currNode.getTreeElement(); + for (int i = 0; i < relationships.length; i++) + { + int index = relationships[i].indexOf(ModelConstants.REL_LOCALNAME_SEPARATOR); + String rel = (index != -1) ? relationships[i].substring(0, index) : relationships[i]; + String localname = (index != -1) ? relationships[i].substring(index + 1, relationships[i].length()) : null; + Enumeration e = currElement.getElements(rel); + Element targetElement = null; + if (localname != null) + { + Element firstElement = null; + while (e.hasMoreElements()) + { + Element nextElement = (Element) e.nextElement(); + if (firstElement == null) + firstElement = nextElement; + if (localname.equals(nextElement.getName())) + { + targetElement = nextElement; + break; + } + } + if (targetElement == null) + targetElement = firstElement; + } + else + { + if (e.hasMoreElements()) + targetElement = (Element) e.nextElement(); + } + if (targetElement != null) + { + currElement = (Element) targetElement; + Node parentNode = currNode.getParent(); + if (parentNode != null && parentNode.getTreeElement() == currElement) + currNode = parentNode; + else + currNode = currNode.getChildNode((TreeElement) currElement); + } + } + } + properties.put(ActionInputs.NODEID, String.valueOf(currNode.getNodeId())); + return properties; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/ViewSelectionTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/ViewSelectionTransformer.java new file mode 100644 index 000000000..d6bd1359a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/engine/transformer/ViewSelectionTransformer.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.engine.transformer; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; +import org.eclipse.wst.ws.internal.datamodel.Element; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.ListElement; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.ListManager; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class ViewSelectionTransformer implements ITransformer +{ + protected Controller controller; + protected String listManagerKey; + protected String viewKey; + + public ViewSelectionTransformer(Controller controller, String listManagerKey, String viewKey) + { + this.controller = controller; + this.listManagerKey = listManagerKey; + this.viewKey = viewKey; + } + + public Hashtable normalize(Hashtable properties) + { + Vector normalizedViewIds = new Vector(); + NodeManager nodeManager = controller.getCurrentPerspective().getNodeManager(); + Node currNode = nodeManager.getSelectedNode(); + TreeElement currElement = currNode.getTreeElement(); + Object listManagerObj = currElement.getPropertyAsObject(listManagerKey); + if (listManagerObj instanceof ListManager) + { + ListManager listManager = (ListManager) listManagerObj; + String[] viewIds = getViewValues(properties); + for (int i = 0; i < viewIds.length; i++) + { + ListElement listElement = null; + try + { + listElement = listManager.getElementWithViewId(Integer.parseInt(viewIds[i])); + } + catch (NumberFormatException nfe) + { + } + if (listElement != null) + { + Object object = listElement.getObject(); + if (object != null && object instanceof Element) + { + Element element = (Element) object; + normalizedViewIds.add(element.getName()); + } + } + } + } + properties.put(viewKey, normalizedViewIds.toArray(new String[0])); + return properties; + } + + public Hashtable deNormalize(Hashtable properties) + { + Vector viewIds = new Vector(); + Node currNode = controller.getCurrentPerspective().getNodeManager().getSelectedNode(); + if (currNode != null) + { + TreeElement currElement = currNode.getTreeElement(); + Object listManagerObj = currElement.getPropertyAsObject(listManagerKey); + if (listManagerObj instanceof ListManager) + { + ListManager listManager = (ListManager) listManagerObj; + String[] normalizedViewIds = getViewValues(properties); + for (int i = 0; i < normalizedViewIds.length; i++) + { + Enumeration e = listManager.getListElements(); + while (e.hasMoreElements()) + { + ListElement listElement = (ListElement) e.nextElement(); + Element element = (Element) listElement.getObject(); + if (element != null && normalizedViewIds[i].equals(element.getName())) + { + viewIds.add(String.valueOf(listElement.getViewId())); + break; + } + } + } + } + } + int size = viewIds.size(); + if (size == 1) + properties.put(viewKey, viewIds.get(0)); + else if (size > 1) + properties.put(viewKey, viewIds.toArray(new String[0])); + return properties; + } + + private String[] getViewValues(Hashtable properties) + { + Object viewValueObj = properties.get(viewKey); + String[] viewValues; + if (viewValueObj == null) + viewValues = new String[0]; + else if (viewValueObj.getClass().isArray()) + viewValues = (String[]) viewValueObj; + else + viewValues = new String[]{(String) viewValueObj}; + return viewValues; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddBusinessToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddBusinessToUDDIPerspectiveAction.java new file mode 100644 index 000000000..32312a53c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddBusinessToUDDIPerspectiveAction.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.RegFindBusinessUUIDAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.UDDIPerspective; + +import java.util.Hashtable; + +public class AddBusinessToUDDIPerspectiveAction extends AddToUDDIPerspectiveAction +{ + public AddBusinessToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesUDDIBusinessElement busElement = (FavoritesUDDIBusinessElement) selectedElement; + String businessName = busElement.getName(); + String inquiryAPI = busElement.getInquiryURL(); + String businessKey = busElement.getBusinessKey(); + // create the registry in the UDDI perspective + if (!createRegistryInUDDIPerspective(inquiryAPI, null, inquiryAPI, null, true)) + return false; + RegFindBusinessUUIDAction action = new RegFindBusinessUUIDAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY, businessKey); + propertyTable.put(UDDIActionInputs.QUERY_NAME, businessName); + if (!action.run()) + { + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_ADD_TO_UDDI_PERSPECTIVE", businessName)); + return false; + } + uddiPerspective.getNavigatorManager().getSelectedNode().setVisibilityOfChildren(true); + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_ADD_TO_UDDI_PERSPECTIVE_SUCCESSFUL", businessName)); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddRegistryToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddRegistryToUDDIPerspectiveAction.java new file mode 100644 index 000000000..174df859d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddRegistryToUDDIPerspectiveAction.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class AddRegistryToUDDIPerspectiveAction extends AddToUDDIPerspectiveAction +{ + public AddRegistryToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesUDDIRegistryElement regElement = (FavoritesUDDIRegistryElement) selectedElement; + String registryName = regElement.getName(); + String inquiryAPI = regElement.getInquiryURL(); + String publishAPI = regElement.getPublishURL(); + String registrationURL = regElement.getRegistrationURL(); + if (!createRegistryInUDDIPerspective(inquiryAPI, publishAPI, registryName, registrationURL, false)) + return false; + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_ADD_TO_UDDI_PERSPECTIVE_SUCCESSFUL", registryName)); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddServiceInterfaceToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddServiceInterfaceToUDDIPerspectiveAction.java new file mode 100644 index 000000000..b3921bda3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddServiceInterfaceToUDDIPerspectiveAction.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.RegFindServiceInterfaceUUIDAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.UDDIPerspective; + +import java.util.Hashtable; + +public class AddServiceInterfaceToUDDIPerspectiveAction extends AddToUDDIPerspectiveAction +{ + public AddServiceInterfaceToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesUDDIServiceInterfaceElement serIntElement = (FavoritesUDDIServiceInterfaceElement) selectedElement; + String serIntName = serIntElement.getName(); + String inquiryAPI = serIntElement.getInquiryURL(); + String serIntKey = serIntElement.getServiceInterfaceKey(); + // create the registry in the UDDI perspective + if (!createRegistryInUDDIPerspective(inquiryAPI, null, inquiryAPI, null, true)) + return false; + RegFindServiceInterfaceUUIDAction action = new RegFindServiceInterfaceUUIDAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY, serIntKey); + propertyTable.put(UDDIActionInputs.QUERY_NAME, serIntName); + if (!action.run()) + { + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_ADD_TO_UDDI_PERSPECTIVE", serIntName)); + return false; + } + uddiPerspective.getNavigatorManager().getSelectedNode().setVisibilityOfChildren(true); + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_ADD_TO_UDDI_PERSPECTIVE_SUCCESSFUL", serIntName)); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddServiceToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddServiceToUDDIPerspectiveAction.java new file mode 100644 index 000000000..26969d2a7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddServiceToUDDIPerspectiveAction.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.RegFindServiceUUIDAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.UDDIPerspective; + +import java.util.Hashtable; + +public class AddServiceToUDDIPerspectiveAction extends AddToUDDIPerspectiveAction +{ + public AddServiceToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesUDDIServiceElement serElement = (FavoritesUDDIServiceElement) selectedElement; + String serviceName = serElement.getName(); + String inquiryAPI = serElement.getInquiryURL(); + String serviceKey = serElement.getServiceKey(); + // create the registry in the UDDI perspective + if (!createRegistryInUDDIPerspective(inquiryAPI, null, inquiryAPI, null, true)) + return false; + RegFindServiceUUIDAction action = new RegFindServiceUUIDAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY, serviceKey); + propertyTable.put(UDDIActionInputs.QUERY_NAME, serviceName); + if (!action.run()) + { + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_ADD_TO_UDDI_PERSPECTIVE", serviceName)); + return false; + } + uddiPerspective.getNavigatorManager().getSelectedNode().setVisibilityOfChildren(true); + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_ADD_TO_UDDI_PERSPECTIVE_SUCCESSFUL", serviceName)); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddToUDDIPerspectiveAction.java new file mode 100644 index 000000000..856d89979 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddToUDDIPerspectiveAction.java @@ -0,0 +1,216 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import java.io.File; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesUDDIBusinessFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesUDDIRegistryFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesUDDIServiceFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesUDDIServiceInterfaceFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.OpenRegistryAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.CategoryModel; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.RegistryElement; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.RegistryNode; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.UDDIMainNode; +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.util.Validator; + +public abstract class AddToUDDIPerspectiveAction extends MultipleLinkAction { + public AddToUDDIPerspectiveAction(Controller controller) { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) { + StringBuffer actionLink = new StringBuffer("favorites/actions/FavoritesAddToUDDIPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() { + return "favorites/actions/FavoritesAddToUDDIPerspectiveActionJSP.jsp"; + } + + protected boolean createRegistryInUDDIPerspective(String inquiryAPI, String publishAPI, String registryName, String registrationURL,boolean useExisting) { + Vector registryNodes = getRegistryNodesByInquiryURL(inquiryAPI); + if (registryNodes != null) + { + if (useExisting) + { + Node registryNode = (Node)registryNodes.elementAt(0); + NodeManager nodeManager = registryNode.getNodeManager(); + nodeManager.setSelectedNodeId(registryNode.getNodeId()); + return true; + } + } + + // open the registry if it is not already opened in the UDDI perspective + OpenRegistryAction openRegAction = new OpenRegistryAction(controller_); + + // populate the property table + Hashtable propertyTable = openRegAction.getPropertyTable(); + if (Validator.validateString(registryName)) + propertyTable.put(UDDIActionInputs.REGISTRY_NAME,registryName); + else + return false; + + if (Validator.validateURL(inquiryAPI)) + propertyTable.put(UDDIActionInputs.INQUIRY_URL,inquiryAPI); + else + return false; + + if (Validator.validateURL(publishAPI)) + propertyTable.put(UDDIActionInputs.PUBLISH_URL,publishAPI); + + if (Validator.validateURL(registrationURL)) + propertyTable.put(UDDIActionInputs.REGISTRATION_URL,registrationURL); + + // If user-defined category metadata exists, search and make the associations. + StringBuffer directoryBuffer = new StringBuffer(); + FavoritesUDDIRegistryFolderElement.formCategoriesDirectory(directoryBuffer,controller_.getServletEngineStateLocation(),registryName); + File categoriesDirectory = new File(directoryBuffer.toString()); + File[] categoryFiles = null; + if (categoriesDirectory.exists()) + { + categoryFiles = categoriesDirectory.listFiles(); + if (categoryFiles.length > 0) + propertyTable.put(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES,Boolean.TRUE); + } + + // run the action + if (!openRegAction.run()) + return false; + + if (categoryFiles != null && categoryFiles.length > 0) + { + RegistryElement regElement = (RegistryElement)(controller_.getUDDIPerspective().getNavigatorManager().getSelectedNode().getTreeElement()); + regElement.setCheckForUserDefinedCategories(true); + Enumeration userDefinedCategories = regElement.getUserDefinedCategories(); + linkCategoryModelsWithSavedData(registryName,regElement.getUserDefinedCategories()); + } + return true; + } + + public final void linkCategoryModelsWithSavedData(String registryName,Enumeration userDefinedCategories) + { + StringBuffer directoryBuffer = new StringBuffer(); + FavoritesUDDIRegistryFolderElement.formCategoriesDirectory(directoryBuffer,controller_.getServletEngineStateLocation(),registryName); + linkCategoryModelsWithSavedData(userDefinedCategories,directoryBuffer.toString()); + } + + public final void linkCategoryModelsWithSavedData(Enumeration userDefinedCategories,String categoriesDirectory) + { + File categoriesDirectoryFile = new File(categoriesDirectory); + File[] categoryFiles = null; + if (categoriesDirectoryFile.exists()) + { + categoryFiles = categoriesDirectoryFile.listFiles(); + if (userDefinedCategories != null) + { + while (userDefinedCategories.hasMoreElements()) + { + CategoryModel categoryModel = (CategoryModel)userDefinedCategories.nextElement(); + String categoryKey = categoryModel.getCategoryKey(); + for (int i=0;i<categoryFiles.length;i++) + { + String categoryPropertiesFileName = categoryFiles[i].getName(); + int lastDotPos = categoryPropertiesFileName.lastIndexOf("."); + String decodedCategoryPropertiesFileNameBase = URLUtils.decode(categoryPropertiesFileName.substring(0,lastDotPos)); + if (lastDotPos > 0 && categoryPropertiesFileName.endsWith(".properties") && categoryKey.equals(decodedCategoryPropertiesFileNameBase)) + { + categoryModel.setDefaultDataFile(categoryFiles[i].getAbsolutePath()); + categoryModel.loadFromDelimiterFile(); + break; + } + } + } + } + } + } + + protected Vector getRegistryNodesByInquiryURL(String inquiryURL) + { + Vector registryNodes = null; + NodeManager navigatorManager = controller_.getUDDIPerspective().getNavigatorManager(); + UDDIMainNode uddiMainNode = (UDDIMainNode)(navigatorManager.getRootNode()); + Vector childNodes = uddiMainNode.getChildNodes(); + for (int i=0;i<childNodes.size();i++) + { + Node childNode = (Node)childNodes.elementAt(i); + if (childNode instanceof RegistryNode) + { + RegistryElement regElement = (RegistryElement)childNode.getTreeElement(); + String currInquiryURL = regElement.getInquiryURL(); + if (currInquiryURL != null && currInquiryURL.equals(inquiryURL)) + { + if (registryNodes == null) + registryNodes = new Vector(); + registryNodes.addElement(childNode); + } + } + } + return registryNodes; + } + + public static AddToUDDIPerspectiveAction newAction(Controller controller) { + TreeElement selectedElement = controller.getFavoritesPerspective().getNodeManager().getSelectedNode().getTreeElement(); + FavoritesFolderElement favoritesFolderElement = null; + + if (selectedElement instanceof FavoritesFolderElement) { + favoritesFolderElement = (FavoritesFolderElement)selectedElement; + } + else if (selectedElement instanceof FavoritesElement) { + favoritesFolderElement = ((FavoritesElement)selectedElement).getParentFolderElement(); + } + else { + return null; + } + + // return an instance of AddToUDDIPerspectiveAction depending on the type of + // favorites folder element being selected. + if (favoritesFolderElement instanceof FavoritesUDDIRegistryFolderElement) + return new AddRegistryToUDDIPerspectiveAction(controller); + else if (favoritesFolderElement instanceof FavoritesUDDIBusinessFolderElement) + return new AddBusinessToUDDIPerspectiveAction(controller); + else if (favoritesFolderElement instanceof FavoritesUDDIServiceFolderElement) + return new AddServiceToUDDIPerspectiveAction(controller); + else if (favoritesFolderElement instanceof FavoritesUDDIServiceInterfaceFolderElement) + return new AddServiceInterfaceToUDDIPerspectiveAction(controller); + else + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddWSILToWSILPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddWSILToWSILPerspectiveAction.java new file mode 100644 index 000000000..80a10308b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/AddWSILToWSILPerspectiveAction.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.OpenWSILAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.WsilActionInputs; + +import java.util.Hashtable; + +public class AddWSILToWSILPerspectiveAction extends MultipleLinkAction +{ + public AddWSILToWSILPerspectiveAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("favorites/actions/AddWSILToWSILPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "favorites/actions/AddWSILToWSILPerspectiveActionJSP.jsp"; + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesWSILElement wsilElement = (FavoritesWSILElement) selectedElement; + String wsilURL = wsilElement.getWsilUrl(); + OpenWSILAction openWSILAction = new OpenWSILAction(controller_); + Hashtable propertyTable = openWSILAction.getPropertyTable(); + propertyTable.put(WsilActionInputs.WSIL_URL, wsilURL); + propertyTable.put(WsilActionInputs.WSIL_INSPECTION_TYPE, String.valueOf(WsilActionInputs.WSIL_DETAILS)); + boolean actionResult = openWSILAction.run(); + if (actionResult) + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_ADD_WSIL_TO_WSIL_PERSPECTIVE_SUCCESSFUL", wsilURL)); + else + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_ADD_WSIL_TO_WSIL_PERSPECTIVE", wsilURL)); + return actionResult; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesAddToWSDLPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesAddToWSDLPerspectiveAction.java new file mode 100644 index 000000000..233e22e39 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesAddToWSDLPerspectiveAction.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesWSDLServiceElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.FavoritesPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.OpenWSDLAction; + +import java.util.Hashtable; + +public class FavoritesAddToWSDLPerspectiveAction extends MultipleLinkAction +{ + public FavoritesAddToWSDLPerspectiveAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("favorites/actions/FavoritesAddToWSDLPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "favorites/actions/FavoritesAddToWSDLPerspectiveActionJSP.jsp"; + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + FavoritesWSDLServiceElement wsdlElement = (FavoritesWSDLServiceElement) selectedNode.getTreeElement(); + String wsdlUrl = wsdlElement.getWsdlUrl(); + OpenWSDLAction openWSDLAction = new OpenWSDLAction(controller_); + Hashtable propertyTable = openWSDLAction.getPropertyTable(); + propertyTable.put(ActionInputs.QUERY_INPUT_WSDL_URL, wsdlUrl); + boolean actionResult = openWSDLAction.run(); + if (actionResult) + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_ADD_WSDL_TO_WSDL_PERSPECTIVE_SUCCESSFUL", wsdlUrl)); + else + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_ADD_WSDL_TO_WSDL_PERSPECTIVE", wsdlUrl)); + return actionResult; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesImportToFileSystemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesImportToFileSystemAction.java new file mode 100644 index 000000000..bad13a92a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesImportToFileSystemAction.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.FavoritesPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; + +import java.io.OutputStream; +import javax.wsdl.Definition; + +public class FavoritesImportToFileSystemAction extends ImportToFileSystemAction { + + private Definition def_; + private String wsdlFileName_; + + public FavoritesImportToFileSystemAction(Controller controller) { + super(controller); + } + + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId) + { + return ImportToFileSystemAction.getActionLink(nodeId,toolId,viewId,viewToolId,"favorites/actions/FavortiesImportToFileSystemActionJSP.jsp"); + } + + public boolean write(OutputStream os) { + if (def_ != null) { + return writeWSDLDefinition(os, def_); + } + else { + return false; + } + } + + public String getDefaultFileName() { + return wsdlFileName_; + } + + public boolean run() { + int nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + + // return false if nodeID == 0, that is the main node + if (nodeID == 0) + return false; + + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + + String wsdlURL = ((FavoritesWSDLServiceElement)selectedElement).getWsdlUrl(); + wsdlFileName_ = WSDLFileNameHelper.getWSDLFileName(wsdlURL); + try { + def_ = (new Uddi4jHelper()).getWSDLDefinition(wsdlURL); + } + catch (Throwable t) { + favPerspective.getMessageQueue().addMessage(t.getMessage()); + return false; + } + return true; + } + + public final String getStatusContentVar() + { + return controller_.getFavoritesPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getFavoritesPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesImportToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesImportToWorkbenchAction.java new file mode 100644 index 000000000..b26d560dc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesImportToWorkbenchAction.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToWorkbenchAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.FavoritesPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Hashtable; + +public class FavoritesImportToWorkbenchAction extends ImportToWorkbenchAction { + public FavoritesImportToWorkbenchAction(Controller controller) { + super(controller); + } + + public FormTool getSelectedFormTool() { + FavoritesPerspective favoritesPerspective = controller_.getFavoritesPerspective(); + return (FormTool)favoritesPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public ImportToFileSystemAction newImportToFileSystemAction() { + FavoritesImportToFileSystemAction action = new FavoritesImportToFileSystemAction(controller_); + Hashtable table = action.getPropertyTable(); + + FavoritesPerspective favoritesPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favoritesPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + + table.put(ActionInputs.NODEID, String.valueOf(selectedNode.getNodeId())); + table.put(ActionInputs.VIEWID, String.valueOf(selectedNode.getViewId())); + + return action; + } + + public final String getStatusContentVar() + { + return controller_.getFavoritesPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getFavoritesPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesLaunchWebServiceWizardAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesLaunchWebServiceWizardAction.java new file mode 100644 index 000000000..58aae22b1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesLaunchWebServiceWizardAction.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LaunchWebServiceWizardAction; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.FavoritesPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesLaunchWebServiceWizardAction extends LaunchWebServiceWizardAction { + + public FavoritesLaunchWebServiceWizardAction(Controller controller) { + super(controller); + } + + public static LaunchWebServiceWizardAction newAction(Controller controller) { + return new FavoritesLaunchWebServiceWizardAction(controller); + } + + public FormTool getSelectedFormTool() { + FavoritesPerspective favoritesPerspective = controller_.getFavoritesPerspective(); + return (FormTool)favoritesPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public boolean run() { + FavoritesPerspective favoritesPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favoritesPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + if (selectedElement instanceof FavoritesWSDLServiceElement) + return launchWizard(((FavoritesWSDLServiceElement)selectedElement).getWsdlUrl()); + else + return false; + } + + public final String getStatusContentVar() + { + return controller_.getFavoritesPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getFavoritesPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesRestoreDefaultFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesRestoreDefaultFavoritesAction.java new file mode 100644 index 000000000..9cd0e35b7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesRestoreDefaultFavoritesAction.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LinkAction; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Vector; +import javax.servlet.http.*; + +public class FavoritesRestoreDefaultFavoritesAction extends LinkAction +{ + public FavoritesRestoreDefaultFavoritesAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("favorites/actions/RestoreDefaultFavoritesConfirmJSP.jsp"); + return actionLink.toString(); + } + + protected boolean processLinkParameters(HttpServletRequest request) + { + return true; + } + + public boolean run() + { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + Node mainNode = nodeManager.getRootNode(); + FavoritesMainElement mainElement = (FavoritesMainElement)mainNode.getTreeElement(); + boolean actionResult = mainElement.restoreFavoritesDefault(); + if (actionResult) + { + Vector folderNodes = mainNode.getChildNodes(); + for (int i = 0; i < folderNodes.size(); i++) + { + Node folderNode = (Node)folderNodes.elementAt(i); + TreeElement treeElement = folderNode.getTreeElement(); + if (treeElement instanceof FavoritesFolderElement) + { + FavoritesFolderElement folderElement = (FavoritesFolderElement)treeElement; + folderElement.removeAllFavorites(controller_.getServletEngineStateLocation()); + folderElement.init(mainElement); + } + } + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_INFO_FAVORITES_RESTORED_TO_DEFAULT")); + return true; + } + else + { + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_OPEN_FAVORITES_BACKUP")); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesToggleNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesToggleNodeAction.java new file mode 100644 index 000000000..d5d337a90 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/FavoritesToggleNodeAction.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesToggleNodeAction extends ToggleNodeAction { + public FavoritesToggleNodeAction(Controller controller) { + super(controller, controller.getFavoritesPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeId, boolean open) { + StringBuffer actionLink = new StringBuffer("favorites/actions/FavoritesToggleNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeId); + actionLink.append('&'); + actionLink.append(ActionInputs.OPEN); + actionLink.append('='); + if (open) + actionLink.append(ActionInputs.OPEN_NODE); + else + actionLink.append(ActionInputs.CLOSE_NODE); + return actionLink.toString(); + } + + public final String getActionLinkForHistory() { + ToolManager toolManager = toggledNode_.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + int nodeId = toggledNode_.getNodeId(); + int toolId = selectedTool.getToolId(); + int viewId = toggledNode_.getViewId(); + int viewToolId = toggledNode_.getViewToolId(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return SelectFavoritesToolAction.getActionLink(nodeId, toolId, viewId, viewToolId, true); + else + return SelectFavoritesNodeAction.getActionLink(nodeId, true); + } + + public final String getTreeContentVar() + { + return controller_.getFavoritesPerspective().getTreeContentVar(); + } + + public final String getTreeContentPage() + { + return controller_.getFavoritesPerspective().getTreeContentPage(); + } + + public final String getPropertiesContainerVar() + { + return controller_.getFavoritesPerspective().getPropertiesContainerVar(); + } + + public final String getPropertiesContainerPage() + { + return controller_.getFavoritesPerspective().getPropertiesContainerPage(); + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_FAVORITES; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/MultipleLinkAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/MultipleLinkAction.java new file mode 100644 index 000000000..7edb7f883 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/MultipleLinkAction.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LinkAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.MassNodeIdTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.http.*; + +public abstract class MultipleLinkAction extends LinkAction +{ + public MultipleLinkAction(Controller controller) + { + super(controller); + } + + protected boolean processLinkParameters(HttpServletRequest request) + { + String isMultipleLinkAction = request.getParameter(FavoritesActionInputs.MULTIPLE_LINK_ACTION); + if (isMultipleLinkAction != null) + { + propertyTable_.put(FavoritesActionInputs.MULTIPLE_LINK_ACTION, isMultipleLinkAction); + return processMultipleLinkActionParameters(request); + } + else + { + propertyTable_.remove(FavoritesActionInputs.MULTIPLE_LINK_ACTION); + String nodeIDString = request.getParameter(ActionInputs.NODEID); + String toolIDString = request.getParameter(ActionInputs.TOOLID); + String viewIDString = request.getParameter(ActionInputs.VIEWID); + String viewToolIDString = request.getParameter(ActionInputs.VIEWTOOLID); + if (nodeIDString != null) + propertyTable_.put(ActionInputs.NODEID, nodeIDString); + if (toolIDString != null) + propertyTable_.put(ActionInputs.TOOLID, toolIDString); + if (viewIDString != null) + propertyTable_.put(ActionInputs.VIEWID, viewIDString); + if (viewToolIDString != null) + propertyTable_.put(ActionInputs.VIEWTOOLID, viewToolIDString); + return true; + } + } + + protected boolean processMultipleLinkActionParameters(HttpServletRequest request) + { + String[] massActionNodeIDs = request.getParameterValues(FavoritesActionInputs.MASS_ACTION_NODE_ID); + propertyTable_.put(FavoritesActionInputs.MASS_ACTION_NODE_ID, massActionNodeIDs); + if (massActionNodeIDs.length == 0) + return false; + else + return true; + } + + public ITransformer[] getTransformers() + { + return new ITransformer[] {new MassNodeIdTransformer(controller_, FavoritesActionInputs.MASS_ACTION_NODE_ID)}; + } + + protected boolean isMultipleLinkAction() + { + return propertyTable_.containsKey(FavoritesActionInputs.MULTIPLE_LINK_ACTION); + } + + protected String[] getMassActionNodeIds() + { + Object object = propertyTable_.get(FavoritesActionInputs.MASS_ACTION_NODE_ID); + if (object == null) + return new String[0]; + else if (object.getClass().isArray()) + return (String[])object; + else + return new String[] {(String)object}; + } + + public boolean run() + { + return (isMultipleLinkAction()) ? executeMultipleLinkAction() : executeSingleLinkAction(); + } + + protected boolean executeMultipleLinkAction() + { + boolean result = false; + String[] massActionNodeIDs = getMassActionNodeIds(); + if (massActionNodeIDs != null) + { + for (int i = 0; i < massActionNodeIDs.length; i++) + { + propertyTable_.put(ActionInputs.NODEID, massActionNodeIDs[i]); + if (executeSingleLinkAction()) + result = true; + } + propertyTable_.remove(ActionInputs.NODEID); + } + return result; + } + + protected abstract boolean executeSingleLinkAction(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/RemoveFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/RemoveFavoritesAction.java new file mode 100644 index 000000000..7c07c5bcb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/RemoveFavoritesAction.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Enumeration; + +public class RemoveFavoritesAction extends MultipleLinkAction +{ + public RemoveFavoritesAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("favorites/actions/RemoveFavoritesActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "favorites/actions/RemoveFavoritesActionJSP.jsp"; + } + + protected boolean executeSingleLinkAction() + { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager nodeManager = favPerspective.getNodeManager(); + String nodeIDString = (String) propertyTable_.get(ActionInputs.NODEID); + int nodeID; + try + { + nodeID = Integer.parseInt(nodeIDString); + } + catch (NumberFormatException nfe) + { + nodeID = nodeManager.getSelectedNodeId(); + } + Node selectedNode = nodeManager.getNode(nodeID); + if (selectedNode == null) + return false; + TreeElement selectedElement = selectedNode.getTreeElement(); + String pluginMetadataDirectory = controller_.getServletEngineStateLocation(); + boolean actionResult; + if (selectedElement instanceof FavoritesElement) + actionResult = ((FavoritesElement) selectedElement).getParentFolderElement().removeFavoriteByNodeID(nodeID, pluginMetadataDirectory); + else if (selectedElement instanceof FavoritesFolderElement) + actionResult = ((FavoritesFolderElement) selectedElement).removeAllFavorites(pluginMetadataDirectory); + else if (selectedElement instanceof FavoritesMainElement) + { + Enumeration e; + FavoritesMainElement mainElement = (FavoritesMainElement) selectedElement; + e = mainElement.getElements(FavoritesModelConstants.REL_WSIL_FOLDER_NODE); + actionResult = ((FavoritesFolderElement) e.nextElement()).removeAllFavorites(pluginMetadataDirectory); + e = mainElement.getElements(FavoritesModelConstants.REL_WSDL_SERVICE_FOLDER_NODE); + actionResult = actionResult && ((FavoritesFolderElement) e.nextElement()).removeAllFavorites(pluginMetadataDirectory); + e = mainElement.getElements(FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE); + actionResult = actionResult && ((FavoritesFolderElement) e.nextElement()).removeAllFavorites(pluginMetadataDirectory); + e = mainElement.getElements(FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE); + actionResult = actionResult && ((FavoritesFolderElement) e.nextElement()).removeAllFavorites(pluginMetadataDirectory); + e = mainElement.getElements(FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_FOLDER_NODE); + actionResult = actionResult && ((FavoritesFolderElement) e.nextElement()).removeAllFavorites(pluginMetadataDirectory); + e = mainElement.getElements(FavoritesModelConstants.REL_UDDI_REGISTRY_FOLDER_NODE); + actionResult = actionResult && ((FavoritesFolderElement) e.nextElement()).removeAllFavorites(pluginMetadataDirectory); + } + else + actionResult = false; + if (actionResult) + favPerspective.getMessageQueue().addMessage(controller_.getMessage("MSG_INFO_NODE_CLEARED", selectedNode.getNodeName())); + return actionResult; + } + + public String getTreeContentVar() + { + return "favNavigatorContent"; + } + + public String getTreeContentPage() + { + return "favorites/fav_navigator_content.jsp"; + } + + public String getPropertiesContainerVar() + { + return "favPropertiesContainer"; + } + + public String getPropertiesContainerPage() + { + return "favorites/fav_properties_container.jsp"; + } + + public String getStatusContentVar() + { + return "favStatusContent"; + } + + public String getStatusContentPage() + { + return "favorites/fav_status_content.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/ResizeFavoritesFramesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/ResizeFavoritesFramesAction.java new file mode 100644 index 000000000..d33c20578 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/ResizeFavoritesFramesAction.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +public class ResizeFavoritesFramesAction extends ResizeFramesAction +{ + public ResizeFavoritesFramesAction(Controller controller) + { + super(controller); + } + + protected boolean processOthers(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(FavoritesActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(FavoritesActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(FavoritesActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(FavoritesActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + // Save the current frameset sizes. + String frameName = (String)propertyTable_.get(ActionInputs.FRAME_NAME); + String perspectiveContentFramesetCols = (String)propertyTable_.get(FavoritesActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(FavoritesActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + + // Set the new frameset sizes. + boolean saveFrameSettings = false; + if (frameName.equals(FavoritesFrameNames.NAVIGATOR_CONTAINER)) + { + favPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + favPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + if (perspectiveContentFramesetCols.startsWith("100%")) + { + // Restore. + favPerspective.setPerspectiveContentFramesetCols(favPerspective.getSavedPerspectiveContentFramesetCols()); + } + else + { + // Maximize. + favPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + favPerspective.setPerspectiveContentFramesetCols("100%,0%"); + } + } + else if (frameName.equals(FavoritesFrameNames.PROPERTIES_CONTAINER)) + { + if (actionsContainerFramesetRows.startsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + favPerspective.setPerspectiveContentFramesetCols(favPerspective.getSavedPerspectiveContentFramesetCols()); + favPerspective.setActionsContainerFramesetRows(favPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + favPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + favPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + favPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + favPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + favPerspective.setActionsContainerFramesetRows("100%,0%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + favPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + favPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + else if (frameName.equals(FavoritesFrameNames.STATUS_CONTAINER)) + { + if (actionsContainerFramesetRows.endsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + favPerspective.setPerspectiveContentFramesetCols(favPerspective.getSavedPerspectiveContentFramesetCols()); + favPerspective.setActionsContainerFramesetRows(favPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + favPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + favPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + favPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + favPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + favPerspective.setActionsContainerFramesetRows("0%,100%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + favPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + favPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SelectFavoritesNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SelectFavoritesNodeAction.java new file mode 100644 index 000000000..32f0e372e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SelectFavoritesNodeAction.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.SelectNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectFavoritesNodeAction extends SelectNodeAction +{ + public SelectFavoritesNodeAction(Controller controller) + { + super(controller, controller.getFavoritesPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeID, boolean keepHistory) + { + StringBuffer actionLink = new StringBuffer("favorites/actions/SelectFavoritesNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + if (keepHistory) { + actionLink.append('&'); + actionLink.append(ActionInputs.ISHISTORY); + actionLink.append("=1"); + } + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + Node selectedNode = getSelectedNode(); + Tool selectedTool = selectedNode.getToolManager().getSelectedTool(); + if (selectedTool == null) + return null; + else if (selectedTool.getToolType() != ToolTypes.ACTION) + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), selectedTool.getToolId(), selectedNode.getViewId(), selectedNode.getViewToolId(), true); + else + return getActionLink(selectedNode.getNodeId(), true); + } + + public final String getTreeContentVar() { + return controller_.getFavoritesPerspective().getTreeContentVar(); + } + + public final String getTreeContentPage() { + return controller_.getFavoritesPerspective().getTreeContentPage(); + } + + public final String getPropertiesContainerVar() { + return controller_.getFavoritesPerspective().getPropertiesContainerVar(); + } + + public final String getPropertiesContainerPage() { + return controller_.getFavoritesPerspective().getPropertiesContainerPage(); + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_FAVORITES; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SelectFavoritesToolAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SelectFavoritesToolAction.java new file mode 100644 index 000000000..9706b1924 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SelectFavoritesToolAction.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.SelectNodeToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectFavoritesToolAction extends SelectNodeToolAction +{ + public SelectFavoritesToolAction(Controller controller) + { + super(controller, controller.getFavoritesPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID, boolean keepHistory) + { + StringBuffer actionLink = new StringBuffer("favorites/actions/SelectFavoritesToolActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + if (viewID != ActionInputs.VIEWID_DEFAULT) { + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + } + if (keepHistory) { + actionLink.append('&'); + actionLink.append(ActionInputs.ISHISTORY); + actionLink.append("=1"); + } + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + if (getSelectedTool().getToolType() != ToolTypes.ACTION) { + Node selectedNode = getSelectedNode(); + return getActionLink(selectedNode.getNodeId(), getSelectedTool().getToolId(), selectedNode.getViewId(), selectedNode.getViewToolId(), true); + } + else + return null; + } + + public final String getTreeContentVar() { + return controller_.getFavoritesPerspective().getTreeContentVar(); + } + + public final String getTreeContentPage() { + return controller_.getFavoritesPerspective().getTreeContentPage(); + } + + public final String getPropertiesContainerVar() { + return controller_.getFavoritesPerspective().getPropertiesContainerVar(); + } + + public final String getPropertiesContainerPage() { + return controller_.getFavoritesPerspective().getPropertiesContainerPage(); + } + + public final String getPropertiesContentVar() { + return controller_.getFavoritesPerspective().getPropertiesContentVar(); + } + + public final String getPropertiesContentPage() { + return controller_.getFavoritesPerspective().getPropertiesContentPage(); + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_FAVORITES; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SwitchPerspectiveFromFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SwitchPerspectiveFromFavoritesAction.java new file mode 100644 index 000000000..4470c6ba4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/actions/SwitchPerspectiveFromFavoritesAction.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +public final class SwitchPerspectiveFromFavoritesAction extends ShowPerspectiveAction +{ + public SwitchPerspectiveFromFavoritesAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(FavoritesActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(FavoritesActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(FavoritesActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(FavoritesActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + String perspectiveContentFramesetCols = (String)propertyTable_.get(FavoritesActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(FavoritesActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + + // Save the frameset sizes iff no frame is maximized. + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + if (!perspectiveContentFramesetCols.startsWith("100%") && !perspectiveContentFramesetCols.endsWith("100%")) + favPerspective.setPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + + if (!actionsContainerFramesetRows.startsWith("100%") && !actionsContainerFramesetRows.endsWith("100%")) + favPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + + return super.run(); + } + + public static final String getFormActionLink(int targetPerspectiveId,boolean forHistory) + { + StringBuffer formLink = new StringBuffer("wsdl/actions/SwitchPerspectiveFromWSDLActionJSP.jsp?"); + formLink.append(ActionInputs.PERSPECTIVE).append('=').append(targetPerspectiveId); + if (forHistory) + formLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return formLink.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesActionInputs.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesActionInputs.java new file mode 100644 index 000000000..c4ca64187 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesActionInputs.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.constants; + +public class FavoritesActionInputs +{ + // mass actions + public final static String MULTIPLE_LINK_ACTION = "multipleLinkAction"; + public final static String MASS_ACTION_NODE_ID = "massActionNodeID"; + + // resize favorites frames action + public final static String FRAMESET_COLS_PERSPECTIVE_CONTENT = "framesetColsPerspectiveContent"; + public final static String FRAMESET_ROWS_ACTIONS_CONTAINER = "framesetRowsActionsContainer"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesFrameNames.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesFrameNames.java new file mode 100644 index 000000000..5a2622049 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesFrameNames.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.constants; + +public class FavoritesFrameNames +{ + public final static String NAVIGATOR_CONTAINER = "fav_navigator_container"; + public final static String NAVIGATOR_TOOLBAR = "fav_navigator_toolbar"; + public final static String NAVIGATOR_CONTENT = "fav_navigator_content"; + public final static String ACTIONS_CONTAINER = "fav_actions_container"; + public final static String PROPERTIES_CONTAINER = "fav_properties_container"; + public final static String PROPERTIES_TOOLBAR = "fav_properties_toolbar"; + public final static String PROPERTIES_CONTENT = "fav_properties_content"; + public final static String STATUS_CONTAINER = "fav_status_container"; + public final static String STATUS_TOOLBAR = "fav_status_toolbar"; + public final static String STATUS_CONTENT = "fav_status_content"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesModelConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesModelConstants.java new file mode 100644 index 000000000..9b935e8f4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/constants/FavoritesModelConstants.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.constants; + +public class FavoritesModelConstants { + // Relations + public final static String REL_WSIL_FOLDER_NODE = "relWSILFolderNode"; + public final static String REL_WSDL_SERVICE_FOLDER_NODE = "relWSDLServiceFolderNode"; + public final static String REL_UDDI_SERVICE_FOLDER_NODE = "relUDDIServiceFolderNode"; + public final static String REL_UDDI_BUSINESS_FOLDER_NODE = "relUDDIBusinessFolderNode"; + public final static String REL_UDDI_SERVICE_INTERFACE_FOLDER_NODE = "relUDDIServiceInterfaceFolderNode"; + public final static String REL_UDDI_REGISTRY_FOLDER_NODE = "relUDDIRegistryFolerNode"; + public final static String REL_WSIL_NODE = "relWSILNode"; + public final static String REL_WSDL_SERVICE_NODE = "relWSDLServiceNode"; + public final static String REL_UDDI_SERVICE_NODE = "relUDDIServiceNode"; + public final static String REL_UDDI_BUSINESS_NODE = "relUDDIBusinessNode"; + public final static String REL_UDDI_SERVICE_INTERFACE_NODE = "relUDDIServiceInterfaceNode"; + public final static String REL_UDDI_REGISTRY_NODE = "relUDDIRegistryNode"; + + // Properties + public final static String PROP_PLUGIN_METADATA_DIRECTORY = "pluginMetadataDirectory"; + public final static String PROP_WSIL_URL = "wsilURL"; + public final static String PROP_WSDL_URL = "wsdlURL"; + public final static String PROP_UDDI_SERVICE_NAME = "UDDIServiceName"; + public final static String PROP_UDDI_SERVICE_INQUIRY_API = "UDDIServiceInquiryAPI"; + public final static String PROP_UDDI_SERVICE_KEY = "UDDIServiceKey"; + public final static String PROP_UDDI_BUSINESS_NAME = "UDDIBusinessName"; + public final static String PROP_UDDI_BUSINESS_INQUIRY_API = "UDDIBusinessInquiryAPI"; + public final static String PROP_UDDI_BUSINESS_KEY = "UDDIBusinessKey"; + public final static String PROP_UDDI_SERVICE_INTERFACE_NAME = "UDDIServiceInterfaceName"; + public final static String PROP_UDDI_SERVICE_INTERFACE_INQUIRY_API = "UDDIServiceInterfaceInquiryAPI"; + public final static String PROP_UDDI_SERVICE_INTERFACE_KEY = "UDDIServiceInterfaceKey"; + public final static String PROP_UDDI_REGISTRY_NAME = "UDDIRegistryName"; + public final static String PROP_UDDI_REGISTRY_INQUIRY_API = "UDDIRegistryInquiryAPI"; + public final static String PROP_UDDI_REGISTRY_PUBLISH_API = "UDDIRegistryPublishAPI"; + public final static String PROP_UDDI_REGISTRY_REGISTRATION_URL = "UDDIRegistryRegistrationURL"; + public final static String PROP_UDDI_REGISTRY_CATEGORIES_ENUM = "UDDIRegistryCategoriesEnum"; + + // List Managers for Favorites + public final static String LIST_MANAGER_WSDL_SERVICES = "wsdlServices"; + public final static String LIST_MANAGER_UDDI_SERVICES = "uddiServices"; + public final static String LIST_MANAGER_UDDI_BUSINESS = "uddiBusiness"; + public final static String LIST_MANAGER_WSIL_LINKS = "wsilLinks"; + public final static String LIST_MANAGER_UDDI_REGISTRY = "uddiRegistry"; + public final static String LIST_MANAGER_UDDI_SERVICE_INTERFACE = "uddiServiceInterface"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesElement.java new file mode 100644 index 000000000..b0833e785 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesElement.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; + +import java.util.Enumeration; + +/** +* The data model element that represents +* a WSIL document +*/ +public class FavoritesElement extends TreeElement { + + public FavoritesElement(String name, Model model) { + super(name, model); + } + + public FavoritesFolderElement getParentFolderElement() { + Enumeration e = getElements(ModelConstants.REL_OWNER); + if (!e.hasMoreElements()) + return null; + else + return (FavoritesFolderElement)e.nextElement(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesFolderElement.java new file mode 100644 index 000000000..567dcc73d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesFolderElement.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +import java.util.Hashtable; +import java.util.Enumeration; + +/** +* The data model element that represents +* a WSIL document +*/ +public abstract class FavoritesFolderElement extends TreeElement +{ + protected NodeManager nodeManager_; + + public FavoritesFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model); + nodeManager_ = nodeManager; + } + + protected FavoritesMainElement getFavoritesMainElement() { + return (FavoritesMainElement)nodeManager_.getRootNode().getTreeElement(); + } + + public abstract void init(FavoritesMainElement favMainElement); + + public abstract boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory); + + public abstract boolean removeAllFavorites(String pluginMetadataDirectory); + + public abstract boolean addFavorite(Hashtable table); + + public abstract boolean favoriteExists(Hashtable table); + + public abstract Enumeration getAllFavorites(); + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesMainElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesMainElement.java new file mode 100644 index 000000000..2ce48a25d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesMainElement.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.favorites.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL document +*/ +public class FavoritesMainElement extends TreeElement +{ + private Controller controller_; + private FavoritesRegistryTypeWSE favRegistry_; + + public FavoritesMainElement(String name, Model model, Controller controller) + { + super(name, model); + controller_ = controller; + favRegistry_ = new FavoritesRegistryTypeWSE( + controller.getDefaultFavoritesLocation(), + controller.getServletEngineStateLocation() + ); + } + + public boolean restoreFavoritesDefault() + { + favRegistry_.restoreFavoritesDefault(); + return saveFavorites(); + } + + public boolean saveFavorites() + { + try + { + favRegistry_.save(); + return true; + } + catch (Throwable t) + { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + favPerspective.getMessageQueue().addMessage(favPerspective.getMessage("MSG_ERROR_SAVE_FAVORITES_WSIL", favRegistry_.getWriteLocation())); + return false; + } + } + + public Link addUDDIRegistry(String registryName, String inquiryAPI, String publishAPI, String registrationURL) + { + return favRegistry_.addUDDIRegistry(registryName, inquiryAPI, publishAPI, registrationURL); + } + + public Link addUDDIBusiness(String businessName, String inquiryAPI, String businessKey) + { + return favRegistry_.addUDDIBusiness(businessName, inquiryAPI, businessKey); + } + + public Service addUDDIService(String serviceName, String inquiryAPI, String serviceKey) + { + return favRegistry_.addUDDIService(serviceName, inquiryAPI, serviceKey); + } + + public Service addUDDIServiceInterface(String serIntName, String inquiryAPI, String serIntKey) + { + return favRegistry_.addUDDIServiceInterface(serIntName, inquiryAPI, serIntKey); + } + + public Service addWSDLService(String url) + { + return favRegistry_.addWSDLService(url); + } + + public Link addWSILLink(String url) + { + return favRegistry_.addWSILLink(url); + } + + public boolean removeService(Service service) { + favRegistry_.removeService(service); + return true; + } + + public boolean removeLink(Link link) { + favRegistry_.removeLink(link); + return true; + } + + public Link[] loadUDDIRegistries() + { + return favRegistry_.loadUDDIRegistries(); + } + + public Link[] loadUDDIBusinesses() + { + return favRegistry_.loadUDDIBusinesses(); + } + + public Service[] loadUDDIServices() + { + return favRegistry_.loadUDDIServices(); + } + + public Service[] loadUDDIServiceInterfaces() + { + return favRegistry_.loadUDDIServiceInterfaces(); + } + + public Service[] loadWSDLServices() + { + return favRegistry_.loadWSDLServices(); + } + + public Link[] loadWSILs() + { + return favRegistry_.loadWSILs(); + } + + public final FavoritesUDDIRegistryFolderElement getFavoritesUDDIRegistryFolderElement() + { + return (FavoritesUDDIRegistryFolderElement)(getElements(FavoritesModelConstants.REL_UDDI_REGISTRY_FOLDER_NODE).nextElement()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIBusinessElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIBusinessElement.java new file mode 100644 index 000000000..fa91fb18d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIBusinessElement.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.parser.favorites.FavoritesUDDIBusiness; +import org.apache.wsil.*; + +public class FavoritesUDDIBusinessElement extends FavoritesElement { + + private FavoritesUDDIBusiness uddiBusiness_; + + public FavoritesUDDIBusinessElement(String name, Model model, Link link) { + super(name, model); + uddiBusiness_ = new FavoritesUDDIBusiness(); + uddiBusiness_.setLink(link); + } + + public Link getLink() { + return uddiBusiness_.getLink(); + } + + public String getName() { + return uddiBusiness_.getName(); + } + + public String getInquiryURL() { + return uddiBusiness_.getInquiryURL(); + } + + public String getBusinessKey() { + return uddiBusiness_.getBusinessKey(); + } + + public String toString() { + return getName(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIBusinessFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIBusinessFolderElement.java new file mode 100644 index 000000000..6fe50a018 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIBusinessFolderElement.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Hashtable; +import java.util.Enumeration; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL document +*/ +public class FavoritesUDDIBusinessFolderElement extends FavoritesFolderElement +{ + public FavoritesUDDIBusinessFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model, nodeManager); + } + + public void init(FavoritesMainElement favMainElement) { + Link[] links = favMainElement.loadUDDIBusinesses(); + for (int i = 0; i < links.length; i++) { + Link link = links[i]; + FavoritesUDDIBusinessElement favUDDIBusinessElement = new FavoritesUDDIBusinessElement((link.getAbstracts())[0].getText(), getModel(), link); + connect(favUDDIBusinessElement, FavoritesModelConstants.REL_UDDI_BUSINESS_NODE, ModelConstants.REL_OWNER); + } + } + + public boolean addFavorite(Hashtable table) { + String businessName = (String)table.get(FavoritesModelConstants.PROP_UDDI_BUSINESS_NAME); + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_BUSINESS_INQUIRY_API); + String businessKey = (String)table.get(FavoritesModelConstants.PROP_UDDI_BUSINESS_KEY); + if (businessName == null || inquiryAPI == null || businessKey == null) + return false; + FavoritesUDDIBusinessElement e = getFavorite(inquiryAPI, businessKey); + if (e != null) + removeFavorite(e); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Link link = favMainElement.addUDDIBusiness(businessName, inquiryAPI, businessKey); + boolean saved = favMainElement.saveFavorites(); + if (saved) { + FavoritesUDDIBusinessElement favUDDIBusinessElement = new FavoritesUDDIBusinessElement(businessName, getModel(), link); + connect(favUDDIBusinessElement, FavoritesModelConstants.REL_UDDI_BUSINESS_NODE, ModelConstants.REL_OWNER); + } + return saved; + } + + public boolean favoriteExists(Hashtable table) { + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_BUSINESS_INQUIRY_API); + String businessKey = (String)table.get(FavoritesModelConstants.PROP_UDDI_BUSINESS_KEY); + if (inquiryAPI == null || businessKey == null) + return false; + return (getFavorite(inquiryAPI, businessKey) != null); + } + + public boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory) { + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (selectedElement instanceof FavoritesUDDIBusinessElement) + return (removeFavorite((FavoritesUDDIBusinessElement)selectedElement) && favMainElement.saveFavorites()); + else + return false; + } + + private boolean removeFavorite(FavoritesUDDIBusinessElement element) { + Link link = element.getLink(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (favMainElement.removeLink(link)) { + element.disconnectAll(); + return true; + } + else + return false; + } + + public boolean removeAllFavorites(String pluginMetadataDirectory) { + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Enumeration e = getAllFavorites(); + while(e.hasMoreElements()) { + FavoritesUDDIBusinessElement favUDDIBusinessElement = (FavoritesUDDIBusinessElement)e.nextElement(); + Link link = favUDDIBusinessElement.getLink(); + favMainElement.removeLink(link); + } + disconnectRel(FavoritesModelConstants.REL_UDDI_BUSINESS_NODE); + return favMainElement.saveFavorites(); + } + + public Enumeration getAllFavorites() { + return getElements(FavoritesModelConstants.REL_UDDI_BUSINESS_NODE); + } + + private FavoritesUDDIBusinessElement getFavorite(String inquiryAPI, String businessKey) { + Enumeration e = getAllFavorites(); + while (e.hasMoreElements()) { + FavoritesUDDIBusinessElement busElement = (FavoritesUDDIBusinessElement)e.nextElement(); + if (inquiryAPI.equals(busElement.getInquiryURL()) && + businessKey.equals(busElement.getBusinessKey())) + return busElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIRegistryElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIRegistryElement.java new file mode 100644 index 000000000..d9d49d511 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIRegistryElement.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.parser.favorites.FavoritesUDDIRegistry; +import org.eclipse.wst.ws.internal.parser.favorites.IFavoritesUDDIRegistry; +import org.apache.wsil.*; + +public class FavoritesUDDIRegistryElement extends FavoritesElement { + + private FavoritesUDDIRegistry uddiReg_; + + public FavoritesUDDIRegistryElement(String name, Model model, Link link) { + super(name, model); + uddiReg_ = new FavoritesUDDIRegistry(); + uddiReg_.setLink(link); + } + + public Link getLink() { + return uddiReg_.getLink(); + } + + public String getName() { + return uddiReg_.getName(); + } + + public String getInquiryURL() { + return uddiReg_.getInquiryURL(); + } + + public String getPublishURL() { + return uddiReg_.getPublishURL(); + } + + public String getRegistrationURL() { + return uddiReg_.getRegistrationURL(); + } + + public String toString() { + return getName(); + } + + public IFavoritesUDDIRegistry getIFavoritesUDDIRegistryInterface() + { + return uddiReg_; + } +} + diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIRegistryFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIRegistryFolderElement.java new file mode 100644 index 000000000..bae3db071 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIRegistryFolderElement.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import java.io.File; +import java.util.Enumeration; +import java.util.Hashtable; + +import org.apache.wsil.Link; +import org.eclipse.wst.ws.internal.datamodel.Model; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.FavoritesModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.CategoryModel; +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; + +/** +* The data model element that represents +* a WSIL document +*/ +public class FavoritesUDDIRegistryFolderElement extends FavoritesFolderElement +{ + public FavoritesUDDIRegistryFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model, nodeManager); + } + + public void init(FavoritesMainElement favMainElement) { + Link[] links = favMainElement.loadUDDIRegistries(); + for (int i = 0; i < links.length; i++) { + Link link = links[i]; + FavoritesUDDIRegistryElement favUDDIRegsitryElement = new FavoritesUDDIRegistryElement((link.getAbstracts())[0].getText(), getModel(), link); + connect(favUDDIRegsitryElement, FavoritesModelConstants.REL_UDDI_REGISTRY_NODE, ModelConstants.REL_OWNER); + } + } + + public boolean addFavorite(Hashtable table) { + String registryName = (String)table.get(FavoritesModelConstants.PROP_UDDI_REGISTRY_NAME); + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_REGISTRY_INQUIRY_API); + String publishAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_REGISTRY_PUBLISH_API); + String registrationURL = (String)table.get(FavoritesModelConstants.PROP_UDDI_REGISTRY_REGISTRATION_URL); + Enumeration userDefinedCategories = (Enumeration)table.get(FavoritesModelConstants.PROP_UDDI_REGISTRY_CATEGORIES_ENUM); + // Save the category data first and undo if necessary. + if (userDefinedCategories != null) + { + String pluginMetadataDirectory = (String)table.get(FavoritesModelConstants.PROP_PLUGIN_METADATA_DIRECTORY); + StringBuffer directoryBuffer = new StringBuffer(); + formCategoriesDirectory(directoryBuffer,pluginMetadataDirectory,registryName); + File categoriesDirectoryFile = new File(directoryBuffer.toString()); + categoriesDirectoryFile.mkdirs(); + StringBuffer categoryFileName = new StringBuffer(); + while (userDefinedCategories.hasMoreElements()) + { + CategoryModel categoryModel = (CategoryModel)userDefinedCategories.nextElement(); + categoryFileName.setLength(0); + String encodedCategoryKey = URLUtils.encode(categoryModel.getCategoryKey()); + categoryFileName.append(categoriesDirectoryFile.getAbsolutePath()).append(File.separatorChar).append(encodedCategoryKey).append(".txt"); + byte rc = categoryModel.saveData(categoryFileName.toString()); + if (rc != CategoryModel.OPERATION_SUCCESSFUL) + { + // Delete the category file if it exists. + File categoryFile = new File(categoryFileName.toString()); + if (categoryFile.exists()) + categoryFile.delete(); + } + } + cleanupCategoryDirectories(categoriesDirectoryFile); + } + if (registryName == null || inquiryAPI == null || publishAPI == null) + return false; + FavoritesUDDIRegistryElement e = getFavorite(registryName); + if (e != null) + removeFavorite(e); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Link link = favMainElement.addUDDIRegistry(registryName, inquiryAPI, publishAPI, registrationURL); + boolean saved = favMainElement.saveFavorites(); + if (saved) { + FavoritesUDDIRegistryElement favUDDIRegsitryElement = new FavoritesUDDIRegistryElement(registryName, getModel(), link); + connect(favUDDIRegsitryElement, FavoritesModelConstants.REL_UDDI_REGISTRY_NODE, ModelConstants.REL_OWNER); + } + return saved; + } + + public static final void formCategoriesDirectory(StringBuffer categoriesDirectory,String pluginMetadataDirectory,String registryName) + { + // <metadata>/uddi/<registryId>/categories + String encodedRegistryName = URLUtils.encode(registryName); + categoriesDirectory.append(pluginMetadataDirectory).append("uddi").append(File.separatorChar).append(encodedRegistryName).append(File.separatorChar).append("categories"); + } + + private final void clearRegistryMetadata(String pluginMetadataDirectory,String registryName) + { + StringBuffer categoriesDirectory = new StringBuffer(); + formCategoriesDirectory(categoriesDirectory,pluginMetadataDirectory,registryName); + File categoriesDirectoryFile = new File(categoriesDirectory.toString()); + File[] categoryFiles = categoriesDirectoryFile.listFiles(); + if (categoryFiles != null) + { + for (int i=0;i<categoryFiles.length;i++) + categoryFiles[i].delete(); + } + cleanupCategoryDirectories(categoriesDirectoryFile); + } + + private final void cleanupCategoryDirectories(File categoriesDirectoryFile) + { + // Delete the categories subdirectory if it is empty. + String[] fileList; + fileList = categoriesDirectoryFile.list(); + if (fileList == null || fileList.length == 0) + categoriesDirectoryFile.delete(); + // Delete the <registryId> subdirectory if it is empty. + File registryIdDirectoryFile = categoriesDirectoryFile.getParentFile(); + fileList = registryIdDirectoryFile.list(); + if (fileList == null || fileList.length == 0) + registryIdDirectoryFile.delete(); + // Delete the uddi subdirectory if it is empty. + File uddiDirectoryFile = registryIdDirectoryFile.getParentFile(); + fileList = uddiDirectoryFile.list(); + if (fileList == null || fileList.length == 0) + uddiDirectoryFile.delete(); + } + + public boolean favoriteExists(Hashtable table) { + String registryName = (String)table.get(FavoritesModelConstants.PROP_UDDI_REGISTRY_NAME); + if (registryName == null) + return false; + return (getFavorite(registryName) != null); + } + + public boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory) { + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (selectedElement instanceof FavoritesUDDIRegistryElement) + { + clearRegistryMetadata(pluginMetadataDirectory,selectedElement.getName()); + boolean rc = removeFavorite((FavoritesUDDIRegistryElement)selectedElement); + rc = rc && favMainElement.saveFavorites(); + return rc; + } + else + return false; + } + + private boolean removeFavorite(FavoritesUDDIRegistryElement element) { + Link link = ((FavoritesUDDIRegistryElement)element).getLink(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (favMainElement.removeLink(link)) { + element.disconnectAll(); + return true; + } + else + return false; + } + + public boolean removeAllFavorites(String pluginMetadataDirectory) { + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Enumeration e = getAllFavorites(); + while(e.hasMoreElements()) { + FavoritesUDDIRegistryElement favUDDIRegistryElement = (FavoritesUDDIRegistryElement)e.nextElement(); + clearRegistryMetadata(pluginMetadataDirectory,favUDDIRegistryElement.getName()); + Link link = favUDDIRegistryElement.getLink(); + favMainElement.removeLink(link); + } + disconnectRel(FavoritesModelConstants.REL_UDDI_REGISTRY_NODE); + return favMainElement.saveFavorites(); + } + + public Enumeration getAllFavorites() { + return getElements(FavoritesModelConstants.REL_UDDI_REGISTRY_NODE); + } + + private FavoritesUDDIRegistryElement getFavorite(String registryName) { + Enumeration e = getAllFavorites(); + while (e.hasMoreElements()) { + FavoritesUDDIRegistryElement regElement = (FavoritesUDDIRegistryElement)e.nextElement(); + if (registryName.equals(regElement.getName())) + return regElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceElement.java new file mode 100644 index 000000000..ee4ce93d3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceElement.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.parser.favorites.FavoritesUDDIService; +import org.apache.wsil.*; + +public class FavoritesUDDIServiceElement extends FavoritesElement { + + private FavoritesUDDIService uddiService_; + + public FavoritesUDDIServiceElement(String name, Model model, Service service) { + super(name, model); + uddiService_ = new FavoritesUDDIService(); + uddiService_.setService(service); + } + + public Service getService() { + return uddiService_.getService(); + } + + public String getName() { + return uddiService_.getName(); + } + + public String getInquiryURL() { + return uddiService_.getInquiryURL(); + } + + public String getServiceKey() { + return uddiService_.getServiceKey(); + } + + public String toString() { + return getName(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceFolderElement.java new file mode 100644 index 000000000..384851598 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceFolderElement.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Hashtable; +import java.util.Enumeration; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL document +*/ +public class FavoritesUDDIServiceFolderElement extends FavoritesFolderElement +{ + + public FavoritesUDDIServiceFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model, nodeManager); + } + + public void init(FavoritesMainElement favMainElement) { + Service[] services = favMainElement.loadUDDIServices(); + for (int i = 0; i < services.length; i++) { + Service service = services[i]; + FavoritesUDDIServiceElement favUDDIServiceElement = new FavoritesUDDIServiceElement((service.getServiceNames())[0].getText(), getModel(), service); + connect(favUDDIServiceElement, FavoritesModelConstants.REL_UDDI_SERVICE_NODE, ModelConstants.REL_OWNER); + } + } + + public boolean addFavorite(Hashtable table) { + String serviceName = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_NAME); + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INQUIRY_API); + String serviceKey = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_KEY); + if (serviceName == null || inquiryAPI == null || serviceKey == null) + return false; + FavoritesUDDIServiceElement e = getFavorite(inquiryAPI, serviceKey); + if (e != null) + removeFavorite(e); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Service service = favMainElement.addUDDIService(serviceName, inquiryAPI, serviceKey); + boolean saved = favMainElement.saveFavorites(); + if (saved) { + FavoritesUDDIServiceElement favUDDIServiceElement = new FavoritesUDDIServiceElement(serviceName, getModel(), service); + connect(favUDDIServiceElement, FavoritesModelConstants.REL_UDDI_SERVICE_NODE, ModelConstants.REL_OWNER); + } + return saved; + } + + public boolean favoriteExists(Hashtable table) { + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INQUIRY_API); + String serviceKey = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_KEY); + if (inquiryAPI == null || serviceKey == null) + return false; + return (getFavorite(inquiryAPI, serviceKey) != null); + } + + public boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory) { + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (selectedElement instanceof FavoritesUDDIServiceElement) + return (removeFavorite((FavoritesUDDIServiceElement)selectedElement) && favMainElement.saveFavorites()); + else + return false; + } + + private boolean removeFavorite(FavoritesUDDIServiceElement element) { + Service service = ((FavoritesUDDIServiceElement)element).getService(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (favMainElement.removeService(service)) { + element.disconnectAll(); + return true; + } + else + return false; + } + + public boolean removeAllFavorites(String pluginMetadataDirectory) { + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Enumeration e = getAllFavorites(); + while(e.hasMoreElements()) { + FavoritesUDDIServiceElement favUDDIServiceElement = (FavoritesUDDIServiceElement)e.nextElement(); + Service service = favUDDIServiceElement.getService(); + favMainElement.removeService(service); + } + disconnectRel(FavoritesModelConstants.REL_UDDI_SERVICE_NODE); + return favMainElement.saveFavorites(); + } + + public Enumeration getAllFavorites() { + return getElements(FavoritesModelConstants.REL_UDDI_SERVICE_NODE); + } + + private FavoritesUDDIServiceElement getFavorite(String inquiryAPI, String serviceKey) { + Enumeration e = getAllFavorites(); + while (e.hasMoreElements()) { + FavoritesUDDIServiceElement serElement = (FavoritesUDDIServiceElement)e.nextElement(); + if (inquiryAPI.equals(serElement.getInquiryURL()) && + serviceKey.equals(serElement.getServiceKey())) + return serElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceInterfaceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceInterfaceElement.java new file mode 100644 index 000000000..d3f892242 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceInterfaceElement.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.parser.favorites.FavoritesUDDIServiceInterface; +import org.apache.wsil.*; + +public class FavoritesUDDIServiceInterfaceElement extends FavoritesElement { + + private FavoritesUDDIServiceInterface uddiSerInt_; + + public FavoritesUDDIServiceInterfaceElement(String name, Model model, Service service) { + super(name, model); + uddiSerInt_ = new FavoritesUDDIServiceInterface(); + uddiSerInt_.setService(service); + } + + public Service getService() { + return uddiSerInt_.getService(); + } + + public String getName() { + return uddiSerInt_.getName(); + } + + public String getInquiryURL() { + return uddiSerInt_.getInquiryURL(); + } + + public String getServiceInterfaceKey() { + return uddiSerInt_.getServiceInterfaceKey(); + } + + public String toString() { + return getName(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceInterfaceFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceInterfaceFolderElement.java new file mode 100644 index 000000000..bbdc90d31 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesUDDIServiceInterfaceFolderElement.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Hashtable; +import java.util.Enumeration; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL document +*/ +public class FavoritesUDDIServiceInterfaceFolderElement extends FavoritesFolderElement +{ + + public FavoritesUDDIServiceInterfaceFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model, nodeManager); + } + + public void init(FavoritesMainElement favMainElement) { + Service[] services = favMainElement.loadUDDIServiceInterfaces(); + for (int i = 0; i < services.length; i++) { + Service service = services[i]; + FavoritesUDDIServiceInterfaceElement favUDDISerIntElement = new FavoritesUDDIServiceInterfaceElement((service.getServiceNames())[0].getText(), getModel(), service); + connect(favUDDISerIntElement, FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE, ModelConstants.REL_OWNER); + } + } + + public boolean addFavorite(Hashtable table) { + String serIntName = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_NAME); + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_INQUIRY_API); + String serIntKey = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_KEY); + if (serIntName == null || inquiryAPI == null || serIntKey == null) + return false; + FavoritesUDDIServiceInterfaceElement e = getFavorite(inquiryAPI, serIntKey); + if (e != null) + removeFavorite(e); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Service service = favMainElement.addUDDIServiceInterface(serIntName, inquiryAPI, serIntKey); + boolean saved = favMainElement.saveFavorites(); + if (saved) { + FavoritesUDDIServiceInterfaceElement favUDDISerIntElement = new FavoritesUDDIServiceInterfaceElement(serIntName, getModel(), service); + connect(favUDDISerIntElement, FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE, ModelConstants.REL_OWNER); + } + return saved; + } + + public boolean favoriteExists(Hashtable table) { + String inquiryAPI = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_INQUIRY_API); + String serIntKey = (String)table.get(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_KEY); + if (inquiryAPI == null || serIntKey == null) + return false; + return (getFavorite(inquiryAPI, serIntKey) != null); + } + + public boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory) { + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (selectedElement instanceof FavoritesUDDIServiceInterfaceElement) + return (removeFavorite((FavoritesUDDIServiceInterfaceElement)selectedElement) && favMainElement.saveFavorites()); + else + return false; + } + + private boolean removeFavorite(FavoritesUDDIServiceInterfaceElement element) { + Service service = ((FavoritesUDDIServiceInterfaceElement)element).getService(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (favMainElement.removeService(service)) { + element.disconnectAll(); + return true; + } + else + return false; + } + + public boolean removeAllFavorites(String pluginMetadataDirectory) { + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Enumeration e = getAllFavorites(); + while(e.hasMoreElements()) { + FavoritesUDDIServiceInterfaceElement favUDDISerIntElement = (FavoritesUDDIServiceInterfaceElement)e.nextElement(); + Service service = favUDDISerIntElement.getService(); + favMainElement.removeService(service); + } + disconnectRel(FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE); + return favMainElement.saveFavorites(); + } + + public Enumeration getAllFavorites() { + return getElements(FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE); + } + + private FavoritesUDDIServiceInterfaceElement getFavorite(String inquiryAPI, String serIntKey) { + Enumeration e = getAllFavorites(); + while (e.hasMoreElements()) { + FavoritesUDDIServiceInterfaceElement serIntElement = (FavoritesUDDIServiceInterfaceElement)e.nextElement(); + if (inquiryAPI.equals(serIntElement.getInquiryURL()) && + serIntKey.equals(serIntElement.getServiceInterfaceKey())) + return serIntElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSDLServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSDLServiceElement.java new file mode 100644 index 000000000..ec9993d12 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSDLServiceElement.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.parser.favorites.FavoritesWSDL; +import org.apache.wsil.*; + +public class FavoritesWSDLServiceElement extends FavoritesElement { + + private FavoritesWSDL wsdl_; + + public FavoritesWSDLServiceElement(String name, Model model, Service service) { + super(name, model); + wsdl_ = new FavoritesWSDL(); + wsdl_.setService(service); + } + + public Service getService() { + return wsdl_.getService(); + } + + public String getWsdlUrl() { + return wsdl_.getWsdlUrl(); + } + + public String toString() { + return getWsdlUrl(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSDLServiceFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSDLServiceFolderElement.java new file mode 100644 index 000000000..7b26004a4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSDLServiceFolderElement.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.Hashtable; +import java.util.Enumeration; +import org.apache.wsil.*; + +public class FavoritesWSDLServiceFolderElement extends FavoritesFolderElement +{ + + public FavoritesWSDLServiceFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model, nodeManager); + } + + public void init(FavoritesMainElement favMainElement) { + Service[] services = favMainElement.loadWSDLServices(); + for (int i = 0; i < services.length; i++) { + Service service = services[i]; + FavoritesWSDLServiceElement favWSDLServiceElement = new FavoritesWSDLServiceElement((service.getDescriptions())[0].getLocation(), getModel(), service); + connect(favWSDLServiceElement, FavoritesModelConstants.REL_WSDL_SERVICE_NODE, ModelConstants.REL_OWNER); + } + } + + public boolean addFavorite(Hashtable table) { + String wsdlURL = (String)table.get(FavoritesModelConstants.PROP_WSDL_URL); + if (wsdlURL == null) + return false; + FavoritesWSDLServiceElement e = getFavorite(wsdlURL); + if (e != null) + removeFavorite(e); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Service service = favMainElement.addWSDLService(wsdlURL); + boolean saved = favMainElement.saveFavorites(); + if (saved) { + FavoritesWSDLServiceElement favWSDLServiceElement = new FavoritesWSDLServiceElement(wsdlURL, getModel(), service); + connect(favWSDLServiceElement, FavoritesModelConstants.REL_WSDL_SERVICE_NODE, ModelConstants.REL_OWNER); + } + return saved; + } + + public boolean favoriteExists(Hashtable table) { + String wsdlURL = (String)table.get(FavoritesModelConstants.PROP_WSDL_URL); + if (wsdlURL == null) + return false; + return (getFavorite(wsdlURL) != null); + } + + public boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory) { + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (selectedElement instanceof FavoritesWSDLServiceElement) + return (removeFavorite((FavoritesWSDLServiceElement)selectedElement) && favMainElement.saveFavorites()); + else + return false; + } + + private boolean removeFavorite(FavoritesWSDLServiceElement element) { + Service service = ((FavoritesWSDLServiceElement)element).getService(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (favMainElement.removeService(service)) { + element.disconnectAll(); + return true; + } + else + return false; + } + + public boolean removeAllFavorites(String pluginMetadataDirectory) { + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Enumeration e = getAllFavorites(); + while(e.hasMoreElements()) { + FavoritesWSDLServiceElement favWSDLServiceElement = (FavoritesWSDLServiceElement)e.nextElement(); + Service service = favWSDLServiceElement.getService(); + favMainElement.removeService(service); + } + disconnectRel(FavoritesModelConstants.REL_WSDL_SERVICE_NODE); + return favMainElement.saveFavorites(); + } + + public Enumeration getAllFavorites() { + return getElements(FavoritesModelConstants.REL_WSDL_SERVICE_NODE); + } + + private FavoritesWSDLServiceElement getFavorite(String wsdlUrl) { + Enumeration e = getAllFavorites(); + while (e.hasMoreElements()) { + FavoritesWSDLServiceElement wsdlElement = (FavoritesWSDLServiceElement)e.nextElement(); + if (wsdlUrl.equals(wsdlElement.getWsdlUrl())) + return wsdlElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSILElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSILElement.java new file mode 100644 index 000000000..764b6d61b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSILElement.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.parser.favorites.FavoritesWSIL; +import org.apache.wsil.*; + +public class FavoritesWSILElement extends FavoritesElement { + + private FavoritesWSIL wsil_; + + public FavoritesWSILElement(String name, Model model, Link link) { + super(name, model); + wsil_ = new FavoritesWSIL(); + wsil_.setLink(link); + } + + public Link getLink() { + return wsil_.getLink(); + } + + public String getWsilUrl() { + return wsil_.getWsilUrl(); + } + + public String toString() { + return getWsilUrl(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSILFolderElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSILFolderElement.java new file mode 100644 index 000000000..d7d10c3f3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/datamodel/FavoritesWSILFolderElement.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.apache.wsil.*; +import java.util.Hashtable; +import java.util.Enumeration; + +public class FavoritesWSILFolderElement extends FavoritesFolderElement { + + public FavoritesWSILFolderElement(String name, Model model, NodeManager nodeManager) { + super(name, model, nodeManager); + } + + public void init(FavoritesMainElement favMainElement) { + Link[] links = favMainElement.loadWSILs(); + for (int i = 0; i < links.length; i++) { + Link link = links[i]; + FavoritesWSILElement favWSILElement = new FavoritesWSILElement(link.getLocation(), getModel(), link); + connect(favWSILElement, FavoritesModelConstants.REL_WSIL_NODE, ModelConstants.REL_OWNER); + } + } + + public boolean addFavorite(Hashtable table) { + String wsilURL = (String)table.get(FavoritesModelConstants.PROP_WSIL_URL); + if (wsilURL == null) + return false; + FavoritesWSILElement e = getFavorite(wsilURL); + if (e != null) + removeFavorite(e); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Link link = favMainElement.addWSILLink(wsilURL); + boolean saved = favMainElement.saveFavorites(); + if (saved) { + FavoritesWSILElement favWSILElement = new FavoritesWSILElement(wsilURL, getModel(), link); + connect(favWSILElement, FavoritesModelConstants.REL_WSIL_NODE, ModelConstants.REL_OWNER); + } + return saved; + } + + public boolean favoriteExists(Hashtable table) { + String wsilURL = (String)table.get(FavoritesModelConstants.PROP_WSIL_URL); + if (wsilURL == null) + return false; + return (getFavorite(wsilURL) != null); + } + + public boolean removeFavoriteByNodeID(int nodeID,String pluginMetadataDirectory) { + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (selectedElement instanceof FavoritesWSILElement) + return (removeFavorite((FavoritesWSILElement)selectedElement) && favMainElement.saveFavorites()); + else + return false; + } + + private boolean removeFavorite(FavoritesWSILElement element) { + Link link = element.getLink(); + FavoritesMainElement favMainElement = getFavoritesMainElement(); + if (favMainElement.removeLink(link)) { + element.disconnectAll(); + return true; + } + else + return false; + } + + public boolean removeAllFavorites(String pluginMetadataDirectory) { + FavoritesMainElement favMainElement = getFavoritesMainElement(); + Enumeration e = getAllFavorites(); + while(e.hasMoreElements()) { + FavoritesWSILElement favWSILElement = (FavoritesWSILElement)e.nextElement(); + Link link = favWSILElement.getLink(); + favMainElement.removeLink(link); + } + disconnectRel(FavoritesModelConstants.REL_WSIL_NODE); + return favMainElement.saveFavorites(); + } + + public Enumeration getAllFavorites() { + return getElements(FavoritesModelConstants.REL_WSIL_NODE); + } + + private FavoritesWSILElement getFavorite(String wsilUrl) { + Enumeration e = getAllFavorites(); + while (e.hasMoreElements()) { + FavoritesWSILElement wsilElement = (FavoritesWSILElement)e.nextElement(); + if (wsilUrl.equals(wsilElement.getWsilUrl())) + return wsilElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/AddToUDDIPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/AddToUDDIPerspectiveTool.java new file mode 100644 index 000000000..a12366d7f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/AddToUDDIPerspectiveTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.AddToUDDIPerspectiveAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class AddToUDDIPerspectiveTool extends ActionTool { + + public AddToUDDIPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/add_to_uddi_perspective_enabled.gif", "favorites/images/add_to_uddi_perspective_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddToUDDIPerspectiveAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId()); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/AddWSILToWSILPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/AddWSILToWSILPerspectiveTool.java new file mode 100644 index 000000000..dbb35d5ff --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/AddWSILToWSILPerspectiveTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.AddWSILToWSILPerspectiveAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class AddWSILToWSILPerspectiveTool extends ActionTool { + + public AddWSILToWSILPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/add_to_wsil_perspective_enabled.gif", "favorites/images/add_to_wsil_perspective_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddWSILToWSILPerspectiveAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId()); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesAddToWSDLPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesAddToWSDLPerspectiveTool.java new file mode 100644 index 000000000..c67c2b277 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesAddToWSDLPerspectiveTool.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesAddToWSDLPerspectiveTool extends AddToWSDLPerspectiveTool { + + public FavoritesAddToWSDLPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return FavoritesAddToWSDLPerspectiveAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesImportToFileSystemTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesImportToFileSystemTool.java new file mode 100644 index 000000000..311099907 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesImportToFileSystemTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToFileSystemTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesImportToFileSystemTool extends ImportToFileSystemTool { + + public FavoritesImportToFileSystemTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return ImportToFileSystemAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(),"favorites/actions/FavoritesImportToFileSystemActionJSP.jsp"); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesImportToWorkbenchTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesImportToWorkbenchTool.java new file mode 100644 index 000000000..035334da6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesImportToWorkbenchTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToWorkbenchTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesImportToWorkbenchTool extends ImportToWorkbenchTool { + + public FavoritesImportToWorkbenchTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesImportToWorkbenchForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesLaunchWebServiceWizardTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesLaunchWebServiceWizardTool.java new file mode 100644 index 000000000..915467d88 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesLaunchWebServiceWizardTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.LaunchWebServiceWizardTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesLaunchWebServiceWizardTool extends LaunchWebServiceWizardTool { + + public FavoritesLaunchWebServiceWizardTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesLaunchWebServiceWizardForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesMainNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesMainNode.java new file mode 100644 index 000000000..debb25816 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesMainNode.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesMainNode extends FavoritesNavigatorNode { + public FavoritesMainNode(TreeElement treeElement, NodeManager nodeManager) { + super(treeElement, nodeManager, 1, "images/root_main.gif"); + + // Create UDDI Registry Folder Node + FavoritesUDDIRegistryFolderElement favUDDIRegistryFolderElement = new FavoritesUDDIRegistryFolderElement(getMessage("FAVORITES_UDDI_REGISTRIES_FOLDER_NODE"), treeElement.getModel(), nodeManager); + treeElement.connect(favUDDIRegistryFolderElement, FavoritesModelConstants.REL_UDDI_REGISTRY_FOLDER_NODE, ModelConstants.REL_OWNER); + FavoritesUDDIRegistryFolderNode favUDDIRegistryFolderNode = new FavoritesUDDIRegistryFolderNode(favUDDIRegistryFolderElement, nodeManager, nodeDepth_ + 1); + addChild(favUDDIRegistryFolderNode); + favUDDIRegistryFolderNode.setVisibilityOfChildren(false); + favUDDIRegistryFolderElement.init((FavoritesMainElement)treeElement); + + // Create UDDI Business Folder Node + FavoritesUDDIBusinessFolderElement favUDDIBusinessFolderElement = new FavoritesUDDIBusinessFolderElement(getMessage("FAVORITES_UDDI_BUSINESSES_FOLDER_NODE"), treeElement.getModel(), nodeManager); + treeElement.connect(favUDDIBusinessFolderElement, FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE, ModelConstants.REL_OWNER); + FavoritesUDDIBusinessFolderNode favUDDIBusinessFolderNode = new FavoritesUDDIBusinessFolderNode(favUDDIBusinessFolderElement, nodeManager, nodeDepth_ + 1); + addChild(favUDDIBusinessFolderNode); + favUDDIBusinessFolderNode.setVisibilityOfChildren(false); + favUDDIBusinessFolderElement.init((FavoritesMainElement)treeElement); + + // Create UDDI Service Folder Node + FavoritesUDDIServiceFolderElement favUDDIServiceFolderElement = new FavoritesUDDIServiceFolderElement(getMessage("FAVORITES_UDDI_SERVICE_FOLDER_NODE"), treeElement.getModel(), nodeManager); + treeElement.connect(favUDDIServiceFolderElement, FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE, ModelConstants.REL_OWNER); + FavoritesUDDIServiceFolderNode favUDDIServiceFolderNode = new FavoritesUDDIServiceFolderNode(favUDDIServiceFolderElement, nodeManager, nodeDepth_ + 1); + addChild(favUDDIServiceFolderNode); + favUDDIServiceFolderNode.setVisibilityOfChildren(false); + favUDDIServiceFolderElement.init((FavoritesMainElement)treeElement); + + // Create UDDI Service Interface Folder Node + FavoritesUDDIServiceInterfaceFolderElement favUDDIServiceInterfaceFolderElement = new FavoritesUDDIServiceInterfaceFolderElement(getMessage("FAVORITES_UDDI_SERVICE_INTERFACES_FOLDER_NODE"), treeElement.getModel(), nodeManager); + treeElement.connect(favUDDIServiceInterfaceFolderElement, FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_FOLDER_NODE, ModelConstants.REL_OWNER); + FavoritesUDDIServiceInterfaceFolderNode favUDDIServiceInterfaceFolderNode = new FavoritesUDDIServiceInterfaceFolderNode(favUDDIServiceInterfaceFolderElement, nodeManager, nodeDepth_ + 1); + addChild(favUDDIServiceInterfaceFolderNode); + favUDDIServiceInterfaceFolderNode.setVisibilityOfChildren(false); + favUDDIServiceInterfaceFolderElement.init((FavoritesMainElement)treeElement); + + // Create WSIL Folder Node + FavoritesWSILFolderElement favWSILFolderElement = new FavoritesWSILFolderElement(getMessage("FAVORITES_WSIL_FOLDER_NODE"), treeElement.getModel(), nodeManager); + treeElement.connect(favWSILFolderElement, FavoritesModelConstants.REL_WSIL_FOLDER_NODE, ModelConstants.REL_OWNER); + FavoritesWSILFolderNode favWSILFolderNode = new FavoritesWSILFolderNode(favWSILFolderElement, nodeManager, nodeDepth_ + 1); + addChild(favWSILFolderNode); + favWSILFolderNode.setVisibilityOfChildren(false); + favWSILFolderElement.init((FavoritesMainElement)treeElement); + + // Create WSDL Service Folder Node + FavoritesWSDLServiceFolderElement favWSDLServiceFolderElement = new FavoritesWSDLServiceFolderElement(getMessage("FAVORITES_WSDL_SERVICE_FOLDER_NODE"), treeElement.getModel(), nodeManager); + treeElement.connect(favWSDLServiceFolderElement, FavoritesModelConstants.REL_WSDL_SERVICE_FOLDER_NODE, ModelConstants.REL_OWNER); + FavoritesWSDLServiceFolderNode favWSDLServiceFolderNode = new FavoritesWSDLServiceFolderNode(favWSDLServiceFolderElement, nodeManager, nodeDepth_ + 1); + addChild(favWSDLServiceFolderNode); + favWSDLServiceFolderNode.setVisibilityOfChildren(false); + favWSDLServiceFolderElement.init((FavoritesMainElement)treeElement); + + } + + protected void initTools() { + } + + private String getMessage(String msg) { + Controller controller = nodeManager_.getController(); + FavoritesPerspective favPerspective = controller.getFavoritesPerspective(); + return favPerspective.getMessage(msg); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesNavigatorFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesNavigatorFolderNode.java new file mode 100644 index 000000000..6af9d73aa --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesNavigatorFolderNode.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.FavoritesToggleNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FolderNode; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public abstract class FavoritesNavigatorFolderNode extends FolderNode { + + public FavoritesNavigatorFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + } + + protected String getToggleNodeActionHref() { + return FavoritesToggleNodeAction.getActionLink(nodeId_,isOpen_); + } + + protected String getLinkActionHref() { + return SelectFavoritesNodeAction.getActionLink(nodeId_, false); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesNavigatorNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesNavigatorNode.java new file mode 100644 index 000000000..1a3368405 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesNavigatorNode.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.FavoritesToggleNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public abstract class FavoritesNavigatorNode extends Node { + + public FavoritesNavigatorNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth, String imagePath) { + super(treeElement, nodeManager, nodeDepth, imagePath); + } + + protected String getToggleNodeActionHref() { + return FavoritesToggleNodeAction.getActionLink(nodeId_,isOpen_); + } + + protected String getLinkActionHref() { + return SelectFavoritesNodeAction.getActionLink(nodeId_, false); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesPerspective.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesPerspective.java new file mode 100644 index 000000000..bff8db015 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesPerspective.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.BasicModel; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesMainElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import javax.servlet.*; + +public class FavoritesPerspective extends Perspective +{ + private BasicModel model_; + private NodeManager nodeManager_; + private String perspectiveContentFramesetCols_; + private String savedPerspectiveContentFramesetCols_; + private String actionsContainerFramesetRows_; + private String savedActionsContainerFramesetRows_; + + public FavoritesPerspective(Controller controller) + { + super("favorites",controller); + } + + public final void initPerspective(ServletContext application) + { + model_ = new BasicModel("FavoritesModel"); + FavoritesMainElement favoritesMainElement = new FavoritesMainElement(getMessage("FAVORITES_MAIN_NODE"), model_, controller_); + model_.setRootElement(favoritesMainElement); + nodeManager_ = new NodeManager(controller_); + FavoritesMainNode favMainNode = new FavoritesMainNode(favoritesMainElement, nodeManager_); + nodeManager_.setRootNode(favMainNode); + + // Starting frameset sizes. + perspectiveContentFramesetCols_ = "30%,*"; + savedPerspectiveContentFramesetCols_ = perspectiveContentFramesetCols_; + actionsContainerFramesetRows_ = "75%,*"; + savedActionsContainerFramesetRows_ = actionsContainerFramesetRows_; + } + + public NodeManager getNodeManager() { + return nodeManager_; + } + + public String getPerspectiveContentPage() + { + return "favorites/fav_perspective_content.jsp"; + } + + public int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_FAVORITES; + } + + public String getPanesFile() { + return "favorites/scripts/favoritesPanes.jsp"; + } + + public String getProcessFramesetsForm() + { + return "favorites/forms/ProcessFavoritesFramesetsForm.jsp"; + } + + public String getFramesetsFile() + { + return "favorites/scripts/favoritesframesets.jsp"; + } + + public String getTreeContentVar() { + return "favNavigatorContent"; + } + + public String getTreeContentPage() { + return "favorites/fav_navigator_content.jsp"; + } + + public String getPropertiesContainerVar() { + return "favPropertiesContainer"; + } + + public String getPropertiesContainerPage() { + return "favorites/fav_properties_container.jsp"; + } + + public String getStatusContentVar() { + return "favStatusContent"; + } + + public String getStatusContentPage() { + return "favorites/fav_status_content.jsp"; + } + + public String getPropertiesContentVar() { + return "favPropertiesContent"; + } + + public String getPropertiesContentPage() { + return "favorites/fav_properties_content.jsp"; + } + + public final String getPerspectiveContentFramesetCols() + { + return perspectiveContentFramesetCols_; + } + + public final void setPerspectiveContentFramesetCols(String cols) + { + perspectiveContentFramesetCols_ = cols; + } + + public final String getSavedPerspectiveContentFramesetCols() + { + return savedPerspectiveContentFramesetCols_; + } + + public final void setSavedPerspectiveContentFramesetCols(String cols) + { + savedPerspectiveContentFramesetCols_ = cols; + } + + public final String getActionsContainerFramesetRows() + { + return actionsContainerFramesetRows_; + } + + public final void setActionsContainerFramesetRows(String rows) + { + actionsContainerFramesetRows_ = rows; + } + + public final String getSavedActionsContainerFramesetRows() + { + return savedActionsContainerFramesetRows_; + } + + public final void setSavedActionsContainerFramesetRows(String rows) + { + savedActionsContainerFramesetRows_ = rows; + } + + public final String getSwitchPerspectiveFormActionLink(int targetPerspectiveId,boolean forHistory) + { + return SwitchPerspectiveFromFavoritesAction.getFormActionLink(targetPerspectiveId,forHistory); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesRestoreDefaultFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesRestoreDefaultFavoritesTool.java new file mode 100644 index 000000000..d5040863b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesRestoreDefaultFavoritesTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.FavoritesRestoreDefaultFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesRestoreDefaultFavoritesTool extends ActionTool { + public FavoritesRestoreDefaultFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/refresh_enabled.gif", "images/refresh_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return FavoritesRestoreDefaultFavoritesAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId()); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesSetDefaultViewTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesSetDefaultViewTool.java new file mode 100644 index 000000000..c5fd41b59 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesSetDefaultViewTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.SetDefaultViewTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesSetDefaultViewTool extends SetDefaultViewTool { + public FavoritesSetDefaultViewTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT, false); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessDetailsTool.java new file mode 100644 index 000000000..ad9a2f043 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessDetailsTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesUDDIBusinessDetailsTool extends FormTool { + + public FavoritesUDDIBusinessDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesUDDIBusinessDetailsPage.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessFolderNode.java new file mode 100644 index 000000000..d354eb4d9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessFolderNode.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class FavoritesUDDIBusinessFolderNode extends FavoritesNavigatorFolderNode { + public FavoritesUDDIBusinessFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(FavoritesModelConstants.REL_UDDI_BUSINESS_NODE)) { + FavoritesUDDIBusinessNode favoritesUDDIBusinessNode = new FavoritesUDDIBusinessNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(favoritesUDDIBusinessNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(FavoritesModelConstants.REL_UDDI_BUSINESS_NODE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(FavoritesModelConstants.REL_UDDI_BUSINESS_NODE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new ListFavoriteUDDIBusinessTool(toolManager_, favPerspective.getMessage("ALT_LIST_FAVORITE_UDDI_BUSINESS")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessNode.java new file mode 100644 index 000000000..cc6f6b263 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIBusinessNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesUDDIBusinessNode extends FavoritesNavigatorNode { + public FavoritesUDDIBusinessNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth, "favorites/images/uddi_business_node.gif"); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new FavoritesUDDIBusinessDetailsTool(toolManager_, favPerspective.getMessage("ALT_FAVORITES_UDDI_BUSINESS_DETAILS")); + new AddToUDDIPerspectiveTool(toolManager_, favPerspective.getMessage("ALT_ADD_TO_UDDI_PERSPECTIVE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryDetailsTool.java new file mode 100644 index 000000000..b979945fc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryDetailsTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesUDDIRegistryDetailsTool extends FormTool { + + public FavoritesUDDIRegistryDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesUDDIRegistryDetailsPage.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryFolderNode.java new file mode 100644 index 000000000..88fc7bd59 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryFolderNode.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +import java.io.*; + +public class FavoritesUDDIRegistryFolderNode extends FavoritesNavigatorFolderNode { + public FavoritesUDDIRegistryFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(FavoritesModelConstants.REL_UDDI_REGISTRY_NODE)) { + TreeElement regElement = (TreeElement)event.getParentElement(); + String imagePath; + StringBuffer categoriesDirectory = new StringBuffer(); + FavoritesUDDIRegistryFolderElement.formCategoriesDirectory(categoriesDirectory,nodeManager_.getController().getServletEngineStateLocation(),regElement.getName()); + File categoryDirectoryFile = new File(categoriesDirectory.toString()); + String[] categoryFiles = categoryDirectoryFile.list(); + if (categoryFiles != null && categoryFiles.length > 0) + imagePath = "favorites/images/uddi_registry_cat_node.gif"; + else + imagePath = "favorites/images/uddi_registry_node.gif"; + FavoritesUDDIRegistryNode favoritesUDDIRegistryNode = new FavoritesUDDIRegistryNode(regElement, nodeManager_, nodeDepth_ + 1, imagePath); + addChild(favoritesUDDIRegistryNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(FavoritesModelConstants.REL_UDDI_REGISTRY_NODE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(FavoritesModelConstants.REL_UDDI_REGISTRY_NODE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new ListFavoriteUDDIRegistryTool(toolManager_, favPerspective.getMessage("ALT_LIST_FAVORITE_UDDI_REGISTRY")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryNode.java new file mode 100644 index 000000000..85fdd7acc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIRegistryNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesUDDIRegistryNode extends FavoritesNavigatorNode { + public FavoritesUDDIRegistryNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth,String imagePath) { + super(treeElement, nodeManager, nodeDepth, imagePath); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new FavoritesUDDIRegistryDetailsTool(toolManager_, favPerspective.getMessage("ALT_FAVORITES_UDDI_REGISTRY_DETAILS")); + new AddToUDDIPerspectiveTool(toolManager_, favPerspective.getMessage("ALT_ADD_TO_UDDI_PERSPECTIVE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceDetailsTool.java new file mode 100644 index 000000000..8e8bf4367 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceDetailsTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesUDDIServiceDetailsTool extends FormTool { + + public FavoritesUDDIServiceDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesUDDIServiceDetailsPage.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceFolderNode.java new file mode 100644 index 000000000..37b722fff --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceFolderNode.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class FavoritesUDDIServiceFolderNode extends FavoritesNavigatorFolderNode { + public FavoritesUDDIServiceFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(FavoritesModelConstants.REL_UDDI_SERVICE_NODE)) { + FavoritesUDDIServiceNode favoritesUDDIServiceNode = new FavoritesUDDIServiceNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(favoritesUDDIServiceNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(FavoritesModelConstants.REL_UDDI_SERVICE_NODE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(FavoritesModelConstants.REL_UDDI_SERVICE_NODE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new ListFavoriteUDDIServiceTool(toolManager_, favPerspective.getMessage("ALT_LIST_FAVORITE_UDDI_SERVICE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceDetailsTool.java new file mode 100644 index 000000000..8e18df13a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceDetailsTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesUDDIServiceInterfaceDetailsTool extends FormTool { + + public FavoritesUDDIServiceInterfaceDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesUDDIServiceIntDetailsPage.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceFolderNode.java new file mode 100644 index 000000000..953000a94 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceFolderNode.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class FavoritesUDDIServiceInterfaceFolderNode extends FavoritesNavigatorFolderNode { + public FavoritesUDDIServiceInterfaceFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE)) { + FavoritesUDDIServiceInterfaceNode favoritesUDDIServiceInterfaceNode = new FavoritesUDDIServiceInterfaceNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(favoritesUDDIServiceInterfaceNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_NODE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new ListFavoriteUDDIServiceInterfaceTool(toolManager_, favPerspective.getMessage("ALT_LIST_FAVORITE_UDDI_SERVICE_INTERFACE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceNode.java new file mode 100644 index 000000000..787993936 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceInterfaceNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesUDDIServiceInterfaceNode extends FavoritesNavigatorNode { + public FavoritesUDDIServiceInterfaceNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth, "favorites/images/uddi_service_interface_node.gif"); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new FavoritesUDDIServiceInterfaceDetailsTool(toolManager_, favPerspective.getMessage("ALT_FAVORITES_UDDI_SERVICE_INTERFACE_DETAILS")); + new AddToUDDIPerspectiveTool(toolManager_, favPerspective.getMessage("ALT_ADD_TO_UDDI_PERSPECTIVE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceNode.java new file mode 100644 index 000000000..1c4024708 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesUDDIServiceNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesUDDIServiceNode extends FavoritesNavigatorNode { + public FavoritesUDDIServiceNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth, "favorites/images/uddi_service_node.gif"); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new FavoritesUDDIServiceDetailsTool(toolManager_, favPerspective.getMessage("ALT_FAVORITES_UDDI_SERVICE_DETAILS")); + new AddToUDDIPerspectiveTool(toolManager_, favPerspective.getMessage("ALT_ADD_TO_UDDI_PERSPECTIVE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLDetailsTool.java new file mode 100644 index 000000000..d809f42de --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLDetailsTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesWSDLDetailsTool extends FormTool { + + public FavoritesWSDLDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesWSDLDetailsPage.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLServiceFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLServiceFolderNode.java new file mode 100644 index 000000000..b82b64487 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLServiceFolderNode.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class FavoritesWSDLServiceFolderNode extends FavoritesNavigatorFolderNode { + public FavoritesWSDLServiceFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(FavoritesModelConstants.REL_WSDL_SERVICE_NODE)) { + FavoritesWSDLServiceNode favoritesWSDLServiceNode = new FavoritesWSDLServiceNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(favoritesWSDLServiceNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(FavoritesModelConstants.REL_WSDL_SERVICE_NODE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(FavoritesModelConstants.REL_WSDL_SERVICE_NODE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new ListFavoriteWSDLServiceTool(toolManager_, favPerspective.getMessage("ALT_LIST_FAVORITE_WSDL_SERVICE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLServiceNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLServiceNode.java new file mode 100644 index 000000000..81c3c1bd0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSDLServiceNode.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesWSDLServiceNode extends FavoritesNavigatorNode { + public FavoritesWSDLServiceNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth, "favorites/images/wsdl_service_node.gif"); + } + + protected void initTools() { + Controller controller = nodeManager_.getController(); + FavoritesPerspective favPerspective = controller.getFavoritesPerspective(); + new FavoritesWSDLDetailsTool(toolManager_, favPerspective.getMessage("ALT_FAVORITES_WSDL_DETAILS")); + new FavoritesImportToWorkbenchTool(toolManager_, controller.getMessage("ALT_IMPORT_WSDL_TO_WORKBENCH")); + new FavoritesImportToFileSystemTool(toolManager_, controller.getMessage("ALT_WSDL_IMPORT_TO_FS")); + new FavoritesLaunchWebServiceWizardTool(toolManager_, controller.getMessage("ALT_LAUNCH_WEB_SERVICE_WIZARD")); + new FavoritesAddToWSDLPerspectiveTool(toolManager_, favPerspective.getMessage("ALT_ADD_WSDL_TO_WSDL_PERSPECTIVE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILDetailsTool.java new file mode 100644 index 000000000..e995aa5c4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILDetailsTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class FavoritesWSILDetailsTool extends FormTool { + + public FavoritesWSILDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "favorites/forms/FavoritesWSILDetailsPage.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILFolderNode.java new file mode 100644 index 000000000..d938c4927 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILFolderNode.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class FavoritesWSILFolderNode extends FavoritesNavigatorFolderNode { + public FavoritesWSILFolderNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(FavoritesModelConstants.REL_WSIL_NODE)) { + FavoritesWSILNode favoritesWSILNode = new FavoritesWSILNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(favoritesWSILNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(FavoritesModelConstants.REL_WSIL_NODE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(FavoritesModelConstants.REL_WSIL_NODE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new ListFavoriteWSILTool(toolManager_, favPerspective.getMessage("ALT_LIST_FAVORITE_WSIL")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILNode.java new file mode 100644 index 000000000..1ae32dd86 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/FavoritesWSILNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class FavoritesWSILNode extends FavoritesNavigatorNode { + public FavoritesWSILNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth, "favorites/images/wsil_node.gif"); + } + + protected void initTools() { + FavoritesPerspective favPerspective = nodeManager_.getController().getFavoritesPerspective(); + new FavoritesWSILDetailsTool(toolManager_, favPerspective.getMessage("ALT_FAVORITES_WSIL_DETAILS")); + new AddWSILToWSILPerspectiveTool(toolManager_, favPerspective.getMessage("ALT_ADD_WSIL_TO_WSIL_PERSPECTIVE")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIBusinessTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIBusinessTool.java new file mode 100644 index 000000000..281fce8c6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIBusinessTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class ListFavoriteUDDIBusinessTool extends FormTool { + public ListFavoriteUDDIBusinessTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/list_business_enabled.gif", "favorites/images/list_business_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "favorites/views/ListFavoriteUDDIBusinessView.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIRegistryTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIRegistryTool.java new file mode 100644 index 000000000..1b016dd08 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIRegistryTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class ListFavoriteUDDIRegistryTool extends FormTool { + public ListFavoriteUDDIRegistryTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/list_registry_enabled.gif", "favorites/images/list_registry_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "favorites/views/ListFavoriteUDDIRegistryView.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIServiceInterfaceTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIServiceInterfaceTool.java new file mode 100644 index 000000000..d4233f560 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIServiceInterfaceTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class ListFavoriteUDDIServiceInterfaceTool extends FormTool { + public ListFavoriteUDDIServiceInterfaceTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/list_service_interface_enabled.gif", "favorites/images/list_service_interface_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "favorites/views/ListFavoriteUDDIServiceInterfaceView.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIServiceTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIServiceTool.java new file mode 100644 index 000000000..f432bf8f2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteUDDIServiceTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class ListFavoriteUDDIServiceTool extends FormTool { + public ListFavoriteUDDIServiceTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/list_service_enabled.gif", "favorites/images/list_service_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "favorites/views/ListFavoriteUDDIServiceView.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteWSDLServiceTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteWSDLServiceTool.java new file mode 100644 index 000000000..4e5e2c171 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteWSDLServiceTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class ListFavoriteWSDLServiceTool extends FormTool { + public ListFavoriteWSDLServiceTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/list_wsdl_enabled.gif", "favorites/images/list_wsdl_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "favorites/views/ListFavoriteWSDLServiceView.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteWSILTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteWSILTool.java new file mode 100644 index 000000000..ede83f1d6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/ListFavoriteWSILTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class ListFavoriteWSILTool extends FormTool { + public ListFavoriteWSILTool(ToolManager toolManager, String alt) { + super(toolManager, "favorites/images/list_WSIL_enabled.gif", "favorites/images/list_WSIL_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "favorites/views/ListFavoriteWSILView.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/RemoveFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/RemoveFavoritesTool.java new file mode 100644 index 000000000..424a6e0a6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/favorites/perspective/RemoveFavoritesTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.RemoveFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.SelectFavoritesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class RemoveFavoritesTool extends ActionTool { + + public RemoveFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/clear_enabled.gif", "images/clear_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectFavoritesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return RemoveFavoritesAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId()); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ActionTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ActionTool.java new file mode 100644 index 000000000..53123381b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ActionTool.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +public abstract class ActionTool extends Tool +{ + public ActionTool(ToolManager toolManager,String enabledImageLink,String highlightedImageLink,String alt) + { + super(toolManager,enabledImageLink,highlightedImageLink,alt,ToolTypes.ACTION); + } + + public String getFormLink() + { + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/AddToWSDLPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/AddToWSDLPerspectiveTool.java new file mode 100644 index 000000000..1282a97e1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/AddToWSDLPerspectiveTool.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +public abstract class AddToWSDLPerspectiveTool extends ActionTool +{ + public AddToWSDLPerspectiveTool(ToolManager toolManager,String alt) + { + super(toolManager,"images/add_to_wsdl_perspective_enabled.gif","images/add_to_wsdl_perspective_highlighted.gif",alt); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/BreadCrumb.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/BreadCrumb.java new file mode 100644 index 000000000..2d211dc0b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/BreadCrumb.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +// A class used to represent a brower breadcrumb. Each breadcrumb encapsulates +// a navigated URL. +public class BreadCrumb +{ + private int perspectiveId_; + private String url_; + + public BreadCrumb(int perspectiveId,String url) + { + perspectiveId_ = perspectiveId; + url_ = url; + } + + /** + * Get the URL associated with this breadcrumb. + * @return String The URL. + */ + public String getURL() + { + return url_; + } + + /** + * Get the ID of the perspective where this breadcrumb belongs. + * @return int The perspectiveID as defined in ActionInputs. + */ + public int getPerspectiveId() + { + return perspectiveId_; + } + + /** + * Test equality between this breadcrumb and another. Both the URLs and perspective + * IDs must be equal for two breadcrumbs to be equal. + * @param BreadCrumb A breadcrumb. + * @return boolean The result of the equality test. + */ + public boolean equals(BreadCrumb b) + { + return ((url_.equals(b.getURL())) && (perspectiveId_ == b.getPerspectiveId())); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Controller.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Controller.java new file mode 100644 index 000000000..355bce7ad --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Controller.java @@ -0,0 +1,225 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.ActionEngine; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +import javax.servlet.*; + +public class Controller extends MessageProvider +{ + private String sessionId_; + private String stateLocation_; + private String defaultFavoritesLocation_; + private String contextPath_; + private int historyDirection_; + private History history_; + private UDDIPerspective uddiPerspective_; + private WSILPerspective wsilPerspective_; + private WSDLPerspective wsdlPerspective_; + private FavoritesPerspective favoritesPerspective_; + private Perspective currentPerspective_; + private boolean isPerspectiveContentBlank_; + private ActionEngine actionEngine; + + // WSDL Browser + private int wsdlType_; + + public Controller() + { + super("explorer"); + contextPath_ = null; + stateLocation_ = null; + history_ = new History(); + uddiPerspective_ = new UDDIPerspective(this); + wsilPerspective_ = new WSILPerspective(this); + wsdlPerspective_ = new WSDLPerspective(this); + favoritesPerspective_ = new FavoritesPerspective(this); + // Set the default perspective to UDDI. + currentPerspective_ = uddiPerspective_; + historyDirection_ = ActionInputs.JUMP_BACK; + wsdlType_ = ActionInputs.WSDL_TYPE_SERVICE_INTERFACE; + isPerspectiveContentBlank_ = true; + actionEngine = new ActionEngine(this); + } + + public final void setStateLocation(String stateLocation) + { + stateLocation_ = stateLocation; + } + + public final void setDefaultFavoritesLocation(String defaultFavoritesLocation) + { + defaultFavoritesLocation_ = defaultFavoritesLocation; + } + + // This method should be called immediately after the Controller bean is instantiated. + private final void setContextPath(String contextPath) + { + if (contextPath_ == null) + contextPath_ = contextPath; + } + + public final String getPathWithContext(String relativePath) + { + if (relativePath == null) + return relativePath; + StringBuffer path = new StringBuffer(relativePath); + if (contextPath_ != null) + path.insert(0,'/').insert(0,contextPath_); + return path.toString(); + } + + public final String getSessionId() + { + return sessionId_; + } + + public final String getContextPath() + { + return contextPath_; + } + + public final String getServletEngineStateLocation() { + return stateLocation_; + } + + public final String getDefaultFavoritesLocation () { + return defaultFavoritesLocation_; + } + + public final void init(String sessionId,ServletContext application,String contextPath) + { + sessionId_ = sessionId; + setContextPath(contextPath); + uddiPerspective_.initPerspective(application); + wsilPerspective_.initPerspective(application); + wsdlPerspective_.initPerspective(application); + favoritesPerspective_.initPerspective(application); + } + + // Setter for the current perspective. + public final void setCurrentPerspective(int perspective) + { + switch (perspective) + { + case ActionInputs.PERSPECTIVE_UDDI: + currentPerspective_ = uddiPerspective_; + break; + case ActionInputs.PERSPECTIVE_WSIL: + currentPerspective_ = wsilPerspective_; + break; + case ActionInputs.PERSPECTIVE_WSDL: + currentPerspective_ = wsdlPerspective_; + break; + case ActionInputs.PERSPECTIVE_FAVORITES: + currentPerspective_ = favoritesPerspective_; + break; + } + } + + // Getter for the current perspective. + public final Perspective getCurrentPerspective() + { + return currentPerspective_; + } + + // Getter for the UDDI perspective. + public final UDDIPerspective getUDDIPerspective() + { + return uddiPerspective_; + } + + // Getter for the WSIL perspective. + public final WSILPerspective getWSILPerspective() + { + return wsilPerspective_; + } + + // Getter for the WSDL perspective. + public final WSDLPerspective getWSDLPerspective() + { + return wsdlPerspective_; + } + + // Getter for the Favorites perspective. + public final FavoritesPerspective getFavoritesPerspective() { + return favoritesPerspective_; + } + + // Getter for the action engine + public final ActionEngine getActionEngine() { + return actionEngine; + } + + public final boolean addToHistory(int perspectiveId,String url) + { + if (url != null) + return history_.addBreadCrumb(new BreadCrumb(perspectiveId,url)); + return false; + } + + // Wrapper for moving forward in the history list and obtaining the breadcrumb. + public final BreadCrumb forward() + { + historyDirection_ = ActionInputs.JUMP_FORWARD; + return history_.forward(); + } + + // Wrapper for moving back in the history list and obtaining the breadcrumb. + public final BreadCrumb back() + { + historyDirection_ = ActionInputs.JUMP_BACK; + return history_.back(); + } + + public final int getHistoryDirection() + { + return historyDirection_; + } + + public final void processStaleBreadCrumb() + { + history_.removeCurrentBreadCrumb(); + } + + // WSDL Browser + public final void setWSDLType(int wsdlType) + { + wsdlType_ = wsdlType; + } + + public final int getWSDLType() + { + return wsdlType_; + } + + public final boolean isPerspectiveContentBlank() + { + return isPerspectiveContentBlank_; + } + + public final void enablePerspectiveContentBlank(boolean isPerspectiveContentBlank) + { + isPerspectiveContentBlank_ = isPerspectiveContentBlank; + } + + public final void dumpHistory() + { + history_.dump(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FolderNode.java new file mode 100644 index 000000000..f95d0af8f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FolderNode.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; + +public abstract class FolderNode extends Node +{ + public FolderNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"images/folder_closed.gif"); + } + + public String getOpenImagePath() + { + return "images/folder_open.gif"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormTool.java new file mode 100644 index 000000000..8765319bb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormTool.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +import java.util.*; + +public abstract class FormTool extends Tool implements FormToolPropertiesInterface +{ + protected FormToolProperties formToolProperties_; + + public FormTool(ToolManager toolManager,String enabledImageLink,String highlightedImageLink,String alt) + { + super(toolManager,enabledImageLink,highlightedImageLink,alt,ToolTypes.FORM); + formToolProperties_ = new FormToolProperties(); + initDefaultProperties(); + } + + protected void initDefaultProperties() + { + } + + public final Object getProperty(Object key) + { + return formToolProperties_.getProperty(key); + } + + public final void setProperty(Object key,Object value) + { + formToolProperties_.setProperty(key,value); + } + + public final void removeProperty(Object key) + { + formToolProperties_.removeProperty(key); + } + + public final void clearPropertyTable() + { + formToolProperties_.clearPropertyTable(); + } + + public final void updatePropertyTable(Hashtable newPropertyTable) + { + formToolProperties_.updatePropertyTable(newPropertyTable); + } + + public final void setPropertyTable(Hashtable newPropertyTable) + { + formToolProperties_.setPropertyTable(newPropertyTable); + } + + public final void flagError(Object inputKey) + { + formToolProperties_.flagError(inputKey); + } + + public final void flagRowError(Object inputKey,int rowNumber) + { + formToolProperties_.flagRowError(inputKey,rowNumber); + } + + public final void flagRowError(Object inputKey,Object rowId) + { + formToolProperties_.flagRowError(inputKey,rowId); + } + + public final void clearErrors() + { + formToolProperties_.clearErrors(); + } + + public final boolean isInputValid(Object inputKey) + { + return formToolProperties_.isInputValid(inputKey); + } + + public final boolean isRowInputValid(Object inputKey,int rowNumber) + { + return formToolProperties_.isRowInputValid(inputKey,String.valueOf(rowNumber)); + } + + // The row number may also be represented by a unique object (e.g. UUID) + public final boolean isRowInputValid(Object inputKey,Object rowId) + { + return formToolProperties_.isRowInputValid(inputKey,rowId); + } + + public final String getActionLink() + { + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormToolProperties.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormToolProperties.java new file mode 100644 index 000000000..09a4436ca --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormToolProperties.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.*; + +public class FormToolProperties implements FormToolPropertiesInterface +{ + private Hashtable propertyTable_; + private Hashtable errantValues_; + + public FormToolProperties() + { + propertyTable_ = new Hashtable(); + errantValues_ = new Hashtable(); + } + + public final Object getProperty(Object key) + { + return propertyTable_.get(key); + } + + public final void setProperty(Object key,Object value) + { + propertyTable_.put(key,value); + } + + public final void removeProperty(Object key) + { + propertyTable_.remove(key); + } + + public final void clearPropertyTable() + { + propertyTable_.clear(); + } + + public final void updatePropertyTable(Hashtable newPropertyTable) + { + Enumeration e = newPropertyTable.keys(); + while (e.hasMoreElements()) + { + String key = (String)e.nextElement(); + propertyTable_.put(key,newPropertyTable.get(key)); + } + } + + public final void setPropertyTable(Hashtable newPropertyTable) + { + clearPropertyTable(); + updatePropertyTable(newPropertyTable); + } + + public final void flagError(Object inputKey) + { + if (isInputValid(inputKey)) + errantValues_.put(inputKey,Boolean.TRUE); + } + + public final void flagRowError(Object inputKey,int rowNumber) + { + flagRowError(inputKey,String.valueOf(rowNumber)); + } + + public final void flagRowError(Object inputKey,Object rowId) + { + Object errorObject = errantValues_.get(inputKey); + Hashtable rowHash; + if (errorObject instanceof Hashtable) + rowHash = (Hashtable)errorObject; + else + rowHash = new Hashtable(); + rowHash.put(rowId,Boolean.TRUE); + errantValues_.put(inputKey,rowHash); + } + + public final void clearErrors() + { + errantValues_.clear(); + } + + public final boolean isInputValid(Object inputKey) + { + return (errantValues_.get(inputKey) == null); + } + + public final boolean isRowInputValid(Object inputKey,int rowNumber) + { + return isRowInputValid(inputKey,String.valueOf(rowNumber)); + } + + public final boolean isRowInputValid(Object inputKey,Object rowId) + { + Hashtable rowHash = (Hashtable)errantValues_.get(inputKey); + if (rowHash == null) + return true; + return (rowHash.get(rowId) == null); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormToolPropertiesInterface.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormToolPropertiesInterface.java new file mode 100644 index 000000000..a5926cfb5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/FormToolPropertiesInterface.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.*; + +public abstract interface FormToolPropertiesInterface +{ + // Getter and Setter for a property. + public abstract Object getProperty(Object key); + public abstract void setProperty(Object key,Object value); + public abstract void removeProperty(Object key); + + // Property table operators. + public abstract void clearPropertyTable(); + public abstract void updatePropertyTable(Hashtable propertyTable); + public abstract void setPropertyTable(Hashtable propertyTable); + + // Error handling. + public abstract void flagError(Object inputKey); + public abstract void flagRowError(Object inputKey,int rowNumber); + public abstract void flagRowError(Object inputKey,Object rowId); + public abstract void clearErrors(); + public abstract boolean isInputValid(Object inputKey); + public abstract boolean isRowInputValid(Object inputKey,int rowNumber); + public abstract boolean isRowInputValid(Object inputKey,Object rowId); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/History.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/History.java new file mode 100644 index 000000000..5fe2251a1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/History.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.*; + +// A class representing a Vector of breadcrumbs. A position index is used +// to navigate through the data structure. +public class History +{ + private Vector items_; + private int position_; + + public History() + { + items_ = new Vector(); + position_ = -1; + } + + // Add a new breadcrumb to the history list. When adding a new breadcrumb + // within the current list, all breadcrumbs after the newly added one are + // removed. + public boolean addBreadCrumb(BreadCrumb b) + { + int numberOfItems = items_.size(); + if (numberOfItems == 0) + { + position_++; + items_.addElement(b); + return true; + } + else + { + BreadCrumb currentBreadCrumb = (BreadCrumb)items_.elementAt(position_); + if (!currentBreadCrumb.equals(b)) + { + position_++; + items_.insertElementAt(b,position_); + for (int i=items_.size()-1;i>position_;i--) + items_.removeElementAt(i); + return true; + } + } + return false; + } + + // Move forward within the history list and obtain the breadcrumb. + public BreadCrumb forward() + { + if (position_ < items_.size()-1) + { + position_++; + BreadCrumb b = (BreadCrumb)items_.elementAt(position_); + return b; + } + return null; + } + + // Move back within the history list and obtain the breadcrumb. + public BreadCrumb back() + { + if (position_ > 0) + { + position_--; + BreadCrumb b = (BreadCrumb)items_.elementAt(position_); + return b; + } + return null; + } + + public void removeCurrentBreadCrumb() + { + items_.removeElementAt(position_); + if (position_ > items_.size()-1) + position_--; + } + + public void dump() + { + for (int i=0;i<items_.size();i++) + { + BreadCrumb b = (BreadCrumb)items_.elementAt(i); + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ImportToFileSystemTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ImportToFileSystemTool.java new file mode 100644 index 000000000..9b53c4eb9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ImportToFileSystemTool.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +public abstract class ImportToFileSystemTool extends ActionTool { + public ImportToFileSystemTool(ToolManager toolManager, String alt) { + super(toolManager, "images/import_fs_enabled.gif", "images/import_fs_highlighted.gif", alt); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ImportToWorkbenchTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ImportToWorkbenchTool.java new file mode 100644 index 000000000..af740540f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ImportToWorkbenchTool.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +public abstract class ImportToWorkbenchTool extends FormTool { + public ImportToWorkbenchTool(ToolManager toolManager, String alt) { + super(toolManager, "images/import_to_workbench_enabled.gif", "images/import_to_workbench_highlighted.gif", alt); + } + + public String getFormLink() { + return "forms/ImportToWorkbenchForm.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/LaunchOptionsManager.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/LaunchOptionsManager.java new file mode 100644 index 000000000..432bf703d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/LaunchOptionsManager.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.Hashtable; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; + +import org.eclipse.wst.ws.internal.explorer.LaunchOptions; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.UDDIPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +public class LaunchOptionsManager +{ + private static LaunchOptionsManager instance_; + + private Hashtable optionsTable_; + + private LaunchOptionsManager() + { + optionsTable_ = new Hashtable(); + } + + public static LaunchOptionsManager getInstance() + { + if (instance_ == null) + instance_ = new LaunchOptionsManager(); + return instance_; + } + + public synchronized void manage(String key, Object value, ServletContext application) + { + if (value instanceof String) + manageSession(key, (String)value, application); + else if (value instanceof Hashtable) + manageOptions(key, (Hashtable)value, application); + } + + private void manageSession(String key, String sessionId, ServletContext application) + { + Object obj = optionsTable_.remove(key); + if (obj != null && (obj instanceof Hashtable)) + loadOptions(sessionId, (Hashtable)obj, application); + else + optionsTable_.put(key, sessionId); + } + + private void manageOptions(String key, Hashtable options, ServletContext application) + { + Object obj = optionsTable_.remove(key); + if (obj != null && (obj instanceof String)) + loadOptions((String)obj, options, application); + else + optionsTable_.put(key, options); + } + + private void loadOptions(String sessionId, Hashtable options, ServletContext application) + { + HttpSession httpSession = (HttpSession)application.getAttribute(sessionId); + if (httpSession != null) + { + Controller controller = (Controller)httpSession.getAttribute("controller"); + String[] stateLocations = (String[])options.get(LaunchOptions.STATE_LOCATION); + String[] defaultFavoritesLocations = (String[])options.get(LaunchOptions.DEFAULT_FAVORITES_LOCATION); + String[] inquiryURLs = (String[])options.get(LaunchOptions.INQUIRY_URL); + String[] publishURLs = (String[])options.get(LaunchOptions.PUBLISH_URL); + String[] serviceNames = (String[])options.get(LaunchOptions.SERVICE_NAME); + String[] serviceKeys = (String[])options.get(LaunchOptions.SERVICE_KEY); + String[] wsdlURLs = (String[])options.get(LaunchOptions.WSDL_URL); + String[] endpoints = (String[])options.get(LaunchOptions.WEB_SERVICE_ENDPOINT); + String[] serviceQNameStrings = (String[])options.get(LaunchOptions.SERVICE_QNAME_STRING); + String[] bindingNameStrings = (String[])options.get(LaunchOptions.BINDING_NAME_STRING); + String stateLocation = (stateLocations == null || stateLocations.length == 0) ? null : stateLocations[0]; + controller.setStateLocation(stateLocation); + String defaultFavoritesLocation = (defaultFavoritesLocations == null || defaultFavoritesLocations.length == 0) ? null : defaultFavoritesLocations[0]; + controller.setDefaultFavoritesLocation(defaultFavoritesLocation); + UDDIPerspective uddiPerspective = controller.getUDDIPerspective(); + uddiPerspective.preloadUDDIRegistries(inquiryURLs, publishURLs); + uddiPerspective.preloadServices(inquiryURLs,serviceNames,serviceKeys); + WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); + wsdlPerspective.preloadWSDL(wsdlURLs); + wsdlPerspective.preloadEndpoints(wsdlURLs, endpoints); + wsdlPerspective.preselectServiceOrBinding(wsdlURLs,serviceQNameStrings,bindingNameStrings); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/LaunchWebServiceWizardTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/LaunchWebServiceWizardTool.java new file mode 100644 index 000000000..1b3ea8d02 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/LaunchWebServiceWizardTool.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +public abstract class LaunchWebServiceWizardTool extends FormTool { + public LaunchWebServiceWizardTool(ToolManager toolManager, String alt) { + super(toolManager, "images/launch_wswizard_enabled.gif", "images/launch_wswizard_highlighted.gif", alt); + } + + public String getFormLink() { + return "forms/LaunchWebServiceWizardForm.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageBundle.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageBundle.java new file mode 100644 index 000000000..ce8c8ca48 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageBundle.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.ResourceBundle; +import java.util.MissingResourceException; + +/** +* An message bundle is a collection of messages drawn from some +* set of properties. +*/ +public class MessageBundle +{ + private ResourceBundle fResourceBundle; + + /** + * Constructs a new MessageBundle from the given ResourceBundle. + */ + public MessageBundle ( ResourceBundle resourceBundle ) + { + fResourceBundle = resourceBundle; + } + + /** + * Returns the message identified by messageId. + * @param messageId The message ID. + * @return String The message text. + */ + public String getMessage ( String messageId ) + { + try + { + return fResourceBundle.getString(messageId); + } + catch (MissingResourceException e) + { + return messageId; + } + } + + /** + * Returns the message identified by messageId. + * @param messageId The message ID. + * @param sub A substitution value for "%1" in the message. + * @return String The message text. + */ + public String getMessage ( String messageId, String sub ) + { + String[] s = {sub}; + return getMessage(messageId,s); + } + + /** + * Returns the message identified by messageId. + * @param messageId The message ID. + * @param sub Substitution values for "%1..%n" (sub[0]..sub[n-1]) in + * the message. + * @return String The message text. + */ + public String getMessage ( String messageId, String[] sub ) + { + String m = getMessage(messageId); + int len = m.length(); + int max = sub.length; + StringBuffer b = new StringBuffer(); + int pos = 0; + while (pos >= 0) + { + int pct = m.indexOf('%',pos); + if (pct >= 0) + { + b.append(m.substring(pos,pct)); + pos = pct + 1; + if (pos < len) + { + char d = m.charAt(pos); + if (Character.isDigit(d) && d != '0') + { + int v = Integer.parseInt(new Character(d).toString()); + if (v <= max) + { + b.append(sub[v-1]); + } + else + { + b.append('?'); + } + pos++; + } + else + { + b.append('%'); + b.append(d); + pos++; + } + } + else + { + b.append('%'); + pos = -1; + } + } + else + { + b.append(m.substring(pos)); + pos = -1; + } + } + return b.toString(); + } + + public ResourceBundle getResourceBundle() + { + return fResourceBundle; + } +} + diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageProvider.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageProvider.java new file mode 100644 index 000000000..1395a32a7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageProvider.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.*; + +// A Class which provides String messages. +public class MessageProvider +{ + protected MessageBundle messageBundle_; + private String messageProviderName_; + + public MessageProvider(String messageBundleFileName) + { + try + { + // Load the message bundle from the WEB-INF\classes subdirectory. + messageProviderName_ = messageBundleFileName; + messageBundle_ = new MessageBundle(ResourceBundle.getBundle(messageBundleFileName)); + } + catch (MissingResourceException e) + { + System.err.println("Could not load "+messageBundleFileName); + e.printStackTrace(); + } + } + + public String getMessage(String messageId) + { + return messageBundle_.getMessage(messageId); + } + + public String getMessage(String messageId,String sub) + { + return messageBundle_.getMessage(messageId,sub); + } + + public String getMessage(String messageId,String[] sub) + { + return messageBundle_.getMessage(messageId,sub); + } + + public String getMessageProviderName() + { + return messageProviderName_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageQueue.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageQueue.java new file mode 100644 index 000000000..cccfc5d24 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/MessageQueue.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +public class MessageQueue +{ + protected Vector messageList_; + + public MessageQueue() + { + messageList_ = new Vector(); + } + + public void addMessage(String message) + { + messageList_.addElement(message); + } + + public String getMessagesFromList() + { + StringBuffer messages = new StringBuffer(); + + if (messageList_.size()==0) + return ""; + + Enumeration e = messageList_.elements(); + while (e.hasMoreElements()) + { + String thisMessage = (String)e.nextElement(); + messages.append(thisMessage); + messages.append(HTMLUtils.LINE_SEPARATOR); + } + messageList_.removeAllElements(); + return messages.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Node.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Node.java new file mode 100644 index 000000000..e3a2cdf68 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Node.java @@ -0,0 +1,448 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import javax.servlet.http.*; +import java.util.*; + +public abstract class Node +{ + protected TreeElement element_; + protected NodeManager nodeManager_; + protected int nodeId_; + protected int nodeDepth_; + protected String imagePath_; + protected boolean isOpen_; + protected Vector childNodes_; + protected ToolManager toolManager_; + protected Node parent_; + private String anchorName_; + private int viewId_; + + public Node(TreeElement element,NodeManager nodeManager,int nodeDepth,String imagePath) + { + element_ = element; + nodeManager_ = nodeManager; + nodeId_ = nodeManager.addToNodeTable(this); + nodeDepth_ = nodeDepth; + Controller controller = nodeManager_.getController(); + if (imagePath == null) + imagePath_ = controller.getPathWithContext(NodeManager.PATH_SPACE); + else + imagePath_ = imagePath; + isOpen_ = true; + childNodes_ = new Vector(); + toolManager_ = new ToolManager(this); + initTools(); + anchorName_ = (new StringBuffer("action")).append(nodeId_).toString(); + parent_ = null; + viewId_ = ActionInputs.VIEWID_DEFAULT; + } + + /** + * Returns the TreeElement associated with this node. + * @return TreeElement The element associated with this node. + */ + public TreeElement getTreeElement() + { + return element_; + } + + /** + * Returns the name of the node. + * @return String + */ + public String getNodeName() + { + return element_.getName(); + } + + /** + * Returns the NodeManager managing this node. + * @return NodeManager + */ + public NodeManager getNodeManager() + { + return nodeManager_; + } + + /** + * Returns the id of this node. + * @return int + */ + public int getNodeId() + { + return nodeId_; + } + + /** + * Returns the depth in the tree of this node relative to the root node + * @return int + */ + public int getNodeDepth() + { + return nodeDepth_; + } + + /** + * Set the path of the image representing this class of Node. + * @param String The path. + */ + public void setImagePath(String path) + { + imagePath_ = path; + } + + /** + * Returns true if the children of this node are visible. Returns false + * if they are not. + * @return boolean + */ + public boolean isOpen() + { + return isOpen_; + } + + public boolean isVisible() + { + Node parentNode = parent_; + while (parentNode != null) + { + if (!parentNode.isOpen()) + return false; + parentNode = parentNode.getParent(); + } + return true; + } + + /** + * Sets the visibility of this node's children to the specified value. + * Updates the NodeManager's record of the maximum depth visible in the tree. + * @param boolean + */ + public final void setVisibilityOfChildren(boolean open) + { + isOpen_ = open; + nodeManager_.updateMaxDepthVisible(); + } + + /** + * Gets the maximum depth displayed in this node's branch of the tree + * Used by NodeManager for html display purposes. + * @return int + */ + public int getMaxDepthVisible() + { + if (!isOpen_) + return nodeDepth_; + else + { + int currentDepth = nodeDepth_; + Enumeration e = childNodes_.elements(); + while (e.hasMoreElements()) + { + Node thisNode = (Node)e.nextElement(); + int depth = thisNode.getMaxDepthVisible(); + if (depth>currentDepth) + currentDepth=depth; + } + return currentDepth; + } + } + + public final void setParent(Node node) + { + parent_ = node; + } + + public final Node getParent() + { + return parent_; + } + + public final void setViewId(int viewId) + { + viewId_ = viewId; + } + + public final int getViewId() + { + return viewId_; + } + + public final int getViewToolId() + { + ToolManager viewToolManager = getViewToolManager(); + if (viewToolManager != null) + return viewToolManager.getSelectedToolId(); + return ActionInputs.VIEWTOOLID_DEFAULT; + } + + /** + * Adds the specified node as a child of this node. + * @param Node The child being added. + * @return boolean Always true. + */ + public final boolean addChild(Node childNode) + { + childNode.setParent(this); + childNodes_.addElement(childNode); + nodeManager_.updateMaxDepthVisible(); + return true; + } + + /** + * Returns the child nodes of this node. If this node has no children, an + * empty vector is returned. + * @return Vector + */ + public Vector getChildNodes() + { + return childNodes_; + } + + public final Node getChildNode(TreeElement element) + { + Enumeration e = childNodes_.elements(); + while (e.hasMoreElements()) + { + Node presentNode = (Node)e.nextElement(); + if (presentNode.getTreeElement() == element) + return presentNode; + } + return null; + } + + public final void removeChildNodes(boolean isEntry) + { + int numberOfChildNodes = childNodes_.size(); + for (int i=numberOfChildNodes-1;i>=0;i--) + { + Node childNode = (Node)childNodes_.elementAt(i); + childNode.removeChildNodes(false); + nodeManager_.removeFromNodeTable(childNode.getNodeId()); + } + if (numberOfChildNodes > 0) + { + childNodes_.removeAllElements(); + if (isEntry) + nodeManager_.updateMaxDepthVisible(); + } + } + + public final boolean removeChildNode(TreeElement element) + { + Node childNode = getChildNode(element); + if (childNode != null) + { + int childNodeId = childNode.getNodeId(); + if (nodeManager_.getSelectedNodeId() == childNodeId) + nodeManager_.setSelectedNodeId(nodeId_); + childNodes_.removeElement(childNode); + nodeManager_.removeFromNodeTable(childNodeId); + nodeManager_.updateMaxDepthVisible(); + return true; + } + return false; + } + + /** + * Get the name of the HTML anchor associated with this node. + * @return String The name of the anchor. + */ + public String getAnchorName() + { + return anchorName_; + } + + public ToolManager getToolManager() + { + return toolManager_; + } + + public ToolManager getViewToolManager() + { + if (viewId_ != ActionInputs.VIEWID_DEFAULT) + { + ViewTool viewTool = (ViewTool)toolManager_.getSelectedTool(); + return viewTool.getToolManager(viewId_); + } + return null; + } + + public ToolManager getCurrentToolManager() + { + ToolManager toolManager = getViewToolManager(); + if (toolManager == null) + toolManager = toolManager_; + return toolManager; + } + + protected abstract void initTools(); + + protected abstract String getToggleNodeActionHref(); + + protected String getToggleNodeActionTarget() + { + return FrameNames.PERSPECTIVE_WORKAREA; + } + + protected void addToggle(HttpServletResponse response,StringBuffer treeView,boolean isLastChild) + { + if (nodeDepth_ != 1) + { + treeView.append(" <td align=\"left\" width=16 height=16 nowrap>"); + String toggleImageTag; + if (childNodes_.size() > 0) + { + // <a href="..." target="...">toggleImageTag</a> + String href = nodeManager_.getController().getPathWithContext(getToggleNodeActionHref()); + if (isOpen_) + { + String toggleAlt = nodeManager_.getController().getMessage("ALT_CLOSE"); + if (isLastChild) + toggleImageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_MINUS_LAST),toggleAlt,"16","16",null); + else + toggleImageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_MINUS_NOTLAST),toggleAlt,"16","16",null); + } + else + { + String toggleAlt = nodeManager_.getController().getMessage("ALT_OPEN"); + if (isLastChild) + toggleImageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_PLUS_LAST),toggleAlt,"16","16",null); + else + toggleImageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_PLUS_NOTLAST),toggleAlt,"16","16",null); + } + String linkTag = HTMLUtils.getHTMLLinkTag(response,href,getToggleNodeActionTarget(),String.valueOf(nodeId_),toggleImageTag,null); + treeView.append(linkTag); + } + else + { + // <img...> + if (isLastChild) + toggleImageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_LINE_LAST),"","16","16",null); + else + toggleImageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_LINE_NOTLAST),"","16","16",null); + treeView.append(toggleImageTag); + } + treeView.append("</td>").append(HTMLUtils.LINE_SEPARATOR); + } + } + + protected abstract String getLinkActionHref(); + + protected String getLinkActionTarget() + { + return FrameNames.PERSPECTIVE_WORKAREA; + } + + public String getOpenImagePath() + { + return imagePath_; + } + + public String getClosedImagePath() + { + return imagePath_; + } + + protected void addHTMLLabel(HttpServletResponse response,StringBuffer treeView,boolean isLastChild) + { + // <a href="..." target="..." onClick="selectNode('...')"><img...></a> + Hashtable additionalAttributes = new Hashtable(); + additionalAttributes.put("name",anchorName_); + String imagePath = (nodeManager_.getSelectedNodeId() == nodeId_)?getOpenImagePath():getClosedImagePath(); + + String imageTag = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(imagePath),"","16","16",additionalAttributes); + String baseHref = getLinkActionHref(); + String href = ((baseHref == null)?baseHref:nodeManager_.getController().getPathWithContext(baseHref)); + String target = getLinkActionTarget(); + additionalAttributes.clear(); + + treeView.append(" <td align=\"left\" width=16 height=16 nowrap>"); + if (href != null) + treeView.append(HTMLUtils.getHTMLLinkTag(response,href,target,null,imageTag,additionalAttributes)); + else + treeView.append(imageTag); + treeView.append("</td>").append(HTMLUtils.LINE_SEPARATOR); + treeView.append(" <td align=\"left\" width=3 height=10 nowrap>").append(HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_SPACE),"","3","10",null)).append("</td>").append(HTMLUtils.LINE_SEPARATOR); + + // <a name="..." href="..." target="...">label</a> + treeView.append(" <td align=\"left\" nowrap>").append(HTMLUtils.LINE_SEPARATOR); + treeView.append(" "); + if (href != null) + { + String textAnchorClass; + if (nodeManager_.getSelectedNodeId() == nodeId_) + textAnchorClass="selectedTextAnchor"; + else + textAnchorClass="unselectedTextAnchor"; + additionalAttributes.put("class",textAnchorClass); + treeView.append(HTMLUtils.getHTMLLinkTag(response,href,target,anchorName_,getNodeName(),additionalAttributes)); + } + else + treeView.append("<strong>").append(getNodeName()).append("</strong>"); + treeView.append(HTMLUtils.LINE_SEPARATOR).append(" </td>").append(HTMLUtils.LINE_SEPARATOR); + } + + public void renderNode(HttpServletResponse response,StringBuffer treeView,String prefixColumns,boolean isLastChild) + { + String space_16x16 = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_SPACE),"","16","16",null); + String line_16x16 = HTMLUtils.getHTMLImageTag(response,nodeManager_.getController().getPathWithContext(NodeManager.PATH_LINE),"","16","16",null); + + // Use border=1 to help with debugging. + treeView.append("<table cellspacing=0 cellpadding=0 border=0>").append(HTMLUtils.LINE_SEPARATOR); + treeView.append(" <tr>").append(HTMLUtils.LINE_SEPARATOR); + treeView.append(" <td align=\"left\" width=16 height=16 nowrap>").append(space_16x16).append("</td>").append(HTMLUtils.LINE_SEPARATOR); + StringBuffer newPrefixColumns = new StringBuffer(prefixColumns); + if (nodeDepth_ >= 2) + { + if (prefixColumns.length() > 0) + treeView.append(prefixColumns).append(HTMLUtils.LINE_SEPARATOR); + // generate a new prefix columns. + newPrefixColumns.append(" <td align=\"left\" width=16 height=16 nowrap>"); + if (isLastChild) + newPrefixColumns.append(space_16x16); + else + newPrefixColumns.append(line_16x16); + newPrefixColumns.append("</td>").append(HTMLUtils.LINE_SEPARATOR); + } + addToggle(response,treeView,isLastChild); + addHTMLLabel(response,treeView,isLastChild); + treeView.append(" </tr>").append(HTMLUtils.LINE_SEPARATOR); + treeView.append("</table>").append(HTMLUtils.LINE_SEPARATOR); + int numberOfChildNodes = childNodes_.size(); + if (numberOfChildNodes > 0) + { + if (isOpen_) + { + for (int i=0;i<numberOfChildNodes-1;i++) + { + Node childNode = (Node)childNodes_.elementAt(i); + childNode.renderNode(response,treeView,newPrefixColumns.toString(),false); + } + Node lastChildNode = (Node)childNodes_.elementAt(numberOfChildNodes-1); + lastChildNode.renderNode(response,treeView,newPrefixColumns.toString(),true); + } + } + } + + // For sorting purposes. + public final String toString() + { + return getNodeName(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/NodeManager.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/NodeManager.java new file mode 100644 index 000000000..edbe5ae85 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/NodeManager.java @@ -0,0 +1,251 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import javax.servlet.http.*; +import java.util.*; + +public class NodeManager +{ + // paths to icon images + public static final String PATH_PLUS_NOTLAST = "images/plus_notlast.gif"; + public static final String PATH_PLUS_LAST = "images/plus_last.gif"; + public static final String PATH_MINUS_NOTLAST = "images/minus_notlast.gif"; + public static final String PATH_MINUS_LAST = "images/minus_last.gif"; + public static final String PATH_LINE = "images/line.gif"; + public static final String PATH_LINE_NOTLAST = "images/line_notlast.gif"; + public static final String PATH_LINE_LAST = "images/line_last.gif"; + public static final String PATH_SPACE = "images/space.gif"; + + private Controller controller_; + private Node rootNode_; + private Hashtable nodeTable_; + private int focusedNodeId_; + private int selectedNodeId_; + private int previousSelectedNodeId_; + private int maxDepthVisible_; + private int nextId_; + + public NodeManager(Controller controller) + { + controller_ = controller; + rootNode_ = null; + nodeTable_ = new Hashtable(); + focusedNodeId_ = -1; + selectedNodeId_ = -1; + previousSelectedNodeId_ = -1; + maxDepthVisible_ = 1; + nextId_ = 0; + } + + /** + * Hook for the controller. + * @return Controller The perspective controller. + */ + public Controller getController() + { + return controller_; + } + + /** + * Sets the root node of the tree. + * @param rootNode The node being designated as the root node. + */ + public void setRootNode(Node rootNode) + { + rootNode_ = rootNode; + } + + /** + * Returns the root node of the tree managed by this NodeManager. + * @return Node The root node. + */ + public Node getRootNode() + { + return rootNode_; + } + + /** + * @param Integer The id of the node being added. + * @param Node The node being added. + * @return The nodeId assigned to this node. + */ + public int addToNodeTable(Node node) + { + int assignedNodeId = nextId_; + nodeTable_.put(String.valueOf(assignedNodeId),node); + nextId_++; + return assignedNodeId; + } + + public void removeFromNodeTable(int nodeId) + { + Vector nodesToRemove = new Vector(); + Node node = getNode(nodeId); + gatherNodesToRemove(nodesToRemove, node); + for (Iterator it = nodesToRemove.iterator(); it.hasNext();) { + nodeTable_.remove(String.valueOf(((Node)it.next()).getNodeId())); + } + } + + private void gatherNodesToRemove(Vector nodesToRemove, Node node) { + if (node != null) { + nodesToRemove.add(node); + Vector childNodes = node.getChildNodes(); + for (Iterator it = childNodes.iterator(); it.hasNext();) { + gatherNodesToRemove(nodesToRemove, (Node)it.next()); + } + } + } + + /** + * Returns the depth of the deepest visible node in the tree. + * @return int + */ + public int getMaxDepthVisible() + { + return maxDepthVisible_; + } + + /** + * Updates the depth of the deepest visible node in the tree. Nodes + * must call this when the visibility of their children changes. + * (e.g. expand/collapse of a parent node). + */ + public void updateMaxDepthVisible() + { + if (rootNode_ != null) + maxDepthVisible_ = rootNode_.getMaxDepthVisible(); + } + + /** + * Returns the next available id for a newly created node. + * @return int + */ + public int getNextNodeId() + { + return nextId_; + } + + /** + * Returns the id of the currently focused node in the tree. A node + * becomes focused when any of the following events occur: + * 1) The node's icon or image are selected by a user. + * 2) The node's expand/collapse icon is clicked. + * 3) Programmatically set by the programmer. + * The treeview will always scroll to the current focused node when loaded. + * @return int The id. + */ + public int getFocusedNodeId() + { + return focusedNodeId_; + } + + /** + * Allows modification of the focused node. + * @param int The id of the node that is in focus. + */ + public void setFocusedNodeId(int nodeId) + { + focusedNodeId_ = nodeId; + } + + public Node getFocusedNode() + { + return getNode(focusedNodeId_); + } + + /** + * Returns the id of the currently selected node in the tree. + * @return int The id. + */ + public int getSelectedNodeId() + { + return selectedNodeId_; + } + + public Node getSelectedNode() + { + return getNode(selectedNodeId_); + } + + /** + * Retrieve a reference to a Node in this manager's node table. + * @return Node The node. + */ + public Node getNode(int nodeId) + { + return (Node)nodeTable_.get(String.valueOf(nodeId)); + } + + /** + * Allows modification of the selected Node. Note that setting a node to become + * selected automatically makes it the focused node. However, this is only a one + * way relationship. + * @param int The id of the node that is being selected. + */ + public void setSelectedNodeId(int nodeId) + { + previousSelectedNodeId_ = selectedNodeId_; + selectedNodeId_ = nodeId; + setFocusedNodeId(selectedNodeId_); + } + + public int getPreviousSelectedNodeId() + { + return previousSelectedNodeId_; + } + + public Node getPreviousSelectedNode() + { + return (Node)nodeTable_.get(String.valueOf(previousSelectedNodeId_)); + } + + /** + * Render the HTML tree view for this node. + * @param HttpServletResponse For encoding URLs. + * @return String The HTML representing the tree view. + */ + public String renderTreeView(HttpServletResponse response) + { + StringBuffer treeView = new StringBuffer(); + rootNode_.renderNode(response,treeView,"",false); + return treeView.toString(); + } + + /** + * Make the provided node is visible by ensuring that its ancestors are visible. + * @param Node The node to be made visible. + * @return boolean Indicator for whether or not the treeview needs refreshing (i.e. an ancestor was not visible). + */ + public final boolean makeNodeVisible(Node node) + { + boolean requiresTreeViewRefresh = false; + while ((node = node.getParent()) != null) + { + if (!node.isOpen()) + { + requiresTreeViewRefresh = true; + node.setVisibilityOfChildren(true); + } + } + return requiresTreeViewRefresh; + } + + /** + * Make the currently selected node visible by ensuring that its ancestors are visible. + */ + public final boolean makeSelectedNodeVisible() + { + return makeNodeVisible(getSelectedNode()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Perspective.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Perspective.java new file mode 100644 index 000000000..bbe34a0f7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Perspective.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import javax.servlet.*; + +public abstract class Perspective extends MessageProvider +{ + protected Controller controller_; + protected MessageQueue messageQueue_; + + public Perspective(String messageBundleFileName,Controller controller) + { + super(messageBundleFileName); + controller_ = controller; + messageQueue_ = new MessageQueue(); + } + + public MessageQueue getMessageQueue() + { + return messageQueue_; + } + + public Controller getController() + { + return controller_; + } + + public abstract String getPanesFile(); + public abstract String getFramesetsFile(); + public abstract String getProcessFramesetsForm(); + + public abstract String getTreeContentVar(); + public abstract String getTreeContentPage(); + public abstract String getPropertiesContainerVar(); + public abstract String getPropertiesContainerPage(); + public abstract String getStatusContentVar(); + public abstract String getStatusContentPage(); + + public abstract String getSwitchPerspectiveFormActionLink(int targetPerspectiveId,boolean forHistory); + public abstract String getPerspectiveContentPage(); + public abstract int getPerspectiveId(); + + // This should only be called after the perspective has been successfully instantiated. + public abstract void initPerspective(ServletContext application); + + // Node manager for the navigator/tree content page + public abstract NodeManager getNodeManager(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/SectionHeaderInfo.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/SectionHeaderInfo.java new file mode 100644 index 000000000..105f395c3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/SectionHeaderInfo.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +public class SectionHeaderInfo +{ + private String containerId_; + private boolean dynamic_; + private Object otherProperties_; + + public SectionHeaderInfo() + { + clear(); + } + + public final void clear() + { + containerId_ = ""; + dynamic_ = true; + otherProperties_ = null; + } + + public final void setContainerId(String containerId) + { + containerId_ = containerId; + } + + public final String getContainerId() + { + return containerId_; + } + + public final void enableDynamic(boolean isEnabled) + { + dynamic_ = isEnabled; + } + + public final boolean isDynamic() + { + return dynamic_; + } + + public final void setOtherProperties(Object object) + { + otherProperties_ = object; + } + + public final Object getOtherProperties() + { + return otherProperties_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/SetDefaultViewTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/SetDefaultViewTool.java new file mode 100644 index 000000000..b3ef1e7a0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/SetDefaultViewTool.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +public abstract class SetDefaultViewTool extends ActionTool +{ + public SetDefaultViewTool(ToolManager viewToolManager,String alt) + { + super(viewToolManager,"images/top_enabled.gif","images/top_highlighted.gif",alt); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Tool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Tool.java new file mode 100644 index 000000000..f7dd679bb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/Tool.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import javax.servlet.http.*; + +import java.util.*; + +// A class for representing toolbar tools. +public abstract class Tool +{ + protected ToolManager toolManager_; + private String enabledImageLink_; + private String highlightedImageLink_; + private String alt_; + protected int toolId_; + protected byte toolType_; + + public Tool(ToolManager toolManager,String enabledImageLink,String highlightedImageLink,String alt,byte toolType) + { + toolManager_ = toolManager; + enabledImageLink_ = enabledImageLink; + highlightedImageLink_ = highlightedImageLink; + alt_ = alt; + toolId_ = toolManager_.addTool(this); + toolType_ = toolType; + } + + public abstract String getSelectToolActionHref(boolean forHistory); + + public String getSelectToolActionTarget() + { + return FrameNames.PERSPECTIVE_WORKAREA; + } + + private final void generateOnMouseValue(StringBuffer value,HttpServletResponse response,String fullImageLink) + { + value.append("src='").append(response.encodeURL(fullImageLink)).append('\''); + } + + public String renderTool(HttpServletResponse response,Controller controller) + { + Hashtable jsImageProperties = new Hashtable(); + StringBuffer propertyValue = new StringBuffer(); + String fullEnabledImageLink = controller.getPathWithContext(enabledImageLink_); + generateOnMouseValue(propertyValue,response,fullEnabledImageLink); + int propertyValueLength = propertyValue.length(); + jsImageProperties.put("class","normal"); + jsImageProperties.put("onMouseOut",propertyValue.append(";mouseout(this)").toString()); + propertyValue.delete(propertyValueLength,propertyValue.length()); + jsImageProperties.put("onMouseUp",propertyValue.append(";mouseup(this)").toString()); + propertyValue.setLength(0); + generateOnMouseValue(propertyValue,response,controller.getPathWithContext(highlightedImageLink_)); + propertyValueLength = propertyValue.length(); + jsImageProperties.put("onMouseOver",propertyValue.append(";mouseover(this)").toString()); + propertyValue.delete(propertyValueLength,propertyValue.length()); + jsImageProperties.put("onMouseDOwn",propertyValue.append(";mousedown(this)").toString()); + + String imageTag = HTMLUtils.getHTMLImageTag(response,fullEnabledImageLink,alt_,"16","16",jsImageProperties); + return HTMLUtils.getHTMLLinkTag(response,controller.getPathWithContext(getSelectToolActionHref(false)),getSelectToolActionTarget(),null,imageTag,null); + } + + public final ToolManager getToolManager() + { + return toolManager_; + } + + public final int getToolId() + { + return toolId_; + } + + public final byte getToolType() + { + return toolType_; + } + + public final String getEnabledImageLink() + { + return enabledImageLink_; + } + + public final String getHighlightedImageLink() + { + return highlightedImageLink_; + } + + public final String getAltText() + { + return alt_; + } + + public abstract String getFormLink(); + public abstract String getActionLink(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ToolManager.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ToolManager.java new file mode 100644 index 000000000..260b109b3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ToolManager.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import java.util.*; + +public class ToolManager +{ + private Vector tools_; + private int selectedToolId_; + private Node node_; + + public ToolManager(Node node) + { + tools_ = new Vector(); + selectedToolId_ = 0; + node_ = node; + } + + public final int getSelectedToolId() + { + return selectedToolId_; + } + + public final int setSelectedToolId(int toolId) + { + if (toolId >= 0 && toolId < tools_.size()) + selectedToolId_ = toolId; + return selectedToolId_; + } + + public final int addTool(Tool tool) + { + tools_.addElement(tool); + return tools_.size()-1; + } + + public final Tool getTool(int toolId) + { + if (toolId >=0 && toolId < getNumberOfTools()) + return (Tool)tools_.elementAt(toolId); + return null; + } + + public final List getTools() + { + return tools_; + } + + public final Tool getSelectedTool() + { + if (selectedToolId_ >=0 && selectedToolId_ < getNumberOfTools()) + return (Tool)tools_.elementAt(selectedToolId_); + return null; + } + + public final int getNumberOfTools() + { + return tools_.size(); + } + + public final Node getNode() + { + return node_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ViewTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ViewTool.java new file mode 100644 index 000000000..5dc398d6b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/perspective/ViewTool.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; + +import java.util.*; + +public abstract class ViewTool extends FormTool +{ + private Hashtable viewToolManagers_; + + public ViewTool(ToolManager toolManager,String enabledImageLink,String highlightedImageLink,String alt) + { + super(toolManager,enabledImageLink,highlightedImageLink,alt); + toolType_ = ToolTypes.VIEW; + viewToolManagers_ = new Hashtable(); + } + + protected abstract void addSetDefaultViewTool(ToolManager viewToolManager,int index); + protected abstract void addTools(ToolManager viewToolManager,int index); + + public final ToolManager createToolManager(int viewId) + { + ToolManager viewToolManager = new ToolManager(toolManager_.getNode()); + addTools(viewToolManager,viewId); + addSetDefaultViewTool(viewToolManager,viewId); + viewToolManagers_.put(String.valueOf(viewId),viewToolManager); + return viewToolManager; + } + + public final ToolManager getToolManager(int viewId) + { + return (ToolManager)(viewToolManagers_.get(String.valueOf(viewId))); + } + + public final void clearViewToolManager(int viewId) + { + viewToolManagers_.remove(String.valueOf(viewId)); + } + + public final void clearViewToolManagers() + { + viewToolManagers_.clear(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddItemsToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddItemsToFavoritesAction.java new file mode 100644 index 000000000..6043aebc1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddItemsToFavoritesAction.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +public class AddItemsToFavoritesAction extends UDDIPropertiesFormAction +{ + public AddItemsToFavoritesAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String[] selectedNodeIds = parser.getParameterValues(ActionInputs.NODEID); + // The client Javascript enforces the rule that at least one item was selected before the form can be submitted. + propertyTable_.put(UDDIActionInputs.SELECTED_NODEIDS,selectedNodeIds); + return true; + } + + public final boolean run() + { + String[] selectedNodeIds = (String[])propertyTable_.get(UDDIActionInputs.SELECTED_NODEIDS); + AddToFavoritesAction action = new AddToFavoritesAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + for (int i=0;i<selectedNodeIds.length;i++) + { + propertyTable.put(ActionInputs.NODEID,selectedNodeIds[i]); + if (action.favoriteExists()) { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + Node node = uddiPerspective.getNavigatorManager().getNode(Integer.parseInt(selectedNodeIds[i])); + String nodeName = node.getNodeName(); + uddiPerspective.getMessageQueue().addMessage(uddiPerspective.getMessage("MSG_ERROR_FAVORITE_ALREADY_EXISTS",nodeName)); + } + else + action.run(); + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddPublisherAssertionsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddPublisherAssertionsAction.java new file mode 100644 index 000000000..91dcb6ff1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddPublisherAssertionsAction.java @@ -0,0 +1,231 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.*; +import org.uddi4j.util.*; +import org.uddi4j.response.*; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.assertion.*; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.transport.TransportException; + +import java.util.*; +import java.net.*; + +public class AddPublisherAssertionsAction extends CommonPublisherAssertionsAction +{ + public AddPublisherAssertionsAction(Controller controller) + { + super(controller); + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + if (registryNode_ == null) + return false; + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + + // ids from uddiObjects_table.jsp + String[] selectedBusIds = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (selectedBusIds == null || selectedBusIds.length == 0) { + // Synchronize client view and server model (uddiObject_table.jsp) + synchronizeUDDIObjectTable(); + inputsValid = false; + } + else { + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, selectedBusIds); + // Synchronize client view and server model (uddiObject_table.jsp) + synchronizeUDDIObjectTable(); + } + + String[] assertionTypes = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_TYPE); + if (assertionTypes != null && assertionTypes.length > 0) + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_TYPE, assertionTypes); + else + inputsValid = false; + + String[] directions = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_DIRECTION); + if (directions != null && directions.length > 0) + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_DIRECTION, directions); + else + inputsValid = false; + + // if not yet logged in, validate the parameters needed to log in + if (!isLoggedIn_) { + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (!Validator.validateString(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userID != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + } + + if (!Validator.validateString(userID)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + } + + return inputsValid; + } + + public boolean run() + { + if (registryNode_ == null) + return false; + + RegistryElement registryElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + Node selectedNode = navigatorManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + + // if not yet logged in, log in first + if (!isLoggedIn_) { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + try { + registryElement.performLogin(publishURL, userID, password); + } + catch (TransportException te) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(te.getMessage()); + return false; + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(uddie.toString()); + return false; + } + catch (MalformedURLException me) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(me.getMessage()); + return false; + } + } + + UDDIProxy proxy = registryElement.getProxy(); + String userID = registryElement.getUserId(); + String cred = registryElement.getCred(); + BusinessElement busElement = (BusinessElement)selectedElement; + + // determine whether this is a owned business + // if not, the AddPublisherAssertionsAction cannot be performed + if (!isBusinessOwned(busElement)) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_NOT_OWNED_BUSINESS")); + return false; + } + + try { + String[] assertionTypes = (String[])propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_TYPE); + String[] directions = (String[])propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_DIRECTION); + String thisBusinessKey = busElement.getBusinessEntity().getBusinessKey(); + + // get all selected businesses + FormTool formTool = (FormTool)(selectedNode.getCurrentToolManager().getSelectedTool()); + String subQueryKey = (String)formTool.getProperty(UDDIActionInputs.SUBQUERY_KEY); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey); + Vector selectedBusinesses = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADD_PUBLISHER_ASSERTIONS); + Enumeration e = selectedBusinesses.elements(); + if (!e.hasMoreElements()) + return true; + + // create a vector of publisher assertions based on all the selected businesses + Vector pubAssertionVector = new Vector(); + int i = 0; + while (e.hasMoreElements()) { + ListElement le = (ListElement)e.nextElement(); + BusinessEntity sp = (BusinessEntity)le.getObject(); + KeyedReference keyedRef = new KeyedReference(assertionTypes[i], assertionTypes[i], TModel.RELATIONSHIPS_TMODEL_KEY); + if (Integer.parseInt(directions[i]) == UDDIActionInputs.DIRECTION_TO) + pubAssertionVector.add(new PublisherAssertion(sp.getBusinessKey(), thisBusinessKey, keyedRef)); + else + pubAssertionVector.add(new PublisherAssertion(thisBusinessKey, sp.getBusinessKey(), keyedRef)); + i++; + } + + // proxy.add_publisherAssertions(...) + DispositionReport report = proxy.add_publisherAssertions(registryElement.getAuthInfoString(), pubAssertionVector); + + // refresh publisher assertions iff proxy reports success + if (report.success()) { + selectedBusinesses.removeAllElements(); + ShowPublisherAssertionsAction showPAAction = new ShowPublisherAssertionsAction(controller_); + Hashtable propertyTable = showPAAction.getPropertyTable(); + Object ids = propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (ids != null) + propertyTable.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, ids); + showPAAction.run(); + } + + return report.success(); + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + DispositionReport report = uddie.getDispositionReport(); + Vector reportErrInfo = report.getResultVector(); + for (int i = 0; i < reportErrInfo.size(); i++) { + messageQueue.addMessage(((Result) reportErrInfo.get(i)).getErrInfo().getText()); + } + return false; + } + catch(Exception e) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("Exception"); + messageQueue.addMessage(e.getMessage()); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddToFavoritesAction.java new file mode 100644 index 000000000..1a337bc0a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/AddToFavoritesAction.java @@ -0,0 +1,231 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import java.util.*; + +public class AddToFavoritesAction extends UDDINodeAction +{ + public AddToFavoritesAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/CheckFavoriteExistsActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean registryExists(String registryName,Node registryNode) + { + RegistryElement regElement = (RegistryElement)registryNode.getTreeElement(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_REGISTRY_NAME,registryName); + return favoriteExists(table,FavoritesModelConstants.REL_UDDI_REGISTRY_FOLDER_NODE); + } + + public final boolean businessExists(String businessName,Node businessNode) + { + BusinessElement busElement = (BusinessElement)businessNode.getTreeElement(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + String businessKey = busElement.getBusinessEntity().getBusinessKey(); + String inquiryURL = regElement.getInquiryURL(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_NAME,businessName); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_KEY, businessKey); + return favoriteExists(table,FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE); + } + + public final boolean serviceExists(String serviceName,Node serviceNode) + { + ServiceElement serviceElement = (ServiceElement)serviceNode.getTreeElement(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + String serviceKey = serviceElement.getBusinessService().getServiceKey(); + String inquiryURL = regElement.getInquiryURL(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_NAME,serviceName); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_KEY,serviceKey); + return favoriteExists(table,FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE); + } + + public final boolean serviceInterfaceExists(String siName,Node siNode) + { + ServiceInterfaceElement siElement = (ServiceInterfaceElement)siNode.getTreeElement(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + String tModelKey = siElement.getTModel().getTModelKey(); + String inquiryURL = regElement.getInquiryURL(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_NAME,siName); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_KEY,tModelKey); + return favoriteExists(table,FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_FOLDER_NODE); + } + + public final boolean addRegistryToFavorites(String registryName,Node registryNode) + { + RegistryElement regElement = (RegistryElement)registryNode.getTreeElement(); + String inquiryURL = regElement.getInquiryURL(); + String publishURL = regElement.getPublishURL(); + if (publishURL == null) + publishURL = ""; + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_REGISTRY_PUBLISH_API,publishURL); + table.put(FavoritesModelConstants.PROP_UDDI_REGISTRY_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_REGISTRY_NAME,registryName); + Enumeration userDefinedCategoriesEnum = regElement.getUserDefinedCategories(); + if (userDefinedCategoriesEnum != null) + { + table.put(FavoritesModelConstants.PROP_UDDI_REGISTRY_CATEGORIES_ENUM,userDefinedCategoriesEnum); + table.put(FavoritesModelConstants.PROP_PLUGIN_METADATA_DIRECTORY,controller_.getServletEngineStateLocation()); + } + return addToFavorites(table,FavoritesModelConstants.REL_UDDI_REGISTRY_FOLDER_NODE); + } + + public final boolean addBusinessToFavorites(String businessName,Node businessNode) + { + BusinessElement busElement = (BusinessElement)businessNode.getTreeElement(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + String businessKey = busElement.getBusinessEntity().getBusinessKey(); + String inquiryURL = regElement.getInquiryURL(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_NAME,businessName); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_KEY, businessKey); + return addToFavorites(table,FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE); + } + + public final boolean addServiceToFavorites(String serviceName,Node serviceNode) + { + ServiceElement serviceElement = (ServiceElement)serviceNode.getTreeElement(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + String serviceKey = serviceElement.getBusinessService().getServiceKey(); + String inquiryURL = regElement.getInquiryURL(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_NAME,serviceName); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_KEY,serviceKey); + return addToFavorites(table,FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE); + } + + public final boolean addServiceInterfaceToFavorites(String siName,Node siNode) + { + ServiceInterfaceElement siElement = (ServiceInterfaceElement)siNode.getTreeElement(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + String tModelKey = siElement.getTModel().getTModelKey(); + String inquiryURL = regElement.getInquiryURL(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_NAME,siName); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_INQUIRY_API,inquiryURL); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INTERFACE_KEY,tModelKey); + return addToFavorites(table,FavoritesModelConstants.REL_UDDI_SERVICE_INTERFACE_FOLDER_NODE); + } + + public boolean favoriteExists() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + Node node = nodeManager_.getNode(nodeId); + String nodeName = node.getNodeName(); + if (node instanceof RegistryNode) + return registryExists(nodeName,node); + else if (node instanceof BusinessNode) + return businessExists(nodeName,node); + else if (node instanceof ServiceNode) + return serviceExists(nodeName,node); + else if (node instanceof ServiceInterfaceNode) + return serviceInterfaceExists(nodeName,node); + else + return false; + } + + public boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + Node node = nodeManager_.getNode(nodeId); + String nodeName = node.getNodeName(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + boolean addToFavoritesResult = false; + if (node instanceof RegistryNode) + { + addToFavoritesResult = addRegistryToFavorites(nodeName,node); + RegistryElement regElement = (RegistryElement)node.getTreeElement(); + Enumeration e = regElement.getUserDefinedCategories(); + if (e != null) + { + while (e.hasMoreElements()) + { + CategoryModel categoryModel = (CategoryModel)e.nextElement(); + Throwable errorException = categoryModel.getErrorException(); + if (errorException != null) + { + String[] args = {categoryModel.getDisplayName(),errorException.getMessage()}; + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_SAVING_CATEGORY_DATA",args)); + } + } + } + } + else if (node instanceof BusinessNode) + addToFavoritesResult = addBusinessToFavorites(nodeName,node); + else if (node instanceof ServiceNode) + addToFavoritesResult = addServiceToFavorites(nodeName,node); + else if (node instanceof ServiceInterfaceNode) + addToFavoritesResult = addServiceInterfaceToFavorites(nodeName,node); + if (addToFavoritesResult) + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_FAVORITE_ADDED",nodeName)); + else + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_FAVORITE_NOT_ADDED",nodeName)); + return addToFavoritesResult; + } + + protected boolean addToFavorites(Hashtable table, String rel) + { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager favNodeManager = favPerspective.getNodeManager(); + TreeElement favRootElement = favNodeManager.getRootNode().getTreeElement(); + Enumeration e = favRootElement.getElements(rel); + if (!e.hasMoreElements()) + return false; + FavoritesFolderElement favFolderElement = (FavoritesFolderElement)e.nextElement(); + return favFolderElement.addFavorite(table); + } + + protected boolean favoriteExists(Hashtable table, String rel) + { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager favNodeManager = favPerspective.getNodeManager(); + TreeElement favRootElement = favNodeManager.getRootNode().getTreeElement(); + Enumeration e = favRootElement.getElements(rel); + if (!e.hasMoreElements()) + return false; + FavoritesFolderElement favFolderElement = (FavoritesFolderElement)e.nextElement(); + return favFolderElement.favoriteExists(table); + } + + public final String getActionLinkForHistory() + { + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusPublishServiceAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusPublishServiceAdvancedAction.java new file mode 100644 index 000000000..6961248ec --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusPublishServiceAdvancedAction.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +import org.uddi4j.datatype.business.BusinessEntity; + +public class BusPublishServiceAdvancedAction extends PublishAction +{ + private RegPublishServiceAdvancedAction regPublishServiceAdvancedAction_; + public BusPublishServiceAdvancedAction(Controller controller) + { + super(controller); + regPublishServiceAdvancedAction_ = new RegPublishServiceAdvancedAction(controller); + propertyTable_ = regPublishServiceAdvancedAction_.getPropertyTable(); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + Node businessNode = getSelectedNavigatorNode(); + BusinessElement businessElement = (BusinessElement)businessNode.getTreeElement(); + BusinessEntity businessEntity = businessElement.getBusinessEntity(); + ListElement busListElement = new ListElement(businessEntity); + Vector serviceBusinessCopy = new Vector(); + serviceBusinessCopy.addElement(busListElement); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS_COPY,serviceBusinessCopy); + boolean result = regPublishServiceAdvancedAction_.processOthers(parser,formToolPI); + if (!propertyTable_.containsKey(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER)) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER,businessEntity); + return result; + } + + public final boolean run() + { + return regPublishServiceAdvancedAction_.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusPublishServiceSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusPublishServiceSimpleAction.java new file mode 100644 index 000000000..ea9da0af8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusPublishServiceSimpleAction.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +import org.uddi4j.datatype.business.BusinessEntity; + +public class BusPublishServiceSimpleAction extends PublishAction +{ + private RegPublishServiceSimpleAction regPublishServiceSimpleAction_; + + public BusPublishServiceSimpleAction(Controller controller) + { + super(controller); + regPublishServiceSimpleAction_ = new RegPublishServiceSimpleAction(controller); + propertyTable_ = regPublishServiceSimpleAction_.getPropertyTable(); + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + Node businessNode = getSelectedNavigatorNode(); + BusinessElement businessElement = (BusinessElement)businessNode.getTreeElement(); + BusinessEntity businessEntity = businessElement.getBusinessEntity(); + ListElement busListElement = new ListElement(businessEntity); + Vector serviceBusinessCopy = new Vector(); + serviceBusinessCopy.addElement(busListElement); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS_COPY,serviceBusinessCopy); + boolean result = regPublishServiceSimpleAction_.processOthers(parser,formToolPI); + if (!propertyTable_.containsKey(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_SERVICE_PROVIDER)) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_SERVICE_PROVIDER,businessEntity); + return result; + } + + public final boolean run() + { + return regPublishServiceSimpleAction_.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusinessGetServicesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusinessGetServicesAction.java new file mode 100644 index 000000000..9f305f803 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/BusinessGetServicesAction.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.business.BusinessEntity; + +import java.util.*; + +public class BusinessGetServicesAction extends UDDINodeAction +{ + private BusinessNode busNode_; + public BusinessGetServicesAction(Controller controller) + { + super(controller); + busNode_ = null; + } + + // uddi/actions/BusinessGetServicesActionJSP.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/BusinessGetServicesActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean validateBusiness() + { + int busNodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + busNode_ = (BusinessNode)nodeManager_.getNode(busNodeId); + BusinessElement busElement = (BusinessElement)busNode_.getTreeElement(); + RegFindBusinessUUIDAction verifyAction = new RegFindBusinessUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,busElement.getBusinessEntity().getBusinessKey()); + boolean result = verifyAction.run(); + if (result) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,propertyTable.get(UDDIActionInputs.LATEST_OBJECT)); + return result; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + BusinessEntity sp = (BusinessEntity)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + + RegFindServicesAdvancedAction action = new RegFindServicesAdvancedAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,uddiPerspective.getMessage("NODE_NAME_BUSINESS_SERVICES",busNode_.getNodeName())); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER,sp); + + ListElement businessListElement = new ListElement(sp); + businessListElement.setTargetViewToolInfo(busNode_.getNodeId(),busNode_.getToolManager().getSelectedToolId(),busNode_.getViewId()); + Vector businessListVector = new Vector(); + businessListVector.addElement(businessListElement); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS,businessListVector); + + + return action.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorFolderNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorFolderNodeAction.java new file mode 100644 index 000000000..3a5db863c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorFolderNodeAction.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class ClearNavigatorFolderNodeAction extends ClearNavigatorNodeAction +{ + public ClearNavigatorFolderNodeAction(Controller controller) + { + super(controller); + } + + // uddi/actions/ClearNavigatorFolderNodeAction.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ClearNavigatorFolderNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + if (!isStaleNode(nodeId)) + { + Node node = nodeManager_.getNode(nodeId); + TreeElement element = node.getTreeElement(); + element.disconnectRel(element.getPropertyAsString(ModelConstants.REL_CHILDREN)); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorNodeAction.java new file mode 100644 index 000000000..75e4b421b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorNodeAction.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class ClearNavigatorNodeAction extends ClearNodeAction +{ + public ClearNavigatorNodeAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getNavigatorManager()); + propertyTable_.put(ActionInputs.NODEID,String.valueOf(controller.getUDDIPerspective().getNavigatorManager().getSelectedNodeId())); + } + + // uddi/actions/ClearNavigatorNodeAction.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ClearNavigatorNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final String getTreeContentVar() + { + return "navigatorContent"; + } + + public final String getTreeContentPage() + { + return "uddi/navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "propertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "uddi/properties_container.jsp"; + } + + public final String getStatusContentVar() + { + return "statusContent"; + } + + public final String getStatusContentPage() + { + return "uddi/status_content.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorNodesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorNodesAction.java new file mode 100644 index 000000000..e0f5166d2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ClearNavigatorNodesAction.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +public class ClearNavigatorNodesAction extends UDDIPropertiesFormAction +{ + public ClearNavigatorNodesAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String[] selectedNodeIds = parser.getParameterValues(ActionInputs.NODEID); + if (selectedNodeIds != null) + propertyTable_.put(UDDIActionInputs.SELECTED_NODEIDS,selectedNodeIds); + else + removeProperty(UDDIActionInputs.SELECTED_NODEIDS); + return true; + } + + public final boolean run() + { + String[] selectedNodeIds = (String[])propertyTable_.get(UDDIActionInputs.SELECTED_NODEIDS); + if (selectedNodeIds != null) + { + ClearNavigatorNodeAction action = new ClearNavigatorNodeAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + for (int i=0;i<selectedNodeIds.length;i++) + { + propertyTable.put(ActionInputs.NODEID,selectedNodeIds[i]); + action.run(); + } + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/CommonPublisherAssertionsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/CommonPublisherAssertionsAction.java new file mode 100644 index 000000000..5e14725a3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/CommonPublisherAssertionsAction.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.response.BusinessInfo; +import org.uddi4j.response.RegisteredInfo; + +import java.util.Vector; +import java.util.Iterator; +import java.util.Enumeration; + +public abstract class CommonPublisherAssertionsAction extends UDDIPropertiesFormAction +{ + + protected RegistryNode registryNode_; + protected boolean isLoggedIn_; + + public CommonPublisherAssertionsAction(Controller controller) + { + super(controller); + + registryNode_ = getRegistryNode(); + if (registryNode_ != null) + isLoggedIn_ = ((RegistryElement)registryNode_.getTreeElement()).isLoggedIn(); + } + + protected void synchronizeUDDIObjectTable() { + String[] selectedBusIds = (String[])propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + Node selectedNode = controller_.getUDDIPerspective().getNavigatorManager().getSelectedNode(); + FormTool formTool = (FormTool)(selectedNode.getCurrentToolManager().getSelectedTool()); + String subQueryKey = (String)formTool.getProperty(UDDIActionInputs.SUBQUERY_KEY); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey); + Vector businessVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADD_PUBLISHER_ASSERTIONS); + ListManager businessCopy = (ListManager)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADD_PUBLISHER_ASSERTIONS_COPY); + if (selectedBusIds == null || selectedBusIds.length <= 0) { + businessVector.removeAllElements(); + businessCopy.clear(); + } + Enumeration e = businessCopy.getListElements(); + while (e.hasMoreElements()) { + boolean isIdFound = false; + ListElement le = (ListElement)e.nextElement(); + int listElementViewId = le.getViewId(); + for (int i = 0; i < selectedBusIds.length; i++) { + if (listElementViewId == Integer.parseInt(selectedBusIds[i])) { + isIdFound = true; + break; + } + } + if (!isIdFound) + businessVector.remove(le); + } + } + + protected boolean isBusinessOwned(BusinessElement busElement) { + boolean isBusinessOwned = false; + String isBusinessOwnedString = busElement.getPropertyAsString(UDDIModelConstants.IS_BUSINESS_OWNED); + if (isBusinessOwnedString != null) { + isBusinessOwned = Boolean.valueOf(isBusinessOwnedString).booleanValue(); + } + else if (isLoggedIn_) { + try { + RegistryElement regElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + RegisteredInfo ri = proxy.get_registeredInfo(regElement.getAuthInfoString()); + Vector beVector = ri.getBusinessInfos().getBusinessInfoVector(); + for (Iterator it = beVector.iterator(); it.hasNext();) + { + BusinessInfo bi = (BusinessInfo)it.next(); + if (bi.getBusinessKey().equals(busElement.getBusinessEntity().getBusinessKey())) + { + isBusinessOwned = true; + break; + } + } + busElement.setPropertyAsString(UDDIModelConstants.IS_BUSINESS_OWNED, String.valueOf(isBusinessOwned)); + } + catch (Exception e) {} + } + return isBusinessOwned; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/CompletePublisherAssertionsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/CompletePublisherAssertionsAction.java new file mode 100644 index 000000000..8f73b8efd --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/CompletePublisherAssertionsAction.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.UDDIException; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; + +import java.util.*; +import java.net.*; + +public class CompletePublisherAssertionsAction extends CommonPublisherAssertionsAction +{ + public CompletePublisherAssertionsAction(Controller controller) + { + super(controller); + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + if (registryNode_ == null) + return false; + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + + // ids from uddiObjects_table + String[] selectedBusIds = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (selectedBusIds != null && selectedBusIds.length > 0) + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, selectedBusIds); + // Synchronize client view and server model (uddiObject_table.jsp) + synchronizeUDDIObjectTable(); + + // if not yet logged in, validate the parameters needed to log in + if (!isLoggedIn_) { + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (!Validator.validateString(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userID != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + } + + if (!Validator.validateString(userID)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + } + + // ids from publisher assertion table + String[] pubAssertionsViewIds = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_VIEWID); + if (pubAssertionsViewIds == null || pubAssertionsViewIds.length == 0) + inputsValid = false; + else + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_VIEWID, pubAssertionsViewIds); + + return inputsValid; + } + + public boolean run() + { + if (registryNode_ == null) + return false; + + RegistryElement registryElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + Node selectedNode = navigatorManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + + // if not yet logged in, log in first + if (!isLoggedIn_) { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + try { + registryElement.performLogin(publishURL, userID, password); + } + catch (TransportException te) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(te.getMessage()); + return false; + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(uddie.toString()); + return false; + } + catch (MalformedURLException me) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(me.getMessage()); + return false; + } + } + + UDDIProxy proxy = registryElement.getProxy(); + String userID = registryElement.getUserId(); + String cred = registryElement.getCred(); + BusinessElement busElement = (BusinessElement)selectedElement; + ListManager pubAssertions = busElement.getPublisherAssertions(); + + // determine whether this is a owned business + // if not, the AddPublisherAssertionsAction cannot be performed + if (!isBusinessOwned(busElement)) { + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NOT_OWNED_BUSINESS")); + return false; + } + + try { + String[] pubAssertionViewIds = (String[])propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_VIEWID); + Vector pubAssertionVector = new Vector(); + + for (int i = 0; i < pubAssertionViewIds.length; i++) { + int viewID = Integer.parseInt(pubAssertionViewIds[i]); + ListElement listElement = pubAssertions.getElementWithViewId(viewID); + PublisherAssertionElement pubAssertionElement = (PublisherAssertionElement)listElement.getObject(); + if (!(pubAssertionElement.getStatus().equals(CompletionStatus.COMPLETE))) + pubAssertionVector.add(pubAssertionElement.getPublisherAssertion()); + } + + if (pubAssertionVector.size() <= 0) { + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NO_INCOMPLETE_ASSERTION_SELECTED")); + return false; + } + + DispositionReport report = proxy.add_publisherAssertions(registryElement.getAuthInfoString(), pubAssertionVector); + //report status + Vector reportErrInfo = report.getResultVector(); + for (int j = 0; j < reportErrInfo.size(); j++) { + messageQueue.addMessage(((Result) reportErrInfo.get(j)).getErrInfo().getText()); + } + + ShowPublisherAssertionsAction showPAAction = new ShowPublisherAssertionsAction(controller_); + Hashtable propertyTable = showPAAction.getPropertyTable(); + Object ids = propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (ids != null) + propertyTable.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, ids); + showPAAction.run(); + + return report.success(); + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + DispositionReport report = uddie.getDispositionReport(); + Vector reportErrInfo = report.getResultVector(); + for (int j = 0; j < reportErrInfo.size(); j++) { + messageQueue.addMessage(((Result) reportErrInfo.get(j)).getErrInfo().getText()); + } + return false; + } + catch (Exception e) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("Exception"); + messageQueue.addMessage(e.getMessage()); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/FindAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/FindAction.java new file mode 100644 index 000000000..b33b22a34 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/FindAction.java @@ -0,0 +1,249 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.MultipartFormDataParserTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +public abstract class FindAction extends UDDIPropertiesFormAction +{ + protected QueryElement queryElement_; + protected String subQueryKey_; + protected boolean isSubQueryGet_; + protected String newSubQuery_; + protected String newSubQueryItem_; + protected boolean subQueryInitiated_; + protected RegistryNode regNode_; + private boolean isRefreshAction_; + + public FindAction(Controller controller) + { + super(controller); + queryElement_ = null; + subQueryKey_ = null; + isSubQueryGet_ = false; + subQueryInitiated_ = false; + regNode_ = getRegistryNode(); + isRefreshAction_ = false; + } + + protected abstract boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException; + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + // Setup for MultipartFormDataParserTransformer + propertyTable_.put(ActionInputs.MULTIPART_FORM_DATA_PARSER, parser); + + newSubQuery_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_INITIATED); + String isSubQueryGetString = parser.getParameter(UDDIActionInputs.SUBQUERY_GET); + newSubQueryItem_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_QUERY_ITEM); + subQueryKey_ = parser.getParameter(UDDIActionInputs.SUBQUERY_KEY); + String queryName = parser.getParameter(UDDIActionInputs.QUERY_NAME); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + formToolPI.clearErrors(); + + if (newSubQuery_ != null && newSubQuery_.length() > 0) + subQueryInitiated_ = true; + else + subQueryInitiated_ = false; + + if (isSubQueryGetString != null) + isSubQueryGet_ = Boolean.valueOf(isSubQueryGetString).booleanValue(); + + if (queryName != null) + propertyTable_.put(UDDIActionInputs.QUERY_NAME,queryName); + + if (!Validator.validateString(queryName) && !subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_QUERY_NAME")); + } + + if (!processOthers(parser,formToolPI) && !subQueryInitiated_) + inputsValid = false; + + for (int i=0;i<removedProperties_.size();i++) + formToolPI.removeProperty(removedProperties_.elementAt(i)); + formToolPI.updatePropertyTable(propertyTable_); + + // Process authentication information. If valid, these should be set in the formTool (not the formToolPI). + String ownedChecked = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_OWNED); + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + + boolean validateAuthentication = (ownedChecked != null) && (!regElement.isLoggedIn()) && !overrideAuthenticationValidation(); + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (!subQueryInitiated_ && validateAuthentication && !Validator.validateString(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userId != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + } + + if (!subQueryInitiated_ && validateAuthentication && !Validator.validateString(userId)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + + return inputsValid; + } + + protected boolean overrideAuthenticationValidation() + { + return false; + } + + public final boolean isSubQueryInitiated() + { + return subQueryInitiated_; + } + + public final boolean isSubQueryGet() + { + return isSubQueryGet_; + } + + public final String getSubQueryKey() + { + return subQueryKey_; + } + + public final String getNewSubQuery() + { + return newSubQuery_; + } + + public final String getNewSubQueryItem() + { + return newSubQueryItem_; + } + + public final void setRefreshAction(boolean isRefreshAction) + { + isRefreshAction_ = isRefreshAction; + } + + public final boolean isRefreshAction() + { + return isRefreshAction_; + } + + protected final void addQueryNode() + { + // If the queryElement already exists, remove it first. + String queryName = queryElement_.getName(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + QueryParentElement queryParentElement = regElement.getQueryParentElement(); + Enumeration e = queryParentElement.getQueries(); + while (e.hasMoreElements()) + { + QueryElement qe = (QueryElement)e.nextElement(); + if (qe.getName().equals(queryName)) + { + SubQueryTransferTarget subQueryTransferTarget = (SubQueryTransferTarget)qe.getPropertyAsObject(UDDIModelConstants.SUBQUERY_TRANSFER_TARGET); + if (subQueryTransferTarget != null && (qe.getQueryType() == queryElement_.getQueryType())) + queryElement_.setPropertyAsObject(UDDIModelConstants.SUBQUERY_TRANSFER_TARGET,subQueryTransferTarget); + qe.disconnectAll(); + break; + } + } + if (!isRefreshAction_) + { + // We can make safe assumptions about the node that is currently selected. + if (subQueryKey_ != null && subQueryKey_.length() > 0) + { + String parentQueryKey; + int lastSeparatorPos = subQueryKey_.lastIndexOf(':'); + if (lastSeparatorPos == -1) + parentQueryKey = ""; + else + parentQueryKey = subQueryKey_.substring(0,lastSeparatorPos); + FormToolPropertiesInterface parentFormToolPI = ((MultipleFormToolPropertiesInterface)getSelectedFormTool()).getFormToolProperties(parentQueryKey); + Object queryItem = parentFormToolPI.getProperty(UDDIActionInputs.QUERY_ITEM); + Object queryStyleBus = parentFormToolPI.getProperty(UDDIActionInputs.QUERY_STYLE_BUSINESSES); + Object queryStyleSer = parentFormToolPI.getProperty(UDDIActionInputs.QUERY_STYLE_SERVICES); + Object queryStyleSerInt = parentFormToolPI.getProperty(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES); + Hashtable parentQueryData = new Hashtable(); + if (queryItem != null) + parentQueryData.put(UDDIActionInputs.QUERY_ITEM, queryItem); + if (queryStyleBus != null) + parentQueryData.put(UDDIActionInputs.QUERY_STYLE_BUSINESSES, queryStyleBus); + if (queryStyleSer != null) + parentQueryData.put(UDDIActionInputs.QUERY_STYLE_SERVICES, queryStyleSer); + if (queryStyleSerInt != null) + parentQueryData.put(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES, queryStyleSerInt); + queryElement_.setPropertyAsObject(UDDIModelConstants.SUBQUERY_TRANSFER_TARGET,new SubQueryTransferTarget(getSelectedNavigatorNode(),subQueryKey_,parentQueryData)); + } + } + queryParentElement.connect(queryElement_,UDDIModelConstants.REL_QUERIES,ModelConstants.REL_OWNER); + QueryNode queryNode = (QueryNode)(regNode_.getChildNode(queryParentElement).getChildNode(queryElement_)); + int newSelectedNodeId; + // If there is only 1 result, select the result. Otherwise, select the query node to present a summary. + if (queryNode.getChildNodes().size() == 1 && (subQueryKey_ == null || subQueryKey_.length() == 0)) + newSelectedNodeId = ((Node)(queryNode.getChildNodes().elementAt(0))).getNodeId(); + else + newSelectedNodeId = queryNode.getNodeId(); + NodeManager nodeManager = regNode_.getNodeManager(); + nodeManager.setSelectedNodeId(newSelectedNodeId); + queryNode.setFindToolProperties(this); + Node selectedNode = nodeManager.getSelectedNode(); + ToolManager toolManager = selectedNode.getCurrentToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + addToHistory(ActionInputs.PERSPECTIVE_UDDI,selectedTool.getSelectToolActionHref(true)); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length + 1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length - 1] = new MultipartFormDataParserTransformer(controller_); + return transformers; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ManageReferencedServicesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ManageReferencedServicesAction.java new file mode 100644 index 000000000..0e470bad6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ManageReferencedServicesAction.java @@ -0,0 +1,365 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.service.BusinessServices; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.UDDIException; +import org.uddi4j.transport.TransportException; + +import java.util.*; +import java.net.*; + +public class ManageReferencedServicesAction extends UDDIPropertiesFormAction +{ + protected String subQueryKey_; + protected boolean isSubQueryGet_; + protected String newSubQuery_; + protected String newSubQueryItem_; + protected boolean subQueryInitiated_; + protected RegistryNode regNode_; + + public ManageReferencedServicesAction(Controller controller) + { + super(controller); + subQueryKey_ = null; + isSubQueryGet_ = false; + subQueryInitiated_ = false; + regNode_ = getRegistryNode(); + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + newSubQuery_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_INITIATED); + String isSubQueryGetString = parser.getParameter(UDDIActionInputs.SUBQUERY_GET); + newSubQueryItem_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_QUERY_ITEM); + subQueryKey_ = parser.getParameter(UDDIActionInputs.SUBQUERY_KEY); + String[] referencedServicesCheckboxes = parser.getParameterValues(UDDIActionInputs.REFERENCED_SERVICE_SELECT_STATE); + String[] serviceNodeIds = parser.getParameterValues(UDDIActionInputs.NODEID_SERVICE); + String operation = parser.getParameter(UDDIActionInputs.MANAGE_REFERENCED_SERVICES_OPERATION); + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + formToolPI.clearErrors(); + + if (newSubQuery_ != null && newSubQuery_.length() > 0) + subQueryInitiated_ = true; + else + subQueryInitiated_ = false; + + if (isSubQueryGetString != null) + isSubQueryGet_ = Boolean.valueOf(isSubQueryGetString).booleanValue(); + + if (operation != null) + propertyTable_.put(UDDIActionInputs.MANAGE_REFERENCED_SERVICES_OPERATION,operation); + else + removeProperty(UDDIActionInputs.MANAGE_REFERENCED_SERVICES_OPERATION); + + if (referencedServicesCheckboxes != null) + propertyTable_.put(UDDIActionInputs.REFERENCED_SERVICE_SELECT_STATE,referencedServicesCheckboxes); + else + removeProperty(UDDIActionInputs.REFERENCED_SERVICE_SELECT_STATE); + + if (serviceNodeIds != null) + { + Vector services = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_SERVICES); + if (services == null) + services = new Vector(); + Hashtable resultHash = new Hashtable(); + for (int i=0;i<serviceNodeIds.length;i++) + resultHash.put(serviceNodeIds[i],Boolean.TRUE); + for (int i=0;i<services.size();i++) + { + ListElement listElement = (ListElement)services.elementAt(i); + if (resultHash.get(String.valueOf(listElement.getTargetNodeId())) == null) + { + services.removeElementAt(i); + i--; + } + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SERVICES,services); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_SERVICES); + + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (!regElement.isLoggedIn()) + { + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (!subQueryInitiated_ && !Validator.validateString(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userId != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + } + + if (!subQueryInitiated_ && !Validator.validateString(userId)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + } + + for (int i=0;i<removedProperties_.size();i++) + formToolPI.removeProperty(removedProperties_.elementAt(i)); + formToolPI.updatePropertyTable(propertyTable_); + + return inputsValid; + } + + public boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + String operationString = (String)propertyTable_.get(UDDIActionInputs.MANAGE_REFERENCED_SERVICES_OPERATION); + int operation = Integer.parseInt(operationString); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + BusinessElement busElement = (BusinessElement)(getSelectedNavigatorNode().getTreeElement()); + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + Vector referencedServices = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_REFERENCED_SERVICES); + boolean operationResult = true; + try + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + UDDIProxy proxy = regElement.getProxy(); + BusinessEntity currentSP = busElement.getBusinessEntity(); + BusinessEntity sp = (BusinessEntity)proxy.get_businessDetail(currentSP.getBusinessKey()).getBusinessEntityVector().get(0); + + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + + Hashtable servicesHash = new Hashtable(); + Vector backupBusServiceVector = new Vector(); + switch (operation) + { + case UDDIActionInputs.MANAGE_REFERENCED_SERVICES_OPERATION_ADD: + Vector services = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SERVICES); + for (int i=0;i<services.size();i++) + { + ListElement serviceListElement = (ListElement)services.elementAt(i); + BusinessService bs = (BusinessService)serviceListElement.getObject(); + servicesHash.put(bs.getServiceKey(),bs); + } + + // Save the current list of BusinessServices for rollback operations. + backupAndUpdateBusinessServices(backupBusServiceVector,sp,servicesHash,true); + + try + { + Vector beVector = new Vector(); + beVector.add(sp); + sp = (BusinessEntity)proxy.save_business(regElement.getAuthInfoString(), beVector).getBusinessEntityVector().get(0); + for (int i=0;i<services.size();i++) + { + ListElement serviceElement = (ListElement)services.elementAt(i); + BusinessService bs = (BusinessService)serviceElement.getObject(); + String bsName = bs.getDefaultNameString(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_REFERENCED",bsName)); + services.removeElementAt(i); + i--; + } + } + catch (TransportException e) + { + // Roll back and restore the old list of services. + rollbackBusinessServices(sp,backupBusServiceVector,services,uddiPerspective,messageQueue,"MSG_ERROR_SERVICE_NOT_REFERENCED"); + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + operationResult = false; + } + catch (UDDIException e) + { + // Roll back and restore the old list of services. + rollbackBusinessServices(sp,backupBusServiceVector,services,uddiPerspective,messageQueue,"MSG_ERROR_SERVICE_NOT_REFERENCED"); + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + operationResult = false; + } + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_SERVICES,services); + break; + case UDDIActionInputs.MANAGE_REFERENCED_SERVICES_OPERATION_REMOVE: + String[] referencedServicesCheckboxes = (String[])propertyTable_.get(UDDIActionInputs.REFERENCED_SERVICE_SELECT_STATE); + Vector selectedReferencedServiceVector = new Vector(); + for (int i=0;i<referencedServicesCheckboxes.length;i++) + { + boolean isChecked = Boolean.valueOf(referencedServicesCheckboxes[i]).booleanValue(); + if (isChecked) + { + ListElement referencedServiceListElement = (ListElement)referencedServices.elementAt(i); + BusinessService bs = (BusinessService)referencedServiceListElement.getObject(); + servicesHash.put(bs.getServiceKey(),bs); + selectedReferencedServiceVector.addElement(bs); + } + } + + // Save the current list of business services for rollback operations. + backupAndUpdateBusinessServices(backupBusServiceVector,sp,servicesHash,false); + + try + { + Vector beVector = new Vector(); + beVector.add(sp); + sp = (BusinessEntity)proxy.save_business(regElement.getAuthInfoString(), beVector).getBusinessEntityVector().get(0); + for (int i=0;i<selectedReferencedServiceVector.size();i++) + { + BusinessService bs = (BusinessService)selectedReferencedServiceVector.elementAt(i); + String bsName = bs.getDefaultNameString(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_REFERENCE_REMOVED",bsName)); + } + } + catch (TransportException e) + { + // Roll back and restore the old list of services. + rollbackBusinessServices(sp,backupBusServiceVector,selectedReferencedServiceVector,uddiPerspective,messageQueue,"MSG_ERROR_REFERENCE_NOT_REMOVED"); + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + operationResult = false; + } + catch (UDDIException e) + { + // Roll back and restore the old list of services. + rollbackBusinessServices(sp,backupBusServiceVector,selectedReferencedServiceVector,uddiPerspective,messageQueue,"MSG_ERROR_REFERENCE_NOT_REMOVED"); + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + operationResult = false; + } + } + // Ensure that the referenced services are refreshed when the form reloads. + formToolPI.removeProperty(UDDIActionInputs.QUERY_INPUT_REFERENCED_SERVICES); + busElement.setBusinessEntity(sp); + return operationResult; + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + operationResult = false; + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + operationResult = false; + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + operationResult = false; + } + return operationResult; + } + + public final boolean isSubQueryInitiated() + { + return subQueryInitiated_; + } + + public final boolean isSubQueryGet() + { + return isSubQueryGet_; + } + + public final String getSubQueryKey() + { + return subQueryKey_; + } + + public final String getNewSubQuery() + { + return newSubQuery_; + } + + public final String getNewSubQueryItem() + { + return newSubQueryItem_; + } + + // Backup the business services and remove those in serviceHash from the current list. Return the updated list of business services + private final void backupAndUpdateBusinessServices(Vector backupBusServiceVector,BusinessEntity be,Hashtable servicesHash,boolean isAdd) + { + // Save the current list of business services for rollback operations. + BusinessServices currentBusServices = be.getBusinessServices(); + if (currentBusServices == null) + currentBusServices = new BusinessServices(); + Vector currentBusServiceVector = currentBusServices.getBusinessServiceVector(); + for (int i=0;i<currentBusServiceVector.size();i++) + { + BusinessService currentBusService = (BusinessService)currentBusServiceVector.elementAt(i); + backupBusServiceVector.addElement(currentBusService); + // If the current business service is a member of the list to be removed/added, remove it now. + if (servicesHash.get(currentBusService.getServiceKey()) != null) + { + currentBusServiceVector.removeElementAt(i); + i--; + } + } + + if (isAdd) + { + Enumeration e = servicesHash.elements(); + while (e.hasMoreElements()) + currentBusServiceVector.addElement((BusinessService)e.nextElement()); + } + be.setBusinessServices(currentBusServices); + } + + private final void rollbackBusinessServices(BusinessEntity be,Vector backupBusServiceVector,Vector operatedServices,Perspective perspective,MessageQueue messageQueue,String errorMessageKey) + { + // Roll back and restore the old list of services. + be.getBusinessServices().setBusinessServiceVector(backupBusServiceVector); + for (int i=0;i<operatedServices.size();i++) + { + ListElement serviceListElement = (ListElement)operatedServices.elementAt(i); + BusinessService bs = (BusinessService)serviceListElement.getObject(); + String bsName = bs.getDefaultNameString(); + messageQueue.addMessage(perspective.getMessage(errorMessageKey,bsName)); + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/OpenCategoryBrowserAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/OpenCategoryBrowserAction.java new file mode 100644 index 000000000..55573c624 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/OpenCategoryBrowserAction.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import javax.servlet.http.*; + +public class OpenCategoryBrowserAction extends Action +{ + public OpenCategoryBrowserAction() + { + } + + private static final void addSessionAndTModelKey(StringBuffer result,String sessionId,String categoryTModelKey) + { + result.append(ActionInputs.SESSIONID).append('=').append(sessionId).append('&').append(UDDIActionInputs.CATEGORY_TMODEL_KEY).append('=').append(categoryTModelKey); + } + + // uddi/category_browser.jsp?sessionId=...&categoryTModelKey=... + public static final String getActionLink(String sessionId,String categoryTModelKey) + { + StringBuffer actionLink = new StringBuffer("uddi/category_browser.jsp?"); + addSessionAndTModelKey(actionLink,sessionId,categoryTModelKey); + return actionLink.toString(); + } + + public static final String getCategoryContentPage(String sessionId,String categoryTModelKey) + { + StringBuffer actionLink = new StringBuffer("uddi/category_content.jsp?"); + addSessionAndTModelKey(actionLink,sessionId,categoryTModelKey); + return actionLink.toString(); + } + + public static final String getWildCardActionLink(String sessionId) + { + return getActionLink(sessionId,"%"); + } + + public final boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public final boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/OpenRegistryAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/OpenRegistryAction.java new file mode 100644 index 000000000..e07820f97 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/OpenRegistryAction.java @@ -0,0 +1,232 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.tmodel.*; +import org.uddi4j.transport.*; +import org.uddi4j.response.*; +import org.uddi4j.util.*; +import org.uddi4j.*; + +import java.util.*; +import java.net.*; + +public class OpenRegistryAction extends UDDIPropertiesFormAction +{ + public OpenRegistryAction(Controller controller) + { + super(controller); + // Select UDDI Main. + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String registryName = parser.getParameter(UDDIActionInputs.REGISTRY_NAME); + String inquiryURL = parser.getParameter(UDDIActionInputs.INQUIRY_URL); + String publishURL = parser.getParameter(UDDIActionInputs.PUBLISH_URL); + String username = parser.getParameter(UDDIActionInputs.UDDI_USERNAME); + String password = parser.getParameter(UDDIActionInputs.UDDI_PASSWORD); + String checkUserDefinedCategoriesChecked = parser.getParameter(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES); + String categoriesDirectory = parser.getParameter(UDDIActionInputs.CATEGORIES_DIRECTORY); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + if (registryName != null) + propertyTable_.put(UDDIActionInputs.REGISTRY_NAME,registryName); + + if (!Validator.validateString(registryName)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.REGISTRY_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_REGISTRY_NAME")); + } + + if (inquiryURL != null) + propertyTable_.put(UDDIActionInputs.INQUIRY_URL,inquiryURL); + if (!Validator.validateURL(inquiryURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.INQUIRY_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_INQUIRY_URL")); + } + + if (publishURL != null) + propertyTable_.put(UDDIActionInputs.PUBLISH_URL, publishURL); + + if (username != null) + propertyTable_.put(UDDIActionInputs.UDDI_USERNAME, username); + + if (password != null) + propertyTable_.put(UDDIActionInputs.UDDI_PASSWORD, password); + + if (checkUserDefinedCategoriesChecked != null) + propertyTable_.put(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES,checkUserDefinedCategoriesChecked); + else + removeProperty(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES); + + if (categoriesDirectory != null) + propertyTable_.put(UDDIActionInputs.CATEGORIES_DIRECTORY,categoriesDirectory); + else + removeProperty(UDDIActionInputs.CATEGORIES_DIRECTORY); + + formTool.updatePropertyTable(propertyTable_); + return inputsValid; + } + + public final void gatherWSUserDefinedCategories(UDDIProxy proxy,Hashtable categoryModels) + { + try + { + CategoryBag categoryBag = new CategoryBag(); + categoryBag.add(new KeyedReference("","categorization",TModel.TYPES_TMODEL_KEY)); + TModelList tModelList = proxy.find_tModel("%",categoryBag,null,null,100); + TModelInfos tModelInfos = tModelList.getTModelInfos(); + Vector tModelKeyVector = new Vector(); + for (int i=0;i<tModelInfos.size();i++) + { + TModelInfo tModelInfo = tModelInfos.get(i); + tModelKeyVector.addElement(tModelInfo.getTModelKey()); + } + TModelDetail tModelDetail = proxy.get_tModelDetail(tModelKeyVector); + Vector tModelVector = tModelDetail.getTModelVector(); + for (int i=0;i<tModelVector.size();i++) + { + TModel tModel = (TModel)tModelVector.elementAt(i); + boolean checked = false; + String displayName = null; + String categoryKey = null; + categoryBag = tModel.getCategoryBag(); + for (int j=0;j<categoryBag.size();j++) + { + KeyedReference kr = categoryBag.get(j); + String krTModelKey = kr.getTModelKey(); + if (krTModelKey.equalsIgnoreCase(TModel.GENERAL_KEYWORDS_TMODEL_KEY)) + { + String krKeyName = kr.getKeyName(); + if (krKeyName.equals("urn:x-ibm:uddi:customTaxonomy:key")) + categoryKey = kr.getKeyValue(); + else if (krKeyName.equals("urn:x-ibm:uddi:customTaxonomy:displayName")) + displayName = kr.getKeyValue(); + } + else if (krTModelKey.equalsIgnoreCase(TModel.TYPES_TMODEL_KEY)) + checked = kr.getKeyValue().equals("checked"); + } + if (categoryKey != null) + { + if (displayName == null) + displayName = tModel.getNameString(); + CategoryModel categoryModel = new CategoryModel(); + categoryModel.setCategoryKey(categoryKey); + categoryModel.enableChecked(checked); + categoryModel.setDisplayName(displayName); + String tModelKey = tModel.getTModelKey(); + categoryModel.setTModelKey(tModelKey); + categoryModels.put(tModelKey,categoryModel); + } + } + } + catch (UDDIException e) + { + } + catch (TransportException e) + { + } + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String registryName = (String)propertyTable_.get(UDDIActionInputs.REGISTRY_NAME); + String inquiryURL = (String)propertyTable_.get(UDDIActionInputs.INQUIRY_URL); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.PUBLISH_URL); + String registrationURL = (String)propertyTable_.get(UDDIActionInputs.REGISTRATION_URL); + String username = (String)propertyTable_.get(UDDIActionInputs.UDDI_USERNAME); + String password = (String)propertyTable_.get(UDDIActionInputs.UDDI_PASSWORD); + boolean checkForUserDefinedCategoriesChecked = (propertyTable_.get(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES) != null); + String categoriesDirectory = (String)propertyTable_.get(UDDIActionInputs.CATEGORIES_DIRECTORY); + + String recognizedPublishURL = uddiPerspective.getKnownRegistryPublishURL(inquiryURL); + String recognizedRegistrationURL = uddiPerspective.getKnownRegistryRegistrationURL(inquiryURL); + + if (publishURL == null) + publishURL = recognizedPublishURL; + if (registrationURL == null) + registrationURL = recognizedRegistrationURL; + + UDDIMainNode uddiMainNode = (UDDIMainNode)(controller_.getUDDIPerspective().getNavigatorManager().getRootNode()); + UDDIMainElement uddiMainElement = (UDDIMainElement)uddiMainNode.getTreeElement(); + Properties props = new Properties(); + props.put(ActionInputs.TRANSPORT_CLASS_NAME, ActionInputs.TRASPORT_CLASS); + UDDIProxy proxy = new UDDIProxy(props); + proxy.setInquiryURL(new URL(inquiryURL)); + RegistryElement registryElement = new RegistryElement(proxy,inquiryURL,registryName,uddiMainElement.getModel()); + // Set registry element's publish URL and registration URL provided by external callers (e.g. favorites). + if (publishURL != null) + registryElement.setCachedPublishURL(publishURL); + if (registrationURL != null) + registryElement.setRegistrationURL(registrationURL); + if (username != null) + registryElement.setUserId(username); + if (password != null) + registryElement.setCred(password); + registryElement.setCheckForUserDefinedCategories(checkForUserDefinedCategoriesChecked); + if (checkForUserDefinedCategoriesChecked) + { + Hashtable categoryModels = new Hashtable(); + gatherWSUserDefinedCategories(proxy,categoryModels); + if (categoryModels.size() > 0) + registryElement.setUserDefinedCategories(categoryModels); + else + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_NO_USER_DEFINED_CATEGORIES_FOUND")); + } + registryElement.setCategoriesDirectory(categoriesDirectory); + uddiMainElement.connect(registryElement,UDDIModelConstants.REL_REGISTRIES,ModelConstants.REL_OWNER); + NodeManager nodeManager = uddiMainNode.getNodeManager(); + int newRegistryNodeId = uddiMainNode.getChildNode(registryElement).getNodeId(); + // Select the new registry node and add the select action to the history. + nodeManager.setSelectedNodeId(newRegistryNodeId); + Node registryNode = nodeManager.getSelectedNode(); + ToolManager toolManager = registryNode.getCurrentToolManager(); + addToHistory(ActionInputs.PERSPECTIVE_UDDI,toolManager.getSelectedTool().getSelectToolActionHref(true)); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_REGISTRY_OPENED",new String[]{registryName,inquiryURL})); + return true; + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + FormTool formTool = getSelectedFormTool(); + formTool.flagError(UDDIActionInputs.INQUIRY_URL); + } + /* + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + */ + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/PublishAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/PublishAction.java new file mode 100644 index 000000000..01a22061e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/PublishAction.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.MultipartFormDataParserTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +import java.util.*; + +public abstract class PublishAction extends UDDIPropertiesFormAction +{ + protected String subQueryKey_; + protected boolean subQueryInitiated_; + protected String newSubQuery_; + protected boolean isSubQueryGet_; + protected String newSubQueryItem_; + protected RegistryNode regNode_; + + public PublishAction(Controller controller) + { + super(controller); + subQueryKey_ = null; + isSubQueryGet_ = false; + subQueryInitiated_ = false; + regNode_ = getRegistryNode(); + } + + protected abstract boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException; + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + // Setup for MultipartFormDataParserTransformer + propertyTable_.put(ActionInputs.MULTIPART_FORM_DATA_PARSER, parser); + + newSubQuery_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_INITIATED); + String isSubQueryGetString = parser.getParameter(UDDIActionInputs.SUBQUERY_GET); + newSubQueryItem_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_QUERY_ITEM); + subQueryKey_ = parser.getParameter(UDDIActionInputs.SUBQUERY_KEY); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + formToolPI.clearErrors(); + + if (newSubQuery_ != null && newSubQuery_.length() > 0) + subQueryInitiated_ = true; + else + subQueryInitiated_ = false; + + if (isSubQueryGetString != null) + isSubQueryGet_ = Boolean.valueOf(isSubQueryGetString).booleanValue(); + + if (!processOthers(parser,formToolPI) && !subQueryInitiated_) + inputsValid = false; + + for (int i=0;i<removedProperties_.size();i++) + formToolPI.removeProperty(removedProperties_.elementAt(i)); + formToolPI.updatePropertyTable(propertyTable_); + + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + + boolean validateAuthentication = !regElement.isLoggedIn(); + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (!subQueryInitiated_ && validateAuthentication && !Validator.validateString(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userId != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + } + + if (!subQueryInitiated_ && validateAuthentication && !Validator.validateString(userId)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + + return inputsValid; + } + + protected final void addPublishedItemNode(BusinessEntity be,RegistryElement regElement) + { + BusinessElement beElement = new BusinessElement(be,regElement.getModel()); + PublishedItemsElement publishedBusinessesElement = regElement.getPublishedBusinessesElement(); + Enumeration e = publishedBusinessesElement.getItems(); + while (e.hasMoreElements()) + { + BusinessElement element = (BusinessElement)e.nextElement(); + BusinessEntity elementBE = element.getBusinessEntity(); + if (elementBE.getBusinessKey().equals(be.getBusinessKey())) + { + element.disconnectAll(); + break; + } + } + connectElements(publishedBusinessesElement,beElement); + } + + protected final void addPublishedItemNode(BusinessService bs,RegistryElement regElement) + { + ServiceElement sElement = new ServiceElement(bs,regElement.getModel()); + PublishedItemsElement publishedServicesElement = regElement.getPublishedServicesElement(); + Enumeration e = publishedServicesElement.getItems(); + while (e.hasMoreElements()) + { + ServiceElement element = (ServiceElement)e.nextElement(); + BusinessService elementBS = element.getBusinessService(); + if (elementBS.getServiceKey().equals(bs.getServiceKey())) + { + element.disconnectAll(); + break; + } + } + connectElements(publishedServicesElement,sElement); + } + + protected final void addPublishedItemNode(TModel tModel,RegistryElement regElement) + { + ServiceInterfaceElement siElement = new ServiceInterfaceElement(tModel,regElement.getModel()); + PublishedItemsElement publishedServiceInterfacesElement = regElement.getPublishedServiceInterfacesElement(); + Enumeration e = publishedServiceInterfacesElement.getItems(); + while (e.hasMoreElements()) + { + ServiceInterfaceElement element = (ServiceInterfaceElement)e.nextElement(); + TModel elementTModel = element.getTModel(); + if (tModel.getTModelKey().equals(elementTModel.getTModelKey())) + { + element.disconnectAll(); + break; + } + } + connectElements(publishedServiceInterfacesElement,siElement); + } + + private final void connectElements(PublishedItemsElement publishedItemsElement,TreeElement itemElement) + { + publishedItemsElement.connect(itemElement,UDDIModelConstants.REL_PUBLISHED_ITEMS,ModelConstants.REL_OWNER); + int newNodeId = regNode_.getChildNode(publishedItemsElement).getChildNode(itemElement).getNodeId(); + NodeManager nodeManager = regNode_.getNodeManager(); + nodeManager.setSelectedNodeId(newNodeId); + Node newNode = nodeManager.getSelectedNode(); + ToolManager toolManager = newNode.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + addToHistory(ActionInputs.PERSPECTIVE_UDDI,selectedTool.getSelectToolActionHref(true)); + } + + public final boolean isSubQueryInitiated() + { + return subQueryInitiated_; + } + + public final boolean isSubQueryGet() + { + return isSubQueryGet_; + } + + public final String getSubQueryKey() + { + return subQueryKey_; + } + + public final String getNewSubQuery() + { + return newSubQuery_; + } + + public final String getNewSubQueryItem() + { + return newSubQueryItem_; + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length + 1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length - 1] = new MultipartFormDataParserTransformer(controller_); + return transformers; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RefreshUDDINodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RefreshUDDINodeAction.java new file mode 100644 index 000000000..489bc0102 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RefreshUDDINodeAction.java @@ -0,0 +1,239 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +import java.util.*; + +public class RefreshUDDINodeAction extends UDDINodeAction +{ + private Vector staleNodes_; + public RefreshUDDINodeAction(Controller controller) + { + super(controller); + propertyTable_.put(ActionInputs.NODEID,String.valueOf(controller.getUDDIPerspective().getNavigatorManager().getSelectedNodeId())); + staleNodes_ = new Vector(); + } + + // uddi/actions/RefreshUDDINodeActionJSP.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/RefreshUDDINodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean verifyNodeData() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + Node node = nodeManager_.getNode(nodeId); + if (node instanceof BusinessNode) + return refreshBusinessElement((BusinessNode)node); + else if (node instanceof ServiceNode) + return refreshServiceElement((ServiceNode)node); + else if (node instanceof ServiceInterfaceNode) + return refreshServiceInterfaceElement((ServiceInterfaceNode)node); + else if (node instanceof QueryNode) + { + // Nothing to verify + return true; + } + else if (node != null) + { + // RegistryNode + if (node instanceof RegistryNode) + refreshRegistryElement((RegistryNode)node); + + // FolderNodes + Vector childNodes = node.getChildNodes(); + Vector refreshActions = new Vector(); + for (int i=0;i<childNodes.size();i++) + { + Node childNode = (Node)childNodes.elementAt(i); + RefreshUDDINodeAction action = new RefreshUDDINodeAction(controller_); + action.setStaleNodes(staleNodes_); + Hashtable propertyTable = action.getPropertyTable(); + String childNodeIdString = String.valueOf(childNode.getNodeId()); + propertyTable.put(ActionInputs.NODEID,childNodeIdString); + if (!action.verifyNodeData()) + staleNodes_.addElement(childNode); + else + refreshActions.addElement(action); + } + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,refreshActions); + return true; + } + return true; + } + + private final void refreshRegistryElement(RegistryNode regNode) + { + RegistryElement regElement = (RegistryElement)regNode.getTreeElement(); + Hashtable userDefinedCategories = null; + if (regElement.getCheckForUserDefinedCategories()) + { + userDefinedCategories = new Hashtable(); + OpenRegistryAction openRegAction = new OpenRegistryAction(controller_); + openRegAction.gatherWSUserDefinedCategories(regElement.getProxy(),userDefinedCategories); + if (!userDefinedCategories.keys().hasMoreElements()) + { + userDefinedCategories = null; + regNode.setImagePath(RegistryNode.IMAGE_PATH_STANDARD); + } + else + { + String categoriesDirectory = regElement.getCategoriesDirectory(); + AddRegistryToUDDIPerspectiveAction addAction = new AddRegistryToUDDIPerspectiveAction(controller_); + if (categoriesDirectory != null) + addAction.linkCategoryModelsWithSavedData(userDefinedCategories.elements(),categoriesDirectory); + else + addAction.linkCategoryModelsWithSavedData(regElement.getName(),userDefinedCategories.elements()); + regNode.setImagePath(RegistryNode.IMAGE_PATH_WITH_USER_DEFINED_CATEGORIES); + } + } + regElement.setUserDefinedCategories(userDefinedCategories); + } + + private final boolean refreshBusinessElement(BusinessNode busNode) + { + BusinessElement busElement = (BusinessElement)busNode.getTreeElement(); + String uuidKey = busElement.getBusinessEntity().getBusinessKey(); + RegFindBusinessUUIDAction verifyAction = new RegFindBusinessUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,uuidKey); + propertyTable.put(UDDIActionInputs.REFRESH_NODE,busNode); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + boolean verifyResult = verifyAction.run(); + if (verifyResult) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,new BusinessElement((BusinessEntity)propertyTable.get(UDDIActionInputs.LATEST_OBJECT),busElement.getModel())); + return verifyResult; + } + + private final boolean refreshServiceElement(ServiceNode serviceNode) + { + ServiceElement serviceElement = (ServiceElement)serviceNode.getTreeElement(); + String uuidKey = serviceElement.getBusinessService().getServiceKey(); + RegFindServiceUUIDAction verifyAction = new RegFindServiceUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,uuidKey); + propertyTable.put(UDDIActionInputs.REFRESH_NODE,serviceNode); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + boolean verifyResult = verifyAction.run(); + if (verifyResult) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,new ServiceElement((BusinessService)propertyTable.get(UDDIActionInputs.LATEST_OBJECT),serviceElement.getModel())); + return verifyResult; + } + + private final boolean refreshServiceInterfaceElement(ServiceInterfaceNode siNode) + { + ServiceInterfaceElement siElement = (ServiceInterfaceElement)siNode.getTreeElement(); + String uuidKey = siElement.getTModel().getTModelKey(); + RegFindServiceInterfaceUUIDAction verifyAction = new RegFindServiceInterfaceUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY,uuidKey); + propertyTable.put(UDDIActionInputs.REFRESH_NODE,siNode); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + boolean verifyResult = verifyAction.run(); + if (verifyResult) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,new ServiceInterfaceElement((TModel)propertyTable.get(UDDIActionInputs.LATEST_OBJECT),siElement.getModel())); + return verifyResult; + } + + public final void connectElements(Node parentNode,TreeElement newElement) + { + TreeElement parentElement = parentNode.getTreeElement(); + String rel = null; + if (parentNode instanceof PublishedItemsNode) + rel = UDDIModelConstants.REL_PUBLISHED_ITEMS; + else if (parentNode instanceof QueryNode) + rel = UDDIModelConstants.REL_QUERY_RESULTS; + else if (parentNode instanceof QueryParentNode) + rel = UDDIModelConstants.REL_QUERIES; + parentElement.connect(newElement,rel,ModelConstants.REL_OWNER); + Node newNode = parentNode.getChildNode(newElement); + int newNodeId = newNode.getNodeId(); + nodeManager_.setSelectedNodeId(newNodeId); + ToolManager toolManager = newNode.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + addToHistory(ActionInputs.PERSPECTIVE_UDDI,selectedTool.getSelectToolActionHref(true)); + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + if (!isStaleNode(nodeId)) + { + Node node = nodeManager_.getNode(nodeId); + Object latestObject = propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + if (latestObject != null) + { + if (latestObject instanceof Vector) + { + Vector refreshActions = (Vector)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + for (int i=0;i<refreshActions.size();i++) + { + RefreshUDDINodeAction refreshAction = (RefreshUDDINodeAction)refreshActions.elementAt(i); + refreshAction.run(); + } + nodeManager_.setSelectedNodeId(nodeId); + } + else + { + TreeElement oldElement = node.getTreeElement(); + oldElement.disconnectAll(); + connectElements(node.getParent(),(TreeElement)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT)); + } + } + else + { + // QueryNodes + QueryNode queryNode = (QueryNode)node; + FindAction findAction = queryNode.getFindAction(); + findAction.setRefreshAction(true); + if (!findAction.run()) + queryNode.removeChildNodes(true); + findAction.setRefreshAction(false); + } + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_NODE_REFRESHED",node.getNodeName())); + return true; + } + return false; + } + + public final Vector getStaleNodes() + { + return staleNodes_; + } + + public final void setStaleNodes(Vector staleNodes) + { + staleNodes_ = staleNodes; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RefreshUDDINodesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RefreshUDDINodesAction.java new file mode 100644 index 000000000..4b3d246e9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RefreshUDDINodesAction.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +public class RefreshUDDINodesAction extends UDDIPropertiesFormAction +{ + private Vector staleNodes_; + + public RefreshUDDINodesAction(Controller controller) + { + super(controller); + staleNodes_ = new Vector(); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String[] selectedNodeIds = parser.getParameterValues(ActionInputs.NODEID); + // The client Javascript enforces the rule that at least one item was selected before the form can be submitted. + propertyTable_.put(UDDIActionInputs.SELECTED_NODEIDS,selectedNodeIds); + return true; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + int collectorNodeId = getSelectedNavigatorNode().getNodeId(); + String[] selectedNodeIds = (String[])propertyTable_.get(UDDIActionInputs.SELECTED_NODEIDS); + RefreshUDDINodeAction action = new RefreshUDDINodeAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + for (int i=0;i<selectedNodeIds.length;i++) + { + propertyTable.put(ActionInputs.NODEID,selectedNodeIds[i]); + if (action.verifyNodeData()) + action.run(); + else + { + int nodeId = Integer.parseInt(selectedNodeIds[i]); + staleNodes_.addElement(navigatorManager.getNode(nodeId)); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NODE_DATA_VALIDATION_FAILED",navigatorManager.getNode(nodeId).getNodeName())); + } + } + navigatorManager.setSelectedNodeId(collectorNodeId); + return true; + } + + public final Vector getStaleNodes() + { + return staleNodes_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessUUIDAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessUUIDAction.java new file mode 100644 index 000000000..34223f5dd --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessUUIDAction.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.transport.TransportException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.business.BusinessEntity; + +import java.util.*; + +public class RegFindBusinessUUIDAction extends FindAction +{ + public RegFindBusinessUUIDAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_BUSINESSES,String.valueOf(UDDIActionInputs.QUERY_STYLE_UUID)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String uuidKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_KEY); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (uuidKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,uuidKey); + + if (!subQueryInitiated_ && !Validator.validateString(uuidKey)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_UUID_KEY")); + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + String uuidKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + + // The action can be run under the context of either a registry or a query node or even UDDIMainNode. + if (regNode_ == null) + regNode_ = getRegistryNode((Node)propertyTable_.get(UDDIActionInputs.REFRESH_NODE)); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + BusinessEntity[] beList = new BusinessEntity[1]; + Vector beVector = proxy.get_businessDetail(uuidKey).getBusinessEntityVector(); + if (beVector.size() > 0) + { + beVector.toArray(beList); + if (shouldAddQueryNode) + { + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(beList,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESSES_FOUND",String.valueOf(beList.length))); + } + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,beList[0]); + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_BUSINESSES_FOUND")); + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessesAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessesAdvancedAction.java new file mode 100644 index 000000000..c4f8fc1d7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessesAdvancedAction.java @@ -0,0 +1,303 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.FormInputException; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.transport.TransportException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.*; +import org.uddi4j.response.BusinessInfo; +import org.uddi4j.response.BusinessInfos; +import org.uddi4j.util.*; + +import java.util.*; +import java.net.MalformedURLException; + +public class RegFindBusinessesAdvancedAction extends FindAction +{ + public RegFindBusinessesAdvancedAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_BUSINESSES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_SEARCH_SET,String.valueOf(UDDIActionInputs.QUERY_MAX_SEARCH_SET)); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_RESULTS,String.valueOf(UDDIActionInputs.QUERY_MAX_RESULTS)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String ownedChecked = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_OWNED); + String[] languages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME_LANGUAGE); + String[] names = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME); + String[] idTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE); + String[] idKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME); + String[] idKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + String[] siNodeIds = parser.getParameterValues(UDDIActionInputs.NODEID_SERVICE_INTERFACE); + String[] discoveryURLValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DISCOVERYURL); + String[] findQualifierValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_FINDQUALIFIER); + String maxSearchSet = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_SEARCH_SET); + String maxResults = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_RESULTS); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + Node selectedNode = getSelectedNavigatorNode(); + Node regNode = getRegistryNode(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + + if (ownedChecked != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_OWNED,ownedChecked); + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_OWNED); + + if (languages != null && names != null) + { + Vector nameVector = new Vector(); + for (int i=0;i<names.length;i++) + { + Name uddi4jName; + if (languages[i].length() > 0) + uddi4jName = new Name(names[i],languages[i]); + else + uddi4jName = new Name(names[i]); + nameVector.addElement(uddi4jName); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,nameVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + + if (idTypes != null && idKeyNames != null && idKeyValues != null) + { + IdentifierBag idBag = new IdentifierBag(); + for (int i=0;i<idKeyNames.length;i++) + { + KeyedReference kr = new KeyedReference(idKeyNames[i],idKeyValues[i],idTypes[i]); + idBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS,idBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + + if (catTypes != null && catKeyNames != null && catKeyValues != null) + { + CategoryBag catBag = new CategoryBag(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + catBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES,catBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + + if (siNodeIds != null) + { + // Although we already have the "submitted" data, deletions occur on the client side and thus the need to track this using hidden form elements. + Vector busServiceInterfaces = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES); + if (busServiceInterfaces == null) + busServiceInterfaces = new Vector(); + else + busServiceInterfaces.removeAllElements(); + Vector busServiceInterfacesCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES_COPY); + Vector tModelKeyStringVector = new Vector(); + Hashtable resultHash = new Hashtable(); + for (int i=0;i<siNodeIds.length;i++) + resultHash.put(siNodeIds[i],Boolean.TRUE); + for (int i=0;i<busServiceInterfacesCopy.size();i++) + { + ListElement listElement = (ListElement)busServiceInterfacesCopy.elementAt(i); + if (resultHash.get(String.valueOf(listElement.getTargetNodeId())) != null) + { + busServiceInterfaces.addElement(listElement); + TModel tModel = (TModel)listElement.getObject(); + tModelKeyStringVector.addElement(tModel.getTModelKey()); + } + } + TModelBag tModelBag = new TModelBag(tModelKeyStringVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES,busServiceInterfaces); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_TMODELBAG,tModelBag); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES); + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_TMODELBAG); + } + + if (discoveryURLValues != null) + { + DiscoveryURLs discoveryURLs = new DiscoveryURLs(); + Vector discoveryURLVector = new Vector(); + for (int i=0;i<discoveryURLValues.length;i++) + { + DiscoveryURL discoveryURL = new DiscoveryURL(discoveryURLValues[i],""); + discoveryURLVector.addElement(discoveryURL); + } + discoveryURLs.setDiscoveryURLVector(discoveryURLVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS,discoveryURLs); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + + if (findQualifierValues != null) + { + FindQualifiers findQualifiers = new FindQualifiers(); + Vector findQualifierVector = new Vector(); + for (int i=0;i<findQualifierValues.length;i++) + { + FindQualifier findQualifier = new FindQualifier(findQualifierValues[i]); + findQualifierVector.addElement(findQualifier); + } + findQualifiers.setFindQualifierVector(findQualifierVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_FINDQUALIFIERS,findQualifiers); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_FINDQUALIFIERS); + + if (maxSearchSet != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_SEARCH_SET,maxSearchSet); + if (!subQueryInitiated_ && !Validator.validateInteger(maxSearchSet)) + { + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_SEARCH_SET); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_MAX_SEARCH_SET")); + inputsValid = false; + } + + if (maxResults != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_RESULTS,maxResults); + if (!subQueryInitiated_ && !Validator.validateInteger(maxResults)) + { + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_RESULTS); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_MAX_RESULTS")); + inputsValid = false; + } + return inputsValid; + } + + private DiscoveryURLs dupDiscoveryURLs(DiscoveryURLs discoveryURLs, String useType, String dupUseType) { + if (discoveryURLs == null) + return discoveryURLs; + Vector discoveryURLVector = discoveryURLs.getDiscoveryURLVector(); + if (discoveryURLVector == null) + return discoveryURLs; + Vector newDiscoveryURLVector = new Vector(discoveryURLVector); + Enumeration e = discoveryURLVector.elements(); + while (e.hasMoreElements()) { + DiscoveryURL discoveryURL = (DiscoveryURL)e.nextElement(); + if (discoveryURL.getUseType().equals(useType)) { + newDiscoveryURLVector.add(new DiscoveryURL(discoveryURL.getText(), dupUseType)); + } + } + DiscoveryURLs newDiscoveryURLs = new DiscoveryURLs(); + newDiscoveryURLs.setDiscoveryURLVector(newDiscoveryURLVector); + return newDiscoveryURLs; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + FindQualifiers findQualifiers = (FindQualifiers)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_FINDQUALIFIERS); + Vector nameVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + DiscoveryURLs discoveryURLs = (DiscoveryURLs)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + IdentifierBag identifierBag = (IdentifierBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + CategoryBag categoryBag = (CategoryBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + TModelBag tModelBag = (TModelBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_TMODELBAG); + boolean owned = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_OWNED) != null); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + int maxSearchSet = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_SEARCH_SET)); + int maxResults = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_RESULTS)); + + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (owned && !regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + + UDDIProxy proxy = regElement.getProxy(); + + BusinessInfos busInfos = null; + if (owned) + busInfos = proxy.get_registeredInfo(regElement.getAuthInfoString()).getBusinessInfos(); + else + busInfos = proxy.find_business(nameVector, dupDiscoveryURLs(discoveryURLs,"",UDDIActionInputs.DISCOVERY_URL_TYPE), identifierBag, categoryBag, tModelBag, findQualifiers, maxSearchSet).getBusinessInfos(); + + int finalNumberOfBusinessEntities = Math.min(maxResults, busInfos.size()); + Vector businessKeys = new Vector(); + for (int i = 0; i < finalNumberOfBusinessEntities; i++) + { + BusinessInfo busInfo = (BusinessInfo)busInfos.get(i); + businessKeys.addElement(busInfo.getBusinessKey()); + } + + if (finalNumberOfBusinessEntities > 0) + { + if (shouldAddQueryNode) + { + Vector beVector = proxy.get_businessDetail(businessKeys).getBusinessEntityVector(); + BusinessEntity[] beList = new BusinessEntity[beVector.size()]; + beVector.toArray(beList); + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(beList,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESSES_FOUND",String.valueOf(beList.length))); + } + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_BUSINESSES_FOUND")); + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessesSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessesSimpleAction.java new file mode 100644 index 000000000..00f285a6c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindBusinessesSimpleAction.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.*; +import org.uddi4j.response.BusinessInfo; +import org.uddi4j.response.BusinessInfos; + +import java.util.*; + +public class RegFindBusinessesSimpleAction extends FindAction +{ + public RegFindBusinessesSimpleAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_BUSINESSES,String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME); + + // Validate the data. + boolean inputsValid = true; + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME,name); + else + { + // This shouldn't occur. + inputsValid = false; + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME); + Vector nameVector = new Vector(); + nameVector.addElement(new Name(name)); + + // The action can be run under the context of either a registry or a query node. + Node selectedNode = getSelectedNavigatorNode(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + + BusinessInfos busInfos = proxy.find_business(nameVector, null, null, null, null, null, UDDIActionInputs.QUERY_MAX_SEARCH_SET).getBusinessInfos(); + int finalNumberOfBusinessEntities = Math.min(UDDIActionInputs.QUERY_MAX_RESULTS, busInfos.size()); + Vector businessKeys = new Vector(); + for (int i = 0; i < finalNumberOfBusinessEntities; i++) + { + BusinessInfo busInfo = busInfos.get(i); + businessKeys.addElement(busInfo.getBusinessKey()); + } + + if (finalNumberOfBusinessEntities > 0) + { + if (shouldAddQueryNode) + { + Vector beVector = proxy.get_businessDetail(businessKeys).getBusinessEntityVector(); + BusinessEntity[] beList = new BusinessEntity[beVector.size()]; + beVector.toArray(beList); + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(beList,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESSES_FOUND",String.valueOf(beList.length))); + } + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_BUSINESSES_FOUND")); + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfaceUUIDAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfaceUUIDAction.java new file mode 100644 index 000000000..ead534a14 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfaceUUIDAction.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.UDDIException; + +import java.util.*; + +public class RegFindServiceInterfaceUUIDAction extends FindAction +{ + public RegFindServiceInterfaceUUIDAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,String.valueOf(UDDIActionInputs.QUERY_STYLE_UUID)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String uuidKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_KEY); + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (uuidKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY,uuidKey); + + if (!subQueryInitiated_ && !Validator.validateString(uuidKey)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_UUID_KEY")); + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + String uuidKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY); + + // The action can be run under the context of either a registry or a query node or even UDDIMainNode. + if (regNode_ == null) + regNode_ = getRegistryNode((Node)propertyTable_.get(UDDIActionInputs.REFRESH_NODE)); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + TModelDetail tModelDetail = proxy.get_tModelDetail(uuidKey); + Vector tModelVector = tModelDetail.getTModelVector(); + if (tModelVector.size() > 0) + { + TModel tModel = (TModel)tModelVector.elementAt(0); + if (shouldAddQueryNode) + { + TModel[] tModelArray = new TModel[1]; + tModelArray[0] = tModel; + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(tModelArray,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACES_FOUND",String.valueOf(tModelArray.length))); + } + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,tModel); + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICE_INTERFACES_FOUND")); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfacesAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfacesAdvancedAction.java new file mode 100644 index 000000000..defaddacb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfacesAdvancedAction.java @@ -0,0 +1,363 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.binding.*; +import org.uddi4j.datatype.service.*; +import org.uddi4j.datatype.tmodel.*; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.util.*; +import org.uddi4j.UDDIException; + +import java.util.*; +import java.net.*; + +public class RegFindServiceInterfacesAdvancedAction extends FindAction +{ + public RegFindServiceInterfacesAdvancedAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_SEARCH_SET,String.valueOf(UDDIActionInputs.QUERY_MAX_SEARCH_SET)); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_RESULTS,String.valueOf(UDDIActionInputs.QUERY_MAX_RESULTS)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String useServiceChecked = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE); + String[] serviceNodeIds = parser.getParameterValues(UDDIActionInputs.NODEID_SERVICE); + String ownedChecked = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_OWNED); + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + String[] idTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE); + String[] idKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME); + String[] idKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + String[] findQualifierValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_FINDQUALIFIER); + String maxSearchSet = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_SEARCH_SET); + String maxResults = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_RESULTS); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + + if (useServiceChecked != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE,useServiceChecked); + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE); + + if (serviceNodeIds != null) + { + // Although we already have the "submitted" data, deletions occur on the client side and thus the need to track this using hidden form elements. + Vector siService = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE); + if (siService == null) + siService = new Vector(); + else + siService.removeAllElements(); + Vector siServiceCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE_COPY); + // The browser will enforce the rule of having only one service in this list. + ListElement listElement = (ListElement)siServiceCopy.elementAt(0); + siService.addElement(listElement); + BusinessService bs = (BusinessService)listElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE,siService); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_BUSINESS_SERVICE,bs); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE); + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_BUSINESS_SERVICE); + if (!subQueryInitiated_ && useServiceChecked != null) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_SERVICE")); + } + } + + if (ownedChecked != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_OWNED,ownedChecked); + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_OWNED); + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME,name); + + if (idTypes != null && idKeyNames != null && idKeyValues != null) + { + IdentifierBag idBag = new IdentifierBag(); + for (int i=0;i<idKeyNames.length;i++) + { + KeyedReference kr = new KeyedReference(idKeyNames[i],idKeyValues[i],idTypes[i]); + idBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS,idBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + + if (catTypes != null && catKeyNames != null && catKeyValues != null) + { + CategoryBag catBag = new CategoryBag(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + catBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES,catBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + + if (findQualifierValues != null) + { + FindQualifiers findQualifiers = new FindQualifiers(); + Vector findQualifierVector = new Vector(); + for (int i=0;i<findQualifierValues.length;i++) + { + FindQualifier findQualifier = new FindQualifier(findQualifierValues[i]); + findQualifierVector.addElement(findQualifier); + } + findQualifiers.setFindQualifierVector(findQualifierVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_FINDQUALIFIERS,findQualifiers); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_FINDQUALIFIERS); + + if (maxSearchSet != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_SEARCH_SET,maxSearchSet); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_SEARCH_SET,maxSearchSet); + } + if (!subQueryInitiated_ && !Validator.validateInteger(maxSearchSet)) + { + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_SEARCH_SET); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_MAX_SEARCH_SET")); + inputsValid = false; + } + + if (maxResults != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_RESULTS,maxResults); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_RESULTS,maxResults); + } + if (!subQueryInitiated_ && !Validator.validateInteger(maxResults)) + { + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_RESULTS); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_MAX_RESULTS")); + inputsValid = false; + } + return inputsValid; + } + + public final boolean overrideAuthenticationValidation() + { + return (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE) != null); + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + boolean useService = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE) != null); + BusinessService bs = (BusinessService)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_BUSINESS_SERVICE); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + FindQualifiers findQualifiers = (FindQualifiers)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_FINDQUALIFIERS); + IdentifierBag identifierBag = (IdentifierBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + CategoryBag categoryBag = (CategoryBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + boolean owned = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_OWNED) != null); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + int maxSearchSet = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_SEARCH_SET)); + int maxResults = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_RESULTS)); + + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + Vector tModelKeyVector = new Vector(); + + if (owned) + { + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + tModelKeyVector = findAllOwnedTModels(proxy, regElement.getAuthInfoString(), maxResults); + } + if (useService) + { + BindingTemplates bindingTemplates = bs.getBindingTemplates(); + boolean endSearch = false; + if (bindingTemplates != null) + { + for (int i=0;i<bindingTemplates.size();i++) + { + BindingTemplate bt = bindingTemplates.get(i); + TModelInstanceDetails tModelInstanceDetails = bt.getTModelInstanceDetails(); + for (int j=0;j<tModelInstanceDetails.size();j++) + { + TModelInstanceInfo tModelInstanceInfo = tModelInstanceDetails.get(j); + if (tModelKeyVector.size() < maxResults) + tModelKeyVector.addElement(tModelInstanceInfo.getTModelKey()); + else + { + endSearch = true; + break; + } + } + if (endSearch) + break; + } + } + } + else + { + TModelList tModelList = proxy.find_tModel(name,categoryBag,identifierBag,findQualifiers,maxSearchSet); + TModelInfos tModelInfos = tModelList.getTModelInfos(); + for (int i=0;i<tModelInfos.size();i++) + { + TModelInfo tModelInfo = tModelInfos.get(i); + if (tModelKeyVector.size() < maxResults) + tModelKeyVector.addElement(tModelInfo.getTModelKey()); + else + break; + } + } + + int finalNumberOfTModelKeys = tModelKeyVector.size(); + if (finalNumberOfTModelKeys > 0) + { + if (shouldAddQueryNode) + { + Vector finalTModelVector = new Vector(); + int currentIndex = 0; + int windowSize = finalNumberOfTModelKeys; + while (currentIndex < tModelKeyVector.size()) + { + int subListToIndex = Math.min(currentIndex+windowSize,tModelKeyVector.size()); + try + { + TModelDetail tModelDetail = proxy.get_tModelDetail(new Vector(tModelKeyVector.subList(currentIndex,subListToIndex))); + Vector tModelVector = tModelDetail.getTModelVector(); + for (int i=0;i<tModelVector.size();i++) + finalTModelVector.addElement(tModelVector.elementAt(i)); + if (tModelDetail.getTruncatedBoolean()) + windowSize = tModelVector.size(); + currentIndex += windowSize; + } + catch (UDDIException e) + { + DispositionReport dr = e.getDispositionReport(); + if (((Result) dr.getResultVector().get(0)).getErrInfo().getErrCode() == DispositionReport.E_invalidKeyPassed) + { + String errInfoText = ((Result) dr.getResultVector().get(0)).getErrInfo().getText(); + for (int i=currentIndex;i<subListToIndex;i++) + { + String tModelKey = (String)tModelKeyVector.elementAt(i); + if (errInfoText.indexOf(tModelKey) != -1 || errInfoText.indexOf(tModelKey.toUpperCase()) != -1 || errInfoText.indexOf(tModelKey.toLowerCase()) != -1) + { + tModelKeyVector.removeElementAt(i); + break; + } + } + } + else + throw e; + } + catch (TransportException e) + { + throw e; + } + } + + int finalNumberOfTModels = finalTModelVector.size(); + if (finalNumberOfTModels > 0) + { + TModel[] tModelArray = new TModel[finalNumberOfTModels]; + finalTModelVector.toArray(tModelArray); + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(tModelArray,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACES_FOUND",String.valueOf(tModelArray.length))); + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICE_INTERFACES_FOUND")); + } + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICE_INTERFACES_FOUND")); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } + + // Copied directly from UDDIWSDLProxy's findAllServiceInterfaces() method with minor modifications. The hardcoded strings should NOT be translated. + private final Vector findAllOwnedTModels(UDDIProxy proxy, String authInfoString, int maxResults) throws UDDIException, TransportException + { + RegisteredInfo registeredInfo = null; + + // Get the complete list of owned (registered) info. + // (A RegisteredInfo consists of BusinessInfos and TModelInfos. + // BusinessInfos also contain ServiceInfos.) + registeredInfo = proxy.get_registeredInfo(authInfoString); + + //Create a Vector to add the TModelKeys from the registeredInfo. + Vector tModelKeyList = new Vector(); + + //Get the TModelInfos from the registeredInfo. + TModelInfos tModelInfos = registeredInfo.getTModelInfos(); + + //Get all the TModelKeys from within the TModelInfos + boolean endSearch = false; + for (int i = 0; i < tModelInfos.size(); i++) + { + TModelInfo tModelInfo = tModelInfos.get(i); + if (tModelKeyList.size() < maxResults) + tModelKeyList.addElement(tModelInfo.getTModelKey()); + else + break; + } + return tModelKeyList; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfacesSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfacesSimpleAction.java new file mode 100644 index 000000000..6cc3c1e87 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceInterfacesSimpleAction.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.UDDIException; + +import java.util.*; + +public class RegFindServiceInterfacesSimpleAction extends FindAction +{ + public RegFindServiceInterfacesSimpleAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME,name); + else + { + // This should never occur. + inputsValid = false; + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME); + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + TModelList tModelList = proxy.find_tModel(name,null,null,null,UDDIActionInputs.QUERY_MAX_SEARCH_SET); + TModelInfos tModelInfos = tModelList.getTModelInfos(); + Vector tModelKeyVector = new Vector(); + + for (int i=0;i<tModelInfos.size();i++) + { + TModelInfo tModelInfo = tModelInfos.get(i); + if (tModelKeyVector.size() < UDDIActionInputs.QUERY_MAX_RESULTS) + tModelKeyVector.addElement(tModelInfo.getTModelKey()); + else + break; + } + + if (tModelKeyVector.size() > 0) + { + if (shouldAddQueryNode) + { + TModelDetail tModelDetail = proxy.get_tModelDetail(tModelKeyVector); + Vector tModelVector = tModelDetail.getTModelVector(); + TModel[] tModelArray = new TModel[tModelVector.size()]; + tModelVector.toArray(tModelArray); + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(tModelArray,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACES_FOUND",String.valueOf(tModelArray.length))); + } + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICE_INTERFACES_FOUND")); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceUUIDAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceUUIDAction.java new file mode 100644 index 000000000..207e86876 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServiceUUIDAction.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.UDDIException; + +import java.util.*; + +public class RegFindServiceUUIDAction extends FindAction +{ + public RegFindServiceUUIDAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICES,String.valueOf(UDDIActionInputs.QUERY_STYLE_UUID)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String uuidKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_KEY); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (uuidKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,uuidKey); + + if (!subQueryInitiated_ && !Validator.validateString(uuidKey)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_UUID_KEY")); + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + String uuidKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY); + + // The action can be run under the context of either a registry or a query node or even UDDIMainNode. + if (regNode_ == null) + regNode_ = getRegistryNode((Node)propertyTable_.get(UDDIActionInputs.REFRESH_NODE)); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + BusinessService[] bsArray = new BusinessService[1]; + ServiceDetail serviceDetail = proxy.get_serviceDetail(uuidKey); + Vector bsVector = serviceDetail.getBusinessServiceVector(); + if (bsVector.size() > 0) + { + bsVector.toArray(bsArray); + if (shouldAddQueryNode) + { + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(bsArray,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICES_FOUND",String.valueOf(bsArray.length))); + } + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,bsArray[0]); + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICES_FOUND")); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServicesAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServicesAdvancedAction.java new file mode 100644 index 000000000..08d064c57 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServicesAdvancedAction.java @@ -0,0 +1,376 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.*; +import org.uddi4j.util.*; +import org.uddi4j.UDDIException; + +import java.util.*; +import java.net.*; + +public class RegFindServicesAdvancedAction extends FindAction +{ + public RegFindServicesAdvancedAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_SEARCH_SET,String.valueOf(UDDIActionInputs.QUERY_MAX_SEARCH_SET)); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_RESULTS,String.valueOf(UDDIActionInputs.QUERY_MAX_RESULTS)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String ownedChecked = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_OWNED); + String[] busNodeIds = parser.getParameterValues(UDDIActionInputs.NODEID_BUSINESS); + String[] languages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME_LANGUAGE); + String[] names = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + String[] siNodeIds = parser.getParameterValues(UDDIActionInputs.NODEID_SERVICE_INTERFACE); + String[] findQualifierValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_FINDQUALIFIER); + String maxSearchSet = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_SEARCH_SET); + String maxResults = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_RESULTS); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + + if (ownedChecked != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_OWNED,ownedChecked); + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_OWNED); + + if (busNodeIds != null) + { + // Although we already have the "submitted" data, deletions occur on the client side and thus the need to track this using hidden form elements. + Vector serviceBusiness = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS); + if (serviceBusiness == null) + serviceBusiness = new Vector(); + else + serviceBusiness.removeAllElements(); + Vector serviceBusinessCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS_COPY); + // The browser will enforce the rule of having only one business in this list. + ListElement listElement = (ListElement)serviceBusinessCopy.elementAt(0); + serviceBusiness.addElement(listElement); + BusinessEntity sp = (BusinessEntity)listElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS,serviceBusiness); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER,sp); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS); + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER); + } + + if (languages != null && names != null) + { + Vector nameVector = new Vector(); + for (int i=0;i<names.length;i++) + { + Name uddi4jName; + if (languages[i].length() > 0) + uddi4jName = new Name(names[i],languages[i]); + else + uddi4jName = new Name(names[i]); + nameVector.addElement(uddi4jName); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,nameVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + + if (catTypes != null && catKeyNames != null && catKeyValues != null) + { + CategoryBag catBag = new CategoryBag(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + catBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES,catBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + + if (siNodeIds != null) + { + // Although we already have the "submitted" data, deletions occur on the client side and thus the need to track this using hidden form elements. + Vector serviceServiceInterfaces = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES); + if (serviceServiceInterfaces == null) + serviceServiceInterfaces = new Vector(); + else + serviceServiceInterfaces.removeAllElements(); + Vector serviceServiceInterfacesCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES_COPY); + Vector tModelKeyStringVector = new Vector(); + Hashtable resultHash = new Hashtable(); + for (int i=0;i<siNodeIds.length;i++) + resultHash.put(siNodeIds[i],Boolean.TRUE); + for (int i=0;i<serviceServiceInterfacesCopy.size();i++) + { + ListElement listElement = (ListElement)serviceServiceInterfacesCopy.elementAt(i); + if (resultHash.get(String.valueOf(listElement.getTargetNodeId())) != null) + { + serviceServiceInterfaces.addElement(listElement); + TModel tModel = (TModel)listElement.getObject(); + tModelKeyStringVector.addElement(tModel.getTModelKey()); + } + } + TModelBag tModelBag = new TModelBag(tModelKeyStringVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES,serviceServiceInterfaces); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODELBAG,tModelBag); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES); + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODELBAG); + } + + if (findQualifierValues != null) + { + FindQualifiers findQualifiers = new FindQualifiers(); + Vector findQualifierVector = new Vector(); + for (int i=0;i<findQualifierValues.length;i++) + { + FindQualifier findQualifier = new FindQualifier(findQualifierValues[i]); + findQualifierVector.addElement(findQualifier); + } + findQualifiers.setFindQualifierVector(findQualifierVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_FINDQUALIFIERS,findQualifiers); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_FINDQUALIFIERS); + + if (maxSearchSet != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_SEARCH_SET,maxSearchSet); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_SEARCH_SET,maxSearchSet); + } + if (!subQueryInitiated_ && !Validator.validateInteger(maxSearchSet)) + { + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_SEARCH_SET); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_MAX_SEARCH_SET")); + inputsValid = false; + } + + if (maxResults != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_MAX_RESULTS,maxResults); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_RESULTS,maxResults); + } + if (!subQueryInitiated_ && !Validator.validateInteger(maxResults)) + { + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_RESULTS); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_MAX_RESULTS")); + inputsValid = false; + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + FindQualifiers findQualifiers = (FindQualifiers)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_FINDQUALIFIERS); + BusinessEntity sp = (BusinessEntity)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER); + Vector nameVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + CategoryBag categoryBag = (CategoryBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + TModelBag tModelBag = (TModelBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODELBAG); + boolean owned = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_OWNED) != null); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + int maxSearchSet = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_SEARCH_SET)); + int maxResults = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_RESULTS)); + + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (owned && !regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + + UDDIProxy proxy = regElement.getProxy(); + String businessKey; + if (sp != null) + businessKey = sp.getBusinessKey(); + else + businessKey = ""; + + int finalNumberOfServiceKeys; + Vector serviceKeyVector; + if (owned) + { + serviceKeyVector = findAllOwnedServices(proxy,regElement.getAuthInfoString(),businessKey,maxResults); + finalNumberOfServiceKeys = serviceKeyVector.size(); + } + else + { + ServiceList serviceList = proxy.find_service(businessKey,nameVector,categoryBag,tModelBag,findQualifiers,maxSearchSet); + ServiceInfos sInfos = serviceList.getServiceInfos(); + finalNumberOfServiceKeys = Math.min(maxResults,sInfos.size()); + serviceKeyVector = new Vector(); + for (int i=0;i<finalNumberOfServiceKeys;i++) + { + ServiceInfo sInfo = sInfos.get(i); + serviceKeyVector.addElement(sInfo.getServiceKey()); + } + } + + if (finalNumberOfServiceKeys > 0) + { + if (shouldAddQueryNode) + { + Vector finalBusServiceVector = new Vector(); + int currentIndex = 0; + int windowSize = finalNumberOfServiceKeys; + while (currentIndex < serviceKeyVector.size()) + { + int subListToIndex = Math.min(currentIndex+windowSize,serviceKeyVector.size()); + try + { + ServiceDetail serviceDetail = proxy.get_serviceDetail(new Vector(serviceKeyVector.subList(currentIndex,subListToIndex))); + Vector busServiceVector = serviceDetail.getBusinessServiceVector(); + for (int i=0;i<busServiceVector.size();i++) + finalBusServiceVector.addElement(busServiceVector.elementAt(i)); + if (serviceDetail.getTruncatedBoolean()) + windowSize = busServiceVector.size(); + currentIndex += windowSize; + } + catch (UDDIException e) + { + DispositionReport dr = e.getDispositionReport(); + if (((Result) dr.getResultVector().get(0)).getErrInfo().getErrCode() == DispositionReport.E_invalidKeyPassed) + { + String errInfoText = ((Result) dr.getResultVector().get(0)).getErrInfo().getText(); + for (int i=currentIndex;i<subListToIndex;i++) + { + String serviceKey = (String)serviceKeyVector.elementAt(i); + if (errInfoText.indexOf(serviceKey) != -1 || errInfoText.indexOf(serviceKey.toUpperCase()) != -1 || errInfoText.indexOf(serviceKey.toLowerCase()) != -1) + { + serviceKeyVector.removeElementAt(i); + break; + } + } + } + else + throw e; + } + catch (TransportException e) + { + throw e; + } + } + + int finalNumberOfBusinessServices = finalBusServiceVector.size(); + if (finalNumberOfBusinessServices > 0) + { + BusinessService[] bsArray = new BusinessService[finalNumberOfBusinessServices]; + finalBusServiceVector.toArray(bsArray); + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + queryElement_ = new QueryElement(bsArray,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICES_FOUND",String.valueOf(bsArray.length))); + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICES_FOUND")); + } + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICES_FOUND")); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + } + return false; + } + + // Copied directly from UDDIWSDLProxy's findAllOwnedServices() method with minor modifications. The hardcoded strings should NOT be translated. + private final Vector findAllOwnedServices(UDDIProxy proxy,String authInfoString,String businessKey,int maxResults) throws UDDIException, TransportException + { + RegisteredInfo registeredInfo = null; + + // Get the complete list of owned (registered) info. + // (A RegisteredInfo consists of BusinessInfos and TModelInfos. + // BusinessInfos also contain ServiceInfos.) + registeredInfo = proxy.get_registeredInfo(authInfoString); + + //Create a vector to add the serviceKeys from the registeredInfo to. + Vector serviceKeyList = new Vector(); + + //Get the businessInfos from the registeredInfo. + BusinessInfos businessInfos = registeredInfo.getBusinessInfos(); + + //Get all the serviceKeys from the serviceInfos within the businessInfos, + //and add them to the serviceKeyList. + boolean endSearch = false; + for (int i = 0; i < businessInfos.size(); i++) + { + BusinessInfo businessInfo = businessInfos.get(i); + String currentBusinessKey = businessInfo.getBusinessKey(); + if (businessKey.length() > 0 && currentBusinessKey.equals(businessKey)) + endSearch = true; + ServiceInfos serviceInfos = businessInfo.getServiceInfos(); + for (int j = 0; j < serviceInfos.size(); j++) + { + ServiceInfo serviceInfo = serviceInfos.get(j); + if (serviceInfo.getBusinessKey().equals(currentBusinessKey)) + { + if (serviceKeyList.size() < maxResults) + serviceKeyList.add(serviceInfo.getServiceKey()); + else + { + endSearch = true; + break; + } + } + } + if (endSearch) + break; + } + return serviceKeyList; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServicesSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServicesSimpleAction.java new file mode 100644 index 000000000..05618e42a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegFindServicesSimpleAction.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.*; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.UDDIException; + +import java.util.*; + +public class RegFindServicesSimpleAction extends FindAction +{ + public RegFindServicesSimpleAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICES,String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME); + + // Validate the data. + boolean inputsValid = true; + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME,name); + else + { + // This shouldn't occur. + inputsValid = false; + } + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + boolean shouldAddQueryNode = (propertyTable_.get(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE) == null); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME); + Vector nameVector = new Vector(); + nameVector.addElement(new Name(name)); + + // The action can be run under the context of either a registry or a query node. + Node selectedNode = getSelectedNavigatorNode(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + ServiceList serviceList = proxy.find_service("",nameVector,null,null,null,UDDIActionInputs.QUERY_MAX_SEARCH_SET); + + ServiceInfos sInfos = serviceList.getServiceInfos(); + int finalNumberOfBusinessServices = Math.min(UDDIActionInputs.QUERY_MAX_RESULTS,sInfos.size()); + Vector serviceKeyVector = new Vector(); + for (int i=0;i<finalNumberOfBusinessServices;i++) + { + ServiceInfo sInfo = sInfos.get(i); + serviceKeyVector.addElement(sInfo.getServiceKey()); + } + + if (finalNumberOfBusinessServices > 0) + { + if (shouldAddQueryNode) + { + ServiceDetail serviceDetail = proxy.get_serviceDetail(serviceKeyVector); + Vector businessServiceVector = serviceDetail.getBusinessServiceVector(); + String queryName = (String)propertyTable_.get(UDDIActionInputs.QUERY_NAME); + BusinessService[] bsArray = new BusinessService[finalNumberOfBusinessServices]; + businessServiceVector.toArray(bsArray); + queryElement_ = new QueryElement(bsArray,queryName,regElement.getModel()); + addQueryNode(); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICES_FOUND",String.valueOf(bsArray.length))); + } + return true; + } + else + throw new FormInputException(uddiPerspective.getMessage("MSG_ERROR_NO_SERVICES_FOUND")); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (FormInputException e) + { + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishBusinessAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishBusinessAdvancedAction.java new file mode 100644 index 000000000..001fbad7e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishBusinessAdvancedAction.java @@ -0,0 +1,265 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.*; +import org.uddi4j.util.IdentifierBag; +import org.uddi4j.util.CategoryBag; +import org.uddi4j.util.DiscoveryURLs; +import org.uddi4j.util.DiscoveryURL; +import org.uddi4j.util.KeyedReference; + +import java.util.*; +import java.net.*; + +public class RegPublishBusinessAdvancedAction extends PublishAction +{ + public RegPublishBusinessAdvancedAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_BUSINESSES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String[] nameLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME_LANGUAGE); + String[] names = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME); + String[] descriptionLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE); + String[] descriptions = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION); + String[] idTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE); + String[] idKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME); + String[] idKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + String[] discoveryURLValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DISCOVERYURL); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + Hashtable languageHash = new Hashtable(); + if (nameLanguages != null && names != null) + { + Vector nameVector = new Vector(); + // UDDI's save API (Appendix C of the UDDI V2 Programmers API Specification) requires the following: + // 1) Only the first row can have a blank language. + // 2) Only 1 name per language. + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_NAME"); + for (int i=0;i<names.length;i++) + { + parameters[1] = String.valueOf(i+1); + Name uddi4jName; + if (nameLanguages[i].length() > 0) + uddi4jName = new Name(names[i],nameLanguages[i]); + else + { + uddi4jName = new Name(names[i]); + if (i != 0 && !subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(nameLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(nameLanguages[i],Boolean.TRUE); + if (names[i].trim().length() < 1) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + nameVector.addElement(uddi4jName); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,nameVector); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + if (!subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NO_NAMES")); + } + } + + if (descriptionLanguages != null && descriptions != null) + { + Vector descriptionVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DESCRIPTION"); + languageHash.clear(); + for (int i=0;i<descriptions.length;i++) + { + parameters[1] = String.valueOf(i+1); + Description uddi4jDescription; + if (descriptionLanguages[i].length() > 0) + uddi4jDescription = new Description(descriptions[i],descriptionLanguages[i]); + else + { + uddi4jDescription = new Description(descriptions[i]); + if (i != 0 && !subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(descriptionLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(descriptionLanguages[i],Boolean.TRUE); + if (descriptions[i].trim().length() < 1) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + descriptionVector.addElement(uddi4jDescription); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,descriptionVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS); + + if (idTypes != null && idKeyNames != null && idKeyValues != null) + { + IdentifierBag idBag = new IdentifierBag(); + for (int i=0;i<idKeyNames.length;i++) + { + KeyedReference kr = new KeyedReference(idKeyNames[i],idKeyValues[i],idTypes[i]); + idBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS,idBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + + if (catTypes != null && catKeyNames != null && catKeyValues != null) + { + CategoryBag catBag = new CategoryBag(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + catBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES,catBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + + if (discoveryURLValues != null) + { + DiscoveryURLs discoveryURLs = new DiscoveryURLs(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DISCOVERYURL"); + for (int i=0;i<discoveryURLValues.length;i++) + { + parameters[1] = String.valueOf(i+1); + if (!subQueryInitiated_ && !Validator.validateURL(discoveryURLValues[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + discoveryURLs.add(new DiscoveryURL(discoveryURLValues[i],"")); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS,discoveryURLs); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + Vector nameVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + Vector descriptionVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS); + IdentifierBag identifierBag = (IdentifierBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + CategoryBag categoryBag = (CategoryBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + DiscoveryURLs discoveryURLs = (DiscoveryURLs)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + UDDIProxy proxy = regElement.getProxy(); + + BusinessEntity be = new BusinessEntity(); + be.setBusinessKey(""); + be.setNameVector(nameVector); + be.setDescriptionVector(descriptionVector); + be.setIdentifierBag(identifierBag); + be.setCategoryBag(categoryBag); + be.setDiscoveryURLs(discoveryURLs); + Vector beVector = new Vector(); + beVector.add(be); + + be = (BusinessEntity)proxy.save_business(regElement.getAuthInfoString(), beVector).getBusinessEntityVector().get(0); + addPublishedItemNode(be,regElement); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESS_PUBLISHED",be.getDefaultNameString())); + return true; + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishBusinessSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishBusinessSimpleAction.java new file mode 100644 index 000000000..10ee7ef74 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishBusinessSimpleAction.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.*; + +import java.util.*; +import java.net.*; + +public class RegPublishBusinessSimpleAction extends PublishAction +{ + public RegPublishBusinessSimpleAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_BUSINESSES,String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE)); + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME); + String description = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_DESCRIPTION); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME,name); + + if (!subQueryInitiated_ && !Validator.validateString(name)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_NAME")); + } + + if (description != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_DESCRIPTION,description); + + return inputsValid; + } + + public final boolean run() + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME); + String description = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_DESCRIPTION); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + try + { + UDDIProxy proxy = regElement.getProxy(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + + BusinessEntity be = new BusinessEntity(); + be.setBusinessKey(""); + be.setDefaultName(new Name(name)); + be.setDefaultDescriptionString(description); + Vector beVector = new Vector(); + beVector.add(be); + + be = (BusinessEntity)proxy.save_business(regElement.getAuthInfoString(), beVector).getBusinessEntityVector().get(0); + addPublishedItemNode(be,regElement); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESS_PUBLISHED",be.getDefaultNameString())); + return true; + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceAdvancedAction.java new file mode 100644 index 000000000..d9a3ca50a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceAdvancedAction.java @@ -0,0 +1,363 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.*; +import org.uddi4j.util.*; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; +import java.util.*; +import java.net.*; + +public class RegPublishServiceAdvancedAction extends PublishAction +{ + public RegPublishServiceAdvancedAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String busNodeIds = parser.getParameter(UDDIActionInputs.NODEID_BUSINESS); + String[] serIntIds = parser.getParameterValues(UDDIActionInputs.NODEID_SERVICE_INTERFACE); + String wsdlURL = parser.getParameter(ActionInputs.QUERY_INPUT_WSDL_URL); + String[] nameLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME_LANGUAGE); + String[] names = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME); + String[] descriptionLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE); + String[] descriptions = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (busNodeIds != null) + { + Vector serviceBusiness = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS); + if (serviceBusiness == null) + serviceBusiness = new Vector(); + else + serviceBusiness.removeAllElements(); + Vector serviceBusinessCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS_COPY); + // The browser will enforce the rule of having only one business in this list. + ListElement listElement = (ListElement)serviceBusinessCopy.elementAt(0); + serviceBusiness.addElement(listElement); + BusinessEntity sp = (BusinessEntity)listElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS,serviceBusiness); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER,sp); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,sp.getBusinessKey()); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS); + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER); + if (!subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_BUSINESS")); + } + } + + if (serIntIds != null && serIntIds.length > 0) + { + Vector serviceInterfaces = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES); + if (serviceInterfaces == null) + serviceInterfaces = new Vector(); + else + serviceInterfaces.removeAllElements(); + Vector serviceInterfacesCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES_COPY); + Vector tmodels = new Vector(); + for (Iterator it = serviceInterfacesCopy.iterator(); it.hasNext();) + { + ListElement listElement = (ListElement)it.next(); + int targetNodeId = listElement.getTargetNodeId(); + for (int i = 0; i < serIntIds.length; i++) + { + try + { + if (targetNodeId == Integer.parseInt(serIntIds[i])) + { + serviceInterfaces.add(listElement); + tmodels.add(listElement.getObject()); + break; + } + } + catch (NumberFormatException nfe) + { + } + } + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES, serviceInterfaces); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODEL, tmodels); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES); + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODEL); + } + + if (wsdlURL != null) + { + propertyTable_.put(ActionInputs.QUERY_INPUT_WSDL_URL,wsdlURL); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL,wsdlURL); + } + + if (!subQueryInitiated_ && !Validator.validateString(wsdlURL)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_WSDL_URL")); + } + + Hashtable languageHash = new Hashtable(); + if (nameLanguages != null && names != null) + { + Vector nameVector = new Vector(); + // UDDI's save API (Appendix C of the UDDI V2 Programmers API Specification) requires the following: + // 1) Only the first row can have a blank language. + // 2) Only 1 name per language. + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_NAME"); + for (int i=0;i<names.length;i++) + { + parameters[1] = String.valueOf(i+1); + Name uddi4jName; + if (nameLanguages[i].length() > 0) + uddi4jName = new Name(names[i],nameLanguages[i]); + else + { + uddi4jName = new Name(names[i]); + if (i != 0 && !subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(nameLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(nameLanguages[i],Boolean.TRUE); + if (names[i].trim().length() < 1) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + nameVector.addElement(uddi4jName); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,nameVector); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + if (!subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NO_NAMES")); + } + } + + if (descriptionLanguages != null && descriptions != null) + { + Vector descriptionVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DESCRIPTION"); + languageHash.clear(); + for (int i=0;i<descriptions.length;i++) + { + parameters[1] = String.valueOf(i+1); + Description uddi4jDescription; + if (descriptionLanguages[i].length() > 0) + uddi4jDescription = new Description(descriptions[i],descriptionLanguages[i]); + else + { + uddi4jDescription = new Description(descriptions[i]); + if (i != 0 && !subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(descriptionLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(descriptionLanguages[i],Boolean.TRUE); + if (descriptions[i].trim().length() < 1) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + descriptionVector.addElement(uddi4jDescription); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,descriptionVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + + if (catTypes != null && catKeyNames != null && catKeyValues != null) + { + CategoryBag catBag = new CategoryBag(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + catBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES,catBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + BusinessEntity be = (BusinessEntity)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER); + String businessKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + Vector tModelVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODEL); + String wsdlURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + Vector nameVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + Vector descriptionVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + CategoryBag categoryBag = (CategoryBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + UDDIProxy proxy = regElement.getProxy(); + + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + Definition def = uddi4jHelper.getWSDLDefinition(wsdlURL); + + BusinessService bs; + if (tModelVector != null && tModelVector.size() > 0) + bs = uddi4jHelper.newBusinessService(wsdlURL, def, (TModel[])tModelVector.toArray(new TModel[0])); + else + { + RegPublishServiceInterfaceSimpleAction regPublishSIAction = new RegPublishServiceInterfaceSimpleAction(controller_); + int currentNodeId = getSelectedNavigatorNode().getNodeId(); + NodeManager nodeManager = regNode_.getNodeManager(); + TModel[] tModels = null; + if (uddi4jHelper.isMonolithicWSDL(def)) + { + tModels = new TModel[1]; + tModels[0] = uddi4jHelper.newTModel(wsdlURL, def); + } + else + { + String[] imports = uddi4jHelper.getImports(def, wsdlURL); + tModels = new TModel[imports.length]; + for (int i = 0; i < tModels.length; i++) + tModels[i] = uddi4jHelper.newTModel(imports[i]); + } + Hashtable tModelsTable = new Hashtable(); + if (tModels != null) + { + for (int i=0;i<tModels.length;i++) + { + boolean inputsValid = regPublishSIAction.populatePropertyTable(uddi4jHelper.getWSDL(tModels[i]), tModels[i]); + if (inputsValid) + { + regPublishSIAction.run(); + Object savedTModel = regPublishSIAction.getPropertyTable().get(UDDIActionInputs.QUERY_OUTPUT_SAVED_TMODEL); + if (savedTModel != null) + tModelsTable.put(((TModel)savedTModel).getNameString(), savedTModel); + // Reselect the current node. + nodeManager.setSelectedNodeId(currentNodeId); + } + } + } + bs = uddi4jHelper.newBusinessService(wsdlURL, def, tModelsTable); + } + + if (be != null) + bs.setBusinessKey(be.getBusinessKey()); + else if (businessKey != null) + bs.setBusinessKey(businessKey); + bs.setNameVector(nameVector); + bs.setDescriptionVector(descriptionVector); + bs.setCategoryBag(categoryBag); + Vector bsVector = new Vector(); + bsVector.add(bs); + regElement.handlePreInvocation(bs); + bs = (BusinessService)proxy.save_service(regElement.getAuthInfoString(), bsVector).getBusinessServiceVector().get(0); + addPublishedItemNode(bs,regElement); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_PUBLISHED",bs.getDefaultNameString())); + return true; + } + catch (WSDLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("WSDLException"); + messageQueue.addMessage(e.getMessage()); + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceInterfaceAdvancedAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceInterfaceAdvancedAction.java new file mode 100644 index 000000000..ef218529a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceInterfaceAdvancedAction.java @@ -0,0 +1,234 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.*; +import org.uddi4j.util.*; + +import javax.wsdl.WSDLException; +import java.util.*; +import java.net.*; + +public class RegPublishServiceInterfaceAdvancedAction extends PublishAction +{ + public RegPublishServiceInterfaceAdvancedAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + } + + protected final boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String wsdlURL = parser.getParameter(ActionInputs.QUERY_INPUT_WSDL_URL); + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + String[] descriptionLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE); + String[] descriptions = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION); + String[] idTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE); + String[] idKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME); + String[] idKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + + // Validate the data. + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + Hashtable languageHash = new Hashtable(); + + if (wsdlURL != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL,wsdlURL); + + if (!subQueryInitiated_ && !Validator.validateString(wsdlURL)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_WSDL_URL")); + } + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME,name); + + if (!subQueryInitiated_ && !Validator.validateString(name)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_NAME")); + } + + if (descriptionLanguages != null && descriptions != null) + { + Vector descriptionVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DESCRIPTION"); + languageHash.clear(); + for (int i=0;i<descriptions.length;i++) + { + parameters[1] = String.valueOf(i+1); + Description uddi4jDescription; + if (descriptionLanguages[i].length() > 0) + uddi4jDescription = new Description(descriptions[i],descriptionLanguages[i]); + else + { + uddi4jDescription = new Description(descriptions[i]); + if (i != 0 && !subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(descriptionLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(descriptionLanguages[i],Boolean.TRUE); + if (descriptions[i].trim().length() < 1) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + descriptionVector.addElement(uddi4jDescription); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,descriptionVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS); + + if (idTypes != null && idKeyNames != null && idKeyValues != null) + { + IdentifierBag idBag = new IdentifierBag(); + for (int i=0;i<idKeyNames.length;i++) + { + KeyedReference kr = new KeyedReference(idKeyNames[i],idKeyValues[i],idTypes[i]); + idBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS,idBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + + if (catTypes != null && catKeyNames != null && catKeyValues != null) + { + CategoryBag catBag = new CategoryBag(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + catBag.add(kr); + } + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES,catBag); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + + return inputsValid; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + String wsdlURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + Vector descriptionVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS); + IdentifierBag identifierBag = (IdentifierBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + CategoryBag categoryBag = (CategoryBag)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + + // The action can be run under the context of either a registry or a query node. + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + UDDIProxy proxy = regElement.getProxy(); + + TModel tModel = (new Uddi4jHelper()).newTModel(wsdlURL); + tModel.setName(name); + tModel.setDescriptionVector(descriptionVector); + tModel.setIdentifierBag(identifierBag); + + // The category bag may contain wsdlSpec. + CategoryBag defaultCategoryBag = tModel.getCategoryBag(); + Vector defaultKeyedReferenceVector = null; + if (defaultCategoryBag != null) + { + if (categoryBag == null) + categoryBag = defaultCategoryBag; + else + { + defaultKeyedReferenceVector = defaultCategoryBag.getKeyedReferenceVector(); + for (int i=0;i<defaultKeyedReferenceVector.size();i++) + { + KeyedReference kr = (KeyedReference)defaultKeyedReferenceVector.elementAt(i); + if (categoryBag != null) + categoryBag.add(kr); + } + } + } + tModel.setCategoryBag(categoryBag); + + Vector tModelVector = new Vector(); + tModelVector.add(tModel); + tModel = (TModel)proxy.save_tModel(regElement.getAuthInfoString(), tModelVector).getTModelVector().get(0); + propertyTable_.put(UDDIActionInputs.QUERY_OUTPUT_SAVED_TMODEL, tModel); + addPublishedItemNode(tModel,regElement); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACE_PUBLISHED",tModel.getNameString())); + return true; + } + catch (WSDLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("WSDLException"); + messageQueue.addMessage(e.getMessage()); + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceInterfaceSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceInterfaceSimpleAction.java new file mode 100644 index 000000000..211baade0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceInterfaceSimpleAction.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.tmodel.TModel; + +import javax.wsdl.WSDLException; +import java.util.*; +import java.net.*; + +public class RegPublishServiceInterfaceSimpleAction extends PublishAction +{ + public RegPublishServiceInterfaceSimpleAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE)); + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String wsdlURL = parser.getParameter(ActionInputs.QUERY_INPUT_WSDL_URL); + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME); + String description = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (wsdlURL != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_WSDL_URL,wsdlURL); + + if (!subQueryInitiated_ && !Validator.validateString(wsdlURL)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_WSDL_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_WSDL_URL")); + } + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME,name); + + if (!subQueryInitiated_ && !Validator.validateString(name)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_NAME")); + } + + if (description != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION,description); + + return inputsValid; + } + + public final boolean populatePropertyTable(String wsdlURL, TModel tModel) + { + boolean inputsValid = true; + String name = tModel.getNameString(); + String description = tModel.getDefaultDescriptionString(); + if (wsdlURL != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_WSDL_URL,wsdlURL); + else + inputsValid = false; + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME,name); + else + inputsValid = false; + + if (description != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION,description); + else + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION,""); + return inputsValid; + } + + public final boolean run() + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + String wsdlURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_WSDL_URL); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME); + String description = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + try + { + UDDIProxy proxy = regElement.getProxy(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + + TModel tModel = (new Uddi4jHelper()).newTModel(wsdlURL); + tModel.setName(name); + tModel.setDefaultDescriptionString(description); + + Vector tModelVector = new Vector(); + tModelVector.add(tModel); + tModel = (TModel)proxy.save_tModel(regElement.getAuthInfoString(), tModelVector).getTModelVector().get(0); + propertyTable_.put(UDDIActionInputs.QUERY_OUTPUT_SAVED_TMODEL, tModel); + addPublishedItemNode(tModel,regElement); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACE_PUBLISHED",tModel.getNameString())); + return true; + } + catch (WSDLException e) + { + e.printStackTrace(); + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("WSDLException"); + messageQueue.addMessage(e.getMessage()); + } + catch (TransportException e) + { + e.printStackTrace(); + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + e.printStackTrace(); + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceSimpleAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceSimpleAction.java new file mode 100644 index 000000000..bbe0caafb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RegPublishServiceSimpleAction.java @@ -0,0 +1,212 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.*; + +import javax.wsdl.WSDLException; +import javax.wsdl.Definition; +import java.util.*; +import java.net.*; + +public class RegPublishServiceSimpleAction extends PublishAction +{ + public RegPublishServiceSimpleAction(Controller controller) + { + super(controller); + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + propertyTable_.put(UDDIActionInputs.QUERY_STYLE_SERVICES,String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE)); + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String busNodeIds = parser.getParameter(UDDIActionInputs.NODEID_BUSINESS); + String wsdlURL = parser.getParameter(ActionInputs.QUERY_INPUT_WSDL_URL); + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME); + String description = parser.getParameter(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_DESCRIPTION); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (busNodeIds != null) + { + Vector serviceBusiness = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS); + if (serviceBusiness == null) + serviceBusiness = new Vector(); + else + serviceBusiness.removeAllElements(); + Vector serviceBusinessCopy = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS_COPY); + // The browser will enforce the rule of having only one business in this list. + ListElement listElement = (ListElement)serviceBusinessCopy.elementAt(0); + serviceBusiness.addElement(listElement); + BusinessEntity be = (BusinessEntity)listElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS,serviceBusiness); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_SERVICE_PROVIDER,be); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,be.getBusinessKey()); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS); + removeProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_SERVICE_PROVIDER); + if (!subQueryInitiated_) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_BUSINESS")); + } + } + + if (wsdlURL != null) + { + propertyTable_.put(ActionInputs.QUERY_INPUT_WSDL_URL,wsdlURL); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_WSDL_URL,wsdlURL); + } + + if (!subQueryInitiated_ && !Validator.validateString(wsdlURL)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_WSDL_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_WSDL_URL")); + } + + if (name != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME,name); + + if (!subQueryInitiated_ && !Validator.validateString(name)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_NAME")); + } + + if (description != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_DESCRIPTION,description); + + return inputsValid; + } + + public final boolean run() + { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + BusinessEntity be = (BusinessEntity)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_SERVICE_PROVIDER); + String businessKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + String wsdlURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_WSDL_URL); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME); + String description = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_DESCRIPTION); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + try + { + UDDIProxy proxy = regElement.getProxy(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + Definition def = uddi4jHelper.getWSDLDefinition(wsdlURL); + RegPublishServiceInterfaceSimpleAction regPublishSIAction = new RegPublishServiceInterfaceSimpleAction(controller_); + int currentNodeId = getSelectedNavigatorNode().getNodeId(); + NodeManager nodeManager = regNode_.getNodeManager(); + + Hashtable tModelsTable = new Hashtable(); + TModel[] tModels = null; + if (uddi4jHelper.isMonolithicWSDL(def)) + { + tModels = new TModel[1]; + tModels[0] = uddi4jHelper.newTModel(wsdlURL, def); + } + else + { + String[] imports = uddi4jHelper.getImports(def, wsdlURL); + tModels = new TModel[imports.length]; + for (int i = 0; i < tModels.length; i++) + tModels[i] = uddi4jHelper.newTModel(imports[i]); + } + + if (tModels != null) + { + for (int i=0;i<tModels.length;i++) + { + boolean inputsValid = regPublishSIAction.populatePropertyTable(uddi4jHelper.getWSDL(tModels[i]), tModels[i]); + if (inputsValid) + { + regPublishSIAction.run(); + Object savedTModel = regPublishSIAction.getPropertyTable().get(UDDIActionInputs.QUERY_OUTPUT_SAVED_TMODEL); + if (savedTModel != null) + { + tModelsTable.put(((TModel)savedTModel).getNameString(), savedTModel); + } + // Reselect the current node. + nodeManager.setSelectedNodeId(currentNodeId); + } + } + } + + BusinessService bs = uddi4jHelper.newBusinessService(wsdlURL, def, tModelsTable); + if (be != null) + bs.setBusinessKey(be.getBusinessKey()); + else if (businessKey != null) + bs.setBusinessKey(businessKey); + bs.setDefaultName(new Name(name)); + bs.setDefaultDescriptionString(description); + Vector bsVector = new Vector(); + bsVector.add(bs); + regElement.handlePreInvocation(bs); + bs = (BusinessService)proxy.save_service(regElement.getAuthInfoString(), bsVector).getBusinessServiceVector().get(0); + addPublishedItemNode(bs,regElement); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_PUBLISHED",bs.getDefaultNameString())); + return true; + } + catch (WSDLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("WSDLException"); + messageQueue.addMessage(e.getMessage()); + } + catch (TransportException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(e.getMessage()); + } + catch (UDDIException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(e.getMessage()); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RemovePublisherAssertionsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RemovePublisherAssertionsAction.java new file mode 100644 index 000000000..87dce12d6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RemovePublisherAssertionsAction.java @@ -0,0 +1,217 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.*; +import org.uddi4j.response.*; +import org.uddi4j.datatype.assertion.*; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; + +import java.util.*; +import java.net.*; + +public class RemovePublisherAssertionsAction extends CommonPublisherAssertionsAction +{ + public RemovePublisherAssertionsAction(Controller controller) + { + super(controller); + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + if (registryNode_ == null) + return false; + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + + // ids from uddiObjects_table + String[] selectedBusIds = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (selectedBusIds != null && selectedBusIds.length > 0) + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, selectedBusIds); + // Synchronize client view and server model (uddiObject_table.jsp) + synchronizeUDDIObjectTable(); + + // if not yet logged in, validate the parameters needed to log in + if (!isLoggedIn_) { + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (!Validator.validateURL(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userID!= null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + } + + if (!Validator.validateString(userID)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + } + + // ids from publisher assertion table + String[] pubAssertionsViewIds = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_VIEWID); + if (pubAssertionsViewIds == null || pubAssertionsViewIds.length == 0) + inputsValid = false; + else + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_VIEWID, pubAssertionsViewIds); + + return inputsValid; + } + + public boolean run() + { + if (registryNode_ == null) + return false; + + RegistryElement registryElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + Node selectedNode = navigatorManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + + if (!(selectedElement instanceof BusinessElement)) + return false; + + // if not yet logged in, log in first + if (!isLoggedIn_) { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + try { + registryElement.performLogin(publishURL, userID, password); + } + catch (TransportException te) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(te.getMessage()); + return false; + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(uddie.toString()); + return false; + } + catch (MalformedURLException me) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(me.getMessage()); + return false; + } + } + + UDDIProxy proxy = registryElement.getProxy(); + String userID = registryElement.getUserId(); + String cred = registryElement.getCred(); + BusinessElement busElement = (BusinessElement)selectedElement; + ListManager pubAssertions = busElement.getPublisherAssertions(); + + // determine whether this is a owned business + // if not, the AddPublisherAssertionsAction cannot be performed + if (!isBusinessOwned(busElement)) { + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NOT_OWNED_BUSINESS")); + return false; + } + + try { + String[] pubAssertionViewIds = (String[])propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_VIEWID); + Vector pubAssertionVector = new Vector(); + boolean refreshRequired = false; + + for (int i = 0; i < pubAssertionViewIds.length; i++) { + int viewID = Integer.parseInt(pubAssertionViewIds[i]); + ListElement listElement = pubAssertions.getElementWithViewId(viewID); + PublisherAssertionElement pubAssertionElement = (PublisherAssertionElement)listElement.getObject(); + PublisherAssertion pubAssertion = pubAssertionElement.getPublisherAssertion(); + pubAssertionVector.add(pubAssertion); + if (pubAssertionElement.getStatus().equals(CompletionStatus.COMPLETE)) + refreshRequired = true; + } + + DispositionReport report = proxy.delete_publisherAssertions(registryElement.getAuthInfoString(), pubAssertionVector); + //report status + Vector reportErrInfo = report.getResultVector(); + for (int i = 0; i < reportErrInfo.size(); i++) { + messageQueue.addMessage(((Result) reportErrInfo.get(i)).getErrInfo().getText()); + } + + // refresh is required, refresh the whole publisher assertion table + if (refreshRequired) { + ShowPublisherAssertionsAction showPAAction = new ShowPublisherAssertionsAction(controller_); + Hashtable propertyTable = showPAAction.getPropertyTable(); + Object ids = propertyTable_.get(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (ids != null) + propertyTable.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, ids); + showPAAction.run(); + } + // refresh is not required, delete the selected publisher assertion elements + else { + for (int k = 0; k < pubAssertionViewIds.length; k++) { + pubAssertions.removeElementWithViewId(Integer.parseInt(pubAssertionViewIds[k])); + } + } + + return report.success(); + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + DispositionReport report = uddie.getDispositionReport(); + Vector reportErrInfo = report.getResultVector(); + for (int i = 0; i < reportErrInfo.size(); i++) { + messageQueue.addMessage(((Result) reportErrInfo.get(i)).getErrInfo().getText()); + } + return false; + } + catch (Exception e) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("Exception"); + messageQueue.addMessage(e.getMessage()); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RemoveSubQueryItemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RemoveSubQueryItemAction.java new file mode 100644 index 000000000..6c824874c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/RemoveSubQueryItemAction.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import javax.servlet.http.*; + +import java.util.*; + +public class RemoveSubQueryItemAction extends Action +{ + private Controller controller_; + + public RemoveSubQueryItemAction(Controller controller) + { + super(); + controller_ = controller; + } + + // uddi/actions/RemoveSubQueryItemActionJSP.jsp?subQueryKey=...&subQueryListKey=...&subQueryListItemId=... + public static final String getActionLink(String subQueryKey,String subQueryListKey,int subQueryListItemId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/RemoveSubQueryItemActionJSP.jsp?"); + actionLink.append(UDDIActionInputs.SUBQUERY_KEY).append('=').append(subQueryKey); + actionLink.append('&').append(UDDIActionInputs.SUBQUERY_LIST_KEY).append('=').append(subQueryListKey); + actionLink.append('&').append(UDDIActionInputs.SUBQUERY_LIST_ITEMID).append('=').append(subQueryListItemId); + return actionLink.toString(); + } + + public boolean populatePropertyTable(HttpServletRequest request) + { + String subQueryKey = request.getParameter(UDDIActionInputs.SUBQUERY_KEY); + String subQueryListKey = request.getParameter(UDDIActionInputs.SUBQUERY_LIST_KEY); + String subQueryListItemId = request.getParameter(UDDIActionInputs.SUBQUERY_LIST_ITEMID); + + if (subQueryKey != null) + propertyTable_.put(UDDIActionInputs.SUBQUERY_KEY,subQueryKey); + + if (subQueryListKey != null) + propertyTable_.put(UDDIActionInputs.SUBQUERY_LIST_KEY,subQueryListKey); + + if (subQueryListItemId != null) + propertyTable_.put(UDDIActionInputs.SUBQUERY_LIST_ITEMID,subQueryListItemId); + + return true; + } + + public boolean run() + { + String subQueryKey = (String)propertyTable_.get(UDDIActionInputs.SUBQUERY_KEY); + String subQueryListKey = (String)propertyTable_.get(UDDIActionInputs.SUBQUERY_LIST_KEY); + int subQueryListItemId = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.SUBQUERY_LIST_ITEMID)); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + Node currentNode = navigatorManager.getSelectedNode(); + FormTool formTool = (FormTool)(currentNode.getCurrentToolManager().getSelectedTool()); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties((String)propertyTable_.get(UDDIActionInputs.SUBQUERY_KEY)); + Vector list = (Vector)formToolPI.getProperty((String)propertyTable_.get(UDDIActionInputs.SUBQUERY_LIST_KEY)); + list.removeElementAt(subQueryListItemId); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ResizeUDDIFramesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ResizeUDDIFramesAction.java new file mode 100644 index 000000000..93041d66d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ResizeUDDIFramesAction.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +public class ResizeUDDIFramesAction extends ResizeFramesAction +{ + public ResizeUDDIFramesAction(Controller controller) + { + super(controller); + } + + protected boolean processOthers(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(UDDIActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(UDDIActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(UDDIActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(UDDIActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + // Save the current frameset sizes. + String frameName = (String)propertyTable_.get(ActionInputs.FRAME_NAME); + String perspectiveContentFramesetCols = (String)propertyTable_.get(UDDIActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(UDDIActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + + // Set the new frameset sizes. + boolean saveFrameSettings = false; + if (frameName.equals(UDDIFrameNames.NAVIGATOR_CONTAINER)) + { + uddiPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + uddiPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + if (perspectiveContentFramesetCols.startsWith("100%")) + { + // Restore. + uddiPerspective.setPerspectiveContentFramesetCols(uddiPerspective.getSavedPerspectiveContentFramesetCols()); + } + else + { + // Maximize. + uddiPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + uddiPerspective.setPerspectiveContentFramesetCols("100%,0%"); + } + } + else if (frameName.equals(UDDIFrameNames.PROPERTIES_CONTAINER)) + { + if (actionsContainerFramesetRows.startsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + uddiPerspective.setPerspectiveContentFramesetCols(uddiPerspective.getSavedPerspectiveContentFramesetCols()); + uddiPerspective.setActionsContainerFramesetRows(uddiPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + uddiPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + uddiPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + uddiPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + uddiPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + uddiPerspective.setActionsContainerFramesetRows("100%,0%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + uddiPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + uddiPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + else if (frameName.equals(UDDIFrameNames.STATUS_CONTAINER)) + { + if (actionsContainerFramesetRows.endsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + uddiPerspective.setPerspectiveContentFramesetCols(uddiPerspective.getSavedPerspectiveContentFramesetCols()); + uddiPerspective.setActionsContainerFramesetRows(uddiPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + uddiPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + uddiPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + uddiPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + uddiPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + uddiPerspective.setActionsContainerFramesetRows("0%,100%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + uddiPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + uddiPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectCategoryNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectCategoryNodeAction.java new file mode 100644 index 000000000..7fa3d43df --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectCategoryNodeAction.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectCategoryNodeAction extends SelectNodeAction +{ + public SelectCategoryNodeAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getCategoryManager()); + } + + // uddi/actions/SelectCategoryNodeAction.jsp?sessionId=...&nodeId=... + public static String getActionLink(String sessionId,int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/SelectCategoryNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId); + actionLink.append('&').append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final String getActionLinkForHistory() + { + // Do not add this action to the history. + return null; + } + + public final boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + performBaseAction(nodeId); + return true; + } + + public final String getTreeContentVar() + { + return "categoryBrowserWindowContent"; + } + + public final String getTreeContentPage() + { + return null; + } + + public final String getPropertiesContainerVar() + { + return null; + } + + public final String getPropertiesContainerPage() + { + return null; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_UDDI; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectFindToolAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectFindToolAction.java new file mode 100644 index 000000000..5afd276b7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectFindToolAction.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import javax.servlet.http.*; + +public class SelectFindToolAction extends SelectPropertiesToolAction +{ + protected String subQueryKey_; + protected boolean toolLinkChanged_; + + public SelectFindToolAction(Controller controller) + { + super(controller); + subQueryKey_ = null; + toolLinkChanged_ = false; + } + + public boolean processLinkParameters(HttpServletRequest request) + { + boolean result = super.processLinkParameters(request); + subQueryKey_ = request.getParameter(UDDIActionInputs.SUBQUERY_KEY); + return result; + } + + // /uddi/actions/SelectFindToolAction.jsp?nodeId=...&toolId=...<&viewId=...&viewToolId=...>&subQueryKey=...<&isHistory=1> + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId,String subQueryKey,boolean forHistory) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/SelectFindToolActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(ActionInputs.TOOLID).append('=').append(toolId); + if (viewId != ActionInputs.VIEWID_DEFAULT) + { + actionLink.append('&').append(ActionInputs.VIEWID).append('=').append(viewId); + actionLink.append('&').append(ActionInputs.VIEWTOOLID).append('=').append(viewToolId); + } + actionLink.append('&').append(UDDIActionInputs.SUBQUERY_KEY).append('=').append(subQueryKey); + + if (forHistory) + actionLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return actionLink.toString(); + } + + public boolean run() + { + if (!super.run()) + return false; + FormTool formTool = (FormTool)(selectedNode_.getCurrentToolManager().getSelectedTool()); + String currentSubQueryKey = (String)formTool.getProperty(UDDIActionInputs.SUBQUERY_KEY); + if (subQueryKey_ != null && !subQueryKey_.equals(currentSubQueryKey)) + { + toolLinkChanged_ = true; + formTool.setProperty(UDDIActionInputs.SUBQUERY_KEY,subQueryKey_); + } + return true; + } + + public boolean requiresViewSelection() + { + return toolLinkChanged_; + } + + protected String getActionLinkForHistory() + { + int nodeId = selectedNode_.getNodeId(); + int toolId = selectedTool_.getToolId(); + int viewId = selectedNode_.getViewId(); + int viewToolId = selectedNode_.getViewToolId(); + return getActionLink(nodeId,toolId,viewId,viewToolId,subQueryKey_,true); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectNavigatorNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectNavigatorNodeAction.java new file mode 100644 index 000000000..a03472c09 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectNavigatorNodeAction.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectNavigatorNodeAction extends SelectNodeAction +{ + public SelectNavigatorNodeAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getNavigatorManager()); + } + + // uddi/actions/SelectNavigatorNodeAction.jsp?nodeId=...<&isHistory=1> + public static String getActionLink(int nodeId,boolean forHistory) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/SelectNavigatorNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + if (forHistory) + actionLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return actionLink.toString(); + } + + public String getActionLinkForHistory() + { + ToolManager toolManager = selectedNode_.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + int nodeId = selectedNode_.getNodeId(); + int toolId = selectedTool.getToolId(); + int viewId = selectedNode_.getViewId(); + int viewToolId = selectedNode_.getViewToolId(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return selectedTool.getSelectToolActionHref(true); + else + return getActionLink(nodeId,true); + } + + public final String getTreeContentVar() + { + return "navigatorContent"; + } + + public final String getTreeContentPage() + { + return "uddi/navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "propertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "uddi/properties_container.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_UDDI; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectPropertiesToolAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectPropertiesToolAction.java new file mode 100644 index 000000000..388995c4c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectPropertiesToolAction.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectPropertiesToolAction extends SelectNodeToolAction +{ + public SelectPropertiesToolAction(Controller controller) + { + super(controller, controller.getUDDIPerspective().getNavigatorManager()); + } + + // /uddi/actions/SelectPropertiesToolAction.jsp?nodeId=...&toolId=...<&viewId=...&viewToolId=...><&isHistory=1> + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId,boolean forHistory) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/SelectPropertiesToolActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(ActionInputs.TOOLID).append('=').append(toolId); + if (viewId != ActionInputs.VIEWID_DEFAULT) + { + actionLink.append('&').append(ActionInputs.VIEWID).append('=').append(viewId); + actionLink.append('&').append(ActionInputs.VIEWTOOLID).append('=').append(viewToolId); + } + if (forHistory) + actionLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + int nodeId = selectedNode_.getNodeId(); + int toolId = selectedTool_.getToolId(); + int viewId = selectedNode_.getViewId(); + int viewToolId = selectedNode_.getViewToolId(); + return getActionLink(nodeId,toolId,viewId,viewToolId,true); + } + + public final String getTreeContentVar() + { + return "navigatorContent"; + } + + public final String getTreeContentPage() + { + return "uddi/navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "propertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "uddi/properties_container.jsp"; + } + + public final String getPropertiesContentVar() + { + return "propertiesContent"; + } + + public final String getPropertiesContentPage() + { + return "uddi/properties_content.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_UDDI; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectSubQueryItemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectSubQueryItemAction.java new file mode 100644 index 000000000..0d9f2f06a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SelectSubQueryItemAction.java @@ -0,0 +1,226 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +import javax.servlet.http.*; + +import java.util.*; + +public class SelectSubQueryItemAction extends SelectPropertiesToolAction +{ + private boolean requiresTreeViewRefresh_; + private boolean requiresViewSelection_; + private boolean newUUIDQueryCreated_; + private String itemName_; + public SelectSubQueryItemAction(Controller controller) + { + super(controller); + requiresTreeViewRefresh_ = false; + requiresViewSelection_ = false; + newUUIDQueryCreated_ = false; + itemName_ = null; + } + + // /uddi/actions/SelectSubQueryItemAction.jsp?nodeId=...&toolId=...<&viewId=...>&subQueryKey=...&subQueryListKey=...&subQueryListItemId=...&queryItem=...<&isHistory=1> + public static final String getActionLink(int nodeId,int toolId,int viewId,String subQueryKey,String subQueryListKey,int subQueryListItemId,int queryItem,boolean forHistory) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/SelectSubQueryItemActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(ActionInputs.TOOLID).append('=').append(toolId); + if (viewId != ActionInputs.VIEWID_DEFAULT) + actionLink.append('&').append(ActionInputs.VIEWID).append('=').append(viewId); + actionLink.append('&').append(UDDIActionInputs.SUBQUERY_KEY).append('=').append(subQueryKey); + actionLink.append('&').append(UDDIActionInputs.SUBQUERY_LIST_KEY).append('=').append(subQueryListKey); + actionLink.append('&').append(UDDIActionInputs.SUBQUERY_LIST_ITEMID).append('=').append(subQueryListItemId); + actionLink.append('&').append(UDDIActionInputs.QUERY_ITEM).append('=').append(queryItem); + + if (forHistory) + actionLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return actionLink.toString(); + } + + public boolean processLinkParameters(HttpServletRequest request) + { + boolean result = super.processLinkParameters(request); + String subQueryKey = request.getParameter(UDDIActionInputs.SUBQUERY_KEY); + String subQueryListKey = request.getParameter(UDDIActionInputs.SUBQUERY_LIST_KEY); + String subQueryListItemId = request.getParameter(UDDIActionInputs.SUBQUERY_LIST_ITEMID); + String queryItemString = request.getParameter(UDDIActionInputs.QUERY_ITEM); + + if (subQueryKey != null) + propertyTable_.put(UDDIActionInputs.SUBQUERY_KEY,subQueryKey); + + if (subQueryListKey != null) + propertyTable_.put(UDDIActionInputs.SUBQUERY_LIST_KEY,subQueryListKey); + + if (subQueryListItemId != null) + propertyTable_.put(UDDIActionInputs.SUBQUERY_LIST_ITEMID,subQueryListItemId); + + if (queryItemString != null) + propertyTable_.put(UDDIActionInputs.QUERY_ITEM,queryItemString); + return result; + } + + private final boolean findByUUID() + { + Node currentNode = nodeManager_.getSelectedNode(); + FormTool formTool = (FormTool)(currentNode.getCurrentToolManager().getSelectedTool()); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties((String)propertyTable_.get(UDDIActionInputs.SUBQUERY_KEY)); + Vector list = (Vector)formToolPI.getProperty((String)propertyTable_.get(UDDIActionInputs.SUBQUERY_LIST_KEY)); + ListElement listElement = (ListElement)list.elementAt(Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.SUBQUERY_LIST_ITEMID))); + int queryItem = Integer.parseInt((String)propertyTable_.get(UDDIActionInputs.QUERY_ITEM)); + FindAction findAction = null; + String uuidKey = null; + String uuidKeyValue = null; + switch (queryItem) + { + case UDDIActionInputs.QUERY_ITEM_BUSINESSES: + findAction = new RegFindBusinessUUIDAction(controller_); + uuidKey = UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY; + BusinessEntity sp = (BusinessEntity)listElement.getObject(); + uuidKeyValue = sp.getBusinessKey(); + itemName_ = sp.getDefaultNameString(); + break; + case UDDIActionInputs.QUERY_ITEM_SERVICES: + findAction = new RegFindServiceUUIDAction(controller_); + uuidKey = UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY; + BusinessService bs = (BusinessService)listElement.getObject(); + uuidKeyValue = bs.getServiceKey(); + itemName_ = bs.getDefaultNameString(); + break; + case UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES: + default: + findAction = new RegFindServiceInterfaceUUIDAction(controller_); + uuidKey = UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY; + TModel tModel = (TModel)listElement.getObject(); + uuidKeyValue = tModel.getTModelKey(); + itemName_ = tModel.getNameString(); + } + Hashtable propertyTable = findAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,uuidKeyValue); + propertyTable.put(uuidKey,uuidKeyValue); + boolean result = findAction.run(); + if (result) + { + Node itemNode = nodeManager_.getSelectedNode(); + int nodeId = itemNode.getNodeId(); + int toolId = itemNode.getToolManager().getSelectedToolId(); + int viewId = ActionInputs.VIEWID_DEFAULT; + int viewToolId = ActionInputs.VIEWTOOLID_DEFAULT; + propertyTable_.put(ActionInputs.NODEID,String.valueOf(nodeId)); + propertyTable_.put(ActionInputs.TOOLID,String.valueOf(toolId)); + propertyTable_.put(ActionInputs.VIEWID,String.valueOf(viewId)); + propertyTable_.put(ActionInputs.VIEWTOOLID,String.valueOf(viewToolId)); + super.run(); + requiresTreeViewRefresh_ = true; + requiresViewSelection_ = true; + newUUIDQueryCreated_ = true; + listElement.setTargetViewToolInfo(nodeId,toolId,viewId); + return true; + } + else + { + // The item is no longer in the registry. + return false; + } + } + + public final String getItemName() + { + return itemName_; + } + + public boolean run() + { + // Given the nodeId, toolId and viewId, check if the node or view is stale. + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + int toolId = Integer.parseInt((String)propertyTable_.get(ActionInputs.TOOLID)); + int viewId = ActionInputs.VIEWID_DEFAULT; + try + { + viewId = Integer.parseInt((String)propertyTable_.get(ActionInputs.VIEWID)); + } + catch (NumberFormatException e) + { + } + int viewToolId = 0; + if (!isStaleNode(nodeId)) + { + // Enusre the node is visible. + requiresTreeViewRefresh_ = makeNodeVisible(nodeManager_.getNode(nodeId)); + + Node node = nodeManager_.getNode(nodeId); + if (viewId != ActionInputs.VIEWID_DEFAULT) + { + ViewTool viewTool = (ViewTool)(node.getToolManager().getTool(toolId)); + ToolManager elementToolManager = viewTool.getToolManager(viewId); + if (elementToolManager != null) + viewToolId = elementToolManager.getSelectedToolId(); + else + { + // Stale view + return findByUUID(); + } + } + propertyTable_.put(ActionInputs.VIEWTOOLID,String.valueOf(viewToolId)); + return super.run(); + } + else + { + // Stale node + return findByUUID(); + } + } + + protected String getActionLinkForHistory() + { + int nodeId = selectedNode_.getNodeId(); + int toolId = selectedTool_.getToolId(); + int viewId = selectedNode_.getViewId(); + int viewToolId = selectedNode_.getViewToolId(); + return SelectPropertiesToolAction.getActionLink(nodeId,toolId,viewId,viewToolId,true); + } + + public boolean requiresTreeViewRefresh() + { + return super.requiresTreeViewRefresh()|requiresTreeViewRefresh_; + } + + public boolean requiresViewSelection() + { + return super.requiresViewSelection()|requiresViewSelection_; + } + + public boolean requiresStatusUpdate() + { + return newUUIDQueryCreated_; + } + + public final String getStatusContentVar() + { + return "statusContent"; + } + + public final String getStatusContentPage() + { + return "uddi/status_content.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceGetBusinessAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceGetBusinessAction.java new file mode 100644 index 000000000..9b0987f8c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceGetBusinessAction.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.service.*; + +import java.util.*; + +public class ServiceGetBusinessAction extends NodeAction +{ + private ServiceNode serviceNode_; + public ServiceGetBusinessAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getNavigatorManager()); + serviceNode_ = null; + } + + // uddi/actions/ServiceGetBusinessActionJSP.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ServiceGetBusinessActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean validateService() + { + int serviceNodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + serviceNode_ = (ServiceNode)nodeManager_.getNode(serviceNodeId); + ServiceElement serviceElement = (ServiceElement)serviceNode_.getTreeElement(); + RegFindServiceUUIDAction verifyAction = new RegFindServiceUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,serviceElement.getBusinessService().getServiceKey()); + boolean result = verifyAction.run(); + if (result) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,propertyTable.get(UDDIActionInputs.LATEST_OBJECT)); + return result; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + BusinessService bs = (BusinessService)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + + RegFindBusinessUUIDAction action = new RegFindBusinessUUIDAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,uddiPerspective.getMessage("NODE_NAME_SERVICE_BUSINESS",serviceNode_.getNodeName())); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,bs.getBusinessKey()); + + return action.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceGetServiceInterfacesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceGetServiceInterfacesAction.java new file mode 100644 index 000000000..22ced4ccb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceGetServiceInterfacesAction.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.service.*; + +import java.util.*; + +public class ServiceGetServiceInterfacesAction extends UDDINodeAction +{ + private ServiceNode serviceNode_; + public ServiceGetServiceInterfacesAction(Controller controller) + { + super(controller); + serviceNode_ = null; + } + + // uddi/actions/ServiceGetServiceInterfacesActionJSP.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ServiceGetServiceInterfacesActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean validateService() + { + int serviceNodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + serviceNode_ = (ServiceNode)nodeManager_.getNode(serviceNodeId); + ServiceElement serviceElement = (ServiceElement)serviceNode_.getTreeElement(); + RegFindServiceUUIDAction verifyAction = new RegFindServiceUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,serviceElement.getBusinessService().getServiceKey()); + boolean result = verifyAction.run(); + if (result) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,propertyTable.get(UDDIActionInputs.LATEST_OBJECT)); + return result; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + BusinessService bs = (BusinessService)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + RegFindServiceInterfacesAdvancedAction action = new RegFindServiceInterfacesAdvancedAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,uddiPerspective.getMessage("NODE_NAME_SERVICE_SERVICE_INTERFACES",serviceNode_.getNodeName())); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE,Boolean.TRUE); + ListElement serviceListElement = new ListElement(bs); + serviceListElement.setTargetViewToolInfo(serviceNode_.getNodeId(),serviceNode_.getToolManager().getSelectedToolId(),serviceNode_.getViewId()); + Vector serviceListVector = new Vector(); + serviceListVector.addElement(serviceListElement); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE,serviceListVector); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_BUSINESS_SERVICE,bs); + return action.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceInterfaceGetBusinessesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceInterfaceGetBusinessesAction.java new file mode 100644 index 000000000..8187288a7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceInterfaceGetBusinessesAction.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.tmodel.*; +import org.uddi4j.util.*; + +import java.util.*; + +public class ServiceInterfaceGetBusinessesAction extends UDDINodeAction +{ + private ServiceInterfaceNode siNode_; + public ServiceInterfaceGetBusinessesAction(Controller controller) + { + super(controller); + siNode_ = null; + } + + // uddi/actions/ServiceInterfacGetBusinessesActionJSP.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ServiceInterfaceGetBusinessesActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean validateServiceInterface() + { + int siNodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + siNode_ = (ServiceInterfaceNode)nodeManager_.getNode(siNodeId); + ServiceInterfaceElement siElement = (ServiceInterfaceElement)siNode_.getTreeElement(); + RegFindServiceInterfaceUUIDAction verifyAction = new RegFindServiceInterfaceUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY,siElement.getTModel().getTModelKey()); + boolean result = verifyAction.run(); + if (result) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,propertyTable.get(UDDIActionInputs.LATEST_OBJECT)); + return result; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + TModel tModel = (TModel)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + + RegFindBusinessesAdvancedAction action = new RegFindBusinessesAdvancedAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,uddiPerspective.getMessage("NODE_NAME_SI_BUSINESSES",siNode_.getNodeName())); + + ListElement siListElement = new ListElement(tModel); + siListElement.setTargetViewToolInfo(siNode_.getNodeId(),siNode_.getToolManager().getSelectedToolId(),siNode_.getViewId()); + Vector siListVector = new Vector(); + siListVector.addElement(siListElement); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES,siListVector); + + Vector tModelKeyStringVector = new Vector(); + tModelKeyStringVector.addElement(tModel.getTModelKey()); + TModelBag tModelBag = new TModelBag(tModelKeyStringVector); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_TMODELBAG,tModelBag); + + return action.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceInterfaceGetServicesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceInterfaceGetServicesAction.java new file mode 100644 index 000000000..52cbeea5e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ServiceInterfaceGetServicesAction.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import org.uddi4j.datatype.tmodel.*; +import org.uddi4j.util.*; + +import java.util.*; + +public class ServiceInterfaceGetServicesAction extends UDDINodeAction +{ + private ServiceInterfaceNode siNode_; + public ServiceInterfaceGetServicesAction(Controller controller) + { + super(controller); + siNode_ = null; + } + + // uddi/actions/ServiceInterfacGetServicesActionJSP.jsp?nodeId=... + public static String getActionLink(int nodeId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ServiceInterfaceGetServicesActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + return actionLink.toString(); + } + + public final boolean validateServiceInterface() + { + int siNodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + siNode_ = (ServiceInterfaceNode)nodeManager_.getNode(siNodeId); + ServiceInterfaceElement siElement = (ServiceInterfaceElement)siNode_.getTreeElement(); + RegFindServiceInterfaceUUIDAction verifyAction = new RegFindServiceInterfaceUUIDAction(controller_); + Hashtable propertyTable = verifyAction.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE,Boolean.TRUE); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY,siElement.getTModel().getTModelKey()); + boolean result = verifyAction.run(); + if (result) + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,propertyTable.get(UDDIActionInputs.LATEST_OBJECT)); + return result; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + TModel tModel = (TModel)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + + RegFindServicesAdvancedAction action = new RegFindServicesAdvancedAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,uddiPerspective.getMessage("NODE_NAME_SI_SERVICES",siNode_.getNodeName())); + + ListElement siListElement = new ListElement(tModel); + siListElement.setTargetViewToolInfo(siNode_.getNodeId(),siNode_.getToolManager().getSelectedToolId(),siNode_.getViewId()); + Vector siListVector = new Vector(); + siListVector.addElement(siListElement); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES,siListVector); + + Vector tModelKeyStringVector = new Vector(); + tModelKeyStringVector.addElement(tModel.getTModelKey()); + TModelBag tModelBag = new TModelBag(tModelKeyStringVector); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_TMODELBAG,tModelBag); + + return action.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ShowPublisherAssertionsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ShowPublisherAssertionsAction.java new file mode 100644 index 000000000..886bc99bf --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ShowPublisherAssertionsAction.java @@ -0,0 +1,408 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.transport.TransportException; +import org.uddi4j.util.*; +import org.uddi4j.response.*; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.client.UDDIProxy; + +import java.util.*; +import java.net.*; + +public class ShowPublisherAssertionsAction extends CommonPublisherAssertionsAction +{ + + protected String subQueryKey_; + protected boolean isSubQueryGet_; + protected boolean subQueryInitiated_; + protected String newSubQuery_; + protected String newSubQueryItem_; + + public ShowPublisherAssertionsAction(Controller controller) + { + super(controller); + + subQueryKey_ = null; + isSubQueryGet_ = false; + subQueryInitiated_ = false; + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + if (registryNode_ == null) + return false; + + // ids from uddiObjects_table + String[] selectedBusIds = parser.getParameterValues(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID); + if (selectedBusIds != null && selectedBusIds.length > 0) + propertyTable_.put(UDDIActionInputs.PUBLISHER_ASSERTIONS_SELECTED_BUS_ID, selectedBusIds); + + newSubQuery_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_INITIATED); + String isSubQueryGetString = parser.getParameter(UDDIActionInputs.SUBQUERY_GET); + newSubQueryItem_ = parser.getParameter(UDDIActionInputs.NEW_SUBQUERY_QUERY_ITEM); + subQueryKey_ = parser.getParameter(UDDIActionInputs.SUBQUERY_KEY); + + // Validate the data. + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + formToolPI.clearErrors(); + + if (newSubQuery_ != null && newSubQuery_.length() > 0) + subQueryInitiated_ = true; + else + subQueryInitiated_ = false; + + if (isSubQueryGetString != null) + isSubQueryGet_ = Boolean.valueOf(isSubQueryGetString).booleanValue(); + + // if not yet logged in, validate the parameters needed to log in + // NOTE: This action does NOT require the user to be logged in. + if (!isLoggedIn_) { + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (userID != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userID); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + } + + return true; + } + + public final boolean isSubQueryInitiated() + { + return subQueryInitiated_; + } + + public final boolean isSubQueryGet() + { + return isSubQueryGet_; + } + + public final String getSubQueryKey() + { + return subQueryKey_; + } + + public final String getNewSubQuery() + { + return newSubQuery_; + } + + public final String getNewSubQueryItem() + { + return newSubQueryItem_; + } + + public boolean run() + { + // Synchronize client view and server model (uddiObject_table.jsp) + synchronizeUDDIObjectTable(); + + if (registryNode_ == null) + return false; + + RegistryElement registryElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + Node selectedNode = navigatorManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + + if (!(selectedElement instanceof BusinessElement)) + return false; + + // if not yet logged in, log in first + if (!isLoggedIn_) { + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userID = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + try { + if (Validator.validateURL(publishURL) && + Validator.validateString(userID) && + password != null) { + registryElement.performLogin(publishURL, userID, password); + isLoggedIn_ = registryElement.isLoggedIn(); + } + } + catch (TransportException te) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("TransportException"); + messageQueue.addMessage(te.getMessage()); + return false; + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(uddie.toString()); + return false; + } + catch (MalformedURLException me) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("MalformedURLException"); + messageQueue.addMessage(me.getMessage()); + return false; + } + } + + // show all assertion iff is logged in and business is owned + // else show only completed ones + BusinessElement busElement = (BusinessElement)selectedElement; + if (isLoggedIn_ && isBusinessOwned(busElement)) + return showPublisherAssertionsForOwnedBus(busElement); + else + return showPublisherAssertionsForNonOwnedBus(busElement); + } + + private boolean showPublisherAssertionsForOwnedBus(BusinessElement busElement) { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + // try to get a list of all publisher assertion based on the current registry's authToken + ListManager listManager = new ListManager(); + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + formToolPI.removeProperty(UDDIActionInputs.QUERY_INPUT_EXISTING_PUBLISHER_ASSERTIONS); + Vector queryInputVector = new Vector(); + RegistryElement registryElement = (RegistryElement)registryNode_.getTreeElement(); + String userID = registryElement.getUserId(); + String cred = registryElement.getCred(); + + // show all publisher assertions + UDDIProxy proxy = ((RegistryElement)registryNode_.getTreeElement()).getProxy(); + AssertionStatusReport assertionReport; + try { + assertionReport = proxy.get_assertionStatusReport(registryElement.getAuthInfoString(), (CompletionStatus)null); + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + DispositionReport report = uddie.getDispositionReport(); + Vector reportErrInfo = report.getResultVector(); + for (int i = 0; i < reportErrInfo.size(); i++) { + messageQueue.addMessage(((Result) reportErrInfo.get(i)).getErrInfo().getText()); + } + return false; + } + catch (Exception e) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("Exception"); + messageQueue.addMessage(e.getMessage()); + return false; + } + Vector assertionVector = assertionReport.getAssertionStatusItemVector(); + Vector otherBusinessKeys = new Vector(); + Vector pubAssertionElements = new Vector(); + + for (int i = 0; i < assertionVector.size(); i++) { + AssertionStatusItem assertionItem = (AssertionStatusItem)assertionVector.elementAt(i); + // determine the from/to business keys + String fromKey = assertionItem.getFromKey().getText(); + String toKey = assertionItem.getToKey().getText(); + String owningBusinessKey = busElement.getBusinessEntity().getBusinessKey(); + // ignore this assertion if neither the from key nor the to key equals to this business's key + if (!owningBusinessKey.equals(fromKey) && !owningBusinessKey.equals(toKey)) + continue; + String otherBusinessKey = ((owningBusinessKey.equals(fromKey)) ? toKey : fromKey); + // retrieve the information of the "other business" + otherBusinessKeys.add(otherBusinessKey); + + // retrieve the status of the publisher assertion + String status = assertionItem.getCompletionStatus().getText(); + KeyedReference keyedRef = assertionItem.getKeyedReference(); + PublisherAssertionElement pubAssertionElement = new PublisherAssertionElement( + fromKey, + toKey, + owningBusinessKey, + null, + -1, + status, + keyedRef); + pubAssertionElements.add(pubAssertionElement); + } + if (otherBusinessKeys.size() > 0) { + Vector busEntities; + try { + busEntities = proxy.get_businessDetail(otherBusinessKeys).getBusinessEntityVector(); + } + catch (Exception ex) { + busEntities = new Vector(); + if (otherBusinessKeys.size() > 1) { + for (int j = 0; j < otherBusinessKeys.size(); j++) { + try { + busEntities.add(proxy.get_businessDetail((String)otherBusinessKeys.get(j)).getBusinessEntityVector().get(0)); + } + catch (Exception exception) { + pubAssertionElements.remove(j); + } + } + } + else + pubAssertionElements.remove(0); + } + for (int j = 0; j < busEntities.size(); j++) { + BusinessEntity be = (BusinessEntity)busEntities.get(j); + PublisherAssertionElement pubAssertionElement = (PublisherAssertionElement)pubAssertionElements.get(j); + ListElement le = new ListElement(be); + queryInputVector.add(le); + int subQueryItemId = queryInputVector.indexOf(le); + pubAssertionElement.setServiceProvider(le); + pubAssertionElement.setSubQueryItemId(subQueryItemId); + listManager.add(new ListElement(pubAssertionElement)); + } + } + busElement.setPublisherAssertions(listManager); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_EXISTING_PUBLISHER_ASSERTIONS, queryInputVector); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_PUBLISHER_ASSERTIONS_REFRESHED")); + return true; + } + + private boolean showPublisherAssertionsForNonOwnedBus(BusinessElement busElement) { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + // try to get a list of publisher assertions based on the business key + ListManager listManager = new ListManager(); + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = ((MultipleFormToolPropertiesInterface)formTool).getFormToolProperties(subQueryKey_); + formToolPI.removeProperty(UDDIActionInputs.QUERY_INPUT_EXISTING_PUBLISHER_ASSERTIONS); + Vector queryInputVector = new Vector(); + UDDIProxy proxy = ((RegistryElement)registryNode_.getTreeElement()).getProxy(); + RelatedBusinessesList relatedBusList; + try { + relatedBusList = proxy.find_relatedBusinesses(busElement.getBusinessEntity().getBusinessKey(), + (KeyedReference)null, + (FindQualifiers)null); + } + catch (UDDIException uddie) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + DispositionReport report = uddie.getDispositionReport(); + Vector reportErrInfo = report.getResultVector(); + for (int i = 0; i < reportErrInfo.size(); i++) { + messageQueue.addMessage(((Result) reportErrInfo.get(i)).getErrInfo().getText()); + } + return false; + } + catch (Exception e) { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("Exception"); + messageQueue.addMessage(e.getMessage()); + return false; + } + Vector relatedBusVector = relatedBusList.getRelatedBusinessInfos().getRelatedBusinessInfoVector(); + Vector otherBusinessKeys = new Vector(); + Vector pubAssertionElements = new Vector(); + for (int i = 0; i < relatedBusVector.size(); i++) { + RelatedBusinessInfo relatedBusInfo = (RelatedBusinessInfo)relatedBusVector.elementAt(i); + // determine the from/to business keys + String fromKey; + String toKey; + String owningBusinessKey; + ListElement sp; + if (relatedBusInfo.getDefaultSharedRelationships().getDirection().equals(SharedRelationships.DIRECTION_FROMKEY)) { + fromKey = busElement.getBusinessEntity().getBusinessKey(); + toKey = relatedBusInfo.getBusinessKey(); + owningBusinessKey = fromKey; + otherBusinessKeys.add(toKey); + } + else { + fromKey = relatedBusInfo.getBusinessKey(); + toKey = busElement.getBusinessEntity().getBusinessKey(); + owningBusinessKey = toKey; + otherBusinessKeys.add(fromKey); + } + + Vector keyedRefVector = relatedBusInfo.getDefaultSharedRelationships().getKeyedReferenceVector(); + PublisherAssertionElement[] pubAssertionElementArray = new PublisherAssertionElement[keyedRefVector.size()]; + for (int k = 0; k < keyedRefVector.size(); k++) { + // retrieve the status of the publisher assertion + String status = CompletionStatus.COMPLETE; + KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(k); + PublisherAssertionElement pubAssertionElement = new PublisherAssertionElement( + fromKey, + toKey, + owningBusinessKey, + null, + -1, + status, + keyedRef); + pubAssertionElementArray[k] = pubAssertionElement; + } + pubAssertionElements.add(pubAssertionElementArray); + } + if (otherBusinessKeys.size() > 0) { + Vector busEntities; + try { + busEntities = proxy.get_businessDetail(otherBusinessKeys).getBusinessEntityVector(); + } + catch (Exception ex) { + busEntities = new Vector(); + if (otherBusinessKeys.size() > 1) { + for (int j = 0; j < otherBusinessKeys.size(); j++) { + try { + busEntities.add(proxy.get_businessDetail((String)otherBusinessKeys.get(j)).getBusinessEntityVector().get(0)); + } + catch (Exception exception) { + pubAssertionElements.remove(j); + } + } + } + else + pubAssertionElements.remove(0); + } + for (int j = 0; j < busEntities.size(); j++) { + BusinessEntity be = (BusinessEntity)busEntities.get(j); + ListElement le = new ListElement(be); + queryInputVector.add(le); + int subQueryItemId = queryInputVector.indexOf(le); + PublisherAssertionElement[] pubAssertionElementArray = (PublisherAssertionElement[])pubAssertionElements.get(j); + for (int k = 0; k < pubAssertionElementArray.length; k++) { + pubAssertionElementArray[k].setServiceProvider(le); + pubAssertionElementArray[k].setSubQueryItemId(subQueryItemId); + listManager.add(new ListElement(pubAssertionElementArray[k])); + } + } + } + busElement.setPublisherAssertions(listManager); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_EXISTING_PUBLISHER_ASSERTIONS, queryInputVector); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_PUBLISHER_ASSERTIONS_REFRESHED")); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SwitchPerspectiveFromUDDIAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SwitchPerspectiveFromUDDIAction.java new file mode 100644 index 000000000..8a142b386 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/SwitchPerspectiveFromUDDIAction.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +public final class SwitchPerspectiveFromUDDIAction extends ShowPerspectiveAction +{ + public SwitchPerspectiveFromUDDIAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(UDDIActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(UDDIActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(UDDIActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(UDDIActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + String perspectiveContentFramesetCols = (String)propertyTable_.get(UDDIActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(UDDIActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + + // Save the frameset sizes iff no frame is maximized. + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + if (!perspectiveContentFramesetCols.startsWith("100%") && !perspectiveContentFramesetCols.endsWith("100%")) + uddiPerspective.setPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + + if (!actionsContainerFramesetRows.startsWith("100%") && !actionsContainerFramesetRows.endsWith("100%")) + uddiPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + + return super.run(); + } + + public static final String getFormActionLink(int targetPerspectiveId,boolean forHistory) + { + StringBuffer formLink = new StringBuffer("uddi/actions/SwitchPerspectiveFromUDDIActionJSP.jsp?"); + formLink.append(ActionInputs.PERSPECTIVE).append('=').append(targetPerspectiveId); + if (forHistory) + formLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return formLink.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ToggleCategoryNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ToggleCategoryNodeAction.java new file mode 100644 index 000000000..43272da62 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ToggleCategoryNodeAction.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +public class ToggleCategoryNodeAction extends ToggleNodeAction +{ + public ToggleCategoryNodeAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getCategoryManager()); + } + + // uddi/actions/ToggleNavigatorNodeAction.jsp?sId=...&nodeId=...&open=... + public static final String getActionLink(String sessionId,int nodeId,boolean open) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ToggleCategoryNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId); + actionLink.append('&').append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(ActionInputs.OPEN).append('=').append(open?ActionInputs.OPEN_NODE:ActionInputs.CLOSE_NODE); + return actionLink.toString(); + } + + public final boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + performBaseAction(nodeId); + return true; + } + + public final String getActionLinkForHistory() + { + return null; + } + + public final String getTreeContentVar() + { + return "categoryBrowserWindowContent"; + } + + public final String getTreeContentPage() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + return OpenCategoryBrowserAction.getCategoryContentPage(controller_.getSessionId(),uddiPerspective.getCategoryTModelKey()); + } + + public final String getTreeContainerPage() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + return OpenCategoryBrowserAction.getActionLink(controller_.getSessionId(),uddiPerspective.getCategoryTModelKey()); + } + + public final String getPropertiesContainerVar() + { + return null; + } + + public final String getPropertiesContainerPage() + { + return null; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_UDDI; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ToggleNavigatorNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ToggleNavigatorNodeAction.java new file mode 100644 index 000000000..a0fccac81 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/ToggleNavigatorNodeAction.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class ToggleNavigatorNodeAction extends ToggleNodeAction +{ + public ToggleNavigatorNodeAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getNavigatorManager()); + } + + // uddi/actions/ToggleNavigatorNodeAction.jsp?nodeId=...&open=... + public static String getActionLink(int nodeId,boolean open) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/ToggleNavigatorNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(ActionInputs.OPEN).append('=').append(open?ActionInputs.OPEN_NODE:ActionInputs.CLOSE_NODE); + return actionLink.toString(); + } + + // This should be called only to select the toggled node when, at the time of + // the collapse event, a descendant node was selected. + public final String getActionLinkForHistory() + { + ToolManager toolManager = toggledNode_.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + int nodeId = toggledNode_.getNodeId(); + int toolId = selectedTool.getToolId(); + int viewId = toggledNode_.getViewId(); + int viewToolId = toggledNode_.getViewToolId(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return SelectPropertiesToolAction.getActionLink(nodeId,toolId,viewId,viewToolId,true); + else + return SelectNavigatorNodeAction.getActionLink(nodeId,true); + } + + public final String getTreeContentVar() + { + return "navigatorContent"; + } + + public final String getTreeContentPage() + { + return "uddi/navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "propertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "uddi/properties_container.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_UDDI; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/TransferSubQueryResultsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/TransferSubQueryResultsAction.java new file mode 100644 index 000000000..46b313493 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/TransferSubQueryResultsAction.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.util.*; + +public class TransferSubQueryResultsAction extends UDDIPropertiesFormAction +{ + private Node targetNode_; + public TransferSubQueryResultsAction(Controller controller) + { + super(controller); + targetNode_ = null; + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String[] selectedNodeIds = parser.getParameterValues(ActionInputs.NODEID); + // The client Javascript enforces the rule that at least one item was selected before the form can be submitted. + propertyTable_.put(UDDIActionInputs.SELECTED_NODEIDS,selectedNodeIds); + return true; + } + + public static final String getActionLinkForReturn() + { + StringBuffer actionLink = new StringBuffer("uddi/actions/TransferSubQueryResultsActionJSP.jsp?"); + actionLink.append(UDDIActionInputs.SHOW_RESULTS_TARGET).append("=1"); + return actionLink.toString(); + } + + public final void enableShowResultsTarget() + { + // This should only be called if the user clicks on the target link on the query results page. Insert a zero element + // array so that no results are transferred but the jump back to the correct query and its info occurs. + propertyTable_.put(UDDIActionInputs.SELECTED_NODEIDS,new String[0]); + } + + public final boolean run() + { + // Transfer the results in this Query node into the property expected by the originating node. + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + String[] selectedNodeIds = (String[])propertyTable_.get(UDDIActionInputs.SELECTED_NODEIDS); + Node currentNode = getSelectedNavigatorNode(); + TreeElement currentElement = currentNode.getTreeElement(); + SubQueryTransferTarget target = (SubQueryTransferTarget)(currentElement.getPropertyAsObject(UDDIModelConstants.SUBQUERY_TRANSFER_TARGET)); + String subQueryKey = target.getSubQueryKey(); + String targetQueryKey; + + int lastSeparatorPos = subQueryKey.lastIndexOf(':'); + if (lastSeparatorPos == -1) + targetQueryKey = ""; + else + targetQueryKey = subQueryKey.substring(0,lastSeparatorPos); + + String targetProperty = subQueryKey.substring(lastSeparatorPos+1,subQueryKey.length()); + FormTool targetFormTool = target.getTargetFormTool(); + FormToolPropertiesInterface subQueryFormToolPI = ((MultipleFormToolPropertiesInterface)targetFormTool).getFormToolProperties(subQueryKey); + FormToolPropertiesInterface targetQueryFormToolPI = ((MultipleFormToolPropertiesInterface)targetFormTool).getFormToolProperties(targetQueryKey); + Vector targetList = (Vector)targetQueryFormToolPI.getProperty(targetProperty); + if (targetList == null) + targetList = new Vector(); + + NodeManager nodeManager = currentNode.getNodeManager(); + for (int i=0;i<selectedNodeIds.length;i++) + { + int selectedNodeId = Integer.parseInt(selectedNodeIds[i]); + Node selectedNode = nodeManager.getNode(selectedNodeId); + TreeElement treeElement = selectedNode.getTreeElement(); + Object object; + if (treeElement instanceof BusinessElement) + object = ((BusinessElement)treeElement).getBusinessEntity(); + else if (treeElement instanceof ServiceElement) + object = ((ServiceElement)treeElement).getBusinessService(); + else + { + // Service interface + object = ((ServiceInterfaceElement)treeElement).getTModel(); + } + ListElement targetListElement = new ListElement(object); + targetListElement.setTargetViewToolInfo(selectedNodeId,selectedNode.getToolManager().getSelectedToolId(),selectedNode.getViewId()); + if (targetProperty.equals(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_BUSINESS) || targetProperty.equals(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_BUSINESS) || targetProperty.equals(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE)) + { + // Clear the manager so a replacement occurs. + targetList.removeAllElements(); + } + targetList.addElement(targetListElement); + } + targetQueryFormToolPI.setProperty(targetProperty,targetList); + Hashtable savedParentQueryProperties = target.getParentQueryData(); + Enumeration e = savedParentQueryProperties.keys(); + while (e.hasMoreElements()) + { + String key = (String)e.nextElement(); + targetQueryFormToolPI.setProperty(key,savedParentQueryProperties.get(key)); + } + + // Select the node and the datastructure which is the target of the subquery. + int targetNodeId = target.getNodeId(); + int targetToolId = target.getToolId(); + int targetViewId = target.getViewId(); + int targetViewToolId = target.getViewToolId(); + nodeManager.setSelectedNodeId(targetNodeId); + targetNode_ = nodeManager.getSelectedNode(); + targetNode_.getToolManager().setSelectedToolId(targetToolId); + targetNode_.setViewId(targetViewId); + if (targetViewId != ActionInputs.VIEWID_DEFAULT) + targetNode_.getViewToolManager().setSelectedToolId(targetViewToolId); + targetFormTool.setProperty(UDDIActionInputs.SUBQUERY_KEY,targetQueryKey); + addToHistory(ActionInputs.PERSPECTIVE_UDDI,SelectFindToolAction.getActionLink(targetNodeId,targetToolId,targetViewId,targetViewToolId,targetQueryKey,true)); + return true; + } + + public final Node getTargetNode() + { + return targetNode_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/TransferToAddCategoryDataAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/TransferToAddCategoryDataAction.java new file mode 100644 index 000000000..566b0b800 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/TransferToAddCategoryDataAction.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import javax.servlet.http.*; + +public class TransferToAddCategoryDataAction extends Action +{ + public TransferToAddCategoryDataAction() + { + } + + // uddi/actions/TransferToAddCategoryDataActionJSP.jsp?sessionId=...&categoryTModelKey=... + public static final String getActionLink(String sessionId,String categoryTModelKey) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/TransferToAddCategoryDataActionJSP.jsp?"); + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId).append('&').append(UDDIActionInputs.CATEGORY_TMODEL_KEY).append('=').append(categoryTModelKey); + return actionLink.toString(); + } + + public final boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public final boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIAddToWSDLPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIAddToWSDLPerspectiveAction.java new file mode 100644 index 000000000..7ee647917 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIAddToWSDLPerspectiveAction.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.*; + +import org.uddi4j.datatype.service.BusinessService; + +import javax.servlet.http.*; +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; + +import java.util.*; +import java.net.*; +import java.io.*; + +public class UDDIAddToWSDLPerspectiveAction extends LinkAction +{ + public UDDIAddToWSDLPerspectiveAction(Controller controller) + { + super(controller); + } + + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId) + { + StringBuffer actionLink = new StringBuffer("uddi/actions/UDDIAddToWSDLPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeId); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolId); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewId); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolId); + return actionLink.toString(); + } + + protected boolean processLinkParameters(HttpServletRequest request) + { + String nodeIdString = request.getParameter(ActionInputs.NODEID); + // Perform data validation. + try + { + int nodeId = Integer.parseInt(nodeIdString); + } + catch (NumberFormatException e) + { + // Validation failed! + return false; + } + propertyTable_.put(ActionInputs.NODEID,nodeIdString); + return true; + } + + public boolean run() + { + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager nodeManager = uddiPerspective.getNavigatorManager(); + Node node = nodeManager.getNode(nodeId); + TreeElement element = node.getTreeElement(); + if (element instanceof ServiceElement) + { + ServiceElement serviceElement = (ServiceElement)element; + BusinessService bs = serviceElement.getBusinessService(); + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + String wsdlURL = uddi4jHelper.getWSDL(bs, serviceElement.getRegistryElement().getProxy()); + if (wsdlURL == null) + { + try + { + Definition def = uddi4jHelper.getWSDLDefinition(wsdlURL); + File tempFile = File.createTempFile("temp",".wsdl"); + UDDIImportWSDLToFileSystemAction action = new UDDIImportWSDLToFileSystemAction(controller_); + action.writeWSDLDefinition(new FileOutputStream(tempFile),def); + wsdlURL = tempFile.toURL().toString(); + } + catch (WSDLException e) + { + wsdlURL = null; + } + catch (MalformedURLException e) + { + wsdlURL = null; + } + catch (IOException e) + { + wsdlURL = null; + } + } + + if (wsdlURL != null) + { + OpenWSDLAction openWSDLAction = new OpenWSDLAction(controller_); + Hashtable propertyTable = openWSDLAction.getPropertyTable(); + propertyTable.put(ActionInputs.QUERY_INPUT_WSDL_URL,wsdlURL); + boolean actionResult = openWSDLAction.run(); + if (actionResult) { + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_WSDL_ADDED_TO_WSDL_PERSPECTIVE",wsdlURL)); + return true; + } + } + } + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_WSDL_NOT_ADDED_TO_WSDL_PERSPECTIVE")); + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIImportWSDLToFileSystemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIImportWSDLToFileSystemAction.java new file mode 100644 index 000000000..f0b281f16 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIImportWSDLToFileSystemAction.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; + +import java.io.*; +import javax.wsdl.Definition; + +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +public class UDDIImportWSDLToFileSystemAction extends ImportToFileSystemAction +{ + private NodeManager nodeManager_; + private Definition def_; + private String defaultWSDLFileName_; + + public UDDIImportWSDLToFileSystemAction(Controller controller) + { + super(controller); + nodeManager_ = controller.getUDDIPerspective().getNavigatorManager(); + def_ = null; + defaultWSDLFileName_ = "temp.wsdl"; + } + + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId) + { + return ImportToFileSystemAction.getActionLink(nodeId,toolId,viewId,viewToolId,"uddi/actions/UDDIImportWSDLToFileSystemActionJSP.jsp"); + } + + public final boolean write(OutputStream os) + { + return writeWSDLDefinition(os,def_); + } + + public final String getDefaultFileName() + { + return defaultWSDLFileName_; + } + + public final boolean run() + { + MessageQueue messageQueue = controller_.getUDDIPerspective().getMessageQueue(); + int nodeId = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + Node node = nodeManager_.getNode(nodeId); + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + String wsdlUrl = null; + if (node != null) + { + TreeElement element = node.getTreeElement(); + if (element instanceof ServiceElement) + { + ServiceElement serviceElement = (ServiceElement)element; + BusinessService bs = serviceElement.getBusinessService(); + wsdlUrl = uddi4jHelper.getWSDL(bs, serviceElement.getRegistryElement().getProxy()); + } + else if (element instanceof ServiceInterfaceElement) + { + TModel tModel = ((ServiceInterfaceElement)element).getTModel(); + wsdlUrl = uddi4jHelper.getWSDL(tModel); + } + } + if (wsdlUrl != null) + { + try + { + def_ = uddi4jHelper.getWSDLDefinition(wsdlUrl); + if (def_ != null) + { + String wsdlPathname; + int index = wsdlUrl.indexOf('/'); + if (index != -1) + wsdlPathname = wsdlUrl.substring(index+1, wsdlUrl.length()); + else + wsdlPathname = wsdlUrl; + defaultWSDLFileName_ = WSDLFileNameHelper.getWSDLFileName(wsdlPathname); + } + return true; + } + catch (Throwable t) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_RETRIEVING_WSDL_DOC")); + } + } + return false; + } + + public final String getStatusContentVar() + { + return controller_.getUDDIPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getUDDIPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIImportWSDLToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIImportWSDLToWorkbenchAction.java new file mode 100644 index 000000000..083435a37 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIImportWSDLToWorkbenchAction.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +import java.util.Hashtable; + +public class UDDIImportWSDLToWorkbenchAction extends ImportToWorkbenchAction +{ + public UDDIImportWSDLToWorkbenchAction(Controller controller) + { + super(controller); + } + + public FormTool getSelectedFormTool() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + return (FormTool)uddiPerspective.getNavigatorManager().getSelectedNode().getCurrentToolManager().getSelectedTool(); + } + + public ImportToFileSystemAction newImportToFileSystemAction() { + UDDIImportWSDLToFileSystemAction action = new UDDIImportWSDLToFileSystemAction(controller_); + Hashtable table = action.getPropertyTable(); + + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + NodeManager nodeManager = uddiPerspective.getNavigatorManager(); + Node selectedNode = nodeManager.getSelectedNode(); + + table.put(ActionInputs.NODEID, String.valueOf(selectedNode.getNodeId())); + + return action; + } + + public final String getStatusContentVar() + { + return controller_.getUDDIPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getUDDIPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDILaunchWebServiceWizardAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDILaunchWebServiceWizardAction.java new file mode 100644 index 000000000..b290772f8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDILaunchWebServiceWizardAction.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; + +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +import java.io.*; +import javax.wsdl.Definition; + +public class UDDILaunchWebServiceWizardAction extends LaunchWebServiceWizardAction +{ + public UDDILaunchWebServiceWizardAction(Controller controller) + { + super(controller); + } + + public FormTool getSelectedFormTool() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + return (FormTool)uddiPerspective.getNavigatorManager().getSelectedNode().getCurrentToolManager().getSelectedTool(); + } + + public boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager nodeManager = uddiPerspective.getNavigatorManager(); + Node node = nodeManager.getSelectedNode(); + TreeElement element = node.getTreeElement(); + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + String wsdlUrl = null; + if (element instanceof ServiceElement) + { + ServiceElement serviceElement = (ServiceElement)element; + BusinessService bs = serviceElement.getBusinessService(); + wsdlUrl = uddi4jHelper.getWSDL(bs, serviceElement.getRegistryElement().getProxy()); + } + else if (element instanceof ServiceInterfaceElement) + { + TModel tModel = ((ServiceInterfaceElement)element).getTModel(); + wsdlUrl = uddi4jHelper.getWSDL(tModel); + } + + try + { + if (wsdlUrl != null) + { + Definition def = uddi4jHelper.getWSDLDefinition(wsdlUrl); + File tempFile = File.createTempFile("temp",".wsdl"); + UDDIImportWSDLToFileSystemAction action = new UDDIImportWSDLToFileSystemAction(controller_); + action.writeWSDLDefinition(new FileOutputStream(tempFile),def); + wsdlUrl = tempFile.toURL().toString(); + return launchWizard(wsdlUrl); + } + } + catch (Throwable t) + { + messageQueue.addMessage(controller_.getMessage("MSG_ERROR_RETRIEVING_WSDL_DOC")); + } + return false; + } + + public final String getStatusContentVar() + { + return controller_.getUDDIPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getUDDIPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDINodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDINodeAction.java new file mode 100644 index 000000000..d21e58239 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDINodeAction.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +public abstract class UDDINodeAction extends NodeAction +{ + protected RegistryNode regNode_; + public UDDINodeAction(Controller controller) + { + super(controller,controller.getUDDIPerspective().getNavigatorManager()); + regNode_ = getRegistryNode(); + } + + public final Node getSelectedNavigatorNode() + { + Node selectedNavigatorNode = nodeManager_.getSelectedNode(); + return selectedNavigatorNode; + } + + public final RegistryNode getRegistryNode() + { + UDDIMainNode uddiMainNode = (UDDIMainNode)nodeManager_.getRootNode(); + return uddiMainNode.getRegistryNode(getSelectedNavigatorNode()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIPropertiesFormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIPropertiesFormAction.java new file mode 100644 index 000000000..4dd19b6bf --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UDDIPropertiesFormAction.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; + +public abstract class UDDIPropertiesFormAction extends FormAction +{ + protected NodeManager navigatorManager_; + public UDDIPropertiesFormAction(Controller controller) + { + super(controller); + navigatorManager_ = controller.getUDDIPerspective().getNavigatorManager(); + } + + public final Node getSelectedNavigatorNode() + { + return navigatorManager_.getSelectedNode(); + } + + public final FormTool getSelectedFormTool() + { + return (FormTool)(getSelectedNavigatorNode().getCurrentToolManager().getSelectedTool()); + } + + public final RegistryNode getRegistryNode() + { + return getRegistryNode(getSelectedNavigatorNode()); + } + + public final RegistryNode getRegistryNode(Node registryChildNode) + { + UDDIMainNode uddiMainNode = (UDDIMainNode)navigatorManager_.getRootNode(); + return uddiMainNode.getRegistryNode(registryChildNode); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UnpublishAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UnpublishAction.java new file mode 100644 index 000000000..b3cca2804 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UnpublishAction.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.transport.TransportException; +import org.uddi4j.response.*; +import org.uddi4j.*; +import org.uddi4j.client.UDDIProxy; + +import java.net.*; + +public class UnpublishAction extends UDDIPropertiesFormAction +{ + protected RegistryNode registryNode_; + protected boolean isLoggedIn_; + + public UnpublishAction(Controller controller) + { + super(controller); + registryNode_ = getRegistryNode(); + } + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + RegistryElement regElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + + // if not yet logged in, validate the parameters needed to log in + if (!regElement.isLoggedIn()) + { + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + boolean inputsValid = true; + if (publishURL != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL, publishURL); + + if (!Validator.validateURL(publishURL)) + { + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + inputsValid = false; + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userId != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + + if (!Validator.validateString(userId)) + { + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + inputsValid = false; + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD, password); + + formTool.updatePropertyTable(propertyTable_); + + return inputsValid; + } + + return true; + } + + public boolean run() + { + RegistryElement registryElement = (RegistryElement)registryNode_.getTreeElement(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + NodeManager navigatorManager = uddiPerspective.getNavigatorManager(); + Node selectedNode = navigatorManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + + try + { + if (!registryElement.isLoggedIn()) + { + // if not yet logged in, log in first + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + + registryElement.performLogin(publishURL,userId,password); + } + + String selectedElementKey = selectedElement.getKey(); + String unpublishTypeMessageKey = null; + UDDIProxy proxy = registryElement.getProxy(); + String authInfo = registryElement.getAuthInfoString(); + DispositionReport dr = null; + if (selectedElement instanceof BusinessElement) + { + unpublishTypeMessageKey = "MSG_INFO_BUSINESS_UNPUBLISHED"; + dr = proxy.delete_business(authInfo,selectedElementKey); + } + else if (selectedElement instanceof ServiceElement) + { + unpublishTypeMessageKey = "MSG_INFO_SERVICE_UNPUBLISHED"; + dr = proxy.delete_service(authInfo,selectedElementKey); + } + else if (selectedElement instanceof ServiceInterfaceElement) + { + unpublishTypeMessageKey = "MSG_INFO_SERVICE_INTERFACE_UNPUBLISHED"; + dr = proxy.delete_tModel(authInfo,selectedElementKey); + } + if (!dr.success()) + throw new Exception(dr.toString()); + else + { + selectedElement.disconnectAll(); + messageQueue.addMessage(uddiPerspective.getMessage(unpublishTypeMessageKey,selectedElement.getName())); + return true; + } + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + return false; + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + return false; + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + return false; + } + catch (Exception e) + { + handleUnexpectedException(uddiPerspective, messageQueue, "Exception", e); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateAction.java new file mode 100644 index 000000000..2bfbb9958 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateAction.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.MultipartFormDataParserTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +import java.util.*; + +public abstract class UpdateAction extends UDDIPropertiesFormAction +{ + protected RegistryNode regNode_; + private boolean requiresAuthentication_; + public UpdateAction(Controller controller,boolean requiresAuthentication) + { + super(controller); + regNode_ = getRegistryNode(); + requiresAuthentication_ = requiresAuthentication; + } + + protected abstract boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException; + + protected final boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + // Setup for MultipartFormDataParserTransformer + propertyTable_.put(ActionInputs.MULTIPART_FORM_DATA_PARSER, parser); + + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + FormToolPropertiesInterface formToolPI = formTool; + formToolPI.clearErrors(); + boolean inputsValid = processOthers(parser,formToolPI); + for (int i=0;i<removedProperties_.size();i++) + formToolPI.removeProperty(removedProperties_.elementAt(i)); + formToolPI.updatePropertyTable(propertyTable_); + + String publishURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + + boolean validateAuthentication = !regElement.isLoggedIn() & requiresAuthentication_; + + if (publishURL != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + } + + if (validateAuthentication && !Validator.validateString(publishURL)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_PUBLISH_URL")); + } + + if (userId != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + } + + if (validateAuthentication && !Validator.validateString(userId)) + { + inputsValid = false; + formTool.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USERID")); + } + + if (password != null) + { + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + formTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + + return inputsValid; + } + + public abstract boolean refreshFromRegistry(); + + protected final void refreshNode(BusinessEntity be) + { + Node node = getSelectedNavigatorNode(); + Node parentNode = node.getParent(); + TreeElement element = node.getTreeElement(); + element.disconnectAll(); + BusinessElement newBusinessElement = new BusinessElement(be,regNode_.getTreeElement().getModel()); + connectElements(parentNode,newBusinessElement); + } + + protected final void refreshNode(BusinessService bs) + { + Node node = getSelectedNavigatorNode(); + Node parentNode = node.getParent(); + TreeElement element = node.getTreeElement(); + element.disconnectAll(); + ServiceElement newServiceElement = new ServiceElement(bs,regNode_.getTreeElement().getModel()); + connectElements(parentNode,newServiceElement); + } + + protected final void refreshNode(TModel tModel) + { + Node node = getSelectedNavigatorNode(); + Node parentNode = node.getParent(); + TreeElement element = node.getTreeElement(); + element.disconnectAll(); + ServiceInterfaceElement newServiceInterfaceElement = new ServiceInterfaceElement(tModel,regNode_.getTreeElement().getModel()); + connectElements(parentNode,newServiceInterfaceElement); + } + + private final void connectElements(Node parentNode,TreeElement newElement) + { + TreeElement parentElement = parentNode.getTreeElement(); + String rel = null; + if (parentNode instanceof PublishedItemsNode) + rel = UDDIModelConstants.REL_PUBLISHED_ITEMS; + else + { + // QueryNode + rel = UDDIModelConstants.REL_QUERY_RESULTS; + } + parentElement.connect(newElement,rel,ModelConstants.REL_OWNER); + Node newNode = parentNode.getChildNode(newElement); + int newNodeId = newNode.getNodeId(); + NodeManager nodeManager = parentNode.getNodeManager(); + nodeManager.setSelectedNodeId(newNodeId); + ToolManager toolManager = newNode.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + addToHistory(ActionInputs.PERSPECTIVE_UDDI,selectedTool.getSelectToolActionHref(true)); + } + + protected final void reindexListElementVector(Vector v) + { + for (int i=0;i<v.size();i++) + { + ListElement listElement = (ListElement)v.elementAt(i); + listElement.setViewId(i); + // targetViewId determines whether or not a successfully validated list element remains in edit state. + } + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length + 1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length - 1] = new MultipartFormDataParserTransformer(controller_); + return transformers; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateBusinessAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateBusinessAction.java new file mode 100644 index 000000000..b4db6d92a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateBusinessAction.java @@ -0,0 +1,401 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.*; +import org.uddi4j.util.*; + +import java.util.*; +import java.net.*; + +public class UpdateBusinessAction extends UpdateAction +{ + private boolean isUpdate_; + public UpdateBusinessAction(Controller controller) + { + super(controller,true); + isUpdate_ = true; + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String uuidKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + String[] discoveryURLModifiedStates = parser.getParameterValues(UDDIActionInputs.DISCOVERYURL_MODIFIED); + String[] discoveryURLViewIds = parser.getParameterValues(UDDIActionInputs.DISCOVERYURL_VIEWID); + String[] discoveryURLs = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DISCOVERYURL); + String[] nameModifiedStates = parser.getParameterValues(UDDIActionInputs.NAME_MODIFIED); + String[] nameViewIds = parser.getParameterValues(UDDIActionInputs.NAME_VIEWID); + String[] nameLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME_LANGUAGE); + String[] names = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME); + String[] descriptionModifiedStates = parser.getParameterValues(UDDIActionInputs.DESCRIPTION_MODIFIED); + String[] descriptionViewIds = parser.getParameterValues(UDDIActionInputs.DESCRIPTION_VIEWID); + String[] descriptionLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE); + String[] descriptions = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION); + String[] idModifiedStates = parser.getParameterValues(UDDIActionInputs.IDENTIFIER_MODIFIED); + String[] idViewIds = parser.getParameterValues(UDDIActionInputs.IDENTIFIER_VIEWID); + String[] idTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE); + String[] idKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME); + String[] idKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE); + String[] catModifiedStates = parser.getParameterValues(UDDIActionInputs.CATEGORY_MODIFIED); + String[] catViewIds = parser.getParameterValues(UDDIActionInputs.CATEGORY_VIEWID); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (uuidKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,uuidKey); + + + if (discoveryURLModifiedStates != null && discoveryURLViewIds != null && discoveryURLs != null) + { + Vector oldDiscoveryURLListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + Vector newDiscoveryURLListElementVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DISCOVERYURL"); + for (int i=0;i<discoveryURLs.length;i++) + { + parameters[1] = String.valueOf(i+1); + DiscoveryURL discoveryURL = new DiscoveryURL(discoveryURLs[i],""); + if (!Validator.validateURL(discoveryURLs[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + + int discoveryURLViewId = Integer.parseInt(discoveryURLViewIds[i]); + boolean isModified = Boolean.valueOf(discoveryURLModifiedStates[i]).booleanValue(); + + if (discoveryURLViewId == -1 || isModified) + newDiscoveryURLListElementVector.addElement(new ListElement(discoveryURL)); + else + newDiscoveryURLListElementVector.addElement(oldDiscoveryURLListElementVector.elementAt(discoveryURLViewId)); + } + reindexListElementVector(newDiscoveryURLListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS,newDiscoveryURLListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + + Hashtable languageHash = new Hashtable(); + if (nameModifiedStates != null && nameViewIds != null && nameLanguages != null && names != null) + { + Vector oldNameListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + Vector newNameListElementVector = new Vector(); + // UDDI's save API (Appendix C of the UDDI V2 Programmers API Specification) requires the following: + // 1) Only the first row can have a blank language. + // 2) Only 1 name per language. + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_NAME"); + for (int i=0;i<names.length;i++) + { + parameters[1] = String.valueOf(i+1); + Name uddi4jName; + if (nameLanguages[i].length() > 0) + uddi4jName = new Name(names[i],nameLanguages[i]); + else + { + uddi4jName = new Name(names[i]); + if (i != 0) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(nameLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(nameLanguages[i],Boolean.TRUE); + if (!Validator.validateString(names[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + + int nameViewId = Integer.parseInt(nameViewIds[i]); + boolean isModified = Boolean.valueOf(nameModifiedStates[i]).booleanValue(); + + if (nameViewId == -1 || isModified) + newNameListElementVector.addElement(new ListElement(uddi4jName)); + else + newNameListElementVector.addElement(oldNameListElementVector.elementAt(nameViewId)); + } + reindexListElementVector(newNameListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,newNameListElementVector); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NO_NAMES")); + } + + if (descriptionModifiedStates != null && descriptionViewIds != null && descriptionLanguages != null && descriptions != null) + { + Vector oldDescriptionListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS); + Vector newDescriptionListElementVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DESCRIPTION"); + languageHash.clear(); + for (int i=0;i<descriptions.length;i++) + { + parameters[1] = String.valueOf(i+1); + Description uddi4jDescription; + if (descriptionLanguages[i].length() > 0) + uddi4jDescription = new Description(descriptions[i],descriptionLanguages[i]); + else + { + uddi4jDescription = new Description(descriptions[i]); + if (i != 0) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(descriptionLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(descriptionLanguages[i],Boolean.TRUE); + if (!Validator.validateString(descriptions[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + + int descriptionViewId = Integer.parseInt(descriptionViewIds[i]); + boolean isModified = Boolean.valueOf(descriptionModifiedStates[i]).booleanValue(); + + if (descriptionViewId == -1 || isModified) + newDescriptionListElementVector.addElement(new ListElement(uddi4jDescription)); + else + newDescriptionListElementVector.addElement(oldDescriptionListElementVector.elementAt(descriptionViewId)); + } + reindexListElementVector(newDescriptionListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,newDescriptionListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS); + + if (idModifiedStates != null && idViewIds != null && idTypes != null && idKeyNames != null && idKeyValues != null) + { + Vector oldIdListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + Vector newIdListElementVector = new Vector(); + for (int i=0;i<idKeyNames.length;i++) + { + KeyedReference kr = new KeyedReference(idKeyNames[i],idKeyValues[i],idTypes[i]); + int idViewId = Integer.parseInt(idViewIds[i]); + boolean isModified = Boolean.valueOf(idModifiedStates[i]).booleanValue(); + if (idViewId == -1 || isModified) + newIdListElementVector.addElement(new ListElement(kr)); + else + newIdListElementVector.addElement(oldIdListElementVector.elementAt(idViewId)); + } + reindexListElementVector(newIdListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS,newIdListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + + if (catModifiedStates != null && catViewIds != null && catTypes != null && catKeyNames != null && catKeyValues != null) + { + Vector oldCatListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + Vector newCatListElementVector = new Vector(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + int catViewId = Integer.parseInt(catViewIds[i]); + boolean isModified = Boolean.valueOf(catModifiedStates[i]).booleanValue(); + if (catViewId == -1 || isModified) + newCatListElementVector.addElement(new ListElement(kr)); + else + newCatListElementVector.addElement(oldCatListElementVector.elementAt(catViewId)); + } + reindexListElementVector(newCatListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES,newCatListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + return inputsValid; + } + + public final boolean refreshFromRegistry() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String uuidKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + Vector beVector = proxy.get_businessDetail(uuidKey).getBusinessEntityVector(); + BusinessEntity be; + if (beVector.size() > 0) + be = (BusinessEntity)beVector.get(0); + else + be = null; + if (be != null) + { + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,be); + return true; + } + } + catch (TransportException e) + { + // Feedback via Javascript popups. + } + catch (UDDIException e) + { + // Feedback via Javascript popups. + } + isUpdate_ = false; + return false; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + BusinessEntity be = (BusinessEntity)propertyTable_.get(UDDIActionInputs.LATEST_OBJECT); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + Vector discoveryURLListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS); + Vector nameListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES); + Vector descriptionListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS); + Vector idListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS); + Vector catListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES); + + Vector discoveryURLVector = new Vector(); + if (discoveryURLListElementVector != null) + { + for (int i=0;i<discoveryURLListElementVector.size();i++) + { + ListElement listElement = (ListElement)discoveryURLListElementVector.elementAt(i); + DiscoveryURL discoveryURL = (DiscoveryURL)listElement.getObject(); + discoveryURLVector.addElement(discoveryURL); + } + } + + Vector nameVector = new Vector(); + for (int i=0;i<nameListElementVector.size();i++) + { + ListElement listElement = (ListElement)nameListElementVector.elementAt(i); + Name name = (Name)listElement.getObject(); + nameVector.addElement(name); + } + + Vector descriptionVector = null; + if (descriptionListElementVector != null) + { + descriptionVector = new Vector(); + for (int i=0;i<descriptionListElementVector.size();i++) + { + ListElement listElement = (ListElement)descriptionListElementVector.elementAt(i); + Description description = (Description)listElement.getObject(); + descriptionVector.addElement(description); + } + } + + IdentifierBag idBag = null; + if (idListElementVector != null) + { + idBag = new IdentifierBag(); + for (int i=0;i<idListElementVector.size();i++) + { + ListElement listElement = (ListElement)idListElementVector.elementAt(i); + KeyedReference kr = (KeyedReference)listElement.getObject(); + idBag.add(kr); + } + } + + CategoryBag catBag = null; + if (catListElementVector != null) + { + catBag = new CategoryBag(); + for (int i=0;i<catListElementVector.size();i++) + { + ListElement listElement = (ListElement)catListElementVector.elementAt(i); + KeyedReference kr = (KeyedReference)listElement.getObject(); + catBag.add(kr); + } + } + + if (discoveryURLVector.size() > 0) + be.setDiscoveryURLs(new DiscoveryURLs(discoveryURLVector)); + else + be.setDiscoveryURLs(null); + be.setNameVector(nameVector); + be.setDescriptionVector(descriptionVector); + be.setIdentifierBag(idBag); + be.setCategoryBag(catBag); + + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + UDDIProxy proxy = regElement.getProxy(); + Vector beVector = new Vector(); + beVector.add(be); + be = (BusinessEntity)proxy.save_business(regElement.getAuthInfoString(), beVector).getBusinessEntityVector().get(0); + refreshNode(be); + if (isUpdate_) + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESS_UPDATED",be.getDefaultNameString())); + else + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_BUSINESS_PUBLISHED",be.getDefaultNameString())); + return true; + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateRegistryAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateRegistryAction.java new file mode 100644 index 000000000..acc9a12f2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateRegistryAction.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import java.text.*; +import java.io.*; + +public class UpdateRegistryAction extends UpdateAction +{ + public UpdateRegistryAction(Controller controller) + { + super(controller,false); + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String nameModifiedState = parser.getParameter(UDDIActionInputs.NAME_MODIFIED); + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME); + String[] userDefinedCategoryTModelKeys = parser.getParameterValues(UDDIActionInputs.CATEGORY_TMODEL_KEY); + String[] userDefinedCategoryData = parser.getParameterValues(UDDIActionInputs.CATEGORY_FILENAME); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (nameModifiedState != null && name != null) + { + boolean isModified = Boolean.valueOf(nameModifiedState).booleanValue(); + String newName; + if (isModified) + newName = name; + else + newName = (String)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME,newName); + if (!Validator.validateString(name)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_NAME")); + } + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME); + + if (userDefinedCategoryTModelKeys != null && userDefinedCategoryData != null) + { + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + for (int i=0;i<userDefinedCategoryTModelKeys.length;i++) + { + CategoryModel userDefinedCategory = regElement.getUserDefinedCategory(userDefinedCategoryTModelKeys[i]); +// TODO: Move UDDIPreferenceContext down to org.eclipse.wst.ws +// UDDIPreferenceContext context = WebServicePlugin.getInstance().getUDDIPreferenceContext(); +// userDefinedCategory.setColumnDelimiter(context.getUddiCatDataColumnDelimiter()); +// userDefinedCategory.setStringDelimiter(context.getUddiCatDataStringDelimiter()); + userDefinedCategory.setColumnDelimiter("#"); + userDefinedCategory.setStringDelimiter("\""); + String displayName = userDefinedCategory.getDisplayName(); + if (userDefinedCategoryData[i] == null || userDefinedCategoryData[i].length() < 1) + { + inputsValid = false; + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USER_DEFINED_CATEGORY_DATA_FILE",displayName)); + formToolPI.flagRowError(UDDIActionInputs.USER_DEFINED_CATEGORIES,userDefinedCategoryTModelKeys[i]); + } + else + { + byte rc = userDefinedCategory.loadData(new BufferedReader(new StringReader(userDefinedCategoryData[i]))); + switch (rc) + { + case CategoryModel.OPERATION_SUCCESSFUL: + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_USER_DEFINED_CATEGORY_DATA_LOADED",displayName)); + break; + case CategoryModel.ERROR_FILE: + inputsValid = false; + ParseException pe = (ParseException)userDefinedCategory.getErrorException(); + String[] args1 = {String.valueOf(pe.getErrorOffset()),displayName,pe.getMessage(),userDefinedCategory.getCategoryKey()}; + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USER_DEFINED_CATEGORY_DATA_FILE_FORMAT",args1)); + formToolPI.flagRowError(UDDIActionInputs.USER_DEFINED_CATEGORIES,userDefinedCategoryTModelKeys[i]); + break; + case CategoryModel.ERROR_CATEGORY_KEY: + default: + inputsValid = false; + String[] args2 = {displayName,userDefinedCategory.getErrorException().getMessage(),userDefinedCategory.getCategoryKey()}; + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_USER_DEFINED_CATEGORY_DATA_FILE_KEY",args2)); + formToolPI.flagRowError(UDDIActionInputs.USER_DEFINED_CATEGORIES,userDefinedCategoryTModelKeys[i]); + } + } + } + } + return inputsValid; + } + + public final boolean refreshFromRegistry() + { + return true; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + String name = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + regElement.setName(name); + regNode_.getTreeElement().setName(name); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_REGISTRY_UPDATED",name)); + return true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateServiceAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateServiceAction.java new file mode 100644 index 000000000..309b18f32 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateServiceAction.java @@ -0,0 +1,483 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.*; +import org.uddi4j.response.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.util.*; +import org.uddi4j.UDDIException; + +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; +import java.util.*; +import java.net.*; + +public class UpdateServiceAction extends UpdateAction +{ + private boolean isUpdate_; + public UpdateServiceAction(Controller controller) + { + super(controller,true); + isUpdate_ = true; + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String uuidBusinessKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + String uuidServiceKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY); + String wsdlURLModifiedState = parser.getParameter(UDDIActionInputs.WSDL_URL_MODIFIED); + String wsdlURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + String[] nameModifiedStates = parser.getParameterValues(UDDIActionInputs.NAME_MODIFIED); + String[] nameViewIds = parser.getParameterValues(UDDIActionInputs.NAME_VIEWID); + String[] nameLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME_LANGUAGE); + String[] names = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_NAME); + String[] descriptionModifiedStates = parser.getParameterValues(UDDIActionInputs.DESCRIPTION_MODIFIED); + String[] descriptionViewIds = parser.getParameterValues(UDDIActionInputs.DESCRIPTION_VIEWID); + String[] descriptionLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE); + String[] descriptions = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION); + String[] catModifiedStates = parser.getParameterValues(UDDIActionInputs.CATEGORY_MODIFIED); + String[] catViewIds = parser.getParameterValues(UDDIActionInputs.CATEGORY_VIEWID); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (uuidBusinessKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,uuidBusinessKey); + + if (uuidServiceKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,uuidServiceKey); + + if (wsdlURLModifiedState != null && wsdlURL != null) + { + ListElement wsdlURLListElement = (ListElement)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + boolean isModified = Boolean.valueOf(wsdlURLModifiedState).booleanValue(); + if (isModified) + wsdlURLListElement = new ListElement(wsdlURL); + else + wsdlURL = (String)wsdlURLListElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL,wsdlURLListElement); + if (!Validator.validateURL(wsdlURL)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_WSDL_URL")); + } + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + + Hashtable languageHash = new Hashtable(); + if (nameModifiedStates != null && nameViewIds != null && nameLanguages != null && names != null) + { + Vector oldNameListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + Vector newNameListElementVector = new Vector(); + // UDDI's save API (Appendix C of the UDDI V2 Programmers API Specification) requires the following: + // 1) Only the first row can have a blank language. + // 2) Only 1 name per language. + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_NAME"); + for (int i=0;i<names.length;i++) + { + parameters[1] = String.valueOf(i+1); + Name uddi4jName; + if (nameLanguages[i].length() > 0) + uddi4jName = new Name(names[i],nameLanguages[i]); + else + { + uddi4jName = new Name(names[i]); + if (i != 0) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(nameLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(nameLanguages[i],Boolean.TRUE); + if (!Validator.validateString(names[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + + int nameViewId = Integer.parseInt(nameViewIds[i]); + boolean isModified = Boolean.valueOf(nameModifiedStates[i]).booleanValue(); + + if (nameViewId == -1 || isModified) + newNameListElementVector.addElement(new ListElement(uddi4jName)); + else + newNameListElementVector.addElement(oldNameListElementVector.elementAt(nameViewId)); + } + reindexListElementVector(newNameListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,newNameListElementVector); + } + else + { + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_NO_NAMES")); + } + + if (descriptionModifiedStates != null && descriptionViewIds != null && descriptionLanguages != null && descriptions != null) + { + Vector oldDescriptionListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + Vector newDescriptionListElementVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DESCRIPTION"); + languageHash.clear(); + for (int i=0;i<descriptions.length;i++) + { + parameters[1] = String.valueOf(i+1); + Description uddi4jDescription; + if (descriptionLanguages[i].length() > 0) + uddi4jDescription = new Description(descriptions[i],descriptionLanguages[i]); + else + { + uddi4jDescription = new Description(descriptions[i]); + if (i != 0) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(descriptionLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(descriptionLanguages[i],Boolean.TRUE); + if (!Validator.validateString(descriptions[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + + int descriptionViewId = Integer.parseInt(descriptionViewIds[i]); + boolean isModified = Boolean.valueOf(descriptionModifiedStates[i]).booleanValue(); + + if (descriptionViewId == -1 || isModified) + newDescriptionListElementVector.addElement(new ListElement(uddi4jDescription)); + else + newDescriptionListElementVector.addElement(oldDescriptionListElementVector.elementAt(descriptionViewId)); + } + reindexListElementVector(newDescriptionListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,newDescriptionListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + + if (catModifiedStates != null && catViewIds != null && catTypes != null && catKeyNames != null && catKeyValues != null) + { + Vector oldCatListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + Vector newCatListElementVector = new Vector(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + int catViewId = Integer.parseInt(catViewIds[i]); + boolean isModified = Boolean.valueOf(catModifiedStates[i]).booleanValue(); + if (catViewId == -1 || isModified) + newCatListElementVector.addElement(new ListElement(kr)); + else + newCatListElementVector.addElement(oldCatListElementVector.elementAt(catViewId)); + } + reindexListElementVector(newCatListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES,newCatListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + return inputsValid; + } + + public final boolean refreshBusinessFromRegistry() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String uuidBusinessKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + Vector beVector = proxy.get_businessDetail(uuidBusinessKey).getBusinessEntityVector(); + BusinessEntity be; + if (beVector.size() > 0) + be = (BusinessEntity)beVector.get(0); + else + be = null; + if (be != null) + { + propertyTable_.put(UDDIActionInputs.LATEST_BUSINESS,be); + return true; + } + } + catch (TransportException e) + { + // Feedback via Javascript popups. + } + catch (UDDIException e) + { + // Feedback via Javascript popups. + } + return false; + } + + public final boolean refreshFromRegistry() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + try + { + String uuidServiceKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + ServiceDetail serviceDetail = proxy.get_serviceDetail(uuidServiceKey); + Vector businessServiceVector = serviceDetail.getBusinessServiceVector(); + if (businessServiceVector.size() > 0) + { + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,businessServiceVector.elementAt(0)); + return true; + } + } + catch (UDDIException e) + { + // Feedback via Javascript popups. + } + catch (TransportException e) + { + // Feedback via Javascript popups. + } + isUpdate_ = false; + return false; + } + + public final RegPublishTool setupRegPublishTool() + { + // Prepare for re-publishing a now-stale service whose business has also been eliminated. + RegPublishTool regPublishTool = regNode_.getRegPublishTool(); + regPublishTool.setProperty(UDDIActionInputs.SUBQUERY_KEY,""); + regPublishTool.setProperty(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + regPublishTool.setProperty(UDDIActionInputs.QUERY_STYLE_SERVICES,String.valueOf(UDDIActionInputs.QUERY_STYLE_ADVANCED)); + + regPublishTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL,propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL)); + + Vector nameListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + Vector descriptionListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + Vector catListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + + Vector nameVector = new Vector(); + for (int i=0;i<nameListElementVector.size();i++) + { + ListElement listElement = (ListElement)nameListElementVector.elementAt(i); + Name name = (Name)listElement.getObject(); + nameVector.addElement(name); + } + + Vector descriptionVector = null; + if (descriptionListElementVector != null) + { + descriptionVector = new Vector(); + for (int i=0;i<descriptionListElementVector.size();i++) + { + ListElement listElement = (ListElement)descriptionListElementVector.elementAt(i); + Description description = (Description)listElement.getObject(); + descriptionVector.addElement(description); + } + } + else + regPublishTool.removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + + CategoryBag catBag = null; + if (catListElementVector != null) + { + catBag = new CategoryBag(); + for (int i=0;i<catListElementVector.size();i++) + { + ListElement listElement = (ListElement)catListElementVector.elementAt(i); + KeyedReference kr = (KeyedReference)listElement.getObject(); + catBag.add(kr); + } + } + else + regPublishTool.removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + + regPublishTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,nameVector); + if (descriptionVector != null) + regPublishTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,descriptionVector); + if (catBag != null) + regPublishTool.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES,catBag); + return regPublishTool; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + try + { + BusinessEntity be = (BusinessEntity)propertyTable_.get(UDDIActionInputs.LATEST_BUSINESS); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + String uuidServiceKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY); + ListElement wsdlURLListElement = (ListElement)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + Vector nameListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES); + Vector descriptionListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS); + Vector catListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES); + + String wsdlURL = (String)wsdlURLListElement.getObject(); + + Vector nameVector = new Vector(); + for (int i=0;i<nameListElementVector.size();i++) + { + ListElement listElement = (ListElement)nameListElementVector.elementAt(i); + Name name = (Name)listElement.getObject(); + nameVector.addElement(name); + } + + Vector descriptionVector = null; + if (descriptionListElementVector != null) + { + descriptionVector = new Vector(); + for (int i=0;i<descriptionListElementVector.size();i++) + { + ListElement listElement = (ListElement)descriptionListElementVector.elementAt(i); + Description description = (Description)listElement.getObject(); + descriptionVector.addElement(description); + } + } + + CategoryBag catBag = null; + if (catListElementVector != null) + { + catBag = new CategoryBag(); + for (int i=0;i<catListElementVector.size();i++) + { + ListElement listElement = (ListElement)catListElementVector.elementAt(i); + KeyedReference kr = (KeyedReference)listElement.getObject(); + catBag.add(kr); + } + } + + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + UDDIProxy proxy = regElement.getProxy(); + + // Note: The JSP will prevent this routine from executing if be is null. + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + Definition def = uddi4jHelper.getWSDLDefinition(wsdlURL); + + // Publish/update the service interfaces first. + RegPublishServiceInterfaceSimpleAction regPublishSIAction = new RegPublishServiceInterfaceSimpleAction(controller_); + int currentNodeId = getSelectedNavigatorNode().getNodeId(); + NodeManager nodeManager = regNode_.getNodeManager(); + + Hashtable tModelsTable = new Hashtable(); + TModel[] tModels = null; + if (uddi4jHelper.isMonolithicWSDL(def)) + { + tModels = new TModel[1]; + tModels[0] = uddi4jHelper.newTModel(wsdlURL, def); + } + else + { + String[] imports = uddi4jHelper.getImports(def, wsdlURL); + tModels = new TModel[imports.length]; + for (int i = 0; i < tModels.length; i++) + tModels[i] = uddi4jHelper.newTModel(imports[i]); + } + + if (tModels != null) + { + for (int i=0;i<tModels.length;i++) + { + boolean inputsValid = regPublishSIAction.populatePropertyTable(uddi4jHelper.getWSDL(tModels[i]), tModels[i]); + if (inputsValid) + { + regPublishSIAction.run(); + Object savedTModel = regPublishSIAction.getPropertyTable().get(UDDIActionInputs.QUERY_OUTPUT_SAVED_TMODEL); + if (savedTModel != null) + { + tModelsTable.put(((TModel)savedTModel).getNameString(), savedTModel); + } + // Reselect the current node. + nodeManager.setSelectedNodeId(currentNodeId); + } + } + } + + BusinessService busService = uddi4jHelper.newBusinessService(wsdlURL, def, tModelsTable); + if (isUpdate_) + busService.setServiceKey(uuidServiceKey); + busService.setBusinessKey(be.getBusinessKey()); + busService.setNameVector(nameVector); + busService.setDescriptionVector(descriptionVector); + busService.setCategoryBag(catBag); + regElement.handlePreInvocation(busService); + Vector bsVector = new Vector(); + bsVector.add(busService); + busService = (BusinessService)proxy.save_service(regElement.getAuthInfoString(), bsVector).getBusinessServiceVector().get(0); + refreshNode(busService); + if (isUpdate_) + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_UPDATED",busService.getDefaultNameString())); + else + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_PUBLISHED",busService.getDefaultNameString())); + return true; + } + catch (WSDLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"WSDLException",e); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateServiceInterfaceAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateServiceInterfaceAction.java new file mode 100644 index 000000000..d8040278e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/actions/UpdateServiceInterfaceAction.java @@ -0,0 +1,331 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.*; +import org.uddi4j.transport.TransportException; +import org.uddi4j.response.*; +import org.uddi4j.util.*; +import org.uddi4j.UDDIException; + +import javax.wsdl.WSDLException; +import java.util.*; +import java.net.*; + +public class UpdateServiceInterfaceAction extends UpdateAction +{ + private boolean isUpdate_; + public UpdateServiceInterfaceAction(Controller controller) + { + super(controller,true); + isUpdate_ = true; + } + + protected boolean processOthers(MultipartFormDataParser parser,FormToolPropertiesInterface formToolPI) throws MultipartFormDataException + { + String uuidKey = parser.getParameter(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY); + String wsdlURLModifiedState = parser.getParameter(UDDIActionInputs.WSDL_URL_MODIFIED); + String wsdlURL = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + String nameModifiedState = parser.getParameter(UDDIActionInputs.NAME_MODIFIED); + String name = parser.getParameter(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + String[] descriptionModifiedStates = parser.getParameterValues(UDDIActionInputs.DESCRIPTION_MODIFIED); + String[] descriptionViewIds = parser.getParameterValues(UDDIActionInputs.DESCRIPTION_VIEWID); + String[] descriptionLanguages = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE); + String[] descriptions = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_DESCRIPTION); + String[] idModifiedStates = parser.getParameterValues(UDDIActionInputs.IDENTIFIER_MODIFIED); + String[] idViewIds = parser.getParameterValues(UDDIActionInputs.IDENTIFIER_VIEWID); + String[] idTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE); + String[] idKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME); + String[] idKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE); + String[] catModifiedStates = parser.getParameterValues(UDDIActionInputs.CATEGORY_MODIFIED); + String[] catViewIds = parser.getParameterValues(UDDIActionInputs.CATEGORY_VIEWID); + String[] catTypes = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_TYPE); + String[] catKeyNames = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME); + String[] catKeyValues = parser.getParameterValues(UDDIActionInputs.QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE); + + boolean inputsValid = true; + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + + if (uuidKey != null) + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY,uuidKey); + + if (wsdlURLModifiedState != null && wsdlURL != null) + { + ListElement wsdlURLListElement = (ListElement)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + boolean isModified = Boolean.valueOf(wsdlURLModifiedState).booleanValue(); + if (isModified) + wsdlURLListElement = new ListElement(wsdlURL); + else + wsdlURL = (String)wsdlURLListElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL,wsdlURLListElement); + if (!Validator.validateURL(wsdlURL)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_WSDL_URL")); + } + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + + if (nameModifiedState != null && name != null) + { + ListElement nameListElement = (ListElement)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + boolean isModified = Boolean.valueOf(nameModifiedState).booleanValue(); + if (isModified) + nameListElement = new ListElement(name); + else + name = (String)nameListElement.getObject(); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME,nameListElement); + if (!Validator.validateString(name)) + { + inputsValid = false; + formToolPI.flagError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_INVALID_NAME")); + } + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + + Hashtable languageHash = new Hashtable(); + if (descriptionModifiedStates != null && descriptionViewIds != null && descriptionLanguages != null && descriptions != null) + { + Vector oldDescriptionListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS); + Vector newDescriptionListElementVector = new Vector(); + String[] parameters = new String[2]; + parameters[0] = uddiPerspective.getMessage("FORM_LABEL_DESCRIPTION"); + languageHash.clear(); + for (int i=0;i<descriptions.length;i++) + { + parameters[1] = String.valueOf(i+1); + Description uddi4jDescription; + if (descriptionLanguages[i].length() > 0) + uddi4jDescription = new Description(descriptions[i],descriptionLanguages[i]); + else + { + uddi4jDescription = new Description(descriptions[i]); + if (i != 0) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_BLANK_LANGUAGE",parameters)); + } + } + if (languageHash.get(descriptionLanguages[i]) != null) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_DUPLICATE_LANGUAGE",parameters)); + } + else + languageHash.put(descriptionLanguages[i],Boolean.TRUE); + if (!Validator.validateString(descriptions[i])) + { + inputsValid = false; + formToolPI.flagRowError(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,i); + messageQueue.addMessage(uddiPerspective.getMessage("MSG_ERROR_ROW_INVALID_TEXT",parameters)); + } + + int descriptionViewId = Integer.parseInt(descriptionViewIds[i]); + boolean isModified = Boolean.valueOf(descriptionModifiedStates[i]).booleanValue(); + + if (descriptionViewId == -1 || isModified) + newDescriptionListElementVector.addElement(new ListElement(uddi4jDescription)); + else + newDescriptionListElementVector.addElement(oldDescriptionListElementVector.elementAt(descriptionViewId)); + } + reindexListElementVector(newDescriptionListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,newDescriptionListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS); + + if (idModifiedStates != null && idViewIds != null && idTypes != null && idKeyNames != null && idKeyValues != null) + { + Vector oldIdListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + Vector newIdListElementVector = new Vector(); + for (int i=0;i<idKeyNames.length;i++) + { + KeyedReference kr = new KeyedReference(idKeyNames[i],idKeyValues[i],idTypes[i]); + int idViewId = Integer.parseInt(idViewIds[i]); + boolean isModified = Boolean.valueOf(idModifiedStates[i]).booleanValue(); + if (idViewId == -1 || isModified) + newIdListElementVector.addElement(new ListElement(kr)); + else + newIdListElementVector.addElement(oldIdListElementVector.elementAt(idViewId)); + } + reindexListElementVector(newIdListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS,newIdListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + + if (catModifiedStates != null && catViewIds != null && catTypes != null && catKeyNames != null && catKeyValues != null) + { + Vector oldCatListElementVector = (Vector)formToolPI.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + Vector newCatListElementVector = new Vector(); + for (int i=0;i<catTypes.length;i++) + { + KeyedReference kr = new KeyedReference(catKeyNames[i],catKeyValues[i],catTypes[i]); + int catViewId = Integer.parseInt(catViewIds[i]); + boolean isModified = Boolean.valueOf(catModifiedStates[i]).booleanValue(); + if (catViewId == -1 || isModified) + newCatListElementVector.addElement(new ListElement(kr)); + else + newCatListElementVector.addElement(oldCatListElementVector.elementAt(catViewId)); + } + reindexListElementVector(newCatListElementVector); + propertyTable_.put(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES,newCatListElementVector); + } + else + removeProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + return inputsValid; + } + + public final boolean refreshFromRegistry() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + try + { + String uuidKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY); + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + UDDIProxy proxy = regElement.getProxy(); + TModelDetail tModelDetail = proxy.get_tModelDetail(uuidKey); + Vector tModelVector = tModelDetail.getTModelVector(); + if (tModelVector.size() > 0) + { + propertyTable_.put(UDDIActionInputs.LATEST_OBJECT,tModelVector.elementAt(0)); + return true; + } + } + catch (UDDIException e) + { + // Feedback via Javascript popups. + } + catch (TransportException e) + { + // Feedback via Javascript popups. + } + isUpdate_ = false; + return false; + } + + public final boolean run() + { + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + MessageQueue messageQueue = uddiPerspective.getMessageQueue(); + try + { + String uuidKey = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY); + String publishURL = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL); + String userId = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID); + String password = (String)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD); + ListElement wsdlURLListElement = (ListElement)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + ListElement nameListElement = (ListElement)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME); + Vector descriptionListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS); + Vector idListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS); + Vector catListElementVector = (Vector)propertyTable_.get(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES); + + String wsdlURL = (String)wsdlURLListElement.getObject(); + + String name = (String)nameListElement.getObject(); + + Vector descriptionVector = null; + if (descriptionListElementVector != null) + { + descriptionVector = new Vector(); + for (int i=0;i<descriptionListElementVector.size();i++) + { + ListElement listElement = (ListElement)descriptionListElementVector.elementAt(i); + Description description = (Description)listElement.getObject(); + descriptionVector.addElement(description); + } + } + + IdentifierBag idBag = null; + if (idListElementVector != null) + { + idBag = new IdentifierBag(); + for (int i=0;i<idListElementVector.size();i++) + { + ListElement listElement = (ListElement)idListElementVector.elementAt(i); + KeyedReference kr = (KeyedReference)listElement.getObject(); + idBag.add(kr); + } + } + + CategoryBag catBag = null; + if (catListElementVector != null) + { + catBag = new CategoryBag(); + for (int i=0;i<catListElementVector.size();i++) + { + ListElement listElement = (ListElement)catListElementVector.elementAt(i); + KeyedReference kr = (KeyedReference)listElement.getObject(); + catBag.add(kr); + } + } + + TModel tModel = (new Uddi4jHelper()).newTModel(wsdlURL); + if (isUpdate_) + tModel.setTModelKey(uuidKey); + tModel.setName(name); + tModel.setDescriptionVector(descriptionVector); + tModel.setIdentifierBag(idBag); + tModel.setCategoryBag(catBag); + + RegistryElement regElement = (RegistryElement)regNode_.getTreeElement(); + if (!regElement.isLoggedIn()) + regElement.performLogin(publishURL,userId,password); + UDDIProxy proxy = regElement.getProxy(); + Vector tModelVector = new Vector(); + tModelVector.add(tModel); + tModel = (TModel)proxy.save_tModel(regElement.getAuthInfoString(), tModelVector).getTModelVector().get(0); + refreshNode(tModel); + if (isUpdate_) + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACE_UPDATED",tModel.getNameString())); + else + messageQueue.addMessage(uddiPerspective.getMessage("MSG_INFO_SERVICE_INTERFACE_PUBLISHED",tModel.getNameString())); + return true; + } + catch (WSDLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"WSDLException",e); + } + catch (TransportException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"TransportException",e); + } + catch (UDDIException e) + { + messageQueue.addMessage(uddiPerspective.getController().getMessage("MSG_ERROR_UNEXPECTED")); + messageQueue.addMessage("UDDIException"); + messageQueue.addMessage(e.toString()); + } + catch (MalformedURLException e) + { + handleUnexpectedException(uddiPerspective,messageQueue,"MalformedURLException",e); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIActionInputs.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIActionInputs.java new file mode 100644 index 000000000..2ee6dde85 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIActionInputs.java @@ -0,0 +1,209 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.constants; + +public class UDDIActionInputs +{ + // OpenRegistryAction + public static final String REGISTRY_NAME = "registryName"; + public static final String INQUIRY_URL = "inquiryURL"; + public static final String PUBLISH_URL = "publishURL"; + public static final String REGISTRATION_URL = "registrationURL"; + public static final String CHECK_USER_DEFINED_CATEGORIES = "checkUserDefinedCategories"; + public static final String UDDI_USERNAME = "uddiUsername"; + public static final String UDDI_PASSWORD = "uddiPassword"; + + // Fixed and user-defined categories + public static final String CATEGORIES_DIRECTORY = "categoriesDirectory"; + public static final String CATEGORY_TMODEL_KEY = "categoryTModelKey"; + public static final String CATEGORY_FILENAME = "categoryFileName"; + public static final String USER_DEFINED_CATEGORIES = "userDefinedCategories"; + + // Discovery URL use type + public static final String DISCOVERY_URL_TYPE = "businessEntity"; + + // Results (NODEID) + public static final String NODEID_SERVICE_INTERFACE = "nodeId_ServiceInterface"; + public static final String NODEID_SERVICE = "nodeId_Service"; + public static final String NODEID_BUSINESS = "nodeId_Business"; + + // RegFind..Actions/RegPublish..Actions + public static final String QUERY_INPUT_OVERRIDE_ADD_QUERY_NODE = "overrideAddQueryNode"; + public static final String QUERY_NAME = "queryName"; + public static final String QUERY_ITEM = "queryItem"; + public static final int QUERY_ITEM_QUERIES = -1; + public static final int QUERY_ITEM_BUSINESSES = 0; + public static final int QUERY_ITEM_SERVICES = 1; + public static final int QUERY_ITEM_SERVICE_INTERFACES = 2; + public static final int QUERY_STYLE_SIMPLE = 0; + public static final int QUERY_STYLE_ADVANCED = 1; + public static final int QUERY_STYLE_UUID = 2; + public static final String QUERY_INPUT_ADVANCED_OWNED = "advancedOwned"; + public static final String QUERY_INPUT_ADVANCED_PUBLISH_URL = "advancedPublishURL"; + public static final String QUERY_INPUT_ADVANCED_USERID = "advancedUserId"; + public static final String QUERY_INPUT_ADVANCED_PASSWORD = "advancedPassword"; + public static final String QUERY_INPUT_ADVANCED_NAME_LANGUAGE = "advancedNameLanguage"; + public static final String QUERY_INPUT_ADVANCED_NAME = "advancedName"; + public static final String QUERY_INPUT_ADVANCED_IDENTIFIER_TYPE = "advancedIdentifierType"; + public static final String QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_NAME = "advancedIdentifierKeyName"; + public static final String QUERY_INPUT_ADVANCED_IDENTIFIER_KEY_VALUE = "advancedIdentifierKeyValue"; + public static final String QUERY_INPUT_ADVANCED_CATEGORY_TYPE = "advancedCategoryType"; + public static final String QUERY_INPUT_ADVANCED_CATEGORY_KEY_NAME = "advancedCategoryKeyName"; + public static final String QUERY_INPUT_ADVANCED_CATEGORY_KEY_VALUE = "advancedCategoryKeyValue"; + public static final String QUERY_INPUT_ADVANCED_DISCOVERYURL = "advancedDiscoveryURL"; + public static final String QUERY_INPUT_ADVANCED_FINDQUALIFIER = "advancedFindQualifier"; + public static final String QUERY_INPUT_ADVANCED_SORT_BY_NAME = "advancedSortByName"; + public static final String QUERY_INPUT_ADVANCED_SORT_BY_DATE = "advancedSortByDate"; + public static final String QUERY_INPUT_ADVANCED_MAX_SEARCH_SET = "advancedMaxSearchSet"; + public static final int QUERY_MAX_SEARCH_SET = 100; + public static final String QUERY_INPUT_ADVANCED_MAX_RESULTS = "advancedMaxResults"; + public static final int QUERY_MAX_RESULTS = 10; + + public static final String QUERY_STYLE_BUSINESSES = "queryStyleBusinesses"; + public static final String QUERY_INPUT_SIMPLE_BUSINESS_NAME = "simpleBusinessName"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_OWNED = "advancedBusinessOwned"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_NAMES = "advancedBusinessNames"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS = "advancedBusinessIdentifiers"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES = "advancedBusinessCategories"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS = "advancedBusinessDiscoveryURLs"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES = "advancedBusinessServiceInterfaces"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_SERVICE_INTERFACES_COPY = "advancedBusinessServiceInterfacesCopy"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_TMODELBAG = "advancedBusinessTModelBag"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_FINDQUALIFIERS = "advancedBusinessFindQualifiers"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_MAX_SEARCH_SET = "advancedBusinessMaxSearchSet"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_MAX_RESULTS = "advancedBusinessMaxResults"; + + public static final String QUERY_STYLE_SERVICES = "queryStyleServices"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_NAME = "simpleServiceName"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_OWNED = "advancedServiceOwned"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_BUSINESS = "advancedServiceBusiness"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_BUSINESS_COPY = "advancedServiceBusinessCopy"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_SERVICE_PROVIDER = "advancedServiceServiceProvider"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_NAMES = "advancedServiceNames"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES = "advancedServiceCategories"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES = "advancedServiceServiceInterfaces"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_SERVICE_INTERFACES_COPY = "advancedServiceServiceInterfacesCopy"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_TMODEL = "advancedServiceTModel"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_TMODELBAG = "advancedServiceTModelBag"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_FINDQUALIFIERS = "advancedServiceFindQualifiers"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_MAX_SEARCH_SET = "advancedServiceMaxSearchSet"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_MAX_RESULTS = "advancedServiceMaxResults"; + + public static final String QUERY_STYLE_SERVICE_INTERFACES = "queryStyleServiceInterfaces"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME = "simpleServiceInterfaceName"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_USE_SERVICE = "advancedUseService"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE = "advancedServiceInterfaceService"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_SERVICE_COPY = "advancedServiceInterfaceServiceCopy"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_BUSINESS_SERVICE = "advancedServiceInterfaceBusinessService"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_OWNED = "advancedServiceInterfaceOwned"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME = "advancedServiceInterfaceName"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS = "advancedServiceInterfaceIdentifiers"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES = "advancedServiceInterfaceCategories"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_FINDQUALIFIERS = "advancedServiceInterfaceFindQualifiers"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_SEARCH_SET = "advancedServiceInterfaceMaxSearchSet"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_RESULTS = "advancedServiceInterfaceMaxResults"; + + public static final String QUERY_INPUT_ADVANCED_REGISTRY_NAME = "advancedRegistryName"; + + public static final String QUERY_INPUT_UUID_KEY = "uuidKey"; + public static final String QUERY_INPUT_UUID_BUSINESS_KEY = "uuidBusinessKey"; + public static final String QUERY_INPUT_UUID_SERVICE_KEY = "uuidServiceKey"; + public static final String QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY = "uuidServiceInterfaceKey"; + + public static final String QUERY_OUTPUT_SAVED_TMODEL = "savedTModel"; + + // Sub Queries: + public static final String SUBQUERIES_PROPERTIES = "subQueriesProperties"; + public static final String SUBQUERY_KEY = "subQueryKey"; + public static final String NEW_SUBQUERY_INITIATED = "newSubQueryInitiated"; + public static final String NEW_SUBQUERY_QUERY_ITEM = "newSubQueryQueryItem"; + public static final String SELECTED_NODEIDS = "selectedNodeIds"; + public static final String SUBQUERY_LIST_KEY = "subQueryListKey"; + public static final String SUBQUERY_LIST_ITEMID = "subQueryListItemId"; + public static final String SHOW_RESULTS_TARGET = "showResultsTarget"; + public static final String SUBQUERY_GET = "subQueryGet"; + + // RegPublish..Actions (some constants from the RegFind...Actions will be reused. + public static final String QUERY_INPUT_SIMPLE_BUSINESS_DESCRIPTION = "simpleBusinessDescription"; + + public static final String QUERY_INPUT_ADVANCED_DESCRIPTION_LANGUAGE = "advancedDescriptionLanguage"; + public static final String QUERY_INPUT_ADVANCED_DESCRIPTION = "advancedDescription"; + public static final String QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS = "advancedBusinessDescriptions"; + + public static final String QUERY_INPUT_WSDL_URL = "wsdlURL"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_WSDL_URL = "simpleServiceInterfaceWSDLURL"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION = "simpleServiceInterfaceDescription"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL = "advancedServiceInterfaceWSDLURL"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS = "advancedServiceInterfaceDescriptions"; + + public static final String QUERY_INPUT_SIMPLE_SERVICE_BUSINESS = "simpleServiceBusiness"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_BUSINESS_COPY = "simpleServiceBusinessCopy"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_SERVICE_PROVIDER = "simpleServiceServiceProvider"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_WSDL_URL = "simpleServiceWSDLURL"; + public static final String QUERY_INPUT_SIMPLE_SERVICE_DESCRIPTION = "simpleServiceDescription"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL = "advancedServiceWSDLURL"; + public static final String QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS = "advancedServiceDescriptions"; + + // WSDL Browser + public static final String PROJECT = "project"; + public static final String WSDL_TYPE = "wsdlType"; + public static final int WSDL_TYPE_SERVICE_INTERFACE = 0; + public static final int WSDL_TYPE_SERVICE = 1; + public static final String QUERY_INPUT_WEBPROJECT_WSDL_URL = "webProjectWSDLURL"; + public static final String QUERY_INPUT_FAVORITE_WSDL_URL = "favoriteWSDLURL"; + + // Details + public static final String LATEST_OBJECT = "latestObject"; + public static final String DISCOVERYURL_MODIFIED = "discoveryURLModified"; + public static final String DISCOVERYURL_VIEWID = "discoveryURLViewId"; + public static final String NAME_MODIFIED = "nameModified"; + public static final String NAME_VIEWID = "businessViewId"; + public static final String DESCRIPTION_MODIFIED = "descriptionModified"; + public static final String DESCRIPTION_VIEWID = "descriptionViewId"; + public static final String IDENTIFIER_MODIFIED = "identifierModified"; + public static final String IDENTIFIER_VIEWID = "identifierViewId"; + public static final String CATEGORY_MODIFIED = "categoryModified"; + public static final String CATEGORY_VIEWID = "categoryViewId"; + public static final String WSDL_URL_MODIFIED = "wsdlURLModified"; + public static final String PUBLISH_ACTION = "publishAction"; + public static final String LATEST_BUSINESS = "latestBusiness"; + + // Refresh action + public static final String REFRESH_NODE = "refreshNode"; + + // Manage PublisherAssertions + // "To" means from another business to my owning business + public static final int DIRECTION_TO = 0; + // "From" means from my owning business to another business + public static final int DIRECTION_FROM = 1; + public static final String PUBLISHER_ASSERTIONS_VIEWID = "publisherAssertionsViewId"; + public static final String PUBLISHER_ASSERTIONS_SELECTED_BUS_ID = "publisherAssertionsSelectedBusID"; + public static final String PUBLISHER_ASSERTIONS_DIRECTION = "publisherAssertionsDirection"; + public static final String QUERY_INPUT_ADD_PUBLISHER_ASSERTIONS = "queryInputAddPublisherAssertions"; + public static final String QUERY_INPUT_ADD_PUBLISHER_ASSERTIONS_COPY = "queryInputAddPublisherAssertionsCopy"; + public static final String QUERY_INPUT_EXISTING_PUBLISHER_ASSERTIONS = "queryInputExistingPublisherAssertions"; + public static final String PUBLISHER_ASSERTIONS_TYPE = "publisherAssertionsType"; + public static final String PUBLISHER_ASSERTIONS_TYPE_PARENT_CHILD = "parent-child"; + public static final String PUBLISHER_ASSERTIONS_TYPE_PEER_TO_PEER = "peer-peer"; + public static final String PUBLISHER_ASSERTIONS_TYPE_IDENTITY = "identity"; + + // Manage Referenced Services + public static final String QUERY_INPUT_REFERENCED_SERVICES = "referencedServices"; + public static final String QUERY_INPUT_SERVICES = "services"; + public static final String MANAGE_REFERENCED_SERVICES_OPERATION = "managedReferencedServicesOperation"; + public static final int MANAGE_REFERENCED_SERVICES_OPERATION_ADD = 0; + public static final int MANAGE_REFERENCED_SERVICES_OPERATION_REMOVE = 1; + public static final String REFERENCED_SERVICE_SELECT_STATE = "referencedServiceSelectState"; + + // ResizeUDDIFrameAction + public static final String FRAMESET_COLS_PERSPECTIVE_CONTENT = "framesetColsPerspectiveContent"; + public static final String FRAMESET_ROWS_ACTIONS_CONTAINER = "framesetRowsActionsContainer"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIFrameNames.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIFrameNames.java new file mode 100644 index 000000000..970fff747 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIFrameNames.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.constants; + +public class UDDIFrameNames +{ + public final static String NAVIGATOR_CONTAINER = "uddi_navigator_container"; + public final static String NAVIGATOR_TOOLBAR = "uddi_navigator_toolbar"; + public final static String NAVIGATOR_CONTENT = "uddi_navigator_content"; + public final static String ACTIONS_CONTAINER = "uddi_actions_container"; + public final static String PROPERTIES_CONTAINER = "uddi_properties_container"; + public final static String PROPERTIES_TOOLBAR = "uddi_properties_toolbar"; + public final static String PROPERTIES_CONTENT = "uddi_properties_content"; + public final static String STATUS_CONTAINER = "uddi_status_container"; + public final static String STATUS_TOOLBAR = "uddi_status_toolbar"; + public final static String STATUS_CONTENT = "uddi_status_content"; + + public final static String CATEGORIES_WORKAREA = "categories_workarea"; + public final static String CATEGORIES_TOOLBAR = "categories_toolbar"; + public final static String CATEGORIES_CONTENT = "categories_content"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIModelConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIModelConstants.java new file mode 100644 index 000000000..b344fe9c2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/constants/UDDIModelConstants.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.constants; + +public class UDDIModelConstants +{ + // Registries under UDDIMain. + public static final String REL_REGISTRIES = "registries"; + + // Executed Queries folder under a registry. + public static final String REL_QUERIES_PARENT = "queriesParent"; + + // Published Businesses folder under a registry. + public static final String REL_PUBLISHED_BUSINESSES_PARENT = "publishedBusinessesParent"; + + // Published Services folder under a registry. + public static final String REL_PUBLISHED_SERVICES_PARENT = "publishedServicesParent"; + + // Published Service interfaces folder under a registry. + public static final String REL_PUBLISHED_SERVICE_INTERFACES_PARENT = "publishedServiceInterfacesParent"; + + // Queries under the Queries folder. + public static final String REL_QUERIES = "queries"; + public static final String INITIAL_RESULTS = "initialResults"; + public static final String QUERY_TYPE = "queryType"; + public static final String SUBQUERY_TRANSFER_TARGET = "subQueryTransferTarget"; + + // Objects under a Query node. + public static final String REL_QUERY_RESULTS = "queryResults"; + + // Categories + public static final String REL_SUBCATEGORIES = "subCategories"; + + // Published items inside the Published items folder. + public static final String REL_PUBLISHED_ITEMS = "publishedItems"; + + // Businesses + public static final String IS_BUSINESS_OWNED = "isBusinessOwned"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/AbstractUDDIElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/AbstractUDDIElement.java new file mode 100644 index 000000000..09562fd8e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/AbstractUDDIElement.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.Model; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; + +import java.util.Enumeration; + +public abstract class AbstractUDDIElement extends TreeElement +{ + public AbstractUDDIElement(String name, Model model) + { + super(name, model); + } + + public final TreeElement getParentElement() + { + return getParentElement(this); + } + + public final TreeElement getParentElement(TreeElement child) + { + Enumeration e = child.getElements(ModelConstants.REL_OWNER); + if (e.hasMoreElements()) + return (TreeElement)e.nextElement(); + else + return null; + } + + public final RegistryElement getRegistryElement() + { + if (this instanceof RegistryElement) + return (RegistryElement)this; + else + { + TreeElement childElement = this; + TreeElement parentElement = getParentElement(childElement); + while (parentElement != null && parentElement != childElement) + { + if (parentElement instanceof RegistryElement) + return (RegistryElement)parentElement; + childElement = parentElement; + parentElement = getParentElement(childElement); + } + return null; + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/BusinessElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/BusinessElement.java new file mode 100644 index 000000000..b1d4ed233 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/BusinessElement.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; + +import org.uddi4j.datatype.business.BusinessEntity; + +public class BusinessElement extends AbstractUDDIElement +{ + private BusinessEntity be_; + private ListManager publisherAssertions_; + + public BusinessElement(BusinessEntity be,Model model) + { + super(be.getDefaultNameString(),model); + be_ = be; + setKey(be_.getBusinessKey()); + publisherAssertions_ = null; + } + + public final BusinessEntity getBusinessEntity() + { + return be_; + } + + public final void setBusinessEntity(BusinessEntity be) + { + be_ = be; + setKey(be_.getBusinessKey()); + } + + public ListManager getPublisherAssertions() + { + return publisherAssertions_; + } + + public void setPublisherAssertions(ListManager listManager) + { + publisherAssertions_ = listManager; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/CategoryElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/CategoryElement.java new file mode 100644 index 000000000..478c87fa9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/CategoryElement.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; + +import org.uddi4j.util.*; + +public class CategoryElement extends AbstractUDDIElement +{ + private KeyedReference category_; + + public CategoryElement(String name,KeyedReference category,Model model) + { + super(name,model); + category_ = category; + saveCategoryProperties(); + } + + private final void saveCategoryProperties() + { + if (category_ != null) + { + String keyName = category_.getKeyName(); + if (keyName != null) + setName(keyName); + } + } + + public final KeyedReference getCategory() + { + return category_; + } + + public final String getNameForTree() + { + StringBuffer nameForTree = new StringBuffer("["); + nameForTree.append(category_.getKeyValue()).append("] ").append(category_.getKeyName()); + return nameForTree.toString(); + } + + public final void updateCategory(String keyName,String keyValue,String tModelKey) + { + category_.setKeyName(keyName); + category_.setKeyValue(keyValue); + category_.setTModelKey(tModelKey); + saveCategoryProperties(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/CategoryModel.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/CategoryModel.java new file mode 100644 index 000000000..85a1ba396 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/CategoryModel.java @@ -0,0 +1,532 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; + +import org.uddi4j.util.*; + +import java.util.*; +import java.text.*; +import java.io.*; + +import javax.servlet.ServletContext; + +public class CategoryModel extends BasicModel +{ + private ServletContext application_; + private String defaultDataFile_; + private Hashtable categoryElements_; + private String columnDelimiter_; + private String stringDelimiter_; + private String categoryKey_; + private boolean checked_; + private String displayName_; + private String tModelKey_; + private Throwable errorException_; + + // Return codes for loading and saving category data. + public static final byte OPERATION_SUCCESSFUL = 0x00; + public static final byte ERROR_FILE = 0x01; + public static final byte ERROR_SECURITY = 0x02; + public static final byte ERROR_ENCODING = 0x03; + public static final byte ERROR_IO = 0x04; + public static final byte ERROR_CATEGORY_KEY = 0x05; + + private final String defaultColumnDelimiter_ = "#"; + private final String defaultStringDelimiter_ = "\""; + + public CategoryModel() + { + super("categories"); + application_ = null; + defaultDataFile_ = null; + columnDelimiter_ = defaultColumnDelimiter_; + stringDelimiter_ = defaultStringDelimiter_; + categoryElements_ = null; + categoryKey_ = null; + checked_ = true; + displayName_ = null; + tModelKey_ = null; + errorException_ = null; + } + + /** + * CategoryModels load their data from the file named via the + * {@link #setDefaultDataFile(String)} method. The data file + * name is interpretted as either a physical pathname or a + * context-root relative pathname depending on whether the + * servlet context or "application" is null (default) or not. + * @param application The application context, null by default. + * Value can be the ServletContext of the WSExplorer or null. + */ + public final void setServletContext(ServletContext application) + { + application_ = application; + } + + public final void setDefaultDataFile(String defaultDataFile) + { + defaultDataFile_ = defaultDataFile; + } + + public final void setCategoryKey(String categoryKey) + { + categoryKey_ = categoryKey; + } + + public final String getCategoryKey() + { + return categoryKey_; + } + + public final void setColumnDelimiter(String columnDelimiter) + { + columnDelimiter_ = columnDelimiter; + } + + public final String getColumnDelimiter() + { + return columnDelimiter_; + } + + public final void setStringDelimiter(String stringDelimiter) + { + stringDelimiter_ = stringDelimiter; + } + + public final String getStringDelimiter() + { + return stringDelimiter_; + } + + public final void enableChecked(boolean isChecked) + { + checked_ = isChecked; + } + + public final boolean isChecked() + { + return checked_; + } + + public final void setDisplayName(String displayName) + { + displayName_ = displayName; + } + + public final String getDisplayName() + { + return displayName_; + } + + public final void setTModelKey(String tModelKey) + { + tModelKey_ = tModelKey; + } + + public final String getTModelKey() + { + return tModelKey_; + } + + public final boolean isDataLoaded() + { + return (categoryElements_ != null); + } + + public final Throwable getErrorException() + { + return errorException_; + } + + private final boolean isEnclosedInQuotes(String string) + { + return string.startsWith("\"") && string.endsWith("\""); + } + + public final byte loadFromDefaultDataFile() + { + try + { + if (defaultDataFile_ == null) + throw new FileNotFoundException(); + BufferedReader br = null; + if (application_ == null) + br = new BufferedReader(new InputStreamReader(new FileInputStream(defaultDataFile_),HTMLUtils.UTF8_ENCODING)); + else + br = new BufferedReader(new InputStreamReader(application_.getResourceAsStream(defaultDataFile_),HTMLUtils.UTF8_ENCODING)); + return loadData(br); + } + catch (FileNotFoundException e) + { + errorException_ = e; + return ERROR_FILE; + } + catch (SecurityException e) + { + errorException_ = e; + return ERROR_SECURITY; + } + catch (UnsupportedEncodingException e) + { + errorException_ = e; + return ERROR_ENCODING; + } + } + + public final byte loadFromDelimiterFile() + { + // Get the associated .properties file and set the delimiters. The defaultDataFile_ is set to the delimiter file in this case. + // The properties file contains the following keys: + // wsad.dataFile - location of the category data file. + // wsad.checked - whether or not the category is checked. + // wsad.name - the display name of the category. + // column.delimiter - the delimiter character used for separating columns. + // string.delimiter - the delimiter character used to encapsulate data such that column delimiter characters are treated as data. + try + { + Properties p = new Properties(); + InputStream fin = null; + if (application_ == null) + fin = new FileInputStream(defaultDataFile_); + else + fin = application_.getResourceAsStream(defaultDataFile_); + p.load(fin); + fin.close(); + columnDelimiter_ = p.getProperty("column.delimiter"); + stringDelimiter_ = p.getProperty("string.delimiter"); + defaultDataFile_ = p.getProperty("wsad.dataFile"); + return loadFromDefaultDataFile(); + } + catch (FileNotFoundException e) + { + errorException_ = e; + return ERROR_FILE; + } + catch (SecurityException e) + { + errorException_ = e; + return ERROR_SECURITY; + } + catch (IOException e) + { + errorException_ = e; + return ERROR_IO; + } + } + + public final byte loadData(BufferedReader br) + { + errorException_ = null; + CategoryElement rootElement = null; + categoryElements_ = new Hashtable(); + byte returnCode = OPERATION_SUCCESSFUL; + String line = null; + int lineNumber = 0; + try + { + char columnDelimiterChar = columnDelimiter_.charAt(0); + char stringDelimiterChar = stringDelimiter_.charAt(0); + Vector values = new Vector(); + while((line = br.readLine()) != null) + { + lineNumber++; + // Ignore blank lines. + if (line.trim().length() == 0) + continue; + int index = 0; + int tokenCount = 0; + int length = line.length(); + boolean inStringDelimiters = false; + values.removeAllElements(); + StringBuffer currentToken = new StringBuffer(); + while (index < length) + { + char currentChar = line.charAt(index); + if (inStringDelimiters) + { + // In quote so ignoring delimiters + if (currentChar == stringDelimiterChar) + { + if (index < length - 1) + { + // currentChar could be a closing string delimiter or escape + // Need to look ahead to be sure... + char followingChar = line.charAt(index + 1); + if (followingChar == stringDelimiterChar) + { + // There is an escaped quote + currentToken.append(stringDelimiterChar); + // jump forward two characters. + index += 2; + } + else + { + // There was a closing string delimiter...jump forward to the next delimiter + inStringDelimiters = false; + //look for the next column delimiter character + int nextDelimiter = line.indexOf(columnDelimiterChar, index); + if (nextDelimiter == -1) + { + // There were no more delimiters so break out of the loop + break; + } + else + { + values.addElement(currentToken.toString()); + //values[tokenCount++] = currentToken.toString(); + currentToken.setLength(0); + inStringDelimiters = false; + index = nextDelimiter + 1; + } + } + } + else + { + // This is the last character and it's a closing string delimiter. + index++; + inStringDelimiters = false; + } + } + else + { + currentToken.append(currentChar); + index++; + } + } + else if (currentChar == columnDelimiterChar) + { + // There was a delimiter outside of quotes + values.addElement(currentToken.toString()); + //values[tokenCount++] = currentToken.toString(); + currentToken.setLength(0); + index++; + } + else if (currentChar == stringDelimiterChar) + { + // A quote appearing outside of quotes must be a opening quote + inStringDelimiters = true; + index++; + } + else + { + // There is a normal char outside of quotes + currentToken.append(currentChar); + index++; + } + } + // Expect token count to be values.length - 1 at this point if everything is ok + if (inStringDelimiters) + { + br.close(); + throw new ParseException(line,lineNumber); + } + + // Add the final token. + values.addElement(currentToken.toString()); + + // 3 columns format. From left to right, these are: + // 1) category's key value + // 2) category's key name + // 3) category's parent key value + // Convert to 4 columns format. + if (values.size() == 3) + { + if (categoryKey_ != null) + values.insertElementAt(categoryKey_, 0); + else + values.insertElementAt(tModelKey_, 0); + } + + // 4 columns format. From left to right, these are: + // 1) type of category (categoryKey) + // 2) category's key value + // 3) category's key name + // 4) category's parent key value + if (values.size() == 4) + { + String categoryKey = (String)values.elementAt(0); + if (categoryKey_ == null) + categoryKey_ = categoryKey; + else if (!categoryKey_.equals(categoryKey)) + throw new Exception(categoryKey); + String keyValue = (String)values.elementAt(1); + String keyName = (String)values.elementAt(2); + String parentKeyValue = (String)values.elementAt(3); + if (rootElement == null) + { + rootElement = new CategoryElement(displayName_,null,this); + setRootElement(rootElement); + } + if (isEnclosedInQuotes(keyName)) + keyName = keyName.substring(1,keyName.length()-1); + // Check if the CategoryElement already exists. If it does, refresh the Category. + CategoryElement categoryElement = (CategoryElement)categoryElements_.get(keyValue); + if (categoryElement != null) + categoryElement.updateCategory(keyName,keyValue,tModelKey_); + else + categoryElement = new CategoryElement(keyName,new KeyedReference(keyName,keyValue,tModelKey_),this); + Element parentElement; + if (parentKeyValue.equals(keyValue)) + parentElement = rootElement; + else + parentElement = (Element)categoryElements_.get(parentKeyValue); + if (parentElement == null) + { + parentElement = new CategoryElement("temp",new KeyedReference("",parentKeyValue,tModelKey_),this); + categoryElements_.put(parentKeyValue,parentElement); + } + else + parentElement.connect(categoryElement,UDDIModelConstants.REL_SUBCATEGORIES,ModelConstants.REL_OWNER); + categoryElements_.put(keyValue,categoryElement); + } + else + { + br.close(); + throw new ParseException(line,lineNumber); + } + } + br.close(); + return returnCode; + } + catch (IOException e) + { + errorException_ = e; + returnCode = ERROR_IO; + } + catch (ParseException e) + { + errorException_ = e; + returnCode = ERROR_FILE; + } + catch (Exception e) + { + errorException_ = e; + returnCode = ERROR_CATEGORY_KEY; + } + categoryElements_ = null; + return returnCode; + } + + private final void saveData(PrintWriter pw,CategoryElement categoryElement,CategoryElement parentElement,boolean isFirst) + { + // File format: + // <categoryKey>#<keyValue>#<keyName>#<parentKeyValue> + KeyedReference kr = categoryElement.getCategory(); + // Check if this is not the root element. + if (kr != null) + { + String keyName = kr.getKeyName(); + String keyValue = kr.getKeyValue(); + String parentKeyValue; + if (parentElement == null) + parentKeyValue = keyValue; + else + { + KeyedReference parentKr = parentElement.getCategory(); + // Check if the parent is the root element. + if (parentKr == null) + parentKeyValue = keyValue; + else + parentKeyValue = parentKr.getKeyValue(); + } + if (!isFirst) + pw.println(); + else + isFirst = false; + pw.print(mangle(categoryKey_)); + pw.print(columnDelimiter_); + pw.print(mangle(keyValue)); + pw.print(columnDelimiter_); + pw.print(mangle(keyName)); + pw.print(columnDelimiter_); + pw.print(mangle(parentKeyValue)); + } + Enumeration e = categoryElement.getElements(UDDIModelConstants.REL_SUBCATEGORIES); + if (e != null) + { + while (e.hasMoreElements()) + saveData(pw,(CategoryElement)e.nextElement(),categoryElement,isFirst); + } + } + + // Mangle an input string if it contains default column delimiter characters by surrounding it with the string delimiters. + private final String mangle(String input) + { + if (input != null && input.indexOf(columnDelimiter_) != -1) + { + StringBuffer s = new StringBuffer(input); + s.insert(0,stringDelimiter_).append(stringDelimiter_); + return s.toString(); + } + return input; + } + + public final byte saveData(String fileName) + { + // The fileName should already be URLEncoded. + byte returnCode = OPERATION_SUCCESSFUL; + errorException_ = null; + if (isDataLoaded()) + { + try + { + PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(fileName),HTMLUtils.UTF8_ENCODING),true); + CategoryElement rootElement = (CategoryElement)getRootElement(); + saveData(pw,rootElement,null,true); + pw.flush(); + pw.close(); + // Save the properties file. + Properties p = new Properties(); + p.setProperty("wsad.dataFile",fileName); + p.setProperty("wsad.checked",String.valueOf(checked_)); + p.setProperty("wsad.name",displayName_); + p.setProperty("column.delimiter",columnDelimiter_); + p.setProperty("string.delimiter",stringDelimiter_); + StringBuffer propertiesFileName = new StringBuffer(fileName.substring(0,fileName.lastIndexOf('.'))); + propertiesFileName.append(".properties"); + FileOutputStream fout = new FileOutputStream(propertiesFileName.toString()); + p.store(fout,null); + fout.close(); + } + catch (FileNotFoundException e) + { + errorException_ = e; + returnCode = ERROR_FILE; + } + catch (SecurityException e) + { + errorException_ = e; + returnCode = ERROR_SECURITY; + } + catch (UnsupportedEncodingException e) + { + errorException_ = e; + returnCode = ERROR_ENCODING; + } + catch (IOException e) + { + errorException_ = e; + returnCode = ERROR_IO; + } + } + return returnCode; + } + + public String toString() + { + return displayName_; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/PublishedItemsElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/PublishedItemsElement.java new file mode 100644 index 000000000..d49432492 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/PublishedItemsElement.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import java.util.*; + +public class PublishedItemsElement extends AbstractUDDIElement +{ + public PublishedItemsElement(int type,String name,Model model) + { + super(name,model); + setPropertyAsString(ModelConstants.REL_CHILDREN,UDDIModelConstants.REL_PUBLISHED_ITEMS); + setPropertyAsString(UDDIModelConstants.QUERY_TYPE,String.valueOf(type)); + } + + public final int getType() + { + return Integer.parseInt(getPropertyAsString(UDDIModelConstants.QUERY_TYPE)); + } + + public Enumeration getItems() + { + return getElements(UDDIModelConstants.REL_PUBLISHED_ITEMS); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/PublisherAssertionElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/PublisherAssertionElement.java new file mode 100644 index 000000000..8580dd6f1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/PublisherAssertionElement.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.uddi4j.datatype.assertion.PublisherAssertion; +import org.uddi4j.util.KeyedReference; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.ListElement; + +public class PublisherAssertionElement { + + // owningBusinessKey_ is the key of the business element that owns this + // publisherAssertionElement + private String fromKey_; + private String toKey_; + private String owningBusinessKey_; + + // the other business that the containing business is asserted from or to + private ListElement sp_; + private int subQueryItemId_; + + // status of this publisherAssertion + private String status_; + private KeyedReference keyedReference_; + + public PublisherAssertionElement(String fromKey, String toKey, String owningBusinessKey, ListElement sp, int subQueryItemId, String status, KeyedReference keyedRef) { + fromKey_ = fromKey; + toKey_ = toKey; + owningBusinessKey_ = owningBusinessKey; + sp_ = sp; + subQueryItemId_ = subQueryItemId; + status_ = status; + keyedReference_ = keyedRef; + } + + public void setFromKey(String fromKey) { + fromKey_ = fromKey; + } + + public String getFromKey() { + return fromKey_; + } + + public void setToKey(String toKey) { + toKey_ = toKey; + } + + public String getToKey() { + return toKey_; + } + + public void setOwningBusinessKey(String key) { + owningBusinessKey_ = key; + } + + public String getOwningBusinessKey() { + return owningBusinessKey_; + } + + public void setServiceProvider(ListElement sp) { + sp_ = sp; + } + + public ListElement getServiceProvider() { + return sp_; + } + + public void setSubQueryItemId(int id) { + subQueryItemId_ = id; + } + + public int getSubQueryItemId() { + return subQueryItemId_; + } + + public void setStatus(String status) { + status_ = status; + } + + public String getStatus() { + return status_; + } + + public void setKeyedRef(KeyedReference keyedRef) { + keyedReference_ = keyedRef; + } + + public KeyedReference getKeyedRef() { + return keyedReference_; + } + + public PublisherAssertion getPublisherAssertion() { + if (fromKey_ == null || + toKey_ == null || + keyedReference_ == null) { + return null; + } + + PublisherAssertion pubAssertion = new PublisherAssertion(fromKey_, toKey_, keyedReference_); + return pubAssertion; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/QueryElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/QueryElement.java new file mode 100644 index 000000000..fdf824f48 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/QueryElement.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.*; + +import java.util.*; + +public class QueryElement extends AbstractUDDIElement +{ + private final void initQueryProperties(int itemType,Object[] results) + { + Vector resultsVector = new Vector(); + for (int i=0;i<results.length;i++) + resultsVector.addElement(results[i]); + setPropertyAsString(ModelConstants.REL_CHILDREN,UDDIModelConstants.REL_QUERY_RESULTS); + setPropertyAsObject(UDDIModelConstants.INITIAL_RESULTS,resultsVector); + setPropertyAsString(UDDIModelConstants.QUERY_TYPE,String.valueOf(itemType)); + } + + public QueryElement(BusinessEntity[] spList,String name,Model model) + { + super(name,model); + initQueryProperties(UDDIActionInputs.QUERY_ITEM_BUSINESSES,spList); + } + + public QueryElement(BusinessService[] bsList,String name,Model model) + { + super(name,model); + initQueryProperties(UDDIActionInputs.QUERY_ITEM_SERVICES,bsList); + } + + public QueryElement(TModel[] tModelList,String name,Model model) + { + super(name,model); + initQueryProperties(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES,tModelList); + } + + public int getQueryType() + { + return Integer.parseInt(getPropertyAsString(UDDIModelConstants.QUERY_TYPE)); + } + + public QueryParentElement getQueryParentElement() + { + return (QueryParentElement)getParentElement(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/QueryParentElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/QueryParentElement.java new file mode 100644 index 000000000..961485ba5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/QueryParentElement.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import java.util.*; + +public class QueryParentElement extends AbstractUDDIElement +{ + public QueryParentElement(String name,Model model) + { + super(name,model); + setPropertyAsString(ModelConstants.REL_CHILDREN,UDDIModelConstants.REL_QUERIES); + } + + public Enumeration getQueries() + { + return getElements(UDDIModelConstants.REL_QUERIES); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/RegistryElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/RegistryElement.java new file mode 100644 index 000000000..2949762db --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/RegistryElement.java @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.parser.discovery.*; +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.response.AuthToken; +import org.uddi4j.transport.TransportException; +import org.uddi4j.datatype.service.*; +import org.uddi4j.datatype.*; +import java.util.*; +import java.net.*; + +public class RegistryElement extends AbstractUDDIElement +{ + private final long AUTH_INFO_TIMEOUT = 3000000; + private UDDIProxy proxy_; + private long authTokenTimestamp_; + private AuthToken authToken_; + private String id_; + private String password_; + private String inquiryURL_; + private String publishURL_; + private String cachedPublishURL_; + private String registrationURL_; + private Hashtable userDefinedCategories_; + private boolean checkForUserDefinedCategories_; + private String categoriesDirectory_; + + public RegistryElement(UDDIProxy proxy, String inquiryURL, String name, Model model) + { + super(name, model); + proxy_ = proxy; + inquiryURL_ = inquiryURL; + publishURL_ = null; + authTokenTimestamp_ = -1; + authToken_ = null; + id_ = null; + password_ = null; + cachedPublishURL_ = null; + registrationURL_ = null; + userDefinedCategories_ = null; + checkForUserDefinedCategories_ = false; + categoriesDirectory_ = null; + } + + public final UDDIProxy getProxy() + { + return proxy_; + } + + public final String getInquiryURL() + { + return inquiryURL_; + } + + public final QueryParentElement getQueryParentElement() + { + return (QueryParentElement) (getElements(UDDIModelConstants.REL_QUERIES_PARENT).nextElement()); + } + + public final PublishedItemsElement getPublishedBusinessesElement() + { + return (PublishedItemsElement) (getElements(UDDIModelConstants.REL_PUBLISHED_BUSINESSES_PARENT).nextElement()); + } + + public final PublishedItemsElement getPublishedServicesElement() + { + return (PublishedItemsElement) (getElements(UDDIModelConstants.REL_PUBLISHED_SERVICES_PARENT).nextElement()); + } + + public final PublishedItemsElement getPublishedServiceInterfacesElement() + { + return (PublishedItemsElement) (getElements(UDDIModelConstants.REL_PUBLISHED_SERVICE_INTERFACES_PARENT).nextElement()); + } + + public final void performLogin(String publishURL, String userId, String password) throws TransportException, UDDIException, MalformedURLException + { + publishURL_ = publishURL; + proxy_.setPublishURL(NetUtils.createURL(publishURL)); + authToken_ = proxy_.get_authToken(userId, password); + authTokenTimestamp_ = System.currentTimeMillis(); + id_ = userId; + password_ = password; + } + + public final String getAuthInfoString() + { + if (!isLoggedIn()) + return null; + if ((System.currentTimeMillis() - authTokenTimestamp_) > AUTH_INFO_TIMEOUT) + { + try + { + authToken_ = proxy_.get_authToken(id_, password_); + authTokenTimestamp_ = System.currentTimeMillis(); + } + catch (Throwable t) + { + } + } + return authToken_.getAuthInfoString(); + } + + public final boolean isLoggedIn() + { + return authToken_ != null; + } + + public final void setCachedPublishURL(String publishURL) + { + cachedPublishURL_ = publishURL; + } + + public final String getPublishURL() + { + if (isLoggedIn() && publishURL_ != null) + return publishURL_; + return cachedPublishURL_; + } + + public final void setRegistrationURL(String registrationURL) + { + registrationURL_ = registrationURL; + } + + public final String getRegistrationURL() + { + return registrationURL_; + } + + public final String getUserId() + { + return id_; + } + + public final void setUserId(String userId) + { + id_ = userId; + } + + public final String getCred() + { + return password_; + } + + public final void setCred(String cred) + { + password_ = cred; + } + + public final void setUserDefinedCategories(Hashtable userDefinedCategories) + { + userDefinedCategories_ = userDefinedCategories; + } + + public final Enumeration getUserDefinedCategories() + { + if (userDefinedCategories_ != null) + return userDefinedCategories_.elements(); + else + return null; + } + + public final CategoryModel getUserDefinedCategory(String tModelKey) + { + return (CategoryModel) userDefinedCategories_.get(tModelKey); + } + + // Special handler to be invoked before sending a message to the registry. + public final void handlePreInvocation(BusinessService busService) + { + // For XMethods, business services must contain a description of the form: + // IMPLEMENTATION: ibmws + if (getInquiryURL().equals("http://uddi.xmethods.net/inquire")) + { + Vector descriptionVector = busService.getDescriptionVector(); + if (descriptionVector == null) + descriptionVector = new Vector(); + boolean containsImplementationDescription = false; + for (int i = 0; i < descriptionVector.size(); i++) + { + Description description = (Description) descriptionVector.elementAt(i); + if (description.getText().startsWith("IMPLEMENTATION: ")) + { + containsImplementationDescription = true; + break; + } + } + if (!containsImplementationDescription) + { + descriptionVector.addElement(new Description("IMPLEMENTATION: ibmws")); + busService.setDescriptionVector(descriptionVector); + } + } + } + + public final void setCheckForUserDefinedCategories(boolean checkForUserDefinedCategories) + { + checkForUserDefinedCategories_ = checkForUserDefinedCategories; + } + + public final boolean getCheckForUserDefinedCategories() + { + return checkForUserDefinedCategories_; + } + + public final void setCategoriesDirectory(String directory) + { + categoriesDirectory_ = directory; + } + + public final String getCategoriesDirectory() + { + return categoriesDirectory_; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/ServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/ServiceElement.java new file mode 100644 index 000000000..62f559fcc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/ServiceElement.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; + +import org.uddi4j.datatype.service.BusinessService; + +public class ServiceElement extends AbstractUDDIElement +{ + private BusinessService bs_; + + public ServiceElement(BusinessService bs,Model model) + { + super(bs.getDefaultNameString(),model); + setKey(bs.getServiceKey()); + bs_ = bs; + } + + public final BusinessService getBusinessService() + { + return bs_; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/ServiceInterfaceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/ServiceInterfaceElement.java new file mode 100644 index 000000000..7eb9acfde --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/ServiceInterfaceElement.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; + +import org.uddi4j.datatype.tmodel.TModel; + +public class ServiceInterfaceElement extends AbstractUDDIElement +{ + private TModel tModel_; + + public ServiceInterfaceElement(TModel tModel,Model model) + { + super(tModel.getNameString(),model); + tModel_ = tModel; + setKey(tModel.getTModelKey()); + } + + public final TModel getTModel() + { + return tModel_; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/UDDIMainElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/UDDIMainElement.java new file mode 100644 index 000000000..1ba793ab5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/datamodel/UDDIMainElement.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; + +import java.util.*; + +public class UDDIMainElement extends TreeElement +{ + private Hashtable registryNames_; + + public UDDIMainElement(String name,Model model) + { + super(name,model); + registryNames_ = new Hashtable(); + } + + public final boolean containsRegistryName(String name) + { + return (registryNames_.get(name) != null); + } + + public final void addRegistryName(String name) + { + registryNames_.put(name,Boolean.TRUE); + } + + public final void removeRegistryName(String name) + { + registryNames_.remove(name); + } + + public final void clearRegistryNames() + { + registryNames_.clear(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/AddToFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/AddToFavoritesTool.java new file mode 100644 index 000000000..b94222ddd --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/AddToFavoritesTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.AddToFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.SelectPropertiesToolAction; + +public class AddToFavoritesTool extends ActionTool { + public AddToFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/favorites_enabled.gif", "images/favorites_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddToFavoritesAction.getActionLink(selectedNode.getNodeId()); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusPublishServiceTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusPublishServiceTool.java new file mode 100644 index 000000000..c45adcafd --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusPublishServiceTool.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class BusPublishServiceTool extends FormTool implements MultipleFormToolPropertiesInterface +{ + private RegFindTool regFindTool_; + + public BusPublishServiceTool(ToolManager toolManager,String alt) + { + super(toolManager,"uddi/images/publish_service_enabled.gif","uddi/images/publish_service_highlighted.gif",alt); + regFindTool_ = new RegFindTool(new ToolManager(toolManager.getNode()), ""); + } + + protected final void initDefaultProperties() + { + UDDIPerspective uddiPerspective = toolManager_.getNode().getNodeManager().getController().getUDDIPerspective(); + + setProperty(UDDIActionInputs.SUBQUERY_KEY,""); + + setProperty(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + String simpleStyleString = String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICES,simpleStyleString); + + // RegPublishServiceSimpleAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_WSDL_URL,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_DESCRIPTION,""); + + // RegPublishServiceAdvancedAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL,""); + } + + public final void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + regFindTool_.addAuthenticationProperties(regElement); + } + + public final FormToolPropertiesInterface getFormToolProperties(Object subQueryKeyObject) + { + // Empty/Non-existent subquerykey implies publish form. All else implies query form. + String subQueryKey = (String)subQueryKeyObject; + if (subQueryKey == null || subQueryKey.length() < 1) + return this; + else + return regFindTool_.getFormToolProperties(subQueryKeyObject); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + String subQueryKey = (String)getProperty(UDDIActionInputs.SUBQUERY_KEY); + return SelectFindToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),subQueryKey,forHistory); + } + + public String getFormLink() + { + Object subQueryKeyObject = getProperty(UDDIActionInputs.SUBQUERY_KEY); + String subQueryKey = null; + if (subQueryKeyObject != null) + { + Hashtable subQueriesProperties = (Hashtable)getProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES); + FormToolPropertiesInterface subQueryProperties = getFormToolProperties(subQueryKeyObject); + Object subQueryGetObject = subQueryProperties.getProperty(UDDIActionInputs.SUBQUERY_GET); + if (subQueryGetObject != null) + { + boolean isSubQueryGet = ((Boolean)subQueryGetObject).booleanValue(); + if (isSubQueryGet) + return "uddi/forms/GetForm.jsp"; + } + subQueryKey = (String)subQueryKeyObject; + } + + if (subQueryKey == null || subQueryKey.length() < 1) + return "uddi/forms/BusPublishServiceForm.jsp"; + else + return regFindTool_.getFormLink(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusinessDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusinessDetailsTool.java new file mode 100644 index 000000000..97ed102f8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusinessDetailsTool.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.util.*; + +import java.util.*; + +public class BusinessDetailsTool extends DetailsTool +{ + public BusinessDetailsTool(ToolManager toolManager,String alt) + { + super(toolManager,alt,ProxyLoadPageAction.getActionLink("uddi/forms/BusinessDetailsForm.jsp")); + } + + public final void initDefaultProperties() + { + clearPropertyTable(); + BusinessElement busElement = (BusinessElement)(toolManager_.getNode().getTreeElement()); + BusinessEntity be = busElement.getBusinessEntity(); + + setProperty(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,be.getBusinessKey()); + + Vector nameVector = new Vector(); + copyIndexVector(be.getNameVector(),nameVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_NAMES,nameVector); + + Vector descriptionVector = new Vector(); + copyIndexVector(be.getDescriptionVector(),descriptionVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DESCRIPTIONS,descriptionVector); + + IdentifierBag idBag = be.getIdentifierBag(); + if (idBag != null) + { + Vector idVector = new Vector(); + copyIndexVector(idBag.getKeyedReferenceVector(),idVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_IDENTIFIERS,idVector); + } + + CategoryBag catBag = be.getCategoryBag(); + if (catBag != null) + { + Vector catVector = new Vector(); + copyIndexVector(catBag.getKeyedReferenceVector(),catVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_CATEGORIES,catVector); + } + + DiscoveryURLs discoveryURLs = be.getDiscoveryURLs(); + if (discoveryURLs != null) + { + Vector discoveryURLVector = new Vector(); + copyIndexVector(discoveryURLs.getDiscoveryURLVector(),discoveryURLVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_DISCOVERYURLS,discoveryURLVector); + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusinessNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusinessNode.java new file mode 100644 index 000000000..307ffde27 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/BusinessNode.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class BusinessNode extends UDDINavigatorNode +{ + private DetailsTool detailsTool_; + private BusPublishServiceTool publishServiceTool_; + private ManagePublisherAssertionsTool managePublisherAssertionsTool_; + private ManageReferencedServicesTool manageReferencedServicesTool_; + private UnpublishTool unpublishTool_; + + public BusinessNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"uddi/images/business_highlighted.gif"); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + UDDIPerspective uddiPerspective = controller.getUDDIPerspective(); + detailsTool_ = new BusinessDetailsTool(toolManager_,uddiPerspective.getMessage("ALT_BUSINESS_DETAILS")); + new GetServicesTool(toolManager_,uddiPerspective.getMessage("ALT_GET_SERVICES"),BusinessGetServicesAction.getActionLink(nodeId_)); + publishServiceTool_ = new BusPublishServiceTool(toolManager_,uddiPerspective.getMessage("ALT_PUBLISH_SERVICE")); + manageReferencedServicesTool_ = new ManageReferencedServicesTool(toolManager_,uddiPerspective.getMessage("ALT_MANAGE_REFERENCED_SERVICES")); + managePublisherAssertionsTool_ = new ManagePublisherAssertionsTool(toolManager_,uddiPerspective.getMessage("ALT_MANAGE_PUBLISHER_ASSERTIONS")); + new AddToFavoritesTool(toolManager_, uddiPerspective.getMessage("ALT_ADD_TO_FAVORITES")); + unpublishTool_ = new UnpublishTool(toolManager_,"uddi/images/unpublish_bus_enabled.gif","uddi/images/unpublish_bus_highlighted.gif",uddiPerspective.getMessage("ALT_UNPUBLISH_BUSINESS")); + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + detailsTool_.addAuthenticationProperties(regElement); + publishServiceTool_.addAuthenticationProperties(regElement); + manageReferencedServicesTool_.addAuthenticationProperties(regElement); + managePublisherAssertionsTool_.addAuthenticationProperties(regElement); + unpublishTool_.addAuthenticationProperties(regElement); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/CategoryNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/CategoryNode.java new file mode 100644 index 000000000..dea0df097 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/CategoryNode.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class CategoryNode extends Node +{ + public CategoryNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"uddi/images/category.gif"); + setVisibilityOfChildren(false); + } + + public final void createChildren() + { + Enumeration children = element_.getElements(UDDIModelConstants.REL_SUBCATEGORIES); + if (children != null) + { + while (children.hasMoreElements()) + { + CategoryElement categoryElement = (CategoryElement)children.nextElement(); + CategoryNode categoryNode = new CategoryNode(categoryElement,nodeManager_,nodeDepth_+1); + addChild(categoryNode); + categoryNode.createChildren(); + } + } + } + + public final String getNodeName() + { + CategoryElement categoryElement = (CategoryElement)element_; + return categoryElement.getNameForTree(); + } + + protected final String getToggleNodeActionHref() + { + return ToggleCategoryNodeAction.getActionLink(getNodeManager().getController().getSessionId(),nodeId_,isOpen_); + } + + protected final String getLinkActionHref() + { + return SelectCategoryNodeAction.getActionLink(getNodeManager().getController().getSessionId(),nodeId_); + } + + protected final String getToggleNodeActionTarget() + { + return UDDIFrameNames.CATEGORIES_WORKAREA; + } + + protected final String getLinkActionTarget() + { + return UDDIFrameNames.CATEGORIES_WORKAREA; + } + + protected final void initTools() + { + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/DetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/DetailsTool.java new file mode 100644 index 000000000..2f8cfcd63 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/DetailsTool.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class DetailsTool extends FormTool +{ + private String formLink_; + + public DetailsTool(ToolManager toolManager,String alt,String formLink) + { + super(toolManager,"images/details_enabled.gif","images/details_highlighted.gif",alt); + formLink_ = formLink; + } + + public void initDefaultProperties() + { + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getFormLink() + { + return formLink_; + } + + protected final void copyIndexVector(Vector source,Vector destination) + { + destination.removeAllElements(); + for (int i=0;i<source.size();i++) + { + ListElement listElement = new ListElement(source.elementAt(i)); + listElement.setViewId(i); + // The next item indicates that this element is to be in non-edit state. + listElement.setTargetViewToolInfo(-1,-1,i); + destination.addElement(listElement); + } + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetBusinessesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetBusinessesTool.java new file mode 100644 index 000000000..4f4f3cf2e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetBusinessesTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class GetBusinessesTool extends ActionTool +{ + private String actionLink_; + public GetBusinessesTool(ToolManager toolManager,String enabledImagePath,String highlightedImagePath,String alt,String actionLink) + { + super(toolManager,enabledImagePath,highlightedImagePath,alt); + actionLink_ = actionLink; + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getActionLink() + { + return actionLink_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetServiceInterfacesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetServiceInterfacesTool.java new file mode 100644 index 000000000..7ea5ac0d0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetServiceInterfacesTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class GetServiceInterfacesTool extends ActionTool +{ + private String actionLink_; + public GetServiceInterfacesTool(ToolManager toolManager,String alt,String actionLink) + { + super(toolManager,"uddi/images/service_interfaces_closed_enabled.gif","uddi/images/service_interfaces_closed_highlighted.gif",alt); + actionLink_ = actionLink; + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getActionLink() + { + return actionLink_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetServicesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetServicesTool.java new file mode 100644 index 000000000..f2f034a3c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/GetServicesTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class GetServicesTool extends ActionTool +{ + private String actionLink_; + public GetServicesTool(ToolManager toolManager,String alt,String actionLink) + { + super(toolManager,"uddi/images/services_closed_enabled.gif","uddi/images/services_closed_highlighted.gif",alt); + actionLink_ = actionLink; + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getActionLink() + { + return actionLink_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ItemsSummaryTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ItemsSummaryTool.java new file mode 100644 index 000000000..e8ef3ee1a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ItemsSummaryTool.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ProxyLoadPageAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.SelectPropertiesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; + +public class ItemsSummaryTool extends FormTool +{ + private String formLink_; + + public ItemsSummaryTool(ToolManager toolManager,String enabledImage,String highlightedImage,String alt,int queryItem) + { + super(toolManager,enabledImage,highlightedImage,alt); + StringBuffer formLink = new StringBuffer("uddi/forms/ItemsSummaryForm.jsp?"); + formLink.append(UDDIActionInputs.QUERY_ITEM).append('=').append(queryItem); + String encodedFormLink = URLUtils.encode(formLink.toString()); + formLink_ = ProxyLoadPageAction.getActionLink(encodedFormLink); + } + + public final void initDefaultProperties() + { + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getFormLink() + { + return formLink_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ManagePublisherAssertionsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ManagePublisherAssertionsTool.java new file mode 100644 index 000000000..95dc27934 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ManagePublisherAssertionsTool.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class ManagePublisherAssertionsTool extends FormTool implements MultipleFormToolPropertiesInterface +{ + ToolManager invisibleToolManager_; + private RegFindTool regFindTool_; + + public ManagePublisherAssertionsTool(ToolManager toolManager, String alt) + { + super(toolManager, "uddi/images/publisher_assertions_enabled.gif", "uddi/images/publisher_assertions_highlighted.gif", alt); + invisibleToolManager_ = new ToolManager(toolManager.getNode()); + regFindTool_ = new RegFindTool(invisibleToolManager_,""); + } + + protected final void initDefaultProperties() + { + setProperty(UDDIActionInputs.SUBQUERY_KEY,""); + setProperty(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + String simpleStyleString = String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE); + setProperty(UDDIActionInputs.QUERY_STYLE_BUSINESSES,simpleStyleString); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICES,simpleStyleString); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,simpleStyleString); + } + + public final FormToolPropertiesInterface getFormToolProperties(Object subQueryKeyObject) + { + // Empty/Non-existent subquerykey implies publish form. All else implies query form. + String subQueryKey = (String)subQueryKeyObject; + if (subQueryKey == null || subQueryKey.length() < 1) + return this; + else + return regFindTool_.getFormToolProperties(subQueryKeyObject); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + String subQueryKey = (String)getProperty(UDDIActionInputs.SUBQUERY_KEY); + return SelectFindToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),subQueryKey,forHistory); + } + + public final void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + regFindTool_.addAuthenticationProperties(regElement); + } + + public String getFormLink() + { + Object subQueryKeyObject = getProperty(UDDIActionInputs.SUBQUERY_KEY); + String subQueryKey = null; + if (subQueryKeyObject != null) + { + Hashtable subQueriesProperties = (Hashtable)getProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES); + FormToolPropertiesInterface subQueryProperties = getFormToolProperties(subQueryKeyObject); + Object subQueryGetObject = subQueryProperties.getProperty(UDDIActionInputs.SUBQUERY_GET); + if (subQueryGetObject != null) + { + boolean isSubQueryGet = ((Boolean)subQueryGetObject).booleanValue(); + if (isSubQueryGet) + return "uddi/forms/GetForm.jsp"; + } + subQueryKey = (String)subQueryKeyObject; + } + + if (subQueryKey == null || subQueryKey.length() < 1) + return ProxyLoadPageAction.getActionLink("uddi/forms/ManagePublisherAssertionsForm.jsp"); + else + return regFindTool_.getFormLink(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ManageReferencedServicesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ManageReferencedServicesTool.java new file mode 100644 index 000000000..1faa92f11 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ManageReferencedServicesTool.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class ManageReferencedServicesTool extends FormTool implements MultipleFormToolPropertiesInterface +{ + ToolManager invisibleToolManager_; + private RegFindTool regFindTool_; + + public ManageReferencedServicesTool(ToolManager toolManager, String alt) + { + super(toolManager, "uddi/images/referenced_services_enabled.gif", "uddi/images/referenced_services_highlighted.gif", alt); + invisibleToolManager_ = new ToolManager(toolManager.getNode()); + regFindTool_ = new RegFindTool(invisibleToolManager_,""); + } + + protected final void initDefaultProperties() + { + setProperty(UDDIActionInputs.SUBQUERY_KEY,""); + setProperty(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_SERVICES)); + String simpleStyleString = String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE); + setProperty(UDDIActionInputs.QUERY_STYLE_BUSINESSES,simpleStyleString); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICES,simpleStyleString); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,simpleStyleString); + } + + public final FormToolPropertiesInterface getFormToolProperties(Object subQueryKeyObject) + { + // Empty/Non-existent subquerykey implies publish form. All else implies query form. + String subQueryKey = (String)subQueryKeyObject; + if (subQueryKey == null || subQueryKey.length() < 1) + return this; + else + return regFindTool_.getFormToolProperties(subQueryKeyObject); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + String subQueryKey = (String)getProperty(UDDIActionInputs.SUBQUERY_KEY); + return SelectFindToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),subQueryKey,forHistory); + } + + public final void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + regFindTool_.addAuthenticationProperties(regElement); + } + + public String getFormLink() + { + Object subQueryKeyObject = getProperty(UDDIActionInputs.SUBQUERY_KEY); + String subQueryKey = null; + if (subQueryKeyObject != null) + { + Hashtable subQueriesProperties = (Hashtable)getProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES); + FormToolPropertiesInterface subQueryProperties = getFormToolProperties(subQueryKeyObject); + Object subQueryGetObject = subQueryProperties.getProperty(UDDIActionInputs.SUBQUERY_GET); + if (subQueryGetObject != null) + { + boolean isSubQueryGet = ((Boolean)subQueryGetObject).booleanValue(); + if (isSubQueryGet) + return "uddi/forms/GetForm.jsp"; + } + subQueryKey = (String)subQueryKeyObject; + } + + if (subQueryKey == null || subQueryKey.length() < 1) + return "uddi/forms/ManageReferencedServicesForm.jsp"; + else + return regFindTool_.getFormLink(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/MultipleFormToolPropertiesInterface.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/MultipleFormToolPropertiesInterface.java new file mode 100644 index 000000000..e3507e2c2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/MultipleFormToolPropertiesInterface.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public abstract interface MultipleFormToolPropertiesInterface +{ + public abstract FormToolPropertiesInterface getFormToolProperties(Object key); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/OpenRegistryTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/OpenRegistryTool.java new file mode 100644 index 000000000..1c3885877 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/OpenRegistryTool.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; + +import java.util.*; + +public class OpenRegistryTool extends FormTool +{ + private Controller controller_; + + public OpenRegistryTool(ToolManager toolManager,String alt) + { + super(toolManager,"uddi/images/open_registry_enabled.gif","uddi/images/open_registry_highlighted.gif",alt); + } + + protected final void initDefaultProperties() + { + controller_ = toolManager_.getNode().getNodeManager().getController(); + UDDIPerspective uddiPerspective = controller_.getUDDIPerspective(); + setProperty(UDDIActionInputs.REGISTRY_NAME,uddiPerspective.getMessage("DEFAULT_REGISTRY_NAME")); + setProperty(UDDIActionInputs.INQUIRY_URL,uddiPerspective.getIBMPublicUDDITestRegistry().getInquiryURL()); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getFormLink() + { + return "uddi/forms/OpenRegistryForm.jsp"; + } + + public final Enumeration getFavoriteRegistryElements() + { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager favoritesNodeManager = favPerspective.getNodeManager(); + TreeElement favoritesMainElement = favoritesNodeManager.getRootNode().getTreeElement(); + TreeElement favoriteRegistriesElement = (TreeElement)(favoritesMainElement.getElements(FavoritesModelConstants.REL_UDDI_REGISTRY_FOLDER_NODE).nextElement()); + return favoriteRegistriesElement.getElements(FavoritesModelConstants.REL_UDDI_REGISTRY_NODE); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/PublishedItemsNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/PublishedItemsNode.java new file mode 100644 index 000000000..c43146192 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/PublishedItemsNode.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class PublishedItemsNode extends UDDINavigatorFolderNode +{ + public PublishedItemsNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(UDDIModelConstants.REL_PUBLISHED_ITEMS)) + { + TreeElement treeElement = (TreeElement)event.getParentElement(); + createChildNode(treeElement); + } + } + + public void relRemoved(RelRemoveEvent event) + { + TreeElement treeElement = null; + if (event.getInBoundRelName().equals(UDDIModelConstants.REL_PUBLISHED_ITEMS)) + treeElement = (TreeElement)event.getInboundElement(); + else if (event.getOutBoundRelName().equals(UDDIModelConstants.REL_PUBLISHED_ITEMS)) + treeElement = (TreeElement)event.getOutBoundElement(); + + if (treeElement != null) + removeChildNode(treeElement); + } + }); + } + + private final void createChildNode(TreeElement element) + { + PublishedItemsElement publishedItemsElement = (PublishedItemsElement)element_; + Node childNode = null; + switch (publishedItemsElement.getType()) + { + case UDDIActionInputs.QUERY_ITEM_BUSINESSES: + childNode = new BusinessNode(element,nodeManager_,nodeDepth_+1); + break; + case UDDIActionInputs.QUERY_ITEM_SERVICES: + childNode = new ServiceNode(element,nodeManager_,nodeDepth_+1); + break; + case UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES: + childNode = new ServiceInterfaceNode(element,nodeManager_,nodeDepth_+1); + } + if (childNode != null) + addChild(childNode); + } + + protected final void initTools() + { + PublishedItemsElement publishedItemsElement = (PublishedItemsElement)element_; + UDDIPerspective uddiPerspective = nodeManager_.getController().getUDDIPerspective(); + int publishedItemsType = publishedItemsElement.getType(); + switch (publishedItemsType) + { + case UDDIActionInputs.QUERY_ITEM_BUSINESSES: + new ItemsSummaryTool(toolManager_,"uddi/images/businesses_closed_enabled.gif","uddi/images/businesses_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_BUSINESSES"),publishedItemsType); + break; + case UDDIActionInputs.QUERY_ITEM_SERVICES: + new ItemsSummaryTool(toolManager_,"uddi/images/services_closed_enabled.gif","uddi/images/services_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_SERVICES"),publishedItemsType); + break; + case UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES: + default: + new ItemsSummaryTool(toolManager_,"uddi/images/service_interfaces_closed_enabled.gif","uddi/images/service_interfaces_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_SERVICE_INTERFACES"),publishedItemsType); + } + } + + public String getOpenImagePath() + { + PublishedItemsElement publishedItemsElement = (PublishedItemsElement)element_; + int publishedItemsType = publishedItemsElement.getType(); + switch (publishedItemsType) + { + case UDDIActionInputs.QUERY_ITEM_BUSINESSES: + return "uddi/images/businesses_open_highlighted.gif"; + case UDDIActionInputs.QUERY_ITEM_SERVICES: + return "uddi/images/services_open_highlighted.gif"; + case UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES: + return "uddi/images/service_interfaces_open_highlighted.gif"; + } + return super.getOpenImagePath(); + } + + public String getClosedImagePath() + { + PublishedItemsElement publishedItemsElement = (PublishedItemsElement)element_; + int publishedItemsType = publishedItemsElement.getType(); + switch (publishedItemsType) + { + case UDDIActionInputs.QUERY_ITEM_BUSINESSES: + return "uddi/images/businesses_closed_highlighted.gif"; + case UDDIActionInputs.QUERY_ITEM_SERVICES: + return "uddi/images/services_closed_highlighted.gif"; + case UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES: + return "uddi/images/service_interfaces_closed_highlighted.gif"; + } + return super.getClosedImagePath(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/QueryNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/QueryNode.java new file mode 100644 index 000000000..435046aa5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/QueryNode.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; + +import java.util.*; + +public class QueryNode extends UDDINavigatorNode +{ + private FormTool regFindTool_; + private FindAction findAction_; + public QueryNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"uddi/images/query.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(UDDIModelConstants.REL_QUERY_RESULTS)) + { + TreeElement treeElement = (TreeElement)event.getParentElement(); + createChildNode(treeElement); + } + } + + public void relRemoved(RelRemoveEvent event) + { + TreeElement treeElement = null; + if (event.getInBoundRelName().equals(UDDIModelConstants.REL_QUERY_RESULTS)) + treeElement = (TreeElement)event.getInboundElement(); + else if (event.getOutBoundRelName().equals(UDDIModelConstants.REL_QUERY_RESULTS)) + treeElement = (TreeElement)event.getOutBoundElement(); + + if (treeElement != null) + removeChildNode(treeElement); + } + }); + createChildren(); + setVisibilityOfChildren(false); + findAction_ = null; + } + + private final void createChildren() + { + Vector initialResults = (Vector)element_.getPropertyAsObject(UDDIModelConstants.INITIAL_RESULTS); + for (int i=0;i<initialResults.size();i++) + { + Object object = initialResults.elementAt(i); + TreeElement childElement = null; + if (object instanceof BusinessEntity) + childElement = new BusinessElement((BusinessEntity)object,element_.getModel()); + else if (object instanceof BusinessService) + childElement = new ServiceElement((BusinessService)object,element_.getModel()); + else if (object instanceof TModel) + childElement = new ServiceInterfaceElement((TModel)object,element_.getModel()); + if (childElement != null) + element_.connect(childElement,UDDIModelConstants.REL_QUERY_RESULTS,ModelConstants.REL_OWNER); + } + } + + private final void createChildNode(TreeElement element) + { + Node childNode = null; + if (element instanceof BusinessElement) + childNode = new BusinessNode(element,nodeManager_,nodeDepth_+1); + else if (element instanceof ServiceElement) + childNode = new ServiceNode(element,nodeManager_,nodeDepth_+1); + else if (element instanceof ServiceInterfaceElement) + childNode = new ServiceInterfaceNode(element,nodeManager_,nodeDepth_+1); + if (childNode != null) + addChild(childNode); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + UDDIPerspective uddiPerspective = controller.getUDDIPerspective(); + new ResultsTool(toolManager_,controller.getMessage("ALT_RESULTS")); + regFindTool_ = new RegFindTool(toolManager_,uddiPerspective.getMessage("ALT_FIND")); + } + + public final void setFindToolProperties(FindAction findAction) + { + findAction_ = findAction; + regFindTool_.updatePropertyTable(findAction.getPropertyTable()); + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + ((RegFindTool)regFindTool_).addAuthenticationProperties(regElement); + Vector childNodes = getChildNodes(); + for (int i=0;i<childNodes.size();i++) + { + UDDINavigatorNode navigatorNode = (UDDINavigatorNode)childNodes.elementAt(i); + navigatorNode.addAuthenticationProperties(regElement); + } + } + + public final FindAction getFindAction() + { + return findAction_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/QueryParentNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/QueryParentNode.java new file mode 100644 index 000000000..177189639 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/QueryParentNode.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class QueryParentNode extends UDDINavigatorFolderNode +{ + public QueryParentNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(UDDIModelConstants.REL_QUERIES)) + { + QueryElement queryElement = (QueryElement)event.getParentElement(); + createChildNode(queryElement); + } + } + + public void relRemoved(RelRemoveEvent event) + { + QueryElement queryElement = null; + if (event.getInBoundRelName().equals(UDDIModelConstants.REL_QUERIES)) + queryElement = (QueryElement)event.getInboundElement(); + else if (event.getOutBoundRelName().equals(UDDIModelConstants.REL_QUERIES)) + queryElement = (QueryElement)event.getOutBoundElement(); + + if (queryElement != null) + removeChildNode(queryElement); + } + }); + } + + private final void createChildNode(QueryElement element) + { + QueryNode queryNode = new QueryNode(element,nodeManager_,nodeDepth_+1); + // Add registry authentication properties. + RegistryElement regElement = (RegistryElement)(getParent().getTreeElement()); + queryNode.addAuthenticationProperties(regElement); + addChild(queryNode); + } + + protected final void initTools() + { + UDDIPerspective uddiPerspective = nodeManager_.getController().getUDDIPerspective(); + new ItemsSummaryTool(toolManager_,"uddi/images/queries_closed_enabled.gif","uddi/images/queries_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_QUERIES"),UDDIActionInputs.QUERY_ITEM_QUERIES); + new ItemsSummaryTool(toolManager_,"uddi/images/businesses_closed_enabled.gif","uddi/images/businesses_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_BUSINESSES"),UDDIActionInputs.QUERY_ITEM_BUSINESSES); + new ItemsSummaryTool(toolManager_,"uddi/images/services_closed_enabled.gif","uddi/images/services_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_SERVICES"),UDDIActionInputs.QUERY_ITEM_SERVICES); + new ItemsSummaryTool(toolManager_,"uddi/images/service_interfaces_closed_enabled.gif","uddi/images/service_interfaces_closed_highlighted.gif",uddiPerspective.getMessage("ALT_SUMMARY_SERVICE_INTERFACES"),UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES); + } + + public String getOpenImagePath() + { + return "uddi/images/queries_open_highlighted.gif"; + } + + public String getClosedImagePath() + { + return "uddi/images/queries_closed_highlighted.gif"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RefreshTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RefreshTool.java new file mode 100644 index 000000000..4e4b12793 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RefreshTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class RefreshTool extends ActionTool +{ + private String actionLink_; + + public RefreshTool(ToolManager toolManager,String alt) + { + super(toolManager,"images/refresh_enabled.gif","images/refresh_highlighted.gif",alt); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getActionLink() + { + return RefreshUDDINodeAction.getActionLink(toolManager_.getNode().getNodeId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegFindTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegFindTool.java new file mode 100644 index 000000000..7db89c617 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegFindTool.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class RegFindTool extends FormTool implements MultipleFormToolPropertiesInterface +{ + public RegFindTool(ToolManager toolManager,String alt) + { + super(toolManager,"uddi/images/find_enabled.gif","uddi/images/find_highlighted.gif",alt); + } + + protected final void initDefaultProperties() + { + initDefaultProperties(this); + setProperty(UDDIActionInputs.SUBQUERY_KEY,""); + setProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES,new Hashtable()); + UDDIPerspective uddiPerspective = toolManager_.getNode().getNodeManager().getController().getUDDIPerspective(); + setProperty(UDDIActionInputs.QUERY_NAME,uddiPerspective.getMessage("DEFAULT_QUERY_NAME")); + } + + private final void initDefaultProperties(FormToolPropertiesInterface formToolPI) + { + UDDIPerspective uddiPerspective = toolManager_.getNode().getNodeManager().getController().getUDDIPerspective(); + + formToolPI.setProperty(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + String simpleStyleString = String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE); + formToolPI.setProperty(UDDIActionInputs.QUERY_STYLE_BUSINESSES,simpleStyleString); + formToolPI.setProperty(UDDIActionInputs.QUERY_STYLE_SERVICES,simpleStyleString); + formToolPI.setProperty(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,simpleStyleString); + + String maxSearchSet = String.valueOf(UDDIActionInputs.QUERY_MAX_SEARCH_SET); + String maxResults = String.valueOf(UDDIActionInputs.QUERY_MAX_RESULTS); + + // RegFindBusinessesSimpleAction inputs + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME,""); + + // RegFindBusinessesAdvancedAction inputs + // The authentication inputs must be added later as this method is called before we can get a valid handle + // to the RegistryElement in the case of a query node. + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_SEARCH_SET,maxSearchSet); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_BUSINESS_MAX_RESULTS,maxResults); + + // RegFindServicesSimpleAction inputs + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME,""); + + // RegFindServicesAdvancedAction inputs + // The authentication inputs must be added later as this method is called before we can get a valid handle + // to the RegistryElement in the case of a query node. + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_SEARCH_SET,maxSearchSet); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_MAX_RESULTS,maxResults); + + // RegFindServiceInterfacesSimpleAction inputs + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME,""); + + // RegFindServiceInterfacesAdvancedAction inputs + // The authentication inputs must be added later as this method is called before we can get a valid handle + // to the RegistryElement in the case of a query node. + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME,""); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_SEARCH_SET,maxSearchSet); + formToolPI.setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_MAX_RESULTS,maxResults); + } + + public final void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + + public final FormToolPropertiesInterface getFormToolProperties(Object subQueryKeyObject) + { + String subQueryKey = (String)subQueryKeyObject; + if (subQueryKey == null || subQueryKey.length() < 1) + return this; + Hashtable subQueriesProperties = (Hashtable)getProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES); + FormToolPropertiesInterface subQueryProperties = (FormToolPropertiesInterface)subQueriesProperties.get(subQueryKey); + if (subQueryProperties == null) + { + subQueryProperties = new FormToolProperties(); + initDefaultProperties(subQueryProperties); + subQueriesProperties.put(subQueryKey,subQueryProperties); + } + return subQueryProperties; + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + String subQueryKey = (String)getProperty(UDDIActionInputs.SUBQUERY_KEY); + return SelectFindToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),subQueryKey,forHistory); + } + + public String getFormLink() + { + Object subQueryKeyObject = getProperty(UDDIActionInputs.SUBQUERY_KEY); + if (subQueryKeyObject != null) + { + Hashtable subQueriesProperties = (Hashtable)getProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES); + FormToolPropertiesInterface subQueryProperties = getFormToolProperties(subQueryKeyObject); + Object subQueryGetObject = subQueryProperties.getProperty(UDDIActionInputs.SUBQUERY_GET); + if (subQueryGetObject != null) + { + boolean isSubQueryGet = ((Boolean)subQueryGetObject).booleanValue(); + if (isSubQueryGet) + return "uddi/forms/GetForm.jsp"; + } + } + return "uddi/forms/RegFindForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegPublishTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegPublishTool.java new file mode 100644 index 000000000..a8babd558 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegPublishTool.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class RegPublishTool extends FormTool implements MultipleFormToolPropertiesInterface +{ + ToolManager invisibleToolManager_; + private RegFindTool regFindTool_; + public RegPublishTool(ToolManager toolManager,String alt) + { + super(toolManager,"uddi/images/publish_enabled.gif","uddi/images/publish_highlighted.gif",alt); + invisibleToolManager_ = new ToolManager(toolManager.getNode()); + regFindTool_ = new RegFindTool(invisibleToolManager_,""); + } + + protected final void initDefaultProperties() + { + UDDIPerspective uddiPerspective = toolManager_.getNode().getNodeManager().getController().getUDDIPerspective(); + + setProperty(UDDIActionInputs.SUBQUERY_KEY,""); + + setProperty(UDDIActionInputs.QUERY_ITEM,String.valueOf(UDDIActionInputs.QUERY_ITEM_BUSINESSES)); + String simpleStyleString = String.valueOf(UDDIActionInputs.QUERY_STYLE_SIMPLE); + setProperty(UDDIActionInputs.QUERY_STYLE_BUSINESSES,simpleStyleString); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICES,simpleStyleString); + setProperty(UDDIActionInputs.QUERY_STYLE_SERVICE_INTERFACES,simpleStyleString); + + // RegPublishBusinessSimpleAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_NAME,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_BUSINESS_DESCRIPTION,""); + + // RegPublishServiceSimpleAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_WSDL_URL,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_NAME,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_DESCRIPTION,""); + + // RegPublishServiceAdvancedAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL,""); + + // RegPublishServiceInterfaceSimpleAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_WSDL_URL,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_NAME,""); + setProperty(UDDIActionInputs.QUERY_INPUT_SIMPLE_SERVICE_INTERFACE_DESCRIPTION,""); + + // RegPublishServiceInterfaceAdvancedAction inputs + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL,""); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME,""); + } + + public final void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + regFindTool_.addAuthenticationProperties(regElement); + } + + public final FormToolPropertiesInterface getFormToolProperties(Object subQueryKeyObject) + { + // Empty/Non-existent subquerykey implies publish form. All else implies query form. + String subQueryKey = (String)subQueryKeyObject; + if (subQueryKey == null || subQueryKey.length() < 1) + return this; + else + return regFindTool_.getFormToolProperties(subQueryKeyObject); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + String subQueryKey = (String)getProperty(UDDIActionInputs.SUBQUERY_KEY); + return SelectFindToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),subQueryKey,forHistory); + } + + public String getFormLink() + { + Object subQueryKeyObject = getProperty(UDDIActionInputs.SUBQUERY_KEY); + String subQueryKey = null; + if (subQueryKeyObject != null) + { + Hashtable subQueriesProperties = (Hashtable)getProperty(UDDIActionInputs.SUBQUERIES_PROPERTIES); + FormToolPropertiesInterface subQueryProperties = getFormToolProperties(subQueryKeyObject); + Object subQueryGetObject = subQueryProperties.getProperty(UDDIActionInputs.SUBQUERY_GET); + if (subQueryGetObject != null) + { + boolean isSubQueryGet = ((Boolean)subQueryGetObject).booleanValue(); + if (isSubQueryGet) + return "uddi/forms/GetForm.jsp"; + } + subQueryKey = (String)subQueryKeyObject; + } + + if (subQueryKey == null || subQueryKey.length() < 1) + return "uddi/forms/RegPublishForm.jsp"; + else + return regFindTool_.getFormLink(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegistryDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegistryDetailsTool.java new file mode 100644 index 000000000..03c35fc54 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegistryDetailsTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class RegistryDetailsTool extends DetailsTool +{ + public RegistryDetailsTool(ToolManager toolManager,String alt) + { + super(toolManager,alt,ProxyLoadPageAction.getActionLink("uddi/forms/RegDetailsForm.jsp")); + } + + public final void initDefaultProperties() + { + clearPropertyTable(); + Controller controller = toolManager_.getNode().getNodeManager().getController(); + RegistryElement regElement = (RegistryElement)(toolManager_.getNode().getTreeElement()); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_REGISTRY_NAME,regElement.getName()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegistryNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegistryNode.java new file mode 100644 index 000000000..15bff92da --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RegistryNode.java @@ -0,0 +1,233 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class RegistryNode extends UDDINavigatorNode +{ + private RegistryDetailsTool regDetailsTool_; + private RegPublishTool regPublishTool_; + + public static final String IMAGE_PATH_STANDARD = "uddi/images/registry.gif"; + public static final String IMAGE_PATH_WITH_USER_DEFINED_CATEGORIES = "uddi/images/regstrycat_obj.gif"; + + public RegistryNode(TreeElement element,NodeManager nodeManager,int nodeDepth,String imagePath) + { + super(element,nodeManager,nodeDepth,imagePath); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(UDDIModelConstants.REL_QUERIES_PARENT)) + { + QueryParentElement queryParentElement = (QueryParentElement)event.getParentElement(); + createChildNode(queryParentElement); + } + else if (isPublishedItemsRel(rel)) + { + PublishedItemsElement publishedItemsElement = (PublishedItemsElement)event.getParentElement(); + createChildNode(publishedItemsElement); + } + } + public void relRemoved(RelRemoveEvent event) + { + TreeElement childElement = null; + String inBoundRelName = event.getInBoundRelName(); + String outBoundRelName = event.getOutBoundRelName(); + if (inBoundRelName.equals(UDDIModelConstants.REL_QUERIES_PARENT) || isPublishedItemsRel(inBoundRelName)) + childElement = (TreeElement)event.getInboundElement(); + else if (outBoundRelName.equals(UDDIModelConstants.REL_QUERIES_PARENT) || isPublishedItemsRel(outBoundRelName)) + childElement = (TreeElement)event.getOutBoundElement(); + + if (childElement != null) + removeChildNode(childElement); + } + }); + UDDIPerspective uddiPerspective = nodeManager_.getController().getUDDIPerspective(); + element.connect(new QueryParentElement(uddiPerspective.getMessage("NODE_NAME_QUERIES_FOLDER"),element_.getModel()),UDDIModelConstants.REL_QUERIES_PARENT,ModelConstants.REL_OWNER); + element.connect(new PublishedItemsElement(UDDIActionInputs.QUERY_ITEM_BUSINESSES,uddiPerspective.getMessage("NODE_NAME_PUBLISHED_BUSINESSES_FOLDER"),element_.getModel()),UDDIModelConstants.REL_PUBLISHED_BUSINESSES_PARENT,ModelConstants.REL_OWNER); + element.connect(new PublishedItemsElement(UDDIActionInputs.QUERY_ITEM_SERVICES,uddiPerspective.getMessage("NODE_NAME_PUBLISHED_SERVICES_FOLDER"),element_.getModel()),UDDIModelConstants.REL_PUBLISHED_SERVICES_PARENT,ModelConstants.REL_OWNER); + element.connect(new PublishedItemsElement(UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES,uddiPerspective.getMessage("NODE_NAME_PUBLISHED_SERVICE_INTERFACES_FOLDER"),element_.getModel()),UDDIModelConstants.REL_PUBLISHED_SERVICE_INTERFACES_PARENT,ModelConstants.REL_OWNER); + setVisibilityOfChildren(false); + } + + private final boolean isPublishedItemsRel(String rel) + { + return rel.equals(UDDIModelConstants.REL_PUBLISHED_BUSINESSES_PARENT) || rel.equals(UDDIModelConstants.REL_PUBLISHED_SERVICES_PARENT) || rel.equals(UDDIModelConstants.REL_PUBLISHED_SERVICE_INTERFACES_PARENT); + } + + private final void createChildNode(QueryParentElement queryParentElement) + { + QueryParentNode queryParentNode = new QueryParentNode(queryParentElement,nodeManager_,nodeDepth_+1); + addChild(queryParentNode); + } + + private final void createChildNode(PublishedItemsElement publishedItemsElement) + { + PublishedItemsNode publishedItemsNode = new PublishedItemsNode(publishedItemsElement,nodeManager_,nodeDepth_+1); + addChild(publishedItemsNode); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + UDDIPerspective uddiPerspective = nodeManager_.getController().getUDDIPerspective(); + regDetailsTool_ = new RegistryDetailsTool(toolManager_ ,uddiPerspective.getMessage("ALT_REGISTRY_DETAILS")); + RegFindTool regFindTool = new RegFindTool(toolManager_,uddiPerspective.getMessage("ALT_FIND")); + regPublishTool_ = new RegPublishTool(toolManager_,uddiPerspective.getMessage("ALT_PUBLISH")); + new AddToFavoritesTool(toolManager_,uddiPerspective.getMessage("ALT_ADD_TO_FAVORITES")); + regFindTool.addAuthenticationProperties((RegistryElement)element_); + regPublishTool_.addAuthenticationProperties((RegistryElement)element_); + } + + public final RegistryDetailsTool getRegDetailsTool() + { + return regDetailsTool_; + } + + public final RegPublishTool getRegPublishTool() + { + return regPublishTool_; + } + + private final void addDiscoveredNodes(Vector allNodes,Node queryParentNode,int queryType) + { + Vector queryNodes = queryParentNode.getChildNodes(); + for (int i=0;i<queryNodes.size();i++) + { + QueryNode queryNode = (QueryNode)queryNodes.elementAt(i); + QueryElement queryElement = (QueryElement)queryNode.getTreeElement(); + if (queryType == UDDIActionInputs.QUERY_ITEM_QUERIES) + allNodes.addElement(queryNode); + else if (queryElement.getQueryType() == queryType) + { + Vector discoveredNodes = queryNode.getChildNodes(); + for (int j=0;j<discoveredNodes.size();j++) + allNodes.addElement(discoveredNodes.elementAt(j)); + } + } + } + + private final void addPublishedNodes(Vector allNodes,Node publishedItemsNode) + { + Vector itemNodes = publishedItemsNode.getChildNodes(); + for (int i=0;i<itemNodes.size();i++) + allNodes.addElement(itemNodes.elementAt(i)); + } + + public final void getAllBusinessNodes(Vector allBusinessNodes) + { + RegistryElement regElement = (RegistryElement)element_; + Node queryParentNode = getChildNode(regElement.getQueryParentElement()); + Node publishedBusinessesNode = getChildNode(regElement.getPublishedBusinessesElement()); + addDiscoveredNodes(allBusinessNodes,queryParentNode,UDDIActionInputs.QUERY_ITEM_BUSINESSES); + addPublishedNodes(allBusinessNodes,publishedBusinessesNode); + } + + public final void getAllServiceNodes(Vector allServicesNodes) + { + RegistryElement regElement = (RegistryElement)element_; + Node queryParentNode = getChildNode(regElement.getQueryParentElement()); + Node publishedServicesNode = getChildNode(regElement.getPublishedServicesElement()); + addDiscoveredNodes(allServicesNodes,queryParentNode,UDDIActionInputs.QUERY_ITEM_SERVICES); + addPublishedNodes(allServicesNodes,publishedServicesNode); + } + + public final void getAllServiceInterfaceNodes(Vector allServiceInterfaceNodes) + { + RegistryElement regElement = (RegistryElement)element_; + Node queryParentNode = getChildNode(regElement.getQueryParentElement()); + Node publishedServiceInterfacesNode = getChildNode(regElement.getPublishedServiceInterfacesElement()); + addDiscoveredNodes(allServiceInterfaceNodes,queryParentNode,UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES); + addPublishedNodes(allServiceInterfaceNodes,publishedServiceInterfacesNode); + } + + public final void getPublishedBusinessNodes(Vector publishedBusinessNodes) + { + RegistryElement regElement = (RegistryElement)element_; + Node publishedBusinessesNode = getChildNode(regElement.getPublishedBusinessesElement()); + addPublishedNodes(publishedBusinessNodes,publishedBusinessesNode); + } + + public final void getPublishedServiceNodes(Vector publishedServiceNodes) + { + RegistryElement regElement = (RegistryElement)element_; + Node publishedServicesNode = getChildNode(regElement.getPublishedServicesElement()); + addPublishedNodes(publishedServiceNodes,publishedServicesNode); + } + + public final void getPublishedServiceInterfaceNodes(Vector publishedServiceInterfaceNodes) + { + RegistryElement regElement = (RegistryElement)element_; + Node publishedServiceInterfacesNode = getChildNode(regElement.getPublishedServiceInterfacesElement()); + addPublishedNodes(publishedServiceInterfaceNodes,publishedServiceInterfacesNode); + } + + public final void getDiscoveredNodes(Vector discoveredNodes,int queryItem) + { + RegistryElement regElement = (RegistryElement)element_; + Node queryParentNode = getChildNode(regElement.getQueryParentElement()); + addDiscoveredNodes(discoveredNodes,queryParentNode,queryItem); + } + + private final boolean hasQueryResults(Node queryParentNode,int queryType) + { + Vector queries = queryParentNode.getChildNodes(); + for (int i=0;i<queries.size();i++) + { + QueryNode queryNode = (QueryNode)queries.elementAt(i); + if (queryNode.getChildNodes().size() > 0) + { + QueryElement queryElement = (QueryElement)queryNode.getTreeElement(); + if (queryElement.getQueryType() == queryType) + return true; + } + } + return false; + } + + public final boolean hasBusiness() + { + RegistryElement regElement = (RegistryElement)element_; + Node publishedBusinessesNode = getChildNode(regElement.getPublishedBusinessesElement()); + if (publishedBusinessesNode.getChildNodes().size() > 0) + return true; + return hasQueryResults(getChildNode(regElement.getQueryParentElement()),UDDIActionInputs.QUERY_ITEM_BUSINESSES); + } + + public final boolean hasService() + { + RegistryElement regElement = (RegistryElement)element_; + Node publishedServicesNode = getChildNode(regElement.getPublishedServicesElement()); + if (publishedServicesNode.getChildNodes().size() > 0) + return true; + return hasQueryResults(getChildNode(regElement.getQueryParentElement()),UDDIActionInputs.QUERY_ITEM_SERVICES); + } + + public final boolean hasServiceInterface() + { + RegistryElement regElement = (RegistryElement)element_; + Node publishedServiceInterfacesNode = getChildNode(regElement.getPublishedServiceInterfacesElement()); + if (publishedServiceInterfacesNode.getChildNodes().size() > 0) + return true; + return hasQueryResults(getChildNode(regElement.getQueryParentElement()),UDDIActionInputs.QUERY_ITEM_SERVICE_INTERFACES); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ResultsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ResultsTool.java new file mode 100644 index 000000000..a6340d0f2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ResultsTool.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class ResultsTool extends FormTool +{ + private String formLink_; + + public ResultsTool(ToolManager toolManager,String alt) + { + super(toolManager,"images/details_enabled.gif","images/details_highlighted.gif",alt); + formLink_ = ProxyLoadPageAction.getActionLink("uddi/forms/ResultsForm.jsp"); + } + + public final void initDefaultProperties() + { + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public String getFormLink() + { + return formLink_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RootCategoryNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RootCategoryNode.java new file mode 100644 index 000000000..5726ee673 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/RootCategoryNode.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +public class RootCategoryNode extends Node +{ + public RootCategoryNode(TreeElement element,NodeManager nodeManager) + { + super(element,nodeManager,1,"images/root_main.gif"); + setVisibilityOfChildren(true); + } + + public final void createChildren() + { + Enumeration children = element_.getElements(UDDIModelConstants.REL_SUBCATEGORIES); + if (children != null) + { + while (children.hasMoreElements()) + { + CategoryElement categoryElement = (CategoryElement)children.nextElement(); + CategoryNode categoryNode = new CategoryNode(categoryElement,nodeManager_,nodeDepth_+1); + addChild(categoryNode); + categoryNode.createChildren(); + } + } + } + + // Root node: no need for toggle action. + protected final String getToggleNodeActionHref() + { + return null; + } + + // Text only node. + protected final String getLinkActionHref() + { + return null; + } + + protected final void initTools() + { + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceDetailsTool.java new file mode 100644 index 000000000..e714ac5d1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceDetailsTool.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import org.uddi4j.datatype.service.*; +import org.uddi4j.util.*; + +import java.util.*; + +public class ServiceDetailsTool extends DetailsTool +{ + public ServiceDetailsTool(ToolManager toolManager,String alt) + { + super(toolManager,alt,ProxyLoadPageAction.getActionLink("uddi/forms/ServiceDetailsForm.jsp")); + } + + public final void initDefaultProperties() + { + clearPropertyTable(); + Controller controller = toolManager_.getNode().getNodeManager().getController(); + ServiceElement serviceElement = (ServiceElement)(toolManager_.getNode().getTreeElement()); + BusinessService busService = serviceElement.getBusinessService(); + + setProperty(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,busService.getServiceKey()); + setProperty(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY,busService.getBusinessKey()); + + Vector nameVector = new Vector(); + copyIndexVector(busService.getNameVector(),nameVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_NAMES,nameVector); + + Vector descriptionVector = new Vector(); + copyIndexVector(busService.getDescriptionVector(),descriptionVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_DESCRIPTIONS,descriptionVector); + + CategoryBag catBag = busService.getCategoryBag(); + if (catBag != null) + { + Vector catVector = new Vector(); + copyIndexVector(catBag.getKeyedReferenceVector(),catVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_CATEGORIES,catVector); + } + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceInterfaceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceInterfaceDetailsTool.java new file mode 100644 index 000000000..5d4f1d970 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceInterfaceDetailsTool.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import org.uddi4j.datatype.tmodel.*; +import org.uddi4j.util.*; + +import java.util.*; + +public class ServiceInterfaceDetailsTool extends DetailsTool +{ + public ServiceInterfaceDetailsTool(ToolManager toolManager,String alt) + { + super(toolManager,alt,ProxyLoadPageAction.getActionLink("uddi/forms/ServiceInterfaceDetailsForm.jsp")); + } + + public final void initDefaultProperties() + { + clearPropertyTable(); + Controller controller = toolManager_.getNode().getNodeManager().getController(); + ServiceInterfaceElement siElement = (ServiceInterfaceElement)(toolManager_.getNode().getTreeElement()); + TModel tModel = siElement.getTModel(); + + setProperty(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_INTERFACE_KEY,tModel.getTModelKey()); + ListElement nameListElement = new ListElement(tModel.getNameString()); + nameListElement.setTargetViewToolInfo(-1,-1,0); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_NAME,nameListElement); + + Vector descriptionVector = new Vector(); + copyIndexVector(tModel.getDescriptionVector(),descriptionVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_DESCRIPTIONS,descriptionVector); + + IdentifierBag idBag = tModel.getIdentifierBag(); + if (idBag != null) + { + Vector idVector = new Vector(); + copyIndexVector(idBag.getKeyedReferenceVector(),idVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_IDENTIFIERS,idVector); + } + + CategoryBag catBag = tModel.getCategoryBag(); + if (catBag != null) + { + Vector catVector = new Vector(); + copyIndexVector(catBag.getKeyedReferenceVector(),catVector); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_CATEGORIES,catVector); + } + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceInterfaceNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceInterfaceNode.java new file mode 100644 index 000000000..bddcad28d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceInterfaceNode.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class ServiceInterfaceNode extends UDDINavigatorNode +{ + private DetailsTool detailsTool_; + private UnpublishTool unpublishTool_; + public ServiceInterfaceNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"uddi/images/service_interface_highlighted.gif"); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + UDDIPerspective uddiPerspective = controller.getUDDIPerspective(); + detailsTool_ = new ServiceInterfaceDetailsTool(toolManager_,uddiPerspective.getMessage("ALT_SERVICE_INTERFACE_DETAILS")); + new GetServicesTool(toolManager_,uddiPerspective.getMessage("ALT_GET_SERVICES"),ServiceInterfaceGetServicesAction.getActionLink(nodeId_)); + new GetBusinessesTool(toolManager_,"uddi/images/businesses_closed_enabled.gif","uddi/images/businesses_closed_highlighted.gif",uddiPerspective.getMessage("ALT_GET_BUSINESSES"),ServiceInterfaceGetBusinessesAction.getActionLink(nodeId_)); + new UDDIImportWSDLToWorkbenchTool(toolManager_,controller.getMessage("ALT_IMPORT_WSDL_TO_WORKBENCH")); + new UDDIImportWSDLToFileSystemTool(toolManager_,controller.getMessage("ALT_WSDL_IMPORT_TO_FS")); + new UDDILaunchWebServiceWizardTool(toolManager_,controller.getMessage("ALT_LAUNCH_WEB_SERVICE_WIZARD")); + new AddToFavoritesTool(toolManager_, uddiPerspective.getMessage("ALT_ADD_TO_FAVORITES")); + unpublishTool_ = new UnpublishTool(toolManager_,"uddi/images/unpublish_service_interface_enabled.gif","uddi/images/unpublish_service_interface_highlighted.gif",uddiPerspective.getMessage("ALT_UNPUBLISH_SERVICE_INTERFACE")); + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + detailsTool_.addAuthenticationProperties(regElement); + unpublishTool_.addAuthenticationProperties(regElement); + } + + public String getWSDLURLFromDetailsTool() + { + ListElement wsdlURLListElement = (ListElement)detailsTool_.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_INTERFACE_WSDL_URL); + if (wsdlURLListElement != null) + return (String)wsdlURLListElement.getObject(); + else + return "temp.wsdl"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceNode.java new file mode 100644 index 000000000..d732b078d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/ServiceNode.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class ServiceNode extends UDDINavigatorNode +{ + private DetailsTool detailsTool_; + private UnpublishTool unpublishTool_; + public ServiceNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"uddi/images/service_highlighted.gif"); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + UDDIPerspective uddiPerspective = controller.getUDDIPerspective(); + detailsTool_ = new ServiceDetailsTool(toolManager_,uddiPerspective.getMessage("ALT_SERVICE_DETAILS")); + new GetBusinessesTool(toolManager_,"uddi/images/business_enabled.gif","uddi/images/business_highlighted.gif",uddiPerspective.getMessage("ALT_GET_BUSINESS"),ServiceGetBusinessAction.getActionLink(nodeId_)); + new GetServiceInterfacesTool(toolManager_,uddiPerspective.getMessage("ALT_GET_SERVICE_INTERFACES"),ServiceGetServiceInterfacesAction.getActionLink(nodeId_)); + new UDDIImportWSDLToWorkbenchTool(toolManager_,controller.getMessage("ALT_IMPORT_WSDL_TO_WORKBENCH")); + new UDDIImportWSDLToFileSystemTool(toolManager_,controller.getMessage("ALT_WSDL_IMPORT_TO_FS")); + new UDDILaunchWebServiceWizardTool(toolManager_,controller.getMessage("ALT_LAUNCH_WEB_SERVICE_WIZARD")); + new UDDIAddToWSDLPerspectiveTool(toolManager_,uddiPerspective.getMessage("ALT_ADD_TO_WSDL_PERSPECTIVE")); + new AddToFavoritesTool(toolManager_,uddiPerspective.getMessage("ALT_ADD_TO_FAVORITES")); + unpublishTool_ = new UnpublishTool(toolManager_,"uddi/images/unpublish_service_enabled.gif","uddi/images/unpublish_service_highlighted.gif",uddiPerspective.getMessage("ALT_UNPUBLISH_SERVICE")); + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + detailsTool_.addAuthenticationProperties(regElement); + unpublishTool_.addAuthenticationProperties(regElement); + } + + public String getWSDLURLFromDetailsTool() + { + ListElement wsdlURLListElement = (ListElement)detailsTool_.getProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_SERVICE_WSDL_URL); + if (wsdlURLListElement != null) + return (String)wsdlURLListElement.getObject(); + else + return "temp.wsdl"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/SubQueryKeyProperty.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/SubQueryKeyProperty.java new file mode 100644 index 000000000..1c1154f26 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/SubQueryKeyProperty.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +public class SubQueryKeyProperty +{ + private String subQueryKey_; + + public SubQueryKeyProperty() + { + subQueryKey_ = ""; + } + + public final void setSubQueryKey(String subQueryKey) + { + subQueryKey_ = subQueryKey; + } + + public final String getSubQueryKey() + { + return subQueryKey_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/SubQueryTransferTarget.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/SubQueryTransferTarget.java new file mode 100644 index 000000000..74a8fac08 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/SubQueryTransferTarget.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.*; + +public class SubQueryTransferTarget +{ + private int nodeId_; + private int toolId_; + private int viewId_; + private int viewToolId_; + private String subQueryKey_; + private NodeManager nodeManager_; + Hashtable parentQueryData_; + + public SubQueryTransferTarget(Node node,String subQueryKey,Hashtable parentQueryData) + { + nodeId_ = node.getNodeId(); + toolId_ = node.getToolManager().getSelectedToolId(); + viewId_ = node.getViewId(); + viewToolId_ = node.getViewToolId(); + subQueryKey_ = subQueryKey; + nodeManager_ = node.getNodeManager(); + parentQueryData_ = parentQueryData; + } + + public final int getNodeId() + { + return nodeId_; + } + + public final int getToolId() + { + return toolId_; + } + + public final int getViewId() + { + return viewId_; + } + + public final int getViewToolId() + { + return viewToolId_; + } + + public final String getSubQueryKey() + { + return subQueryKey_; + } + + public final FormTool getTargetFormTool() + { + Node node = nodeManager_.getNode(nodeId_); + if (node == null) + return null; + + Tool tool = node.getToolManager().getTool(toolId_); + + if (viewId_ != ActionInputs.VIEWID_DEFAULT) + { + ViewTool viewTool = (ViewTool)tool; + ToolManager viewToolManager = viewTool.getToolManager(viewId_); + if (viewToolManager != null) + tool = viewToolManager.getTool(viewToolId_); + else + tool = null; + } + return (FormTool)tool; + } + + public final Hashtable getParentQueryData() + { + return parentQueryData_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIAddToWSDLPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIAddToWSDLPerspectiveTool.java new file mode 100644 index 000000000..d621f8e28 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIAddToWSDLPerspectiveTool.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class UDDIAddToWSDLPerspectiveTool extends AddToWSDLPerspectiveTool { + public UDDIAddToWSDLPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return UDDIAddToWSDLPerspectiveAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIImportWSDLToFileSystemTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIImportWSDLToFileSystemTool.java new file mode 100644 index 000000000..fe9f7f802 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIImportWSDLToFileSystemTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class UDDIImportWSDLToFileSystemTool extends ImportToFileSystemTool +{ + public UDDIImportWSDLToFileSystemTool(ToolManager toolManager,String alt) + { + super(toolManager,alt); + } + + public final String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public final String getActionLink() + { + Node node = toolManager_.getNode(); + return UDDIImportWSDLToFileSystemAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIImportWSDLToWorkbenchTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIImportWSDLToWorkbenchTool.java new file mode 100644 index 000000000..2752ad811 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIImportWSDLToWorkbenchTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class UDDIImportWSDLToWorkbenchTool extends ImportToWorkbenchTool +{ + public UDDIImportWSDLToWorkbenchTool(ToolManager toolManager,String alt) + { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public final String getFormLink() + { + return "uddi/forms/UDDIImportWSDLToWorkbenchForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDILaunchWebServiceWizardTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDILaunchWebServiceWizardTool.java new file mode 100644 index 000000000..ee99d18f4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDILaunchWebServiceWizardTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public class UDDILaunchWebServiceWizardTool extends LaunchWebServiceWizardTool +{ + public UDDILaunchWebServiceWizardTool(ToolManager toolManager,String alt) + { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public final String getFormLink() + { + return "uddi/forms/UDDILaunchWebServiceWizardForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIMainNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIMainNode.java new file mode 100644 index 000000000..a8773d3ee --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIMainNode.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +import java.util.*; + +// Root node for the UDDI Navigator Tree View +public class UDDIMainNode extends UDDINavigatorNode +{ + public UDDIMainNode(TreeElement element,NodeManager nodeManager) + { + super(element,nodeManager,1,"images/root_main.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(UDDIModelConstants.REL_REGISTRIES)) + { + RegistryElement registryElement = (RegistryElement)event.getParentElement(); + UDDIMainElement uddiMainElement = (UDDIMainElement)element_; + uddiMainElement.addRegistryName(registryElement.getName()); + createChildNode(registryElement); + } + } + + public void relRemoved(RelRemoveEvent event) + { + RegistryElement childElement = null; + if (event.getInBoundRelName().equals(UDDIModelConstants.REL_REGISTRIES)) + childElement = (RegistryElement)event.getInboundElement(); + else if (event.getOutBoundRelName().equals(UDDIModelConstants.REL_REGISTRIES)) + childElement = (RegistryElement)event.getOutBoundElement(); + + if (childElement != null) + { + UDDIMainElement uddiMainElement = (UDDIMainElement)element_; + uddiMainElement.removeRegistryName(childElement.getName()); + removeChildNode(childElement); + } + } + }); + } + + private final void createChildNode(TreeElement element) + { + RegistryElement regElement = (RegistryElement)element; + Enumeration userDefinedCategories = regElement.getUserDefinedCategories(); + String imagePath; + if (userDefinedCategories != null && userDefinedCategories.hasMoreElements()) + imagePath = RegistryNode.IMAGE_PATH_WITH_USER_DEFINED_CATEGORIES; + else + imagePath = RegistryNode.IMAGE_PATH_STANDARD; + + RegistryNode regNode = new RegistryNode(element,nodeManager_,nodeDepth_+1,imagePath); + addChild(regNode); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + UDDIPerspective uddiPerspective = controller.getUDDIPerspective(); + new OpenRegistryTool(toolManager_,uddiPerspective.getMessage("ALT_OPEN_REGISTRY")); + } + + // Given a node under a particular registry node, obtain the registry node. + public final RegistryNode getRegistryNode(Node currentNode) + { + RegistryNode regNode = null; + if (currentNode instanceof RegistryNode) + { + regNode = (RegistryNode)currentNode; + } + else if (currentNode instanceof QueryNode) + { + // Query -> Query folder -> Registry + regNode = (RegistryNode)(currentNode.getParent().getParent()); + } + else if (currentNode instanceof QueryParentNode || currentNode instanceof PublishedItemsNode) + { + // Query folder -> Registry + regNode = (RegistryNode)(currentNode.getParent()); + } + else if (currentNode instanceof BusinessNode || currentNode instanceof ServiceNode || currentNode instanceof ServiceInterfaceNode) + { + // itemNode -> Published Items folder -> Registry + // OR: + // itemNode -> QueryNode -> Query folder -> Registry + Node parentNode = currentNode.getParent(); + if (parentNode instanceof QueryNode) + regNode = (RegistryNode)(parentNode.getParent().getParent()); + else + regNode = (RegistryNode)parentNode.getParent(); + } + return regNode; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDINavigatorFolderNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDINavigatorFolderNode.java new file mode 100644 index 000000000..63f6a2bd8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDINavigatorFolderNode.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; + +public abstract class UDDINavigatorFolderNode extends FolderNode +{ + public UDDINavigatorFolderNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth); + } + + // uddi/actions/ToggleNavigatorNodeAction.jsp?nodeId=... + public final String getToggleNodeActionHref() + { + return ToggleNavigatorNodeAction.getActionLink(nodeId_,isOpen_); + } + + // uddi/actions/SelectNavigatorNodeAction.jsp?nodeId=... + public final String getLinkActionHref() + { + return SelectNavigatorNodeAction.getActionLink(nodeId_,false); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDINavigatorNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDINavigatorNode.java new file mode 100644 index 000000000..2490287f7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDINavigatorNode.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public abstract class UDDINavigatorNode extends Node +{ + public UDDINavigatorNode(TreeElement element,NodeManager nodeManager,int nodeDepth,String imagePath) + { + super(element,nodeManager,nodeDepth,imagePath); + } + + // uddi/actions/ToggleNavigatorNodeAction.jsp?nodeId=... + public final String getToggleNodeActionHref() + { + return ToggleNavigatorNodeAction.getActionLink(nodeId_,isOpen_); + } + + // uddi/actions/SelectNavigatorNodeAction.jsp?nodeId=... + public final String getLinkActionHref() + { + return SelectNavigatorNodeAction.getActionLink(nodeId_,false); + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIPerspective.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIPerspective.java new file mode 100644 index 000000000..222189502 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UDDIPerspective.java @@ -0,0 +1,506 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Properties; +import java.util.Vector; + +import javax.servlet.ServletContext; + +import org.eclipse.wst.ws.internal.datamodel.BasicModel; +import org.eclipse.wst.ws.internal.datamodel.Model; +import org.eclipse.wst.ws.internal.explorer.favorites.FavoritesRegistryTypeDefault; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.actions.AddRegistryToUDDIPerspectiveAction; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesMainElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesUDDIRegistryElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesUDDIRegistryFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Perspective; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.OpenRegistryAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.RegFindServiceUUIDAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.SwitchPerspectiveFromUDDIAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.CategoryModel; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.RegistryElement; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.UDDIMainElement; +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.util.Validator; +import org.eclipse.wst.ws.internal.parser.favorites.IFavoritesUDDIRegistry; +import org.uddi4j.datatype.tmodel.TModel; + +public class UDDIPerspective extends Perspective +{ + private Hashtable knownRegistries_; + private IFavoritesUDDIRegistry ibmPublicUDDITestRegistry_; + private Model navigatorModel_; + private NodeManager navigatorManager_; + private int wsdlType_; + private Hashtable categoryManagers_; + String categoryTModelKey_; + + // Window sizes + private String perspectiveContentFramesetCols_; + private String savedPerspectiveContentFramesetCols_; + private String actionsContainerFramesetRows_; + private String savedActionsContainerFramesetRows_; + + private final String IBM_TEST_REG_INQUIRY_URL = "http://uddi.ibm.com/testregistry/inquiryapi"; + private final String IBM_TEST_REG_PUBLISH_URL = "https://uddi.ibm.com/testregistry/publishapi"; + + public UDDIPerspective(Controller controller) + { + super("uddi",controller); + } + + public final void initPerspective(ServletContext application) + { + String defaultFavorites = controller_.getDefaultFavoritesLocation(); + FavoritesRegistryTypeDefault favRegTypeDefault = new FavoritesRegistryTypeDefault(defaultFavorites); + IFavoritesUDDIRegistry[] favRegistriesDefault = favRegTypeDefault.getFavoritesUDDIRegistries(); + knownRegistries_ = new Hashtable(); + for (int i=0;i<favRegistriesDefault.length;i++) + { + if (favRegistriesDefault[i].getInquiryURL().equals(IBM_TEST_REG_INQUIRY_URL) && favRegistriesDefault[i].getPublishURL().equals(IBM_TEST_REG_PUBLISH_URL)) + ibmPublicUDDITestRegistry_ = favRegistriesDefault[i]; + knownRegistries_.put(favRegistriesDefault[i].getInquiryURL(),favRegistriesDefault[i]); + } + if (ibmPublicUDDITestRegistry_ == null && favRegistriesDefault.length > 0) + ibmPublicUDDITestRegistry_ = favRegistriesDefault[0]; + + navigatorModel_ = new BasicModel("uddiModel"); + UDDIMainElement uddiMainElement = new UDDIMainElement(getMessage("NODE_NAME_UDDI_MAIN"),navigatorModel_); + navigatorModel_.setRootElement(uddiMainElement); + navigatorManager_ = new NodeManager(controller_); + UDDIMainNode uddiMainNode = new UDDIMainNode(uddiMainElement,navigatorManager_); + navigatorManager_.setRootNode(uddiMainNode); + + wsdlType_ = UDDIActionInputs.WSDL_TYPE_SERVICE_INTERFACE; + categoryManagers_ = new Hashtable(); + + // Initialize the default category models. + if (application.getAttribute("commonCategoryModels") == null) + { + synchronized (application) + { + if (application.getAttribute("commonCategoryModels") == null) + { + Hashtable commonCategoryModels = new Hashtable(); + + CategoryModel naicsModel = new CategoryModel(); + naicsModel.setServletContext(application); + naicsModel.setDefaultDataFile("/uddi/data/naics-data.txt"); + naicsModel.setDisplayName(getMessage("FORM_OPTION_CATEGORY_NAICS")); + naicsModel.setTModelKey(TModel.NAICS_TMODEL_KEY); + commonCategoryModels.put(TModel.NAICS_TMODEL_KEY,naicsModel); + + CategoryModel unspscModel = new CategoryModel(); + unspscModel.setServletContext(application); + unspscModel.setDefaultDataFile("/uddi/data/unspsc-data.txt"); + unspscModel.setDisplayName(getMessage("FORM_OPTION_CATEGORY_UNSPSC_73")); + unspscModel.setTModelKey(TModel.UNSPSC_73_TMODEL_KEY); + commonCategoryModels.put(TModel.UNSPSC_73_TMODEL_KEY,unspscModel); + + CategoryModel geoModel = new CategoryModel(); + geoModel.setServletContext(application); + geoModel.setDefaultDataFile("/uddi/data/geo-data.txt"); + geoModel.setDisplayName(getMessage("FORM_OPTION_CATEGORY_GEO")); + geoModel.setTModelKey(TModel.ISO_CH_TMODEL_KEY); + commonCategoryModels.put(TModel.ISO_CH_TMODEL_KEY,geoModel); + + CategoryModel dWCommunityModel = new CategoryModel(); + dWCommunityModel.setServletContext(application); + dWCommunityModel.setDefaultDataFile("/uddi/data/dWCommunity-data.txt"); + dWCommunityModel.setDisplayName(getMessage("FORM_OPTION_CATEGORY_DWCOMMUNITY")); + dWCommunityModel.setTModelKey("UUID:8F497C50-EB05-11D6-B618-000629DC0A53"); + commonCategoryModels.put("UUID:8F497C50-EB05-11D6-B618-000629DC0A53",dWCommunityModel); + + application.setAttribute("commonCategoryModels",commonCategoryModels); + } + } + } + categoryTModelKey_ = null; + + // Starting frameset sizes. + perspectiveContentFramesetCols_ = "30%,*"; + savedPerspectiveContentFramesetCols_ = perspectiveContentFramesetCols_; + actionsContainerFramesetRows_ = "75%,*"; + savedActionsContainerFramesetRows_ = actionsContainerFramesetRows_; + } + + public final Hashtable getKnownRegistries() + { + // We must always query the favorites to see if additional registries were added over time. This property cannot be cached. + FavoritesMainElement favMainElement = (FavoritesMainElement)(controller_.getFavoritesPerspective().getNodeManager().getRootNode().getTreeElement()); + FavoritesUDDIRegistryFolderElement favRegFolderElement = favMainElement.getFavoritesUDDIRegistryFolderElement(); + Enumeration e = favRegFolderElement.getAllFavorites(); + while (e.hasMoreElements()) + { + FavoritesUDDIRegistryElement favRegElement = (FavoritesUDDIRegistryElement)e.nextElement(); + String inquiryURL = favRegElement.getInquiryURL(); + if (knownRegistries_.get(inquiryURL) == null) + knownRegistries_.put(inquiryURL,favRegElement.getIFavoritesUDDIRegistryInterface()); + } + return knownRegistries_; + } + + public final String getKnownRegistryPublishURL(String inquiryURL) + { + IFavoritesUDDIRegistry knownRegistry = (IFavoritesUDDIRegistry)getKnownRegistries().get(inquiryURL); + if (knownRegistry != null) + { + String publishURL = knownRegistry.getPublishURL(); + if (Validator.validateURL(publishURL)) + return publishURL; + } + return null; + } + + public final String getKnownRegistryRegistrationURL(String inquiryURL) + { + IFavoritesUDDIRegistry knownRegistry = (IFavoritesUDDIRegistry)getKnownRegistries().get(inquiryURL); + if (knownRegistry != null) + { + String registrationURL = knownRegistry.getRegistrationURL(); + if (Validator.validateURL(registrationURL)) + return registrationURL; + } + return null; + } + + public final IFavoritesUDDIRegistry getIBMPublicUDDITestRegistry() + { + return ibmPublicUDDITestRegistry_; + } + + public final void preloadUDDIRegistries(String[] inquiryURLs, String[] publishURLs) + { + if (inquiryURLs != null) + { + Hashtable knownRegistries = getKnownRegistries(); + StringBuffer directoryBuffer = new StringBuffer(); + for (int i = 0; i < inquiryURLs.length; i++) + { + String inquiryURL = URLUtils.decode(inquiryURLs[i]); + String publishURL = null; + String regName = null; + String registrationURL = null; + // continue to the next registry if inquiryURL does not exist + if (!Validator.validateURL(inquiryURL)) + continue; + // populate and run an OpenRegistryAction + OpenRegistryAction action = new OpenRegistryAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + IFavoritesUDDIRegistry knownRegistry = (IFavoritesUDDIRegistry)knownRegistries.get(inquiryURL); + boolean checkForUserDefinedCategories = false; + File directoryFile = null; + if (knownRegistry != null) + { + publishURL = knownRegistry.getPublishURL(); + regName = knownRegistry.getName(); + registrationURL = knownRegistry.getRegistrationURL(); + directoryBuffer.setLength(0); + FavoritesUDDIRegistryFolderElement.formCategoriesDirectory(directoryBuffer,controller_.getServletEngineStateLocation(),regName); + directoryFile = new File(directoryBuffer.toString()); + if (directoryFile.exists() && directoryFile.listFiles().length > 0) + checkForUserDefinedCategories = true; + } + if (regName == null) + regName = inquiryURL; + if (publishURL == null && publishURLs != null && i < publishURLs.length && publishURLs[i] != null) { + publishURL = URLUtils.decode(publishURLs[i]); + } + // populate the action + propertyTable.put(UDDIActionInputs.INQUIRY_URL, inquiryURL); + propertyTable.put(UDDIActionInputs.REGISTRY_NAME, regName); + if (Validator.validateURL(publishURL)) + propertyTable.put(UDDIActionInputs.PUBLISH_URL, publishURL); + if (Validator.validateURL(registrationURL)) + propertyTable.put(UDDIActionInputs.REGISTRATION_URL, registrationURL); + + // Check if private registry category information is available for this registry. + directoryBuffer.setLength(0); + String encodedInquiryURL = URLUtils.encode(inquiryURL); + directoryBuffer.append(controller_.getServletEngineStateLocation()).append(encodedInquiryURL).append(".properties"); + directoryFile = new File(directoryBuffer.toString()); + if (directoryFile.exists()) + { + try + { + Properties p = new Properties(); + FileInputStream fin = new FileInputStream(directoryFile); + p.load(fin); + fin.close(); + directoryFile.delete(); + String dataDirectory = p.getProperty(UDDIActionInputs.CATEGORIES_DIRECTORY); + if (dataDirectory != null) + propertyTable.put(UDDIActionInputs.CATEGORIES_DIRECTORY,dataDirectory); + checkForUserDefinedCategories = true; + } + catch (IOException e) + { + checkForUserDefinedCategories = false; + } + } + + if (checkForUserDefinedCategories) + propertyTable.put(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES,Boolean.TRUE); + else + propertyTable.remove(UDDIActionInputs.CHECK_USER_DEFINED_CATEGORIES); + + // run the action + action.run(); + + RegistryElement regElement = (RegistryElement)(navigatorManager_.getSelectedNode().getTreeElement()); + Enumeration userDefinedCategories = regElement.getUserDefinedCategories(); + if (userDefinedCategories != null && userDefinedCategories.hasMoreElements()) + { + AddRegistryToUDDIPerspectiveAction action2 = new AddRegistryToUDDIPerspectiveAction(controller_); + String categoriesDirectory = regElement.getCategoriesDirectory(); + if (categoriesDirectory != null) + action2.linkCategoryModelsWithSavedData(userDefinedCategories,categoriesDirectory); + else + action2.linkCategoryModelsWithSavedData(regElement.getName(),userDefinedCategories); + } + } + if (inquiryURLs.length > 0) + controller_.setCurrentPerspective(ActionInputs.PERSPECTIVE_UDDI); + } + } + + // Preconditions: + // serviceNames and serviceKeys have length >= 1. + // regNode != null + private final void preloadServicesForRegistry(RegistryNode regNode,String[] serviceNames,String[] serviceKeys) + { + int regNodeId = regNode.getNodeId(); + for (int i=0;i<serviceKeys.length;i++) + { + navigatorManager_.setSelectedNodeId(regNodeId); + RegFindServiceUUIDAction action = new RegFindServiceUUIDAction(controller_); + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_NAME,serviceNames[i]); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY,serviceKeys[i]); + action.run(); + navigatorManager_.makeSelectedNodeVisible(); + } + } + + public final void preloadServices(String[] inquiryURLs,String[] serviceNames,String[] serviceKeys) + { + // The algorithm will search for each service key in each inquiry URL. + if (serviceKeys != null && serviceNames != null && serviceNames.length == serviceKeys.length) + { + for (int i=0;i<serviceKeys.length;i++) + { + if (inquiryURLs != null) + { + // Eliminate duplicate inquiry URLs. + Hashtable inquiryURLsHash = new Hashtable(); + for (int j=0;j<inquiryURLs.length;j++) + inquiryURLsHash.put(inquiryURLs[j],Boolean.TRUE); + // Loop through all the available registries and use them if possible. + Node uddiMainNode = navigatorManager_.getRootNode(); + Vector registryNodes = uddiMainNode.getChildNodes(); + for (int k=0;k<registryNodes.size();k++) + { + RegistryNode regNode = (RegistryNode)registryNodes.elementAt(k); + RegistryElement regElement = (RegistryElement)regNode.getTreeElement(); + String existingRegistryInquiryURL = regElement.getInquiryURL(); + if (inquiryURLsHash.get(existingRegistryInquiryURL) != null) + { + preloadServicesForRegistry(regNode,serviceNames,serviceKeys); + inquiryURLsHash.remove(existingRegistryInquiryURL); + } + } + Enumeration inquiryURLsEnum = inquiryURLsHash.keys(); + while (inquiryURLsEnum.hasMoreElements()) + { + String inquiryURL = (String)inquiryURLsEnum.nextElement(); + preloadUDDIRegistries(new String[] {inquiryURL},null); + RegistryNode regNode = (RegistryNode)navigatorManager_.getSelectedNode(); + preloadServicesForRegistry(regNode,serviceNames,serviceKeys); + } + } + } + } + } + + public final void setCategoryTModelKey(String categoryTModelKey) + { + categoryTModelKey_ = categoryTModelKey; + } + + public final String getCategoryTModelKey() + { + return categoryTModelKey_; + } + + private final void initCategoryBrowser(CategoryModel categoryModel,NodeManager nodeManager) + { + TreeElement categoryRootElement = (TreeElement)categoryModel.getRootElement(); + RootCategoryNode rootCategoryNode = new RootCategoryNode(categoryRootElement,nodeManager); + nodeManager.setRootNode(rootCategoryNode); + rootCategoryNode.createChildren(); + } + + public final NodeManager getCategoryManager() + { + return (NodeManager)categoryManagers_.get(categoryTModelKey_); + } + + public final NodeManager getCategoryManager(CategoryModel categoryModel) + { + String tModelKey = categoryModel.getTModelKey(); + NodeManager categoryManager = (NodeManager)categoryManagers_.get(tModelKey); + if (categoryManager == null) + { + categoryManager = new NodeManager(controller_); + initCategoryBrowser(categoryModel,categoryManager); + categoryManagers_.put(tModelKey,categoryManager); + } + return categoryManager; + } + + public final NodeManager getNavigatorManager() + { + return navigatorManager_; + } + + public final NodeManager getNodeManager() + { + return getNavigatorManager(); + } + + public final void setWSDLType(int wsdlType) + { + wsdlType_ = wsdlType; + } + + public final int getWSDLType() + { + return wsdlType_; + } + + public final String getPerspectiveContentPage() + { + return "uddi/uddi_perspective_content.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_UDDI; + } + + public final String getFramesetsFile() + { + return "uddi/scripts/uddiframesets.jsp"; + } + + public final String getProcessFramesetsForm() + { + return "uddi/forms/ProcessUDDIFramesetsForm.jsp"; + } + + public final String getPanesFile() + { + return "uddi/scripts/uddipanes.jsp"; + } + + public final String getTreeContentVar() + { + return "navigatorContent"; + } + + public final String getTreeContentPage() + { + return "uddi/navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "propertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "uddi/properties_container.jsp"; + } + + public final String getStatusContentVar() + { + return "statusContent"; + } + + public final String getStatusContentPage() + { + return "uddi/status_content.jsp"; + } + + public final String getSavePerspectiveActionLink() + { + //return SaveUDDIPerspectiveAction.getActionLink(); + return ""; + } + + public final String getPerspectiveContentFramesetCols() + { + return perspectiveContentFramesetCols_; + } + + public final void setPerspectiveContentFramesetCols(String cols) + { + perspectiveContentFramesetCols_ = cols; + } + + public final void setSavedPerspectiveContentFramesetCols(String cols) + { + savedPerspectiveContentFramesetCols_ = cols; + } + + public final String getSavedPerspectiveContentFramesetCols() + { + return savedPerspectiveContentFramesetCols_; + } + + public final String getActionsContainerFramesetRows() + { + return actionsContainerFramesetRows_; + } + + public final void setActionsContainerFramesetRows(String rows) + { + actionsContainerFramesetRows_ = rows; + } + + public final void setSavedActionsContainerFramesetRows(String rows) + { + savedActionsContainerFramesetRows_ = rows; + } + + public final String getSavedActionsContainerFramesetRows() + { + return savedActionsContainerFramesetRows_; + } + + public final String getSwitchPerspectiveFormActionLink(int targetPerspectiveId,boolean forHistory) + { + return SwitchPerspectiveFromUDDIAction.getFormActionLink(targetPerspectiveId,forHistory); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UnpublishTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UnpublishTool.java new file mode 100644 index 000000000..a0dd6ae3e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/perspective/UnpublishTool.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.*; + +public class UnpublishTool extends FormTool +{ + public UnpublishTool(ToolManager toolManager, String enableImage, String highlightImage, String alt) + { + super(toolManager, enableImage, highlightImage, alt); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node node = toolManager_.getNode(); + return SelectPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public void addAuthenticationProperties(RegistryElement regElement) + { + String publishURL = regElement.getPublishURL(); + String userId = regElement.getUserId(); + String password = regElement.getCred(); + + if (publishURL == null) + publishURL = ""; + if (userId == null) + userId = ""; + if (password == null) + password = ""; + + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PUBLISH_URL,publishURL); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_USERID,userId); + setProperty(UDDIActionInputs.QUERY_INPUT_ADVANCED_PASSWORD,password); + } + + public String getFormLink() + { + return "uddi/forms/UnpublishForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/util/Uddi4jHelper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/util/Uddi4jHelper.java new file mode 100644 index 000000000..5dfca9ebe --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/uddi/util/Uddi4jHelper.java @@ -0,0 +1,398 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.uddi.util; + +import java.util.Hashtable; +import java.util.Vector; +import java.util.List; +import java.util.Iterator; +import javax.wsdl.Definition; +import javax.wsdl.Service; +import javax.wsdl.Port; +import javax.wsdl.Binding; +import javax.wsdl.PortType; +import javax.wsdl.Message; +import javax.wsdl.Import; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.http.HTTPAddress; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.CharacterData; +import org.uddi4j.UDDIException; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.binding.AccessPoint; +import org.uddi4j.datatype.binding.BindingTemplate; +import org.uddi4j.datatype.binding.BindingTemplates; +import org.uddi4j.datatype.binding.InstanceDetails; +import org.uddi4j.datatype.binding.TModelInstanceDetails; +import org.uddi4j.datatype.binding.TModelInstanceInfo; +import org.uddi4j.datatype.service.BusinessService; +import org.uddi4j.datatype.tmodel.TModel; +import org.uddi4j.datatype.OverviewDoc; +import org.uddi4j.datatype.OverviewURL; +import org.uddi4j.response.TModelDetail; +import org.uddi4j.transport.TransportException; +import org.uddi4j.util.CategoryBag; +import org.uddi4j.util.KeyedReference; + +import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt; + +public class Uddi4jHelper +{ + public final KeyedReference getWSDLKeyedReference() + { + KeyedReference keyRef = new KeyedReference("types", "wsdlSpec"); + keyRef.setTModelKey("UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4"); + return keyRef; + } + + public final TModel newTModel(String wsdlUrl) throws WSDLException + { + return newTModel(wsdlUrl, getWSDLDefinition(wsdlUrl)); + } + + public final TModel newTModel(String wsdlUrl, Definition def) throws WSDLException + { + TModel tModel = new TModel(); + tModel.setTModelKey(""); + tModel.setName(def.getTargetNamespace()); + tModel.setDefaultDescriptionString(""); + OverviewDoc overviewDoc = new OverviewDoc(); + overviewDoc.setOverviewURL(wsdlUrl); + tModel.setOverviewDoc(overviewDoc); + CategoryBag catBag = new CategoryBag(); + Vector keyRefVector = new Vector(); + keyRefVector.add(getWSDLKeyedReference()); + catBag.setKeyedReferenceVector(keyRefVector); + tModel.setCategoryBag(catBag); + return tModel; + } + + public final BusinessService newBusinessService(String wsdlUrl, Hashtable tModelsTable) throws WSDLException + { + return newBusinessService(wsdlUrl, getWSDLDefinition(wsdlUrl), tModelsTable); + } + + public final BusinessService newBusinessService(String wsdlUrl, Definition def, Hashtable tModelsTable) throws WSDLException + { + BusinessService bs = new BusinessService(); + bs.setServiceKey(""); + BindingTemplates bindingTemplates = new BindingTemplates(); + Vector bindingTemplateVector = new Vector(); + Service[] services = (Service[])def.getServices().values().toArray(new Service[0]); + if (services.length > 0) + { + Port[] ports = (Port[])services[0].getPorts().values().toArray(new Port[0]); + for (int i = 0; i < ports.length; i++) + { + TModelInstanceDetails tModelDetails = new TModelInstanceDetails(); + Vector tModelInfoVector = new Vector(); + TModel tModel = (TModel)tModelsTable.get(ports[i].getBinding().getPortType().getQName().getNamespaceURI()); + tModelInfoVector.add(createTModelInstanceInfo(wsdlUrl, ports[i], tModel.getTModelKey())); + tModelDetails.setTModelInstanceInfoVector(tModelInfoVector); + BindingTemplate bindingTemplate = new BindingTemplate(); + bindingTemplate.setDefaultDescriptionString(createDescription(ports[i])); + bindingTemplate.setAccessPoint(createAccessPoint(ports[i])); + bindingTemplate.setTModelInstanceDetails(tModelDetails); + bindingTemplate.setBindingKey(""); + bindingTemplateVector.add(bindingTemplate); + } + } + bindingTemplates.setBindingTemplateVector(bindingTemplateVector); + bs.setBindingTemplates(bindingTemplates); + return bs; + } + + public final BusinessService newBusinessService(String wsdlUrl, Definition def, TModel[] tModels) throws WSDLException + { + BusinessService bs = new BusinessService(); + bs.setServiceKey(""); + BindingTemplates bindingTemplates = new BindingTemplates(); + Vector bindingTemplateVector = new Vector(); + Service[] services = (Service[])def.getServices().values().toArray(new Service[0]); + if (services.length > 0) + { + Port[] ports = (Port[])services[0].getPorts().values().toArray(new Port[0]); + for (int i = 0; i < ports.length; i++) + { + for (int j = 0; j < tModels.length; j++) + { + TModelInstanceDetails tModelDetails = new TModelInstanceDetails(); + Vector tModelInfoVector = new Vector(); + tModelInfoVector.add(createTModelInstanceInfo(wsdlUrl, ports[i], tModels[j].getTModelKey())); + tModelDetails.setTModelInstanceInfoVector(tModelInfoVector); + BindingTemplate bindingTemplate = new BindingTemplate(); + bindingTemplate.setDefaultDescriptionString(createDescription(ports[i])); + bindingTemplate.setAccessPoint(createAccessPoint(ports[i])); + bindingTemplate.setTModelInstanceDetails(tModelDetails); + bindingTemplate.setBindingKey(""); + bindingTemplateVector.add(bindingTemplate); + } + } + } + bindingTemplates.setBindingTemplateVector(bindingTemplateVector); + bs.setBindingTemplates(bindingTemplates); + return bs; + } + + public Definition getWSDLDefinition(String wsdlUrl) throws WSDLException + { + try + { + WebServicesParserExt parser = new WebServicesParserExt(); + String proxySet = System.getProperty("http.proxySet"); + if (proxySet != null && proxySet.equals("true")) + { + parser.setHTTPBasicAuthUsername(System.getProperty("http.proxyUserName")); + parser.setHTTPBasicAuthPassword(System.getProperty("http.proxyPassword")); + } + return parser.getWSDLDefinitionVerbose(wsdlUrl); + } + catch (Exception e) + { + throw new WSDLException(WSDLException.PARSER_ERROR, e.getMessage(), e); + } + } + + private final String createDescription(Port port) + { + String desc = null; + Element e = port.getDocumentationElement(); + if (e != null) + { + Node node = e.getFirstChild(); + StringBuffer sb = new StringBuffer(); + while (node != null) + { + switch (node.getNodeType()) + { + case Node.TEXT_NODE: + case Node.CDATA_SECTION_NODE: + sb.append(((CharacterData)node).getData()); + default: + node = node.getNextSibling(); + break; + } + } + desc = sb.toString(); + } + return desc; + } + + private final TModelInstanceInfo createTModelInstanceInfo(String wsdlUrl, Port port, String tModelKey) + { + InstanceDetails details = new InstanceDetails(); + OverviewDoc overviewDoc = new OverviewDoc(); + TModelInstanceInfo tModelInfo = new TModelInstanceInfo(); + StringBuffer overviewURLString = new StringBuffer(wsdlUrl); + String portName = port.getName(); + if (portName != null) + { + overviewURLString.append("#"); + overviewURLString.append(portName); + } + overviewDoc.setOverviewURL(new OverviewURL(overviewURLString.toString())); + details.setOverviewDoc(overviewDoc); + tModelInfo.setInstanceDetails(details); + if (tModelKey != null) + tModelInfo.setTModelKey(tModelKey); + return tModelInfo; + } + + private final AccessPoint createAccessPoint(Port port) + { + AccessPoint accessPoint = null; + List list = port.getExtensibilityElements(); + for (int j = 0; j < list.size(); j++) + { + ExtensibilityElement extElement = (ExtensibilityElement)list.get(j); + if (extElement instanceof SOAPAddress) + { + String locationURI = ((SOAPAddress)extElement).getLocationURI(); + accessPoint = new AccessPoint(locationURI, getURLType(locationURI)); + break; + } + else if (extElement instanceof HTTPAddress) + { + String locationURI = ((HTTPAddress)extElement).getLocationURI(); + accessPoint = new AccessPoint(locationURI, getURLType(locationURI)); + break; + } + } + return accessPoint; + } + + private final String URL_TYPE_OTHER = "other"; + private final String URL_TYPES = "http https mail ftp fax phone other"; + + private final String getURLType(String url) + { + int i = url.indexOf(":"); + String type; + if (i == -1) + type = URL_TYPE_OTHER; + else + { + type = url.substring(0, i); + if (type.equals("") || URL_TYPES.indexOf(type) == -1) + type = URL_TYPE_OTHER; + } + return type; + } + + public boolean isMonolithicWSDL(Definition def) + { + return hasMessage(def) && hasPortType(def) && hasBinding(def) && hasService(def); + } + + public boolean isServiceImplement(Definition def) + { + return hasImport(def) && hasService(def); + } + + public boolean isServiceInterface(Definition def) + { + return hasMessage(def) && hasPortType(def) && hasBinding(def); + } + + public boolean isServiceInterfaceWithBindingsOnly(Definition def) + { + return !hasService(def) && hasBinding(def); + } + + private boolean hasMessage(Definition def) + { + for(Iterator it = def.getMessages().values().iterator(); it.hasNext();) + if (!((Message)it.next()).isUndefined()) + return true; + return false; + } + + private boolean hasPortType(Definition def) + { + for(Iterator it = def.getPortTypes().values().iterator(); it.hasNext();) + if (!((PortType)it.next()).isUndefined()) + return true; + return false; + } + + private boolean hasBinding(Definition def) + { + for(Iterator it = def.getBindings().values().iterator(); it.hasNext();) + if (!((Binding)it.next()).isUndefined()) + return true; + return false; + } + + private boolean hasService(Definition def) + { + return !def.getServices().isEmpty(); + } + + private boolean hasImport(Definition def) + { + return !def.getImports().isEmpty(); + } + + public String[] getImports(Definition def, String wsdlUrl) + { + Import[] imports = (Import [])def.getImports().values().toArray(new Import[0]); + String[] importStrings = new String[imports.length]; + String s; + if (wsdlUrl != null && wsdlUrl.indexOf('/') != -1) + s = wsdlUrl.substring(0, wsdlUrl.lastIndexOf('/')+1); + else + s = ""; + for (int i = 0; i < importStrings.length; i++) + { + StringBuffer sb = new StringBuffer(); + String locationURI = imports[i].getLocationURI(); + if (locationURI.indexOf(':') != -1) + sb.append(locationURI); + else + sb.append(s).append(locationURI); + importStrings[i] = sb.toString(); + } + return importStrings; + } + + public String getWSDL(BusinessService bs, UDDIProxy proxy) + { + Vector bindingTemplateVector = bs.getBindingTemplates().getBindingTemplateVector(); + if (bindingTemplateVector.size() > 0) + { + BindingTemplate bt = (BindingTemplate)bindingTemplateVector.get(0); + TModelInstanceDetails tModelDetails = bt.getTModelInstanceDetails(); + if (tModelDetails != null) + { + Vector tModelInfoVector = tModelDetails.getTModelInstanceInfoVector(); + if (tModelInfoVector.size() > 0) + { + TModelInstanceInfo tModelInfo = (TModelInstanceInfo)tModelInfoVector.get(0); + InstanceDetails details = tModelInfo.getInstanceDetails(); + if (details != null) + { + OverviewDoc overviewDoc = details.getOverviewDoc(); + if (overviewDoc != null) + return parse(overviewDoc.getOverviewURLString()); + } + else if (proxy != null) + { + String tModelKey = tModelInfo.getTModelKey(); + if (tModelKey != null) + { + try + { + TModelDetail t = proxy.get_tModelDetail(tModelKey); + if (t != null) + { + Vector tModelVector = t.getTModelVector(); + if (tModelVector != null && tModelVector.size() > 0) + return getWSDL((TModel)tModelVector.get(0)); + } + } + catch (UDDIException uddie) + { + } + catch (TransportException te) + { + } + } + } + } + } + } + return null; + } + + public String getWSDL(TModel tModel) + { + OverviewDoc overviewDoc = tModel.getOverviewDoc(); + if (overviewDoc != null) + return parse(overviewDoc.getOverviewURLString()); + else + return null; + } + + private String parse(String s) + { + if (s != null && s.length() > 0) + { + int index = s.indexOf('#'); + if (index != -1) + return s.substring(0, index); + } + return s; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/CharArrayWrapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/CharArrayWrapper.java new file mode 100644 index 000000000..ff74f6717 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/CharArrayWrapper.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import javax.servlet.http.*; + +import java.io.*; + +public class CharArrayWrapper extends HttpServletResponseWrapper +{ + private CharArrayWriter charArrayWriter_; + + public CharArrayWrapper(HttpServletResponse response) + { + super(response); + charArrayWriter_ = new CharArrayWriter(); + } + + public PrintWriter getWriter() + { + return new PrintWriter(charArrayWriter_); + } + + public String toString() + { + return charArrayWriter_.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/HTMLUtils.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/HTMLUtils.java new file mode 100644 index 000000000..e2af06ba3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/HTMLUtils.java @@ -0,0 +1,185 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import javax.servlet.http.*; +import java.util.*; + +public final class HTMLUtils +{ + public static final String UTF8_ENCODING = "UTF-8"; + public static final String LINE_BREAK = "<br>"; + public static final String LINE_SEPARATOR = System.getProperties().getProperty("line.separator"); + + /** + * Get the HTML tag for an image. + * @return String The HTML tag for this image. + * @param HttpServletResponse To encode the src attribute. + * @param String src attribute defining the path to the image file. This must include the context path. + * @param String Optional alt text to be displayed with the image. Set this to null to disable the attribute. + * @param String Optional width of the rendered image. Set this to null to disable the attribute. + * @param String Optional height of the rendered imag. Set this to null to disable the attribute. + * @param Hashtable Optional key-value pairs of additional strings to be added as-is to the tag. Set this to null to disable. + * @return String The image tag. + */ + public static final String getHTMLImageTag(HttpServletResponse response,String src,String alt,String width,String height,Hashtable additionalAttributes) + { + StringBuffer tag = new StringBuffer("<img src=\""); + tag.append(response.encodeURL(src)).append('\"'); + if (alt != null) + tag.append(" alt=\"").append(alt).append('\"'); + if (width != null) + tag.append(" width=").append(width); + if (height != null) + tag.append(" height=").append(height); + tag.append(" border=0"); + if (additionalAttributes != null) + { + Enumeration keys = additionalAttributes.keys(); + while (keys.hasMoreElements()) + { + String key = (String)keys.nextElement(); + tag.append(' ').append(key).append("=\"").append((String)additionalAttributes.get(key)).append('\"'); + } + } + tag.append('>'); + return tag.toString(); + } + + /** + * Get the HTML tag for this link. The complete tag consists of the open tag <a> followed by a subelement and, finally, by an end tag </a>. + * @return String The HTML tag of the link. + * @param HttpServletResponse To encode the href attribute. + * @param String The href attribute of the link. This must include the context path. + * @param String target Optional target attribute for the link. Set this to null to disable the attribute. + * @param String Optional name for the link. Set this to null to disable the attribute. + * @param String The label which acts as the subelement. i.e. <a>label</a>. + * @param Hashtable Optional key-value pairs of additional string attributes to be added as-is to the open tag. Set this to null to disable. + */ + public static final String getHTMLLinkTag(HttpServletResponse response,String href,String target,String name,String label,Hashtable additionalAttributes) + { + StringBuffer tag = new StringBuffer("<a href=\""); + tag.append(response.encodeURL(href)).append('\"'); + if (target != null) + tag.append(" target=\"").append(target).append('\"'); + if (name != null) + tag.append(" name=\"").append(name).append('\"'); + if (additionalAttributes != null) + { + Enumeration keys = additionalAttributes.keys(); + while (keys.hasMoreElements()) + { + String key = (String)keys.nextElement(); + tag.append(' ').append(key).append("=\"").append((String)additionalAttributes.get(key)).append('\"'); + } + } + tag.append('>'); + tag.append(label); + tag.append("</a>"); + return tag.toString(); + } + + /** + * Get the HTML tag for a red asterist. + * @return String The HTML tag for the red asterisk. + */ + public static final String redAsterisk() + { + return "<font color=\"#ff0000\">*</font>"; + } + + /** + * Get the Javascript mangled version of a given input String. + * @return String The Javascript mangled String. + */ + public static final String JSMangle(String input) + { + if (input == null) + return ""; + + StringBuffer mangledOutput = new StringBuffer(); + for (int i=0;i<input.length();i++) + { + char c = input.charAt(i); + switch (c) + { + case '\n': + mangledOutput.append("\\n"); + break; + case '\r': + mangledOutput.append("\\r"); + break; + case '\\': + case '\"': + case '\'': + mangledOutput.append('\\'); + default: + mangledOutput.append(c); + } + } + return mangledOutput.toString(); + } + + private static final String LESS_THAN = "<"; + private static final String LESS_THAN_HTML_ENTITY = "<"; + private static final String GREATER_THAN = ">"; + private static final String GREATER_THAN_HTML_ENTITY = ">"; + private static final String SPACE = " "; + private static final String SPACE_HTML_ENTITY = " "; + private static final String AMPERSAND = "&"; + private static final String AMPERSAND_HTML_ENTITY = "&"; + private static final String QUOTATION = "\""; + private static final String QUOTATION_HTML_ENTITY = """; + + /** + * Replace special characters with HTML entities representing these characters. + * @return String The converted String. Note: Order is important so that corrected entity references are not re-mangled. + */ + public static final String charactersToHTMLEntities(String s) { + s = stringReplace(s, AMPERSAND, AMPERSAND_HTML_ENTITY); + s = stringReplace(s, LESS_THAN, LESS_THAN_HTML_ENTITY); + s = stringReplace(s, GREATER_THAN, GREATER_THAN_HTML_ENTITY); + s = stringReplace(s, SPACE, SPACE_HTML_ENTITY); + s = stringReplace(s, QUOTATION, QUOTATION_HTML_ENTITY); + return s; + } + + /** + * Replace HTML character entities with their associated characters. + * @return String The converted String. + */ + public static final String htmlEntitiesToCharacters(String s) { + s = stringReplace(s, LESS_THAN_HTML_ENTITY, LESS_THAN); + s = stringReplace(s, GREATER_THAN_HTML_ENTITY, GREATER_THAN); + s = stringReplace(s, SPACE_HTML_ENTITY, SPACE); + s = stringReplace(s, AMPERSAND_HTML_ENTITY, AMPERSAND); + s = stringReplace(s, QUOTATION_HTML_ENTITY, QUOTATION); + return s; + } + + private static final String stringReplace(String s, String oldString, String newString) { + String sCopy = s; + int fromIndex = 0; + int oldStringIndex = sCopy.indexOf(oldString, fromIndex); + StringBuffer sb = new StringBuffer(); + while (oldStringIndex != -1) { + sb.setLength(0); + sb.append(sCopy.substring(0, oldStringIndex)); + sb.append(newString); + sb.append(sCopy.substring(oldStringIndex + oldString.length(), sCopy.length())); + sCopy = sb.toString(); + fromIndex = oldStringIndex + newString.length(); + oldStringIndex = sCopy.indexOf(oldString, fromIndex); + } + return sCopy; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/MultipartFormDataException.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/MultipartFormDataException.java new file mode 100644 index 000000000..39008b18c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/MultipartFormDataException.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.util; + +public final class MultipartFormDataException extends Throwable +{ + /** + * Comment for <code>serialVersionUID</code> + */ + private static final long serialVersionUID = 3257845472227110961L; + +public MultipartFormDataException(String message) + { + super(message); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/MultipartFormDataParser.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/MultipartFormDataParser.java new file mode 100644 index 000000000..d442218ec --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/MultipartFormDataParser.java @@ -0,0 +1,243 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import java.io.*; +import java.util.*; + +import javax.servlet.http.*; + +public final class MultipartFormDataParser +{ + private Hashtable paramTable_; + + private static final String HEADER_CONTENT_TYPE = "Content-Type"; + private static final String HEADER_MULTIPART = "multipart"; + private static final String HEADER_BOUNDARY = "boundary="; + private static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition: form-data"; + private static final String HEADER_NAME = "name=\""; + + private static final byte PARSER_STATE_INITIAL = 0; + private static final byte PARSER_STATE_BOUNDARY = 1; + private static final byte PARSER_STATE_PARAMETER = 2; + private static final byte PARSER_STATE_BLANK = 3; + private static final byte PARSER_STATE_DATA = 4; + + private static String parserStates[] = {"initial","boundary","parameter name","blank line","data"}; + + public MultipartFormDataParser() + { + } + + public MultipartFormDataParser(Hashtable parameters) + { + paramTable_ = new Hashtable(); + for (Iterator it = parameters.keySet().iterator(); it.hasNext();) + { + Object key = it.next(); + Object value = parameters.get(key); + if (value instanceof List) + { + List list = (List)value; + for (Iterator it2 = list.iterator(); it2.hasNext();) + saveData(key.toString(), it2.next().toString()); + } + else if (value.getClass().isArray()) + { + Object[] array = (Object[])value; + for (int i = 0; i < array.length; i++) + saveData(key.toString(), array[i].toString()); + } + else + { + saveData(key.toString(), value.toString()); + } + } + } + + /** + * Parse a multipart/form-data encoded post request with a given encoding. + * If the encoding is null, use the system default encoding. utf-8 is not a + * bad choice for the encoding. + */ + public final void parseRequest(HttpServletRequest request,String encoding) throws MultipartFormDataException + { + // Content-Type header should have the form: + // multipart/form-data; boundary=... + // + // RFC2046 5.1.1 page 19, paragraph 2: + // The Content-Type field for multipart entities requires one parameter, "boundary" (no quotes) + String contentType = request.getHeader(HEADER_CONTENT_TYPE); + if (contentType == null || !contentType.startsWith(HEADER_MULTIPART) || contentType.indexOf(HEADER_BOUNDARY) == -1) + throw new MultipartFormDataException("Content-Type is not multipart/form-data"); + + // RFC2046 5.1.1 page 19, paragraph 4: + // The boundary value may be enclosed in double quotes. Strip these if they are present. + String boundary = contentType.substring(contentType.indexOf(HEADER_BOUNDARY)+HEADER_BOUNDARY.length(),contentType.length()); + if (boundary.charAt(0) == '\"' && boundary.charAt(boundary.length()-1) == '\"') + boundary = boundary.substring(1,boundary.length()-1); + + // RFC2046 5.1.1 page 19, paragraph 2: + // The boundary delimiter line is then defined as a line consisting entirely + // of two hyphen characters. + String delimiter = "--"+boundary; + + if (paramTable_ == null) + paramTable_ = new Hashtable(); + else + paramTable_.clear(); + + try + { + BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(),encoding)); + String line = null; + String parameterName = null; + StringBuffer parameterValue = new StringBuffer(); + byte currentParserState = PARSER_STATE_INITIAL; + while ((line = br.readLine()) != null) + { + // Lines appear in the following sequence. + // 1) boundary indicating the start of a new parameter and end of a data segment. + // 2) Content-Disposition: form-data; name="..." - the name of a new parameter. + // 3) a blank line + // 4) data + // + // For each parameter, the sequence is repeated. + if (line.startsWith(delimiter)) + { + byte[] expectedParserStates = {PARSER_STATE_INITIAL,PARSER_STATE_DATA}; + if (isValidParserState(currentParserState,expectedParserStates)) + { + // Save any current data and prepare for a new parameter name. + if (parameterName != null) + { + saveData(parameterName,parameterValue.toString()); + parameterName = null; + parameterValue.setLength(0); + } + currentParserState = PARSER_STATE_BOUNDARY; + } + else + throw new MultipartFormDataException(getParserExceptionMessage(currentParserState,expectedParserStates)); + } + else if (line.startsWith(HEADER_CONTENT_DISPOSITION)) + { + byte[] expectedParserStates = {PARSER_STATE_BOUNDARY}; + if (isValidParserState(currentParserState,expectedParserStates)) + { + // Obtain the parameter name without the surrounding double quotes. Accounts for RFC 1867 too. + int parameterNameStartingPosition = line.indexOf(HEADER_NAME)+HEADER_NAME.length(); + parameterName = line.substring(parameterNameStartingPosition,+parameterNameStartingPosition+line.substring(parameterNameStartingPosition).indexOf('\"')); + currentParserState = PARSER_STATE_PARAMETER; + } + } + else if (currentParserState == PARSER_STATE_PARAMETER) + { + // A blank line should follow the PARAMETER. Discard the line and move on. + currentParserState = PARSER_STATE_BLANK; + } + else + { + // Expect the line to contain data. + if (parameterValue.length() > 0) + parameterValue.append('\n'); + parameterValue.append(line); + currentParserState = PARSER_STATE_DATA; + } + } + } + catch (Throwable t) + { + throw new MultipartFormDataException(t.getMessage()); + } + //dumpParamTable(); + } + + /** + * Returns the value of a request parameter as a String, or null if the parameter does not exist. + * If the parameter has multiple values, only the first value is returned. Use getParameterValues() + * for parameters with multiple values. + */ + public final String getParameter(String parameter) throws MultipartFormDataException + { + if (paramTable_ == null) + throw new MultipartFormDataException("Parser contains no parsed data"); + Vector values = (Vector)paramTable_.get(parameter); + return ((values != null)?((String)values.elementAt(0)):null); + } + + public final String[] getParameterValues(String parameter) throws MultipartFormDataException + { + if (paramTable_ == null) + throw new MultipartFormDataException("Parser contains no parsed data"); + Vector valuesVector = (Vector)paramTable_.get(parameter); + if (valuesVector == null) + return null; + String[] valuesArray = new String[valuesVector.size()]; + for (int i=0;i<valuesArray.length;i++) + valuesArray[i] = (String)valuesVector.elementAt(i); + return valuesArray; + } + + public final String[] getParameterNames() throws MultipartFormDataException + { + if (paramTable_ == null) + throw new MultipartFormDataException("Parser contains no parsed data"); + + int size = paramTable_.size(); + if (size == 0) + return null; + String[] names = new String[size]; + Enumeration keys = paramTable_.keys(); + for (int i=0;i<size;i++) + names[i] = (String)keys.nextElement(); + return names; + } + + private final void saveData(String parameterName,String parameterValue) + { + Vector values = (Vector)paramTable_.get(parameterName); + if (values == null) + values = new Vector(); + values.addElement(parameterValue); + paramTable_.put(parameterName,values); + } + + private final boolean isValidParserState(byte currentState,byte[] expectedStates) + { + boolean validity = false; + for (int i=0;i<expectedStates.length;i++) + { + if (currentState == expectedStates[i]) + { + validity = true; + break; + } + } + return validity; + } + + private final String getParserExceptionMessage(byte currentState,byte[] expectedStates) + { + StringBuffer msg = new StringBuffer("Parser state inconsistency!"); + msg.append('\n'); + msg.append("Current state : ").append(parserStates[currentState]).append('\n'); + msg.append("Expected state(s): "); + for (int i=0;i<expectedStates.length;i++) + { + msg.append(parserStates[expectedStates[i]]); + if (i != expectedStates.length-1) + msg.append(", "); + } + msg.append('\n'); + return msg.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/QuickSort.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/QuickSort.java new file mode 100644 index 000000000..085151316 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/QuickSort.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import java.text.*; +import java.util.Vector; + +public class QuickSort +{ + public static final void sort(Object[] a,int lo,int hi) + { + Object tmp; + int i = lo; + int j = hi; + Object x = a[(lo+hi)/2]; + Collator collator = Collator.getInstance(); + + do + { + while (collator.compare(a[i].toString(),x.toString()) < 0) i++; + while (collator.compare(a[j].toString(),x.toString()) > 0) j--; + if (i <= j) + { + tmp = a[i]; + a[i] = a[j]; + a[j] = tmp; + i++; + j--; + } + } while (i <= j); + + if (lo < j) + sort(a,lo,j); + if (i < hi) + sort(a,i,hi); + } + + /* + * This method will use the same algorithm as above + * with the exception that any nulls will be attached + * at the end + */ + public static final void sort(Vector v) + { + // do not sort if vector contains less than 2 elements + if (v.size() < 2) + return; + + // pulls out the nulls + Vector nulls = new Vector(); + for (int i = 0; i < v.size(); i++) { + Object obj = v.elementAt(i); + if (obj == null || obj.toString() == null) { + nulls.add(obj); + v.remove(i); + i--; + } + } + + // sort the not null objects + Object[] objs = v.toArray(); + // do not sort if array contains less than 2 objects + if (objs.length >= 2) + sort(objs, 0, objs.length-1); + + // re-construct the vector from the sorted objects, then the nulls + v.clear(); + for (int j = 0; j < objs.length; j++) { + v.add(objs[j]); + } + v.addAll(nulls); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/TrimFilter.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/TrimFilter.java new file mode 100644 index 000000000..3f3fc03d0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/TrimFilter.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import javax.servlet.http.*; +import javax.servlet.*; + +import java.io.*; + +public class TrimFilter implements Filter +{ + + /* (non-Javadoc) + * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) + */ + public void init(FilterConfig arg0) throws ServletException + { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) + */ + public void doFilter(ServletRequest req, ServletResponse resp, FilterChain fc) throws IOException, ServletException + { + // TODO Auto-generated method stub + CharArrayWrapper responseWrapper = new CharArrayWrapper((HttpServletResponse)resp); + // Hack for Tomcat performance problem with filters. + OutputStreamWriter osw = new OutputStreamWriter(resp.getOutputStream(),HTMLUtils.UTF8_ENCODING); + fc.doFilter(req,responseWrapper); + String responseString = responseWrapper.toString(); + osw.write(responseString.trim()); + osw.close(); + } + + /* (non-Javadoc) + * @see javax.servlet.Filter#destroy() + */ + public void destroy() + { + // TODO Auto-generated method stub + + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/URLUtils.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/URLUtils.java new file mode 100644 index 000000000..b7070b348 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/URLUtils.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; + +/** + * This class contains utility methods for managing URLs + * as used by the Web Services Explorer Web application. + * @author cbrealey@ca.ibm.com + */ +public final class URLUtils +{ + /** + * Objects of this class should not be constructed. + */ + private URLUtils () + { + } + + /** + * UTF-8 + */ + public static final String UTF8 = "UTF-8"; + + /** + * Equivalent to {@link #encode(String,String)} + * with second parameter set to the "UTF-8" encoding. + * @param s The string to encode. + * @return The encoded string. + */ + public static String encode(String s) + { + return encode(s,UTF8); + } + + /** + * Equivalent to {@link URLEncoder#encode(String,String)}, + * only throws an unchecked {@link RuntimeException} wrapped + * around an {@link UnsupportedEncodingException} instead of + * an {@link UnsupportedEncodingException}. + * @param s The string to encode. + * @param enc The encoding to use. + * @return The encoded string. + */ + public static String encode(String s, String enc) + { + try + { + return URLEncoder.encode(s,enc); + } + catch (UnsupportedEncodingException e) + { + // TODO: MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8 + throw new RuntimeException("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8",e); + } + } + + /** + * Equivalent to {@link #decode(String,String)} + * with second parameter set to the "UTF-8" encoding. + * @param s The string to decode. + * @return The decoded string. + */ + public static String decode(String s) + { + return decode(s,UTF8); + } + + /** + * Equivalent to {@link URLEncoder#decode(String,String)}, + * only throws an unchecked {@link RuntimeException} wrapped + * around an {@link UnsupportedEncodingException} instead of + * an {@link UnsupportedEncodingException}. + * @param s The string to decode. + * @param enc The encoding to use. + * @return The decoded string. + */ + public static String decode(String s, String enc) + { + try + { + return URLDecoder.decode(s,enc); + } + catch (UnsupportedEncodingException e) + { + // TODO: MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8 + throw new RuntimeException("%MSG_BROKEN_VM_DOES_NOT_SUPPORT_UTF-8",e); + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/Validator.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/Validator.java new file mode 100644 index 000000000..6a6de221f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/Validator.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.util; + +public class Validator +{ + public static final boolean validateString(String input) + { + return ((input != null) && (input.trim().length() > 0)); + } + + public static final boolean validateURL(String input) + { + return ((input != null) && (input.indexOf("://") != -1)); + } + + public static final boolean validateInteger(String input) + { + try + { + Integer.parseInt(input); + return true; + } + catch (NumberFormatException e) + { + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/XMLUtils.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/XMLUtils.java new file mode 100644 index 000000000..bcbe4d487 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/util/XMLUtils.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.util; + +import org.w3c.dom.*; +import org.xml.sax.*; + +import javax.xml.parsers.*; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import java.io.*; + +public final class XMLUtils +{ + /** + * Serialize an XML Element into a String. + * @param e Element to be serialized. + * @param omitXMLDeclaration boolean representing whether or not to omit the XML declaration. + * @return String representation of the XML document fragment. + */ + public static final String serialize(Element e,boolean omitXMLDeclaration) + { + if (e != null) + { + try + { + DOMSource domSource = new DOMSource(e); + Transformer serializer = TransformerFactory.newInstance().newTransformer(); + serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, ((omitXMLDeclaration) ? "yes" : "no")); + serializer.setOutputProperty(OutputKeys.INDENT, "yes"); + serializer.setOutputProperty(OutputKeys.ENCODING, HTMLUtils.UTF8_ENCODING); + serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + serializer.transform(domSource, new StreamResult(baos)); + baos.close(); + return new String(baos.toByteArray(), HTMLUtils.UTF8_ENCODING); + } + catch (Throwable t) + { + } + } + return null; + } + + /** + * Serialize an XML Element into a String. + * @param df DocumentFragment to be serialized. + * @param omitXMLDeclaration boolean representing whether or not to omit the XML declaration. + * @return String representation of the XML document fragment. + */ + public static final String serialize(DocumentFragment df,boolean omitXMLDeclaration) + { + if (df != null) + { + try + { + DOMSource domSource = new DOMSource(df); + Transformer serializer = TransformerFactory.newInstance().newTransformer(); + serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, ((omitXMLDeclaration) ? "yes" : "no")); + serializer.setOutputProperty(OutputKeys.INDENT, "yes"); + serializer.setOutputProperty(OutputKeys.ENCODING, HTMLUtils.UTF8_ENCODING); + serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + serializer.transform(domSource, new StreamResult(baos)); + baos.close(); + return new String(baos.toByteArray(), HTMLUtils.UTF8_ENCODING); + } + catch (Throwable t) + { + } + } + return null; + } + + /** + * Create a new XML Document. + * @param docBuilder DocumentBuilder. Setting this to null will create a new DocumentBuilder. + * @return Document + */ + public static final Document createNewDocument(DocumentBuilder docBuilder) throws ParserConfigurationException + { + if (docBuilder == null) + { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(false); + factory.setValidating(false); + docBuilder = factory.newDocumentBuilder(); + } + Document doc = docBuilder.newDocument(); + return doc; + } + + /** + * Convert the String representation of an Element into an Element + * @param String representation of an Element. + * @return Element + */ + public static Element stringToElement(String s) throws ParserConfigurationException, SAXException, UnsupportedEncodingException, IOException { + return stringToElement(s, false); + } + + /** + * Convert the String representation of an Element into an Element + * @param String representation of an Element. + * @param boolean set whether the return Element should be namespace aware. + * @return Element + */ + public static Element stringToElement(String s, boolean namespaceAware) throws ParserConfigurationException, SAXException, UnsupportedEncodingException, IOException + { + return byteArrayToElement(s.getBytes(HTMLUtils.UTF8_ENCODING), namespaceAware); + } + + /** + * Convert the byte array representation of an Element into an Element + * @param byte[] representation of an Element. + * @param boolean set whether the return Element should be namespace aware. + * @return Element + */ + public static Element byteArrayToElement(byte[] b, boolean namespaceAware) throws ParserConfigurationException, SAXException, UnsupportedEncodingException, IOException + { + DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + docBuilderFactory.setNamespaceAware(namespaceAware); + docBuilderFactory.setValidating(false); + DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); + Document doc = docBuilder.parse(new ByteArrayInputStream(b)); + return doc.getDocumentElement(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ClearWSDLAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ClearWSDLAction.java new file mode 100644 index 000000000..4c16789d0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ClearWSDLAction.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ClearNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLMainNode; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLNode; + +import javax.servlet.http.*; + +public class ClearWSDLAction extends ClearNodeAction { + + public ClearWSDLAction(Controller controller) { + super(controller, controller.getWSDLPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeID) { + StringBuffer actionLink = new StringBuffer("wsdl/actions/ClearWSDLActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + return actionLink.toString(); + } + + protected boolean processLinkParameters(HttpServletRequest request) { + String nodeIDString = request.getParameter(ActionInputs.NODEID); + int nodeID; + try { + nodeID = Integer.parseInt(nodeIDString); + } + catch (NumberFormatException nfe) { + nodeID = nodeManager_.getSelectedNodeId(); + } + boolean paramValid = false; + Node node = nodeManager_.getNode(nodeID); + if (node instanceof WSDLMainNode) + paramValid = true; + else if (node instanceof WSDLNode) + paramValid = true; + else { + while (node != null && !(node instanceof WSDLMainNode)) { + node = node.getParent(); + if (node instanceof WSDLNode) { + nodeID = node.getNodeId(); + paramValid = true; + break; + } + } + } + propertyTable_.put(ActionInputs.NODEID, String.valueOf(nodeID)); + return paramValid; + } + + public boolean run() { + if (super.run()) { + nodeManager_.setSelectedNodeId(nodeManager_.getRootNode().getNodeId()); + return true; + } + else + return false; + } + + public String getTreeContentVar() { + return "wsdlNavigatorContent"; + } + + public String getTreeContentPage() { + return "wsdl/wsdl_navigator_content.jsp"; + } + + public String getPropertiesContainerVar() { + return "wsdlPropertiesContainer"; + } + + public String getPropertiesContainerPage() { + return "wsdl/wsdl_properties_container.jsp"; + } + + public String getStatusContentVar() { + return "wsdlStatusContent"; + } + + public String getStatusContentPage() { + return "wsdl/wsdl_status_content.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/CreateInstanceAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/CreateInstanceAction.java new file mode 100644 index 000000000..abca81e9d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/CreateInstanceAction.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDMapFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.InvokeWSDLOperationTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +import javax.wsdl.Part; +import java.util.Iterator; + +public class CreateInstanceAction extends WSDLPropertiesFormAction +{ + public CreateInstanceAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + super.processParsedResults(parser); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + InvokeWSDLOperationTool invokeWSDLOperationTool = (InvokeWSDLOperationTool)(selectedNode.getCurrentToolManager().getSelectedTool()); + WSDLOperationElement operElement = (WSDLOperationElement)selectedNode.getTreeElement(); + Iterator it = operElement.getOrderedBodyParts().iterator(); + boolean resultsValid = true; + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = operElement.getFragment(part); + if (!frag.processParameterValues(parser)) + resultsValid = false; + } + String fragmentID = parser.getParameter(FragmentConstants.FRAGMENT_ID); + if (fragmentID != null && fragmentID.length() > 0) + propertyTable_.put(FragmentConstants.FRAGMENT_ID, fragmentID); + else + { + propertyTable_.remove(FragmentConstants.FRAGMENT_ID); + resultsValid = false; + } + String nameAnchorID = parser.getParameter(FragmentConstants.NAME_ANCHOR_ID); + invokeWSDLOperationTool.setFragmentNameAnchorID(nameAnchorID); + return resultsValid; + } + + public FormTool getSelectedFormTool() + { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + return (FormTool)wsdlPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public boolean run() + { + String fragmentID = (String)propertyTable_.get(FragmentConstants.FRAGMENT_ID); + if (fragmentID != null && fragmentID.length() > 0) + { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + WSDLOperationElement operElement = (WSDLOperationElement)selectedNode.getTreeElement(); + IXSDFragment frag = operElement.getFragmentByID(fragmentID); + if ((frag instanceof IXSDMapFragment) && ((IXSDMapFragment)frag).createInstance() != null) + return true; + else + return false; + } + else + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpGetOperationFormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpGetOperationFormAction.java new file mode 100644 index 000000000..d069e4312 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpGetOperationFormAction.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import java.io.IOException; +import java.net.URLConnection; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageQueue; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; +import org.eclipse.wst.ws.internal.parser.discovery.NetUtils; + +public class InvokeWSDLHttpGetOperationFormAction extends InvokeWSDLHttpOperationFormAction +{ + public InvokeWSDLHttpGetOperationFormAction(Controller controller) + { + super(controller); + } + + public boolean run() + { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + StringBuffer endPoint = new StringBuffer(getEndPoint()); + endPoint.append('?'); + addParameters(endPoint); + String endPointString = endPoint.toString(); + boolean result = false; + try + { + URLConnection conn = NetUtils.getURLConnection(endPointString); + if (conn != null) + { + recordHttpResponse(conn,messageQueue); + wsdlPerspective.setOperationNode(getSelectedNavigatorNode()); + result = true; + } + else + throw new IOException(wsdlPerspective.getMessage("MSG_ERROR_UNABLE_TO_CONNECT",endPointString)); + } + catch (IOException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"IOException",e); + } + return result; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpOperationFormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpOperationFormAction.java new file mode 100644 index 000000000..d85832a19 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpOperationFormAction.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; + +import javax.wsdl.*; + +import java.util.*; +import java.net.*; +import java.io.*; + +public abstract class InvokeWSDLHttpOperationFormAction extends WSDLPropertiesFormAction +{ + private static final String CONTENT_TYPE_CHARSETEQ = "charset="; + + public InvokeWSDLHttpOperationFormAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + super.processParsedResults(parser); + String endPoint = parser.getParameter(WSDLActionInputs.END_POINT); + Node selectedNode = getSelectedNavigatorNode(); + InvokeWSDLOperationTool invokeWSDLOperationTool = (InvokeWSDLOperationTool)(selectedNode.getCurrentToolManager().getSelectedTool()); + invokeWSDLOperationTool.setEndPoint(endPoint); + WSDLOperationElement operElement = (WSDLOperationElement)(selectedNode.getTreeElement()); + propertyTable_.put(WSDLActionInputs.OPERATION_ELEMENT,operElement); + Iterator it = operElement.getOrderedBodyParts().iterator(); + boolean resultsValid = true; + while (it.hasNext()) { + Part part = (Part)it.next(); + IFragment frag = operElement.getFragment(part); + if (!frag.processParameterValues(parser)) + resultsValid = false; + } + return resultsValid; + } + + protected String getEndPoint() + { + StringBuffer endPoint = new StringBuffer((String)propertyTable_.get(WSDLActionInputs.END_POINT)); + WSDLOperationElement operElement = (WSDLOperationElement)propertyTable_.get(WSDLActionInputs.OPERATION_ELEMENT); + if (endPoint.charAt(endPoint.length()-1) != '/') + endPoint.append('/'); + endPoint.append(operElement.getName()); + return endPoint.toString(); + } + + protected void addParameters(StringBuffer buffer) + { + WSDLOperationElement operElement = (WSDLOperationElement)propertyTable_.get(WSDLActionInputs.OPERATION_ELEMENT); + Iterator it = operElement.getOrderedBodyParts().iterator(); + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = operElement.getFragment(part); + buffer.append(HTTPUtil.genURLEncodedParameters(frag)); + if (it.hasNext()) + buffer.append('&'); + } + } + + protected void recordHttpResponse(URLConnection conn,MessageQueue messageQueue) throws IOException + { + BufferedReader br = null; + try + { + InputStreamReader in = null; + String contentType = conn.getContentType(); + if (contentType != null) + { + int charsetEqPos = contentType.indexOf(CONTENT_TYPE_CHARSETEQ); + if (charsetEqPos != -1) + in = new InputStreamReader(conn.getInputStream(),contentType.substring(charsetEqPos+CONTENT_TYPE_CHARSETEQ.length())); + } + if (in == null) + in = new InputStreamReader(conn.getInputStream()); + br = new BufferedReader(in); + String s; + while ((s = br.readLine()) != null) + messageQueue.addMessage(s); + br.close(); + br = null; + } + catch (IOException e) + { + if (br != null) + br.close(); + throw e; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpPostOperationFormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpPostOperationFormAction.java new file mode 100644 index 000000000..981c4307f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLHttpPostOperationFormAction.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URLConnection; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageQueue; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; +import org.eclipse.wst.ws.internal.parser.discovery.NetUtils; + +public class InvokeWSDLHttpPostOperationFormAction extends InvokeWSDLHttpOperationFormAction +{ + + public InvokeWSDLHttpPostOperationFormAction(Controller controller) + { + super(controller); + } + + public boolean run() + { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + boolean result = false; + String endPointString = getEndPoint(); + URLConnection conn = NetUtils.getURLConnection(endPointString); + if (conn != null) + { + StringBuffer parameters = new StringBuffer(); + addParameters(parameters); + conn.setDoOutput(true); + PrintWriter out = null; + try + { + out = new PrintWriter(conn.getOutputStream()); + out.print(parameters); + out.close(); + out = null; + recordHttpResponse(conn,messageQueue); + wsdlPerspective.setOperationNode(getSelectedNavigatorNode()); + result = true; + } + catch (IOException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"IOException",e); + } + finally + { + if (out != null) + out.close(); + } + } + else + handleUnexpectedException(wsdlPerspective,messageQueue,"Exception",new IOException(wsdlPerspective.getMessage("MSG_ERROR_UNABLE_TO_CONNECT",endPointString))); + return result; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java new file mode 100644 index 000000000..29397e179 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationAction.java @@ -0,0 +1,270 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPException; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPTransport; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.*; +import org.eclipse.wst.ws.internal.parser.discovery.*; + +import org.apache.axis.Constants; + +import org.w3c.dom.*; + +import javax.xml.parsers.*; +import javax.wsdl.*; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.servlet.http.HttpServletResponse; + +import java.util.*; +import java.io.*; + +public abstract class InvokeWSDLSOAPOperationAction extends WSDLPropertiesFormAction +{ + public InvokeWSDLSOAPOperationAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + super.processParsedResults(parser); + String endPoint = parser.getParameter(WSDLActionInputs.END_POINT); + InvokeWSDLOperationTool invokeWSDLOperationTool = (InvokeWSDLOperationTool)(getSelectedNavigatorNode().getCurrentToolManager().getSelectedTool()); + invokeWSDLOperationTool.setEndPoint(endPoint); + return true; + } + + protected final void addRPCWrapper(Vector bodyEntries,WSDLElement wsdlElement,WSDLOperationElement operElement,Hashtable soapEnvelopeNamespaceTable) throws ParserConfigurationException + { + // Must be RPC style. + String encodingNamespaceURI = null; + /* + * WS-I: In a rpc-literal SOAP binding, the serialized child element of the + * soap:Body element consists of a wrapper element, whose namespace is the value + * of the namespace attribute of the soapbind:body element and whose local name is + * either the name of the operation or the name of the operation suffixed + * with "Response". The namespace attribute is required, as opposed to being + * optional, to ensure that the children of the soap:Body element are namespace- + * qualified. + */ + BindingOperation bindingOperation = operElement.getBindingOperation(); + if (bindingOperation != null) + { + BindingInput bindingInput = bindingOperation.getBindingInput(); + if (bindingInput != null) + { + List extElements = bindingInput.getExtensibilityElements(); + for (Iterator it = extElements.iterator(); it.hasNext();) + { + ExtensibilityElement extElement = (ExtensibilityElement)it.next(); + if (extElement instanceof SOAPBody) + { + encodingNamespaceURI = ((SOAPBody)extElement).getNamespaceURI(); + break; + } + } + } + } + // If the namespace of the soapbind:body element is not set, get it from the operation element + if (encodingNamespaceURI == null) + encodingNamespaceURI = operElement.getEncodingNamespace(); + // If the namespace of the operation element is not set, get it from the definition element + if (encodingNamespaceURI == null) + { + Definition definition = wsdlElement.getDefinition(); + encodingNamespaceURI = definition.getTargetNamespace(); + } + // Generate an RPC style wrapper element. + Document doc = XMLUtils.createNewDocument(null); + String encodingStyle = (operElement.isUseLiteral() ? null : operElement.getEncodingStyle()); + Element wrapperElement = SoapHelper.createRPCWrapperElement(doc,soapEnvelopeNamespaceTable,encodingNamespaceURI,operElement.getOperation().getName(),encodingStyle); + for (int i=0;i<bodyEntries.size();i++) + wrapperElement.appendChild(doc.importNode((Element)bodyEntries.elementAt(i),true)); + bodyEntries.removeAllElements(); + bodyEntries.addElement(wrapperElement); + } + + /** + * Generate a Vector of the elements inside the Soap Body. + * @param soapEnvelopeNamespaceTable - Hashtable containing a map of the namespace URIs to prefixes. + * @param operElement - WSDLOperationElement encapsulating the WSDL operation. + */ + protected Vector getBodyEntries(Hashtable soapEnvelopeNamespaceTable,WSDLOperationElement operElement,WSDLBindingElement bindingElement,WSDLServiceElement serviceElement) throws ParserConfigurationException,Exception + { + Vector bodyEntries = new Vector(); + boolean isUseLiteral = operElement.isUseLiteral(); + String encodingStyle = operElement.getEncodingStyle(); + boolean addEncodingStyle = (!isUseLiteral && !Constants.URI_SOAP11_ENC.equals(encodingStyle)); + Iterator it = operElement.getOrderedBodyParts().iterator(); + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = (IXSDFragment)operElement.getFragment(part); + XSDToFragmentConfiguration config = frag.getXSDToFragmentConfiguration(); + Element[] instanceDocuments = frag.genInstanceDocumentsFromParameterValues(!isUseLiteral,soapEnvelopeNamespaceTable, XMLUtils.createNewDocument(null)); + for (int j=0;j<instanceDocuments.length;j++) + { + if (instanceDocuments[j] == null) + continue; + if (addEncodingStyle) + instanceDocuments[j].setAttribute("soapenv:encodingStyle",encodingStyle); + bodyEntries.addElement(instanceDocuments[j]); + } + } + + if (!operElement.isDocumentStyle()) + { + try + { + addRPCWrapper(bodyEntries,(WSDLElement)serviceElement.getParentElement(),operElement,soapEnvelopeNamespaceTable); + } + catch (ParserConfigurationException e) + { + throw e; + } + } + return bodyEntries; + } + + protected Element getSOAPEnvelope(Hashtable soapEnvelopeNamespaceTable, Vector bodyEntries) throws ParserConfigurationException + { + DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document doc = XMLUtils.createNewDocument(docBuilder); + Element soapEnvelopeElement = SoapHelper.createSoapEnvelopeElement(doc,soapEnvelopeNamespaceTable); + Element soapBodyElement = SoapHelper.createSoapBodyElement(doc); + for (int i=0;i<bodyEntries.size();i++) + soapBodyElement.appendChild(doc.importNode((Element)bodyEntries.elementAt(i),true)); + soapEnvelopeElement.appendChild(soapBodyElement); + return soapEnvelopeElement; + } + + private final void recordSoapRequest(SOAPMessageQueue soapRequestQueue,Hashtable soapEnvelopeNamespaceTable,Element soapEnvelope) throws ParserConfigurationException,IOException + { + soapRequestQueue.clear(); + soapRequestQueue.addMessage(XMLUtils.serialize(soapEnvelope,false)); + } + + private final void recordSOAPResponse(SOAPMessageQueue soapResponseQueue,BufferedReader responseReader) throws IOException + { + soapResponseQueue.clear(); + if (responseReader != null) + { + String line = null; + while ((line = responseReader.readLine()) != null) + soapResponseQueue.addMessage(line); + responseReader.close(); + } + } + + public boolean run() + { + String soapAddressLocation = (String)propertyTable_.get(WSDLActionInputs.END_POINT); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + WSDLOperationElement operElement = (WSDLOperationElement)getSelectedNavigatorNode().getTreeElement(); + WSDLBindingElement bindingElement = (WSDLBindingElement)operElement.getParentElement(); + WSDLServiceElement serviceElement = (WSDLServiceElement)bindingElement.getParentElement(); + operElement.setPropertyAsObject(WSDLActionInputs.SOAP_RESPONSE_CACHED, new Boolean(false)); + try + { + // Generate the SOAP envelope and its children. We need to create a DOM element version to display and the object version to execute. + // <SOAP-ENV:Envelope + // xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" + // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + // xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + // ... + Hashtable soapEnvelopeNamespaceTable = new Hashtable(); + SoapHelper.addDefaultSoapEnvelopeNamespaces(soapEnvelopeNamespaceTable); + Vector bodyEntries = getBodyEntries(soapEnvelopeNamespaceTable,operElement,bindingElement,serviceElement); + Element soapEnvelope = getSOAPEnvelope(soapEnvelopeNamespaceTable, bodyEntries); + recordSoapRequest(wsdlPerspective.getSOAPRequestQueue(),soapEnvelopeNamespaceTable,soapEnvelope); + + // Execute the SOAP operation. + if (soapAddressLocation != null) + { + // Send the message and record the SOAP Response Envelope. + HTTPTransport transport = createTransport(bindingElement, soapAddressLocation); + transport.send(NetUtils.createURL(soapAddressLocation),operElement.getSoapAction(),XMLUtils.serialize(soapEnvelope, true)); + recordSOAPResponse(wsdlPerspective.getSOAPResponseQueue(),transport.receive()); + wsdlPerspective.setOperationNode(getSelectedNavigatorNode()); + return true; + } + throw new IOException(wsdlPerspective.getMessage("MSG_ERROR_UNABLE_TO_CONNECT",soapAddressLocation)); + } + catch (ParserConfigurationException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"ParserConfigurationException",e); + } + catch (IOException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"IOException",e); + } + catch (HTTPException httpe) + { + throwHTTPException(bindingElement, soapAddressLocation, httpe); + } + catch (Exception e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"Exception",e); + } + return false; + } + + private void throwHTTPException(WSDLBindingElement bindingElement, String endpointString, HTTPException httpException) throws HTTPException + { + if (httpException.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) + { + Endpoint endpoint = bindingElement.getEndpoint(endpointString); + if (endpoint != null) + { + endpoint.setRequireHTTPBasicAuth(true); + endpoint.setHttpBasicAuthUsername(null); + endpoint.setHttpBasicAuthPassword(null); + } + } + throw httpException; + } + + private HTTPTransport createTransport(WSDLBindingElement bindingElement, String endpointString) + { + HTTPTransport transport = new HTTPTransport(); + Endpoint endpoint = bindingElement.getEndpoint(endpointString); + if (endpoint != null) + { + if (endpoint.isRequireHTTPBasicAuth()) + { + String httpBasicAuthUsername = endpoint.getHttpBasicAuthUsername(); + String httpBasicAuthPassword = endpoint.getHttpBasicAuthPassword(); + if (httpBasicAuthUsername == null || httpBasicAuthPassword == null) + { + httpBasicAuthUsername = (String)propertyTable_.get(WSDLActionInputs.HTTP_BASIC_AUTH_USERNAME); + httpBasicAuthPassword = (String)propertyTable_.get(WSDLActionInputs.HTTP_BASIC_AUTH_PASSWORD); + endpoint.setHttpBasicAuthUsername(httpBasicAuthUsername); + endpoint.setHttpBasicAuthPassword(httpBasicAuthPassword); + } + if (httpBasicAuthUsername != null && httpBasicAuthPassword != null) + { + transport.setHttpBasicAuthUsername(httpBasicAuthUsername); + transport.setHttpBasicAuthPassword(httpBasicAuthPassword); + } + } + } + return transport; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationFormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationFormAction.java new file mode 100644 index 000000000..db7653225 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationFormAction.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.transformer.FragmentTransformer; + +import javax.wsdl.*; +import java.util.*; + +public class InvokeWSDLSOAPOperationFormAction extends InvokeWSDLSOAPOperationAction +{ + public InvokeWSDLSOAPOperationFormAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + boolean resultsValid = true; + super.processParsedResults(parser); + String sourceContent = parser.getParameter(FragmentConstants.SOURCE_CONTENT); + if (sourceContent == null) + { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + WSDLOperationElement operElement = (WSDLOperationElement) getSelectedNavigatorNode().getTreeElement(); + Iterator it = operElement.getOrderedBodyParts().iterator(); + while (it.hasNext()) + { + Part part = (Part) it.next(); + IFragment frag = operElement.getFragment(part); + if (!frag.processParameterValues(parser)) + { + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_ERROR_VALIDATING_PARAMETER", part.getName())); + resultsValid = false; + } + } + } + return resultsValid; + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length + 1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length - 1] = new FragmentTransformer(controller_); + return transformers; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java new file mode 100644 index 000000000..76a6d9ae4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/InvokeWSDLSOAPOperationSourceAction.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.util.*; + +import org.w3c.dom.*; +import org.xml.sax.*; + +import javax.xml.parsers.*; +import javax.wsdl.*; + +import java.util.*; +import java.io.*; + +public class InvokeWSDLSOAPOperationSourceAction extends InvokeWSDLSOAPOperationAction +{ + private boolean newFileSelected_; + private boolean saveAsSelected_; + private static final String DUMMY_WRAPPER_START_TAG = "<dummyWrapper>"; + private static final String DUMMY_WRAPPER_END_TAG = "</dummyWrapper>"; + + public InvokeWSDLSOAPOperationSourceAction(Controller controller) + { + super(controller); + newFileSelected_ = false; + saveAsSelected_ = false; + } + + private final void fragmentize(StringBuffer fileContents) throws ParserConfigurationException,SAXException,UnsupportedEncodingException,IOException + { + fileContents.insert(0,DUMMY_WRAPPER_START_TAG).append(DUMMY_WRAPPER_END_TAG); + Element dummyWrapperElement = XMLUtils.stringToElement(fileContents.toString()); + Vector partElements = new Vector(); + NodeList partNodes = dummyWrapperElement.getChildNodes(); + for (int i=0;i<partNodes.getLength();i++) + { + org.w3c.dom.Node partNode = partNodes.item(i); + if (partNode instanceof Element) + partElements.addElement(partNode); + } + Element[] elementArray = new Element[partElements.size()]; + partElements.copyInto(elementArray); + WSDLOperationElement operElement = (WSDLOperationElement)(getSelectedNavigatorNode().getTreeElement()); + Iterator it = operElement.getOrderedBodyParts().iterator(); + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment fragment = operElement.getFragment(part); + fragment.setParameterValuesFromInstanceDocuments(elementArray); + } + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + super.processParsedResults(parser); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + WSDLOperationElement operElement = (WSDLOperationElement)getSelectedNavigatorNode().getTreeElement(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + newFileSelected_ = false; + saveAsSelected_ = false; + /* try and catch is needed if we are doing fragmentization. + try + { + */ + String submissionAction = parser.getParameter(WSDLActionInputs.SUBMISSION_ACTION); + String sourceContents = parser.getParameter(FragmentConstants.SOURCE_CONTENT); + if (sourceContents != null) + operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT,sourceContents); + if (WSDLActionInputs.SUBMISSION_ACTION_BROWSE_FILE.equals(submissionAction)) + { + newFileSelected_ = true; + String fileContents = parser.getParameter(WSDLActionInputs.SELECTED_FILE); + if (fileContents != null) + operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT,fileContents); + } + else + { + if (WSDLActionInputs.SUBMISSION_ACTION_SAVE_AS.equals(submissionAction)) + { + // Save As... action + saveAsSelected_ = true; + } + else + { + // Fragmentize on Go action. + // fragmentize(new StringBuffer(sourceContents)); + String[] nsDeclarations = parser.getParameterValues(FragmentConstants.SOURCE_CONTENT_NAMESPACE); + if (nsDeclarations != null) + operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE,nsDeclarations); + } + } + return true; + /* + } + catch (ParserConfigurationException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"ParserConfigurationException",e); + } + catch (SAXException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"SAXException",e); + } + catch (UnsupportedEncodingException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"UnsupportedEncodingException",e); + } + catch (IOException e) + { + handleUnexpectedException(wsdlPerspective,messageQueue,"IOException",e); + } + return false; + */ + } + + /** + * Generate a Vector of the elements inside the Soap Body. + * @param soapEnvelopeNamespaceTable - Hashtable containing a map of the namespace URIs to prefixes. + * @param operElement - WSDLOperationElement encapsulating the WSDL operation. + */ + protected Vector getBodyEntries(Hashtable soapEnvelopeNamespaceTable,WSDLOperationElement operElement,WSDLBindingElement bindingElement,WSDLServiceElement serviceElement) throws ParserConfigurationException,Exception + { + Vector bodyEntries = new Vector(); + String[] nsDeclarations = (String[])operElement.getPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE); + for (int i = 0; i < nsDeclarations.length; i++) + { + String[] prefix_ns = SoapHelper.decodeNamespaceDeclaration(nsDeclarations[i]); + if (!soapEnvelopeNamespaceTable.contains(prefix_ns[1])) + soapEnvelopeNamespaceTable.put(prefix_ns[1], prefix_ns[0]); + } + StringBuffer sourceContent = new StringBuffer(operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT)); + sourceContent.insert(0,DUMMY_WRAPPER_START_TAG).append(DUMMY_WRAPPER_END_TAG); + Element dummyWrapperElement = XMLUtils.stringToElement(sourceContent.toString()); + NodeList nl = dummyWrapperElement.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) + { + if (nl.item(i) instanceof Element) + bodyEntries.add(nl.item(i)); + } + if (!operElement.isDocumentStyle()) + { + try + { + addRPCWrapper(bodyEntries,(WSDLElement)serviceElement.getParentElement(),operElement,soapEnvelopeNamespaceTable); + } + catch (ParserConfigurationException e) + { + throw e; + } + } + return bodyEntries; + } + + public final boolean wasNewFileSelected() + { + return newFileSelected_; + } + + public final boolean wasSaveAsSelected() + { + return saveAsSelected_; + } + + public final String getDefaultSaveAsFileName() + { + WSDLOperationElement operElement = (WSDLOperationElement)(getSelectedNavigatorNode().getTreeElement()); + return (new StringBuffer(operElement.getOperation().getName())).append(".txt").toString(); + } + + public final void writeSourceContent(OutputStream os) + { + WSDLOperationElement operElement = (WSDLOperationElement)(getSelectedNavigatorNode().getTreeElement()); + PrintWriter pw = new PrintWriter(os); + pw.println(operElement.getPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT)); + pw.close(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/OpenWSDLAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/OpenWSDLAction.java new file mode 100644 index 000000000..df77a253a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/OpenWSDLAction.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +import javax.wsdl.WSDLException; +import java.util.Vector; + +public class OpenWSDLAction extends WSDLPropertiesFormAction { + + public OpenWSDLAction(Controller controller) { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException { + String wsdlUrl = parser.getParameter(ActionInputs.QUERY_INPUT_WSDL_URL); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + propertyTable_.put(ActionInputs.QUERY_INPUT_WSDL_URL, wsdlUrl); + formTool.updatePropertyTable(propertyTable_); + return true; + } + + public boolean run() { + String wsdlUrl = (String)propertyTable_.get(ActionInputs.QUERY_INPUT_WSDL_URL); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node rootNode = nodeManager.getRootNode(); + TreeElement rootElement = rootNode.getTreeElement(); + + // create a WSDLElement representing the WSDL + WSDLElement wsdlElement = new WSDLElement(wsdlUrl, rootElement.getModel(), wsdlUrl); + try + { + // open WSDL + Vector errorMessages = wsdlElement.loadWSDL(); + if (errorMessages.size() > 0) + { + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_ERROR_XSD_VALIDATION")); + for (int i=0;i<errorMessages.size();i++) + messageQueue.addMessage((String)errorMessages.elementAt(i)); + } + } + catch (WSDLException e) + { + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_ERROR_OPEN_WSDL",wsdlUrl)); + handleUnexpectedException(wsdlPerspective,messageQueue,"WSDLException",e); + return false; + } + rootElement.connect(wsdlElement,WSDLModelConstants.REL_WSDL, ModelConstants.REL_OWNER); + + // build the datamodel for this WSDLElement + wsdlElement.buildModel(); + + // If there is more than 1 service node, select the WSDL node. If there is more than 1 binding node, select the service node. + // If there is just the one service and binding node, select the binding node. + // select the new WSDL node + Node wsdlNode = rootNode.getChildNode(wsdlElement); + Vector serviceNodes = wsdlNode.getChildNodes(); + int newSelectedNodeId = wsdlNode.getNodeId(); + if (serviceNodes.size() == 1) + { + Node serviceNode = (Node)serviceNodes.elementAt(0); + Vector bindingNodes = serviceNode.getChildNodes(); + if (bindingNodes.size() == 1) + { + Node bindingNode = (Node)bindingNodes.elementAt(0); + newSelectedNodeId = bindingNode.getNodeId(); + } + else + newSelectedNodeId = serviceNode.getNodeId(); + } + nodeManager.setSelectedNodeId(newSelectedNodeId); + nodeManager.makeNodeVisible(nodeManager.getNode(newSelectedNodeId)); + addToHistory(ActionInputs.PERSPECTIVE_WSDL,SelectWSDLPropertiesToolAction.getActionLink(newSelectedNodeId, 0, ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT, true)); + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_INFO_OPEN_WSDL_SUCCESSFUL", wsdlUrl)); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/OpenXSDInfoDialogAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/OpenXSDInfoDialogAction.java new file mode 100644 index 000000000..c12cfd50a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/OpenXSDInfoDialogAction.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +import javax.servlet.http.*; + +public class OpenXSDInfoDialogAction extends Action +{ + public OpenXSDInfoDialogAction() + { + } + + public static final String getActionLink(String sessionId,int nodeId,String fragId) + { + StringBuffer actionLink = new StringBuffer("wsdl/fragment/XSDInfoDialog.jsp?"); + actionLink.append(ActionInputs.SESSIONID).append('=').append(sessionId); + actionLink.append('&').append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(WSDLActionInputs.FRAGMENT_ID).append('=').append(fragId); + return actionLink.toString(); + } + + public final boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public final boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/RefreshWSDLAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/RefreshWSDLAction.java new file mode 100644 index 000000000..8cb9062b8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/RefreshWSDLAction.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LinkAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; + +import java.util.Vector; +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; +import javax.servlet.http.*; + +public class RefreshWSDLAction extends LinkAction { + + public RefreshWSDLAction(Controller controller) { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) { + StringBuffer actionLink = new StringBuffer("wsdl/actions/WSDLRefreshActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + protected boolean processLinkParameters(HttpServletRequest request) { + NodeManager nodeManager = controller_.getWSDLPerspective().getNodeManager(); + String nodeIDString = request.getParameter(ActionInputs.NODEID); + int nodeID; + try { + nodeID = Integer.parseInt(nodeIDString); + } + catch (NumberFormatException nfe) { + nodeID = nodeManager.getSelectedNodeId(); + } + Node node = nodeManager.getNode(nodeID); + while (node != null && !(node instanceof WSDLMainNode)) { + if (node instanceof WSDLNode) { + propertyTable_.put(ActionInputs.NODEID, String.valueOf(node.getNodeId())); + return true; + } + node = node.getParent(); + } + return false; + } + + public boolean run() { + int nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node wsdlNode = nodeManager.getNode(nodeID); + WSDLElement wsdlElement = (WSDLElement)wsdlNode.getTreeElement(); + Definition definitionCopy = wsdlElement.getDefinition(); + Vector schemaListCopy = wsdlElement.getSchemaList(); + wsdlElement.setDefinition(null); + wsdlElement.setSchemaList(new Vector()); + int selectedNodeID = nodeManager.getSelectedNode().getNodeId(); + + try { + // open WSDL + Vector errorMessages = wsdlElement.loadWSDL(); + if (errorMessages.size() > 0) { + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_ERROR_XSD_VALIDATION")); + for (int i=0;i<errorMessages.size();i++) + messageQueue.addMessage((String)errorMessages.elementAt(i)); + } + } + catch (WSDLException e) + { + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_ERROR_OPEN_WSDL",wsdlElement.getWsdlUrl())); + handleUnexpectedException(wsdlPerspective,messageQueue,"WSDLException",e); + wsdlElement.setDefinition(definitionCopy); + wsdlElement.setSchemaList(schemaListCopy); + return false; + } + + // build the datamodel for this WSDLElement + wsdlElement.buildModel(); + + // Select a new node if the previous selected node no longer exists + // If there is more than 1 service node, select the WSDL node. If there is more than 1 binding node, select the service node. + // If there is just the one service and binding node, select the binding node. + Node node = nodeManager.getNode(selectedNodeID); + if (node == null) { + selectedNodeID = wsdlNode.getNodeId(); + Vector serviceNodes = wsdlNode.getChildNodes(); + if (serviceNodes.size() == 1) + { + Node serviceNode = (Node)serviceNodes.elementAt(0); + Vector bindingNodes = serviceNode.getChildNodes(); + if (bindingNodes.size() == 1) + { + Node bindingNode = (Node)bindingNodes.elementAt(0); + selectedNodeID = bindingNode.getNodeId(); + } + else + selectedNodeID = serviceNode.getNodeId(); + } + nodeManager.setSelectedNodeId(selectedNodeID); + nodeManager.makeNodeVisible(nodeManager.getNode(selectedNodeID)); + } + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_INFO_REFRESH_WSDL_SUCCESSFUL", wsdlElement.getWsdlUrl())); + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ResizeWSDLFramesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ResizeWSDLFramesAction.java new file mode 100644 index 000000000..3b67ae977 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ResizeWSDLFramesAction.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; + +public class ResizeWSDLFramesAction extends ResizeFramesAction +{ + public ResizeWSDLFramesAction(Controller controller) + { + super(controller); + } + + protected boolean processOthers(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(WSDLActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(WSDLActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(WSDLActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(WSDLActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + // Save the current frameset sizes. + String frameName = (String)propertyTable_.get(ActionInputs.FRAME_NAME); + String perspectiveContentFramesetCols = (String)propertyTable_.get(WSDLActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(WSDLActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + + // Set the new frameset sizes. + boolean saveFrameSettings = false; + if (frameName.equals(WSDLFrameNames.WSDL_NAVIGATOR_CONTAINER)) + { + wsdlPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + wsdlPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + if (perspectiveContentFramesetCols.startsWith("100%")) + { + // Restore. + wsdlPerspective.setPerspectiveContentFramesetCols(wsdlPerspective.getSavedPerspectiveContentFramesetCols()); + } + else + { + // Maximize. + wsdlPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsdlPerspective.setPerspectiveContentFramesetCols("100%,0%"); + } + } + else if (frameName.equals(WSDLFrameNames.WSDL_PROPERTIES_CONTAINER)) + { + if (actionsContainerFramesetRows.startsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + wsdlPerspective.setPerspectiveContentFramesetCols(wsdlPerspective.getSavedPerspectiveContentFramesetCols()); + wsdlPerspective.setActionsContainerFramesetRows(wsdlPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + wsdlPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsdlPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsdlPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + wsdlPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsdlPerspective.setActionsContainerFramesetRows("100%,0%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + wsdlPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsdlPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + else if (frameName.equals(WSDLFrameNames.WSDL_STATUS_CONTAINER)) + { + if (actionsContainerFramesetRows.endsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + wsdlPerspective.setPerspectiveContentFramesetCols(wsdlPerspective.getSavedPerspectiveContentFramesetCols()); + wsdlPerspective.setActionsContainerFramesetRows(wsdlPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + wsdlPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsdlPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsdlPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + wsdlPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsdlPerspective.setActionsContainerFramesetRows("0%,100%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + wsdlPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsdlPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SelectWSDLNavigatorNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SelectWSDLNavigatorNodeAction.java new file mode 100644 index 000000000..94af20b05 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SelectWSDLNavigatorNodeAction.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.SelectNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectWSDLNavigatorNodeAction extends SelectNodeAction +{ + + public SelectWSDLNavigatorNodeAction(Controller controller) + { + super(controller,controller.getWSDLPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeID, boolean forHistory) + { + StringBuffer actionLink = new StringBuffer("wsdl/actions/SelectWSDLNavigatorNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeID); + if (forHistory) + actionLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + ToolManager toolManager = selectedNode_.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + int nodeId = selectedNode_.getNodeId(); + int toolId = selectedTool.getToolId(); + int viewId = selectedNode_.getViewId(); + int viewToolId = selectedNode_.getViewToolId(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return selectedTool.getSelectToolActionHref(true); + else + return getActionLink(nodeId,true); + } + + public final String getTreeContentVar() { + return "wsdlNavigatorContent"; + } + + public final String getTreeContentPage() { + return "wsdl/wsdl_navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() { + return "wsdlPropertiesContainer"; + } + + public final String getPropertiesContainerPage() { + return "wsdl/wsdl_properties_container.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSDL; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SelectWSDLPropertiesToolAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SelectWSDLPropertiesToolAction.java new file mode 100644 index 000000000..89d53cafd --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SelectWSDLPropertiesToolAction.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.SelectNodeToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectWSDLPropertiesToolAction extends SelectNodeToolAction +{ + + public SelectWSDLPropertiesToolAction(Controller controller) + { + super(controller, controller.getWSDLPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID, boolean keepHistory) + { + StringBuffer actionLink = new StringBuffer("wsdl/actions/SelectWSDLPropertiesToolActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + if (viewID != ActionInputs.VIEWID_DEFAULT) { + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + } + if (keepHistory) { + actionLink.append('&'); + actionLink.append(ActionInputs.ISHISTORY); + actionLink.append("=1"); + } + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + int nodeId = selectedNode_.getNodeId(); + int toolId = selectedTool_.getToolId(); + int viewId = selectedNode_.getViewId(); + int viewToolId = selectedNode_.getViewToolId(); + return getActionLink(nodeId,toolId,viewId,viewToolId,true); + } + + public final String getTreeContentVar() { + return "wsdlNavigatorContent"; + } + + public final String getTreeContentPage() { + return "wsdl/wsdl_navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() { + return "wsdlPropertiesContainer"; + } + + public final String getPropertiesContainerPage() { + return "wsdl/wsdl_properties_container.jsp"; + } + + public final String getPropertiesContentVar() { + return "wsdlPropertiesContent"; + } + + public final String getPropertiesContentPage() { + return "wsdl/wsdl_properties_content.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSDL; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SwitchPerspectiveFromWSDLAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SwitchPerspectiveFromWSDLAction.java new file mode 100644 index 000000000..920c57352 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SwitchPerspectiveFromWSDLAction.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; + +public final class SwitchPerspectiveFromWSDLAction extends ShowPerspectiveAction +{ + public SwitchPerspectiveFromWSDLAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(WSDLActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(WSDLActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(WSDLActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(WSDLActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + String perspectiveContentFramesetCols = (String)propertyTable_.get(WSDLActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(WSDLActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + + // Save the frameset sizes iff no frame is maximized. + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + if (!perspectiveContentFramesetCols.startsWith("100%") && !perspectiveContentFramesetCols.endsWith("100%")) + wsdlPerspective.setPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + + if (!actionsContainerFramesetRows.startsWith("100%") && !actionsContainerFramesetRows.endsWith("100%")) + wsdlPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + + return super.run(); + } + + public static final String getFormActionLink(int targetPerspectiveId,boolean forHistory) + { + StringBuffer formLink = new StringBuffer("wsdl/actions/SwitchPerspectiveFromWSDLActionJSP.jsp?"); + formLink.append(ActionInputs.PERSPECTIVE).append('=').append(targetPerspectiveId); + if (forHistory) + formLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return formLink.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java new file mode 100644 index 000000000..8ed578f9f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/SynchronizeFragmentViewsAction.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.*; + +import javax.wsdl.*; +import java.util.*; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class SynchronizeFragmentViewsAction extends WSDLPropertiesFormAction +{ + public SynchronizeFragmentViewsAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + super.processParsedResults(parser); + Node selectedNode = getSelectedNavigatorNode(); + WSDLOperationElement operElement = (WSDLOperationElement)selectedNode.getTreeElement(); + Iterator it = operElement.getOrderedBodyParts().iterator(); + InvokeWSDLOperationTool invokeWSDLOperationTool = (InvokeWSDLOperationTool)(selectedNode.getCurrentToolManager().getSelectedTool()); + String viewID = parser.getParameter(FragmentConstants.FRAGMENT_VIEW_ID); + propertyTable_.put(FragmentConstants.FRAGMENT_VIEW_ID, viewID); + if (viewID.equals(FragmentConstants.FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE)) + { + invokeWSDLOperationTool.setFragmentViewID(FragmentConstants.FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE); + return processFormViewParsedResults(parser, operElement, it); + } + else + { + invokeWSDLOperationTool.setFragmentViewID(FragmentConstants.FRAGMENT_VIEW_SWITCH_SOURCE_TO_FORM); + return processSourceViewParsedResults(parser, operElement, it); + } + } + + private boolean processFormViewParsedResults(MultipartFormDataParser parser, WSDLOperationElement operElement, Iterator it) throws MultipartFormDataException + { + operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT, null); + operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE, null); + boolean resultsValid = true; + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = operElement.getFragment(part); + if (!frag.processParameterValues(parser)) + resultsValid = false; + } + if (resultsValid) + operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT,null); + return resultsValid; + } + + private boolean processSourceViewParsedResults(MultipartFormDataParser parser, WSDLOperationElement operElement, Iterator it) throws MultipartFormDataException + { + String sourceContent = parser.getParameter(FragmentConstants.SOURCE_CONTENT); + if (sourceContent != null) + operElement.setPropertyAsString(WSDLModelConstants.PROP_SOURCE_CONTENT, sourceContent); + String[] nsDeclarations = parser.getParameterValues(FragmentConstants.SOURCE_CONTENT_NAMESPACE); + if (nsDeclarations != null) + operElement.setPropertyAsObject(WSDLModelConstants.PROP_SOURCE_CONTENT_NAMESPACE,nsDeclarations); + sourceContent = addRootElement(sourceContent); + try + { + Element sourceElements = XMLUtils.stringToElement(sourceContent); + NodeList nl = sourceElements.getChildNodes(); + Vector elementsVector = new Vector(); + for (int i = 0; i < nl.getLength(); i++) + { + org.w3c.dom.Node node = nl.item(i); + if (node != null && node instanceof Element) + elementsVector.add(node); + } + Element[] instanceDocuments = new Element[elementsVector.size()]; + elementsVector.copyInto(instanceDocuments); + boolean sourceElementsValid = true; + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = operElement.getFragment(part); + if (!frag.setParameterValuesFromInstanceDocuments(instanceDocuments)) + sourceElementsValid = false; + } + return sourceElementsValid; + } + catch (Throwable t) + { + return false; + } + } + + private String addRootElement(String element) + { + StringBuffer sb = new StringBuffer(); + sb.append(FragmentConstants.ROOT_ELEMENT_START_TAG); + sb.append(element); + sb.append(FragmentConstants.ROOT_ELEMENT_END_TAG); + return sb.toString(); + } + + public boolean run() { + return true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ToggleWSDLNavigatorNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ToggleWSDLNavigatorNodeAction.java new file mode 100644 index 000000000..42a6e4b82 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/ToggleWSDLNavigatorNodeAction.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class ToggleWSDLNavigatorNodeAction extends ToggleNodeAction +{ + public ToggleWSDLNavigatorNodeAction(Controller controller) + { + super(controller,controller.getWSDLPerspective().getNodeManager()); + } + + // uddi/actions/ToggleNavigatorNodeAction.jsp?nodeId=...&open=... + public static String getActionLink(int nodeId,boolean open) + { + StringBuffer actionLink = new StringBuffer("wsdl/actions/ToggleWSDLNavigatorNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID).append('=').append(nodeId); + actionLink.append('&').append(ActionInputs.OPEN).append('=').append(open?ActionInputs.OPEN_NODE:ActionInputs.CLOSE_NODE); + return actionLink.toString(); + } + + // This should be called only to select the toggled node when, at the time of + // the collapse event, a descendant node was selected. + public final String getActionLinkForHistory() + { + ToolManager toolManager = toggledNode_.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + int nodeId = toggledNode_.getNodeId(); + int toolId = selectedTool.getToolId(); + int viewId = toggledNode_.getViewId(); + int viewToolId = toggledNode_.getViewToolId(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return SelectWSDLPropertiesToolAction.getActionLink(nodeId,toolId,viewId,viewToolId,true); + else + return SelectWSDLNavigatorNodeAction.getActionLink(nodeId,true); + } + + public final String getTreeContentVar() + { + return "wsdlNavigatorContent"; + } + + public final String getTreeContentPage() + { + return "wsdl/wsdl_navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "wsdlPropertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "wsdl/wsdl_properties_container.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSDL; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/UpdateWSDLBindingAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/UpdateWSDLBindingAction.java new file mode 100644 index 000000000..eaf6bffb9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/UpdateWSDLBindingAction.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLBindingElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.InvokeWSDLOperationTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLBindingNode; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +import java.util.Vector; +import java.util.List; +import java.util.Iterator; + +public class UpdateWSDLBindingAction extends WSDLPropertiesFormAction +{ + public UpdateWSDLBindingAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String[] nodeIds = parser.getParameterValues(ActionInputs.NODEID); + if (nodeIds == null) + nodeIds = new String[0]; + propertyTable_.put(ActionInputs.NODEID, nodeIds); + String[] endpoints = parser.getParameterValues(WSDLActionInputs.END_POINT); + if (endpoints == null) + endpoints = new String[0]; + propertyTable_.put(WSDLActionInputs.END_POINT, endpoints); + return true; + } + + public boolean run() + { + String[] nodeIds = getPropertyAsStringArray(ActionInputs.NODEID); + String[] endpoints = getPropertyAsStringArray(WSDLActionInputs.END_POINT); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + for (int i = 0; i < nodeIds.length; i++) + { + try + { + Node bindingNode = nodeManager.getNode(Integer.parseInt(nodeIds[i])); + if (bindingNode instanceof WSDLBindingNode) + { + WSDLBindingElement bindingElement = (WSDLBindingElement)bindingNode.getTreeElement(); + String[] endpointsCopy = endpoints; + bindingElement.setEndPoints(endpointsCopy); + if (endpointsCopy.length <= 0) + endpointsCopy = bindingElement.getEndPoints(); + if (endpointsCopy.length > 0) + { + Vector operationNodes = bindingNode.getChildNodes(); + for (Iterator it = operationNodes.iterator(); it.hasNext();) + { + Node operationNode = (Node)it.next(); + List tools = operationNode.getCurrentToolManager().getTools(); + for (Iterator toolsIterator = tools.iterator(); toolsIterator.hasNext();) + { + Tool tool = (Tool)toolsIterator.next(); + if (tool instanceof InvokeWSDLOperationTool) + ((InvokeWSDLOperationTool)tool).setEndPoint(endpointsCopy[0]); + } + } + } + } + } + catch (NumberFormatException nfe) + { + } + } + MessageQueue messageQueue = wsdlPerspective.getMessageQueue(); + messageQueue.addMessage(wsdlPerspective.getMessage("MSG_INFO_UPDATE_WSDL_BINDING_SUCCESSFUL")); + return true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLAddToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLAddToFavoritesAction.java new file mode 100644 index 000000000..8f00ab1c5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLAddToFavoritesAction.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LinkAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.FavoritesModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.FavoritesPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +import java.util.Enumeration; +import java.util.Hashtable; +import javax.servlet.http.*; + +public class WSDLAddToFavoritesAction extends LinkAction { + public WSDLAddToFavoritesAction(Controller controller) { + super(controller); + } + + protected boolean processLinkParameters(HttpServletRequest request) { + String nodeID = request.getParameter(ActionInputs.NODEID); + try { + Integer.parseInt(nodeID); + propertyTable_.put(ActionInputs.NODEID, nodeID); + return true; + } + catch (Throwable t) { + return false; + } + } + + public static String getActionLink(int nodeID) { + StringBuffer actionLink = new StringBuffer("wsdl/actions/WSDLCheckFavoriteExistsActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + return actionLink.toString(); + } + + public boolean favoriteExists() { + String wsdlUrl = getWsdlUrl(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_WSDL_URL, wsdlUrl); + FavoritesFolderElement favFolderElement = getFavWSDLFolderElement(); + return favFolderElement.favoriteExists(table); + } + + public boolean run() { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + String wsdlUrl = getWsdlUrl(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_WSDL_URL, wsdlUrl); + FavoritesFolderElement favFolderElement = getFavWSDLFolderElement(); + if (favFolderElement.addFavorite(table)) { + wsdlPerspective.getMessageQueue().addMessage(wsdlPerspective.getMessage("MSG_INFO_ADD_TO_FAVORITES_SUCCESSFUL", wsdlUrl)); + return true; + } + else { + wsdlPerspective.getMessageQueue().addMessage(wsdlPerspective.getMessage("MSG_ERROR_ADD_TO_FAVORITES", wsdlUrl)); + return false; + } + } + + private String getWsdlUrl() { + String nodeID = (String)propertyTable_.get(ActionInputs.NODEID); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager wsdlNodeManager = wsdlPerspective.getNodeManager(); + WSDLElement selectedElement = (WSDLElement)wsdlNodeManager.getNode(Integer.parseInt(nodeID)).getTreeElement(); + return selectedElement.getWsdlUrl(); + } + + private FavoritesFolderElement getFavWSDLFolderElement() { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager favNodeManager = favPerspective.getNodeManager(); + TreeElement favRootElement = favNodeManager.getRootNode().getTreeElement(); + Enumeration e = favRootElement.getElements(FavoritesModelConstants.REL_WSDL_SERVICE_FOLDER_NODE); + return (FavoritesFolderElement)e.nextElement(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLImportWSDLToFileSystemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLImportWSDLToFileSystemAction.java new file mode 100644 index 000000000..30e314f93 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLImportWSDLToFileSystemAction.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.actions.WSDLFileNameHelper; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +import javax.wsdl.Definition; +import java.io.OutputStream; + +public class WSDLImportWSDLToFileSystemAction extends ImportToFileSystemAction { + private Definition definition_; + private String defaultWSDLFileName_; + + public WSDLImportWSDLToFileSystemAction(Controller controller) { + super(controller); + definition_ = null; + defaultWSDLFileName_ = "temp.wsdl"; + } + + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId) { + return ImportToFileSystemAction.getActionLink(nodeId,toolId,viewId,viewToolId,"wsdl/actions/WSDLImportWSDLToFileSystemActionJSP.jsp"); + } + + public final boolean write(OutputStream os) { + return writeWSDLDefinition(os, definition_); + } + + public final String getDefaultFileName() { + return defaultWSDLFileName_; + } + + public final boolean run() { + int nodeID; + try { + nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + } + catch (NumberFormatException nfe) { + return false; + } + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node node = nodeManager.getNode(nodeID); + WSDLElement wsdlElement = (WSDLElement)node.getTreeElement(); + definition_ = wsdlElement.getDefinition(); + defaultWSDLFileName_ = WSDLFileNameHelper.getWSDLFileName(wsdlElement.getWsdlUrl()); + return (definition_ != null); + } + + public final String getStatusContentVar() { + return controller_.getWSDLPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() { + return controller_.getWSDLPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLImportWSDLToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLImportWSDLToWorkbenchAction.java new file mode 100644 index 000000000..ed9c54bf7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLImportWSDLToWorkbenchAction.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToWorkbenchAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +import java.util.Hashtable; + +public class WSDLImportWSDLToWorkbenchAction extends ImportToWorkbenchAction { + public WSDLImportWSDLToWorkbenchAction(Controller controller) { + super(controller); + } + + public FormTool getSelectedFormTool() { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + return (FormTool)wsdlPerspective.getNodeManager().getSelectedNode().getCurrentToolManager().getSelectedTool(); + } + + public ImportToFileSystemAction newImportToFileSystemAction() { + WSDLImportWSDLToFileSystemAction action = new WSDLImportWSDLToFileSystemAction(controller_); + Hashtable table = action.getPropertyTable(); + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + table.put(ActionInputs.NODEID, String.valueOf(selectedNode.getNodeId())); + return action; + } + + public final String getStatusContentVar() { + return controller_.getWSDLPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() { + return controller_.getWSDLPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLLaunchWebServiceWizardAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLLaunchWebServiceWizardAction.java new file mode 100644 index 000000000..681b90aef --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLLaunchWebServiceWizardAction.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LaunchWebServiceWizardAction; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective; + +public class WSDLLaunchWebServiceWizardAction extends LaunchWebServiceWizardAction { + + public WSDLLaunchWebServiceWizardAction(Controller controller) { + super(controller); + } + + public FormTool getSelectedFormTool() { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + return (FormTool)wsdlPerspective.getNodeManager().getSelectedNode().getCurrentToolManager().getSelectedTool(); + } + + public boolean run() { + WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective(); + NodeManager nodeManager = wsdlPerspective.getNodeManager(); + Node node = nodeManager.getSelectedNode(); + WSDLElement element = (WSDLElement)node.getTreeElement(); + return launchWizard(element.getWsdlUrl()); + } + + public final String getStatusContentVar() { + return controller_.getWSDLPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() { + return controller_.getWSDLPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLPropertiesFormAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLPropertiesFormAction.java new file mode 100644 index 000000000..cf6685d53 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/actions/WSDLPropertiesFormAction.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; + +public abstract class WSDLPropertiesFormAction extends FormAction +{ + protected NodeManager navigatorManager_; + public WSDLPropertiesFormAction(Controller controller) + { + super(controller); + navigatorManager_ = controller.getWSDLPerspective().getNodeManager(); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String[] keys = parser.getParameterNames(); + for (int i = 0; i < keys.length; i++) + { + String[] values = parser.getParameterValues(keys[i]); + if (values != null) + { + if (values.length == 1) + propertyTable_.put(keys[i], values[0]); + else if (values.length > 1) + propertyTable_.put(keys[i], values); + } + } + return true; + } + + public Node getSelectedNavigatorNode() + { + return navigatorManager_.getSelectedNode(); + } + + public FormTool getSelectedFormTool() + { + return (FormTool)(getSelectedNavigatorNode().getCurrentToolManager().getSelectedTool()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/BindingTypes.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/BindingTypes.java new file mode 100644 index 000000000..ed8af597f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/BindingTypes.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants; + +public class BindingTypes +{ + public static final int UNSUPPORTED = -1; + public static final int SOAP = 0; + public static final int HTTP_GET = 1; + public static final int HTTP_POST = 2; + + public static final String HTTP_VERB_GET = "GET"; + public static final String HTTP_VERB_POST = "POST"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/FragmentConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/FragmentConstants.java new file mode 100644 index 000000000..145d9dad1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/FragmentConstants.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants; + +public class FragmentConstants +{ + // XSD minOccurs and maxOccurs + public static final int DEFAULT_MIN_OCCURS = 1; + public static final int DEFAULT_MAX_OCCURS = 1; + public static final int UNBOUNDED = -1; + + // WSDL style + public static final int STYLE_DOCUMENT = 0; + public static final int STYLE_RPC = 1; + + // WSDL Encoding styles + public static final int ENCODING_LITERAL = 0; + public static final int ENCODING_SOAP = 1; + public static final int ENCODING_URL = 2; // HTTP Get/Post + + // IDs used by the fragment model + public static final String ID_SEPERATOR = "::"; + public static final String INPUT_ID = "::input"; + public static final String OUTPUT_ID = "::output"; + public static final String TABLE_ID = "::tableID"; + public static final String FRAGMENT_ID = "::fragmentID"; + public static final String NAME_ANCHOR_ID = "::nameAnchorID"; + public static final String FRAGMENT_VIEW_ID = "::fragmentViewID"; + public static final String XSD_ATOMIC_ENUM_ID = "::xsdAtomicEnumID"; + public static final String XSD_ALL_GROUP_ID = "::xsdAllGroupID"; + + // Fragment view IDs + public static final String FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE = "::fragmentViewSwitchFormToSource"; + public static final String FRAGMENT_VIEW_SWITCH_SOURCE_TO_FORM = "::fragmentViewSwitchSourceToForm"; + public static final String SOURCE_CONTENT = "::sourceContent"; + public static final String SOURCE_CONTENT_NAMESPACE = "::sourceContentNS"; + + // Action input constants + public static final String NAME_ANCHOR = "nameAnchor"; + + // Namespaces contants + public static final String URI_XSD = "http://www.w3.org/2001/XMLSchema"; + public static final String URI_SOAP = "http://schemas.xmlsoap.org/soap/encoding/"; + public static final String URI_SOAP_ENV = "http://schemas.xmlsoap.org/soap/envelope/"; + public static final String URI_WSDL = "http://schemas.xmlsoap.org/wsdl/"; + public static final String URI_XSI = "http://www.w3.org/2001/XMLSchema-instance"; + public static final String SOAP_ENC_ARRAY_TYPE = "arrayType"; + public static final String XSI_TYPE = "type"; + public static final String QNAME_PREFIX = "q"; + public static final String QNAME_LOCAL_NAME_ARRAY_TYPE = "arrayType"; + public static final String QNAME_LOCAL_NAME_ARRAY = "Array"; + public static final String COLON = ":"; + public static final String QNAME_LOCAL_NAME_BODY = "Body"; + public static final String QNAME_LOCAL_NAME_FAULT = "Fault"; + + // List + public static final String LIST_SEPERATOR = " "; + + // SOAP-ENC:Array + public static final String LEFT_SQUARE_BRACKET = "["; + public static final String RIGHT_SQUARE_BRACKET = "]"; + + // XSDDefaultFragment + public static final String ROOT_ELEMENT_START_TAG = "<root>"; + public static final String ROOT_ELEMENT_END_TAG = "</root>"; + + // Namespace URIs. + public static final String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/"; + public static final String NS_URI_SOAP_ENV = "http://schemas.xmlsoap.org/soap/envelope/"; + public static final String NS_URI_SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/"; + public static final String NS_URI_1999_SCHEMA_XSI = "http://www.w3.org/1999/XMLSchema-instance"; + public static final String NS_URI_1999_SCHEMA_XSD = "http://www.w3.org/1999/XMLSchema"; + public static final String NS_URI_2000_SCHEMA_XSI = "http://www.w3.org/2000/10/XMLSchema-instance"; + public static final String NS_URI_2000_SCHEMA_XSD = "http://www.w3.org/2000/10/XMLSchema"; + public static final String NS_URI_2001_SCHEMA_XSI = "http://www.w3.org/2001/XMLSchema-instance"; + public static final String NS_URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; + public static final String NS_URI_CURRENT_SCHEMA_XSI = NS_URI_2001_SCHEMA_XSI; + public static final String NS_URI_CURRENT_SCHEMA_XSD = NS_URI_2001_SCHEMA_XSD; + public static final String NS_URI_XML_SOAP = "http://xml.apache.org/xml-soap"; + public static final String NS_URI_XML_SOAP_DEPLOYMENT = "http://xml.apache.org/xml-soap/deployment"; + public static final String NS_URI_LITERAL_XML = "http://xml.apache.org/xml-soap/literalxml"; + public static final String NS_URI_XMI_ENC = "http://www.ibm.com/namespaces/xmi"; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLActionInputs.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLActionInputs.java new file mode 100644 index 000000000..341de9105 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLActionInputs.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants; + +public class WSDLActionInputs +{ + public static final String FRAMESET_COLS_PERSPECTIVE_CONTENT = "framesetColsPerspectiveContent"; + public static final String FRAMESET_ROWS_ACTIONS_CONTAINER = "framesetRowsActionsContainer"; + + public static final String SESSION_ID = "sessionID"; + public static final String FRAGMENT_ID = "fragmentID"; + + public static final String SOAP_ENVELOPE_TYPE = "soapEnvelopeType"; + public static final int SOAP_ENVELOPE_TYPE_REQUEST = 0; + public static final int SOAP_ENVELOPE_TYPE_RESPONSE = 1; + public static final String SOAP_RESPONSE_CACHED = "soapResponseCached"; + + public static final String SUBMISSION_ACTION = "submissionAction"; + public static final String SUBMISSION_ACTION_FORM = "submissionActionForm"; + public static final String SUBMISSION_ACTION_BROWSE_FILE = "submissionActionBrowseFile"; + public static final String SUBMISSION_ACTION_SAVE_AS = "submissionActionSaveAs"; + public static final String SELECTED_FILE = "selectedFile"; + public static final String OPERATION_ELEMENT = "operationElement"; + + public static final String END_POINT = "::endPoint"; + public static final String HTTP_BASIC_AUTH_USERNAME = "httpBasicAuthUsername"; + public static final String HTTP_BASIC_AUTH_PASSWORD = "httpBasicAuthPassword"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLFrameNames.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLFrameNames.java new file mode 100644 index 000000000..29f7137e8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLFrameNames.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants; + +public class WSDLFrameNames +{ + public final static String WSDL_NAVIGATOR_CONTAINER = "wsdl_navigator_container"; + public final static String WSDL_NAVIGATOR_TOOLBAR = "wsdl_navigator_toolbar"; + public final static String WSDL_NAVIGATOR_CONTENT = "wsdl_navigator_content"; + public final static String WSDL_ACTIONS_CONTAINER = "wsdl_actions_container"; + public final static String WSDL_PROPERTIES_CONTAINER = "wsdl_properties_container"; + public final static String WSDL_PROPERTIES_TOOLBAR = "wsdl_properties_toolbar"; + public final static String WSDL_PROPERTIES_CONTENT = "wsdl_properties_content"; + public final static String WSDL_STATUS_CONTAINER = "wsdl_status_container"; + public final static String WSDL_STATUS_TOOLBAR = "wsdl_status_toolbar"; + public final static String WSDL_STATUS_CONTENT = "wsdl_status_content"; + + // XSD Info Dialog + public final static String XSD_INFO_TOOLBAR = "xsd_info_toolbar"; + public final static String XSD_INFO_CONTENT = "xsd_info_content"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java new file mode 100644 index 000000000..13b19b674 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/constants/WSDLModelConstants.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants; + +public class WSDLModelConstants +{ + // Relation + public final static String REL_WSDL = "relWSDL"; + public final static String REL_WSDL_SERVICE = "relWSDLService"; + public final static String REL_WSDL_BINDING = "relWSDLBinding"; + public final static String REL_WSDL_OPERATION = "relWSDLOperation"; + + // Documentation + public final static String PROP_DOCUMENTATION = "propDocumentation"; + + // Source Content + public final static String PROP_SOURCE_CONTENT = "propSourceContent"; + public final static String PROP_SOURCE_CONTENT_NAMESPACE = "propSourceContentNS"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/Endpoint.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/Endpoint.java new file mode 100644 index 000000000..ea3c92fd9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/Endpoint.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; + +public class Endpoint +{ + private String endpoint; + private boolean requireHTTPBasicAuth; + private String httpBasicAuthUsername; + private String httpBasicAuthPassword; + + public Endpoint() + { + endpoint = null; + requireHTTPBasicAuth = false; + httpBasicAuthUsername = null; + httpBasicAuthPassword = null; + } + + public String getEndpoint() + { + return endpoint; + } + + public void setEndpoint(String endpoint) + { + this.endpoint = endpoint; + } + + public boolean isRequireHTTPBasicAuth() + { + return requireHTTPBasicAuth; + } + + public void setRequireHTTPBasicAuth(boolean requireHTTPBasicAuth) + { + this.requireHTTPBasicAuth = requireHTTPBasicAuth; + } + + public String getHttpBasicAuthUsername() + { + return httpBasicAuthUsername; + } + + public void setHttpBasicAuthUsername(String httpBasicAuthUsername) + { + this.httpBasicAuthUsername = httpBasicAuthUsername; + } + + public String getHttpBasicAuthPassword() + { + return httpBasicAuthPassword; + } + + public void setHttpBasicAuthPassword(String httpBasicAuthPassword) + { + this.httpBasicAuthPassword = httpBasicAuthPassword; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLBindingElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLBindingElement.java new file mode 100644 index 000000000..babdcb68e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLBindingElement.java @@ -0,0 +1,226 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +import javax.xml.namespace.QName; +import javax.wsdl.extensions.soap.*; +import javax.wsdl.extensions.http.*; +import javax.wsdl.extensions.*; +import javax.wsdl.*; + +import java.util.*; + +public class WSDLBindingElement extends WSDLCommonElement +{ + private int bindingType_; + private Binding binding_; + private ExtensibilityElement bindingExtensibilityElement_; + private Vector endPoints_; + + private final void setBindingExtensibilityElement() + { + bindingExtensibilityElement_ = null; + bindingType_ = BindingTypes.UNSUPPORTED; + List extensibilityElements = binding_.getExtensibilityElements(); + for (Iterator i = extensibilityElements.iterator();i.hasNext();) + { + ExtensibilityElement e = (ExtensibilityElement)i.next(); + if (e instanceof HTTPBinding) + { + HTTPBinding binding = (HTTPBinding)e; + String verb = binding.getVerb(); + if (BindingTypes.HTTP_VERB_GET.equals(verb)) + bindingType_ = BindingTypes.HTTP_GET; + else if (BindingTypes.HTTP_VERB_POST.equals(verb)) + bindingType_ = BindingTypes.HTTP_POST; + } + else if (e instanceof SOAPBinding) + bindingType_ = BindingTypes.SOAP; + if (bindingType_ != BindingTypes.UNSUPPORTED) + { + bindingExtensibilityElement_ = e; + break; + } + } + } + + public WSDLBindingElement(String name, Model model, Binding binding) + { + super(name, model); + setBinding(binding); + endPoints_ = new Vector(); + } + + public void setBinding(Binding binding) { + binding_ = binding; + setDocumentation(binding.getDocumentationElement()); + setBindingExtensibilityElement(); + } + + public Binding getBinding() { + return binding_; + } + + public ExtensibilityElement getBindingExtensibilityElement() + { + return bindingExtensibilityElement_; + } + + public int getBindingType() + { + return bindingType_; + } + + private void resetEndPoints() + { + WSDLServiceElement serviceElement = (WSDLServiceElement)getParentElement(); + String fixedEndpointString = serviceElement.getAddressLocation(binding_); + Endpoint fixedEndpoint = getEndpoint(fixedEndpointString); + if (fixedEndpoint == null) + { + fixedEndpoint = new Endpoint(); + fixedEndpoint.setEndpoint(fixedEndpointString); + } + endPoints_.clear(); + endPoints_.add(fixedEndpoint); + } + + public String[] getEndPoints() + { + String[] endPoints = new String[endPoints_.size()]; + for (int i = 0; i < endPoints.length; i++) + endPoints[i] = ((Endpoint)endPoints_.get(i)).getEndpoint(); + return endPoints; + } + + public Endpoint getEndpoint(String endpointString) + { + if (endpointString != null && endpointString.length() > 0) + { + for (Iterator it = endPoints_.iterator(); it.hasNext();) + { + Endpoint endpoint = (Endpoint)it.next(); + if (endpointString.equals(endpoint.getEndpoint())) + return endpoint; + } + } + return null; + } + + public void setEndPoints(String[] endpoints) + { + Vector endpointVector = new Vector(); + for (int i = 0; i < endpoints.length; i++) + { + Endpoint endpoint = getEndpoint(endpoints[i]); + if (endpoint == null) + { + endpoint = new Endpoint(); + endpoint.setEndpoint(endpoints[i]); + } + endpointVector.add(endpoint); + } + resetEndPoints(); + endPoints_.addAll(endpointVector); + } + + public void addEndPoint(String endpointString) + { + if (endpointString != null && endpointString.length() > 0) + { + Endpoint endpoint = new Endpoint(); + endpoint.setEndpoint(endpointString); + endPoints_.add(endpoint); + } + } + + public void removeEndPoint(String endpointString) + { + if (endpointString != null && endpointString.length() > 0) + { + WSDLServiceElement serviceElement = (WSDLServiceElement)getParentElement(); + String fixedEndpointString = serviceElement.getAddressLocation(binding_); + if (fixedEndpointString == null || !fixedEndpointString.equals(endpointString)) + { + for (int i = 0; i < endPoints_.size(); i++) + { + if (endpointString.equals(((Endpoint)endPoints_.get(i)).getEndpoint())) + { + endPoints_.remove(i); + break; + } + } + } + } + } + + public void buildModel() { + resetEndPoints(); + if (binding_ != null) { + PortType pt = binding_.getPortType(); + if (pt != null) { + List operations = pt.getOperations(); + HashMap operationsMap = new HashMap(); + for (Iterator it = operations.iterator();it.hasNext();) { + Operation operation = (Operation)it.next(); + operationsMap.put(createOperationUniqueName(operation), operation); + } + WSDLOperationElement[] wsdlOperationElements = new WSDLOperationElement[getNumberOfElements(WSDLModelConstants.REL_WSDL_OPERATION)]; + Enumeration e = getElements(WSDLModelConstants.REL_WSDL_OPERATION); + for (int i = 0; i < wsdlOperationElements.length; i++) { + wsdlOperationElements[i] = (WSDLOperationElement)e.nextElement(); + } + for (int j = 0; j < wsdlOperationElements.length; j++) { + String operationName = createOperationUniqueName(wsdlOperationElements[j].getOperation()); + Operation operation = (Operation)operationsMap.get(operationName); + if (operation != null) { + operationsMap.remove(operationName); + wsdlOperationElements[j].setOperation(this, operation); + } + else + disconnect(wsdlOperationElements[j], WSDLModelConstants.REL_WSDL_OPERATION); + } + for (Iterator it = operationsMap.values().iterator();it.hasNext();) { + Operation oper = (Operation)it.next(); + WSDLOperationElement wsdlOperationElement = new WSDLOperationElement(oper.getName(), this, oper); + connect(wsdlOperationElement,WSDLModelConstants.REL_WSDL_OPERATION,ModelConstants.REL_OWNER); + } + } + } + } + + private String createOperationUniqueName(Operation operation) + { + StringBuffer name = new StringBuffer(); + name.append(operation.getName()); + Input inputMsg = operation.getInput(); + if (inputMsg != null) + { + QName qname = inputMsg.getMessage().getQName(); + name.append(qname.getNamespaceURI()); + name.append(":"); + name.append(qname.getLocalPart()); + } + Output outputMsg = operation.getOutput(); + if (outputMsg != null) + { + QName qname = outputMsg.getMessage().getQName(); + name.append(qname.getNamespaceURI()); + name.append(":"); + name.append(qname.getLocalPart()); + } + return name.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLCommonElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLCommonElement.java new file mode 100644 index 000000000..5016477fa --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLCommonElement.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +import org.w3c.dom.*; + +import javax.xml.parsers.*; + +public class WSDLCommonElement extends TreeElement +{ + + public WSDLCommonElement(String name, Model model) { + super(name, model); + } + + public final TreeElement getParentElement() { + return (TreeElement)getElements(ModelConstants.REL_OWNER).nextElement(); + } + + protected final void setDocumentation(Node documentationElement) + { + String documentation = ""; + try + { + if (documentationElement != null) + { + Document doc = XMLUtils.createNewDocument(null); + DocumentFragment df = doc.createDocumentFragment(); + NodeList documentationNodes = documentationElement.getChildNodes(); + for (int i=0;i<documentationNodes.getLength();i++) + df.appendChild(doc.importNode(documentationNodes.item(i),true)); + documentation = XMLUtils.serialize(df,true); + } + } + catch (ParserConfigurationException e) + { + } + setPropertyAsString(WSDLModelConstants.PROP_DOCUMENTATION,documentation); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java new file mode 100644 index 000000000..777ddb419 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java @@ -0,0 +1,326 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.parser.discovery.*; +import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; +import org.eclipse.wst.wsdl.internal.impl.XSDSchemaExtensibilityElementImpl; + +import org.eclipse.xsd.util.*; +import org.eclipse.xsd.impl.*; +import org.eclipse.xsd.*; +import org.eclipse.emf.common.util.EList; + +import javax.xml.namespace.QName; +import javax.wsdl.extensions.*; +import javax.wsdl.*; +import java.util.*; +import java.io.*; + +public class WSDLElement extends WSDLCommonElement +{ + + private String wsdlUrl_; + private Definition definition_; + private Vector schemaList_; + + private static Vector w3SchemaQNameList_; + private static Vector constantSchemaList_; + + static + { + // w3 schema URI list: + // http://www.w3.org/2001/XMLSchema + // http://www.w3.org/2000/10/XMLSchema + // http://www.w3.org/1999/XMLSchema + w3SchemaQNameList_ = new Vector(); + w3SchemaQNameList_.addElement(new QName(FragmentConstants.NS_URI_CURRENT_SCHEMA_XSD,"schema")); + w3SchemaQNameList_.addElement(new QName(FragmentConstants.NS_URI_2000_SCHEMA_XSD,"schema")); + w3SchemaQNameList_.addElement(new QName(FragmentConstants.NS_URI_1999_SCHEMA_XSD,"schema")); + + // Constant schema URI list: + // http://www.w3.org/2001/XMLSchema + // http://www.w3.org/2000/10/XMLSchema + // http://www.w3.org/1999/XMLSchema + // http://schemas.xmlsoap.org/soap/encoding/ + // http://schemas.xmlsoap.org/wsdl/ + constantSchemaList_ = new Vector(); + constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_CURRENT_SCHEMA_XSD)); + constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_2000_SCHEMA_XSD)); + constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_1999_SCHEMA_XSD)); + constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.NS_URI_SOAP_ENC)); + constantSchemaList_.addElement(XSDSchemaImpl.getSchemaForSchema(FragmentConstants.URI_WSDL)); + } + + public WSDLElement(String name, Model model, String wsdlUrl) + { + super(name, model); + wsdlUrl_ = wsdlUrl; + definition_ = null; + schemaList_ = new Vector(); + } + + public void setWsdlUrl(String wsdlUrl) { + wsdlUrl_ = wsdlUrl; + } + + public String getWsdlUrl() { + return wsdlUrl_; + } + + public void setSchemaList(Vector schemaList) + { + schemaList_ = schemaList; + } + + public Vector getSchemaList() + { + return schemaList_; + } + + private final Definition loadWSDL(String wsdlURL) throws WSDLException + { + WebServicesParser parser = new WebServicesParserExt(); + try + { + return parser.getWSDLDefinitionVerbose(wsdlURL); + } + catch (WSDLException wsdle) + { + throw wsdle; + } + catch (Throwable t) + { + throw new WSDLException(WSDLException.OTHER_ERROR , t.getMessage(), t); + } + } + + public Vector loadWSDL() throws WSDLException + { + Vector errorMessages = new Vector(); + definition_ = loadWSDL(wsdlUrl_); + if (definition_ != null) + { + setDocumentation(definition_.getDocumentationElement()); + gatherSchemas(definition_, wsdlUrl_); + // Validate the schemas. + for (int i=0;i<schemaList_.size();i++) + { + XSDSchema xsdSchema = (XSDSchema)schemaList_.elementAt(i); + xsdSchema.validate(); + EList errors = xsdSchema.getAllDiagnostics(); + if (!errors.isEmpty()) + { + for (ListIterator li = errors.listIterator();li.hasNext();) + { + XSDDiagnostic xd = (XSDDiagnostic)li.next(); + String msg = xd.getMessage(); + // do not report low severity diagnostics or erroneous array reference errors. + if (xd.getSeverity().getValue() == XSDDiagnosticSeverity.FATAL_LITERAL.getValue() || (msg != null && msg.length() > 0 && msg.toLowerCase().indexOf("#array") != -1)) + li.remove(); + else + { + if (msg != null && msg.length() > 0) + errorMessages.addElement(xd.getMessage()); + } + } + } + } + + for (int i=0;i<constantSchemaList_.size();i++) + schemaList_.addElement(constantSchemaList_.elementAt(i)); + } + return errorMessages; + } + + private final void gatherSchemas(Definition definition, String definitionURL) + { + Types types = definition.getTypes(); + if (types != null) + { + List extTypes = types.getExtensibilityElements(); + if (extTypes != null) + { + for (int i=0;i<extTypes.size();i++) + { + Object obj = extTypes.get(i); + if (obj instanceof UnknownExtensibilityElement) + { + UnknownExtensibilityElement schemaElement = (UnknownExtensibilityElement)obj; + if (isW3SchemaElementType(schemaElement.getElementType())) + { + XSDSchema xsdSchema = XSDSchemaImpl.createSchema(schemaElement.getElement()); + schemaList_.addElement(xsdSchema); + gatherSchemaDirective(xsdSchema, definitionURL); + } + } + else if (obj instanceof XSDSchemaExtensibilityElementImpl) + { + XSDSchemaExtensibilityElementImpl schemaElement = (XSDSchemaExtensibilityElementImpl)obj; + XSDSchema xsdSchema = XSDSchemaImpl.createSchema(schemaElement.getElement()); + schemaList_.addElement(xsdSchema); + gatherSchemaDirective(xsdSchema, definitionURL); + } + } + } + } + Map imports = definition.getImports(); + if (imports != null) + gatherImportedSchemas(definition,imports); + } + + private final void gatherSchemaDirective(XSDSchema xsdSchema, String xsdSchemaURL) + { + if (xsdSchema != null) + { + EList xsdSchemaContents = xsdSchema.getContents(); + for (Iterator it = xsdSchemaContents.iterator(); it.hasNext();) + { + Object content = it.next(); + if (content instanceof XSDSchemaDirective) + { + XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)content; + StringBuffer xsdSchemaDirectiveURL = new StringBuffer(); + String xsdSchemaDirectiveLocation = xsdSchemaDirective.getSchemaLocation(); + if (xsdSchemaDirectiveLocation != null && xsdSchemaDirectiveLocation.indexOf(':') == -1 && xsdSchemaURL != null && xsdSchemaURL.indexOf(':') != -1) + { + // relative URL + int index = xsdSchemaURL.lastIndexOf('/'); + if (index != -1) + xsdSchemaDirectiveURL.append(xsdSchemaURL.substring(0, index+1)); + else + { + xsdSchemaDirectiveURL.append(xsdSchemaURL); + xsdSchemaDirectiveURL.append('/'); + } + } + xsdSchemaDirectiveURL.append(xsdSchemaDirectiveLocation); + // resolve schema directive + XSDSchema resolvedSchema = xsdSchemaDirective.getResolvedSchema(); + if (resolvedSchema == null && xsdSchemaDirectiveURL.length() > 0) + resolvedSchema = getSchema(xsdSchemaDirectiveURL.toString()); + if (resolvedSchema != null) + { + schemaList_.addElement(resolvedSchema); + gatherSchemaDirective(resolvedSchema, xsdSchemaDirectiveURL.toString()); + } + } + } + } + } + + private final boolean isW3SchemaElementType(QName qname) + { + for (int i=0;i<w3SchemaQNameList_.size();i++) + { + QName w3SchemaQName = (QName)w3SchemaQNameList_.elementAt(i); + if (w3SchemaQName.equals(qname)) + return true; + } + return false; + } + + private final void gatherImportedSchemas(Definition definition,Map imports) + { + for (Iterator iterator = imports.keySet().iterator();iterator.hasNext();) + { + List importList = (List)imports.get(iterator.next()); + for (int i=0;i<importList.size();i++) + { + Import imp = (Import)importList.get(i); + StringBuffer locURI = new StringBuffer(imp.getLocationURI()); + if (!Validator.validateURL(locURI.toString())) + { + String base = definition.getDocumentBaseURI(); + locURI.insert(0,base.substring(0,base.lastIndexOf('/')+1)); + } + try + { + Definition importDef = loadWSDL(locURI.toString()); + gatherSchemas(importDef, locURI.toString()); + } + catch (WSDLException e) + { + // May be an XSD file. + gatherSchema(locURI.toString()); + } + } + } + } + + private final void gatherSchema(String locURI) + { + XSDSchema xsdSchema = getSchema(locURI); + if (xsdSchema != null) + { + schemaList_.addElement(xsdSchema); + gatherSchemaDirective(xsdSchema, locURI); + } + } + + private final XSDSchema getSchema(String locURI) + { + XSDSchema xsdSchema = XSDSchemaImpl.getSchemaForSchema(locURI); + if (xsdSchema == null) + { + XSDParser p = new XSDParser(); + InputStream is = NetUtils.getURLInputStream(locURI); + if (is != null) + { + p.parse(is); + xsdSchema = p.getSchema(); + } + } + return xsdSchema; + } + + public void setDefinition(Definition definition) + { + definition_ = definition; + } + + public Definition getDefinition() + { + return definition_; + } + + public void buildModel() { + if (definition_ != null) { + Map services = new HashMap(definition_.getServices()); + WSDLServiceElement[] wsdlServiceElements = new WSDLServiceElement[getNumberOfElements(WSDLModelConstants.REL_WSDL_SERVICE)]; + Enumeration e = getElements(WSDLModelConstants.REL_WSDL_SERVICE); + for (int i = 0; i < wsdlServiceElements.length; i++) { + wsdlServiceElements[i] = (WSDLServiceElement)e.nextElement(); + } + for (int j = 0; j < wsdlServiceElements.length; j++) { + QName qname = wsdlServiceElements[j].getService().getQName(); + Service service = (Service)services.get(qname); + if (service != null) { + services.remove(qname); + wsdlServiceElements[j].setService(service); + wsdlServiceElements[j].buildModel(); + } + else + disconnect(wsdlServiceElements[j], WSDLModelConstants.REL_WSDL_SERVICE); + } + for (Iterator it = services.values().iterator();it.hasNext();) { + Service service = (Service)it.next(); + WSDLServiceElement wsdlServiceElement = new WSDLServiceElement(service.getQName().getLocalPart(), getModel(), service); + connect(wsdlServiceElement,WSDLModelConstants.REL_WSDL_SERVICE,ModelConstants.REL_OWNER); + wsdlServiceElement.buildModel(); + } + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java new file mode 100644 index 000000000..d1a102163 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLOperationElement.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.*; + +import javax.wsdl.extensions.soap.*; +import javax.wsdl.extensions.*; +import javax.wsdl.*; + +import java.util.*; + +public class WSDLOperationElement extends WSDLCommonElement +{ + public static final int OPERATION_TYPE_SOAP = 0; + public static final int OPERATION_TYPE_HTTP_GET = 1; + public static final int OPERATION_TYPE_HTTP_POST = 2; + + private int operationType_; + private Operation operation_; + private WSDLPartsToXSDTypeMapper wsdlPartsToXsdTypeMapper_; + private XSDToFragmentController fragController_; + private boolean isDocumentStyle_; + private boolean isUseLiteral_; + private String soapAction_; + private String encodingStyle_; + private String encodingNamespace_; + + private final void gatherSoapInformation(WSDLBindingElement bindingElement,SOAPBinding soapBinding) + { + // Initialize defaults. + isDocumentStyle_ = true; + soapAction_ = ""; + isUseLiteral_ = true; + encodingStyle_ = null; + encodingNamespace_ = null; + + Binding binding = bindingElement.getBinding(); + if (soapBinding != null) + isDocumentStyle_ = "document".equals(soapBinding.getStyle()); + BindingOperation bindingOperation = getBindingOperation(bindingElement); + SOAPOperation soapOperation = null; + String soapAction = ""; + for (Iterator i = bindingOperation.getExtensibilityElements().iterator();i.hasNext();) + { + ExtensibilityElement e = (ExtensibilityElement)i.next(); + if (e instanceof SOAPOperation) + { + soapOperation = (SOAPOperation)e; + soapAction_ = soapOperation.getSoapActionURI(); + String style = soapOperation.getStyle(); + if (style != null) + isDocumentStyle_ = style.equals("document"); + break; + } + } + + BindingInput bindingInput = bindingOperation.getBindingInput(); + SOAPBody soapBody = null; + for (Iterator i = bindingInput.getExtensibilityElements().iterator();i.hasNext();) + { + ExtensibilityElement e = (ExtensibilityElement)i.next(); + if (e instanceof SOAPBody) + { + soapBody = (SOAPBody)e; + isUseLiteral_ = "literal".equals(soapBody.getUse()); + if (!isUseLiteral_) + { + // Encoded. + for (Iterator j = soapBody.getEncodingStyles().iterator();j.hasNext();) + { + encodingStyle_ = (String)j.next(); + encodingNamespace_ = soapBody.getNamespaceURI(); + break; + } + } + break; + } + } + } + + public WSDLOperationElement(String name,WSDLBindingElement bindingElement,Operation operation) + { + super(name, bindingElement.getModel()); + // Set the default operation type to be SOAP. + setOperation(bindingElement,operation); + } + + public void setOperation(WSDLBindingElement bindingElement,Operation operation) { + operation_ = operation; + setDocumentation(operation.getDocumentationElement()); + fragController_ = null; + wsdlPartsToXsdTypeMapper_ = null; + operationType_ = bindingElement.getBindingType(); + ExtensibilityElement bindingExtensibilityElement = bindingElement.getBindingExtensibilityElement(); + switch (operationType_) + { + case BindingTypes.SOAP: + gatherSoapInformation(bindingElement,(SOAPBinding)bindingExtensibilityElement); + case BindingTypes.HTTP_GET: + case BindingTypes.HTTP_POST: + default: + break; + } + } + + public Operation getOperation() { + return operation_; + } + + public BindingOperation getBindingOperation() + { + return getBindingOperation((WSDLBindingElement)getParentElement()); + } + + private BindingOperation getBindingOperation(WSDLBindingElement bindingElement) + { + Binding binding = bindingElement.getBinding(); + String operationInputName = null; + String operationOutputName = null; + Input operationInput = operation_.getInput(); + Output operationOutput = operation_.getOutput(); + if (operationInput != null) + operationInputName = operationInput.getName(); + if (operationOutput != null) + operationOutputName = operationOutput.getName(); + BindingOperation bindingOperation = binding.getBindingOperation(operation_.getName(),operationInputName,operationOutputName); + if (bindingOperation == null) + bindingOperation = binding.getBindingOperation(operation_.getName(),null,null); + return bindingOperation; + } + + public List getOrderedBodyParts() + { + List parts = new Vector(operation_.getInput().getMessage().getOrderedParts(operation_.getParameterOrdering())); + BindingOperation bindingOperation = getBindingOperation(); + BindingInput bindingInput = bindingOperation.getBindingInput(); + for (Iterator it = bindingInput.getExtensibilityElements().iterator(); it.hasNext();) + { + ExtensibilityElement e = (ExtensibilityElement)it.next(); + if (e instanceof SOAPBody) + { + SOAPBody soapBody = (SOAPBody)e; + List bodyParts = soapBody.getParts(); + if (bodyParts != null) + { + for (int i = 0; i < parts.size(); i++) + { + Part part = (Part)parts.get(i); + if (!bodyParts.contains(part) && !bodyParts.contains(part.getName())) + { + parts.remove(i); + i--; + } + } + } + break; + } + } + return parts; + } + + private XSDToFragmentController getXSDToFragmentController() { + if (fragController_ == null) { + fragController_ = new XSDToFragmentController(); + fragController_.setWSDLPartsToXSDTypeMapper(wsdlPartsToXsdTypeMapper_); + } + return fragController_; + } + + private XSDNamedComponent getSchema(Part part, String id) { + if (wsdlPartsToXsdTypeMapper_ == null) { + wsdlPartsToXsdTypeMapper_ = new WSDLPartsToXSDTypeMapper(); + WSDLBindingElement bindingElement = (WSDLBindingElement)getParentElement(); + WSDLServiceElement serviceElement = (WSDLServiceElement)bindingElement.getParentElement(); + WSDLElement wsdlElement = (WSDLElement)serviceElement.getParentElement(); + wsdlPartsToXsdTypeMapper_.addSchemas(wsdlElement.getSchemaList()); + } + return wsdlPartsToXsdTypeMapper_.getXSDType(part, id); + } + + public IXSDFragment getFragment(Part part) { + return getFragment(part, true); + } + + public IXSDFragment getFragment(Part part, boolean isInput) { + StringBuffer id = new StringBuffer(); + if (isInput) + id.append(FragmentConstants.INPUT_ID); + else + id.append(FragmentConstants.OUTPUT_ID); + String partName = part.getName(); + id.append(partName); + XSDToFragmentConfiguration config = new XSDToFragmentConfiguration(); + config.setIsWSDLPart(true); + config.setWSDLPartName(partName); + config.setXSDComponent(getSchema(part, id.toString())); + if (isDocumentStyle()) + config.setStyle(FragmentConstants.STYLE_DOCUMENT); + else + config.setStyle(FragmentConstants.STYLE_RPC); + if (operationType_ == BindingTypes.SOAP) + { + if (!isUseLiteral_) + config.setPartEncoding(FragmentConstants.ENCODING_SOAP); + } + else + config.setPartEncoding(FragmentConstants.ENCODING_URL); + IXSDFragment fragment = getXSDToFragmentController().getFragment(config, id.toString(), part.getName()); + return fragment; + } + + public IXSDFragment getFragmentByID(String id) { + return getXSDToFragmentController().getCachedFragment(id); + } + + public void removeAllFragment() { + getXSDToFragmentController().emptyCache(); + } + + public boolean isDocumentStyle() + { + return isDocumentStyle_; + } + + public String getSoapAction() + { + return soapAction_; + } + + public boolean isUseLiteral() + { + return isUseLiteral_; + } + + public String getEncodingStyle() + { + return encodingStyle_; + } + + public String getEncodingNamespace() + { + return encodingNamespace_; + } + + public int getOperationType() + { + return operationType_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLServiceElement.java new file mode 100644 index 000000000..7d3045679 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLServiceElement.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +import javax.xml.namespace.QName; +import javax.wsdl.extensions.soap.*; +import javax.wsdl.extensions.http.*; +import javax.wsdl.extensions.*; +import javax.wsdl.*; + +import java.util.*; + +public class WSDLServiceElement extends WSDLCommonElement +{ + + private Service service_; + + public WSDLServiceElement(String name, Model model, Service service) + { + super(name, model); + setService(service); + } + + public void setService(Service service) { + service_ = service; + setDocumentation(service.getDocumentationElement()); + } + + public Service getService() { + return service_; + } + + public String getAddressLocation(Binding binding) + { + Map ports = service_.getPorts(); + for (Iterator i = ports.values().iterator();i.hasNext();) + { + Port port = (Port)i.next(); + if (port.getBinding().getQName().equals(binding.getQName())) + { + List extensibilityElements = port.getExtensibilityElements(); + for (Iterator j = extensibilityElements.iterator();j.hasNext();) + { + ExtensibilityElement element = (ExtensibilityElement)j.next(); + if (element instanceof SOAPAddress) + { + SOAPAddress soapAddress = (SOAPAddress)element; + return soapAddress.getLocationURI(); + } + else if (element instanceof HTTPAddress) + { + HTTPAddress httpAddress = (HTTPAddress)element; + return httpAddress.getLocationURI(); + } + } + } + } + return null; + } + + public void buildModel() { + if (service_ != null) { + Map ports = service_.getPorts(); + Map bindings = new HashMap(); + for (Iterator it = ports.values().iterator();it.hasNext();) { + Port port = (Port)it.next(); + Binding binding = port.getBinding(); + if (binding.getPortType() == null) + continue; + else + bindings.put(binding.getQName(), binding); + } + WSDLBindingElement[] wsdlBindingElements = new WSDLBindingElement[getNumberOfElements(WSDLModelConstants.REL_WSDL_BINDING)]; + Enumeration e = getElements(WSDLModelConstants.REL_WSDL_BINDING); + for (int i = 0; i < wsdlBindingElements.length; i++) { + wsdlBindingElements[i] = (WSDLBindingElement)e.nextElement(); + } + for (int j = 0; j < wsdlBindingElements.length; j++) { + QName qname = wsdlBindingElements[j].getBinding().getQName(); + Binding binding = (Binding)bindings.get(qname); + if (binding != null) { + bindings.remove(qname); + wsdlBindingElements[j].setBinding(binding); + wsdlBindingElements[j].buildModel(); + } + else + disconnect(wsdlBindingElements[j], WSDLModelConstants.REL_WSDL_BINDING); + } + for (Iterator it = bindings.values().iterator();it.hasNext();) { + Binding binding = (Binding)it.next(); + WSDLBindingElement wsdlBindingElement = new WSDLBindingElement(binding.getQName().getLocalPart(), getModel(), binding); + connect(wsdlBindingElement,WSDLModelConstants.REL_WSDL_BINDING,ModelConstants.REL_OWNER); + wsdlBindingElement.buildModel(); + } + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IFragment.java new file mode 100644 index 000000000..114e13d29 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IFragment.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; + +import java.util.Vector; + +public interface IFragment { + public void setID(String id); + public String getID(); + + public void setName(String name); + public String getName(); + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException; + + public void setParameterValues(String paramKey, String[] params); + public void setParameterValues(String paramKey, Vector params); + public String[] getParameterValues(String paramKey); + public String getParameterValue(String paramKey, int paramIndex); + + public boolean validateAllParameterValues(); + public boolean validateParameterValues(String paramKey); + public boolean validateParameterValue(String paramKey, int paramIndex); + + public String getInformationFragment(); + public String getWriteFragment(); + public String getReadFragment(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/ISOAPEncArrayFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/ISOAPEncArrayFragment.java new file mode 100644 index 000000000..d30dbd5b4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/ISOAPEncArrayFragment.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface ISOAPEncArrayFragment extends IXSDGroupSeqFragment { + public String createSOAPEncArrayInstance(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/ISOAPEncodingWrapperFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/ISOAPEncodingWrapperFragment.java new file mode 100644 index 000000000..65013d94b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/ISOAPEncodingWrapperFragment.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import java.util.Hashtable; + +public interface ISOAPEncodingWrapperFragment extends IXSDDelegationFragment +{ + public void setURIReferences(Hashtable uriReferences); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDComplexFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDComplexFragment.java new file mode 100644 index 000000000..dca6da2be --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDComplexFragment.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDComplexFragment extends IXSDMapFragment { + public String createComplexInstance(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDDelegationFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDDelegationFragment.java new file mode 100644 index 000000000..eb43be581 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDDelegationFragment.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDDelegationFragment extends IXSDFragment { + public void setXSDDelegationFragment(IXSDFragment xsdFragment); + public IXSDFragment getXSDDelegationFragment(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDElementFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDElementFragment.java new file mode 100644 index 000000000..19b872b0f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDElementFragment.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDElementFragment extends IXSDDelegationFragment { + public int getMinOccurs(); + public int getMaxOccurs(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDFragment.java new file mode 100644 index 000000000..e15ae7694 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDFragment.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.xsd.XSDTypeDefinition; +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import java.util.Hashtable; + +public interface IXSDFragment extends IFragment { + public void setXSDToFragmentConfiguration(XSDToFragmentConfiguration config); + public XSDToFragmentConfiguration getXSDToFragmentConfiguration(); + + public void setXSDTypeDefinition(XSDTypeDefinition typeDef); + public XSDTypeDefinition getXSDTypeDefinition(); + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments); + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc); + + public String genID(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupAllFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupAllFragment.java new file mode 100644 index 000000000..9bd54e66e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupAllFragment.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDGroupAllFragment extends IXSDGroupFragment { + public String getGroupAllInstance(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupChoiceFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupChoiceFragment.java new file mode 100644 index 000000000..864837cc2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupChoiceFragment.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.xsd.XSDParticle; + +public interface IXSDGroupChoiceFragment extends IXSDGroupFragment { + public XSDParticle[] getChoices(); + public String createGroupChoiceInstance(int choiceIndex); + public int getChoiceIndex(String groupID); + public void setChoiceIndex(String groupID, int choiceIndex); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupFragment.java new file mode 100644 index 000000000..9da875972 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupFragment.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.xsd.XSDModelGroup; + +public interface IXSDGroupFragment extends IXSDMapFragment { + public void setXSDModelGroup(XSDModelGroup xsdModelGroup); + public XSDModelGroup getXSDModelGroup(); + + public String[] getGroupIDs(); + public String[] getGroupMemberIDs(String groupID); + public IXSDFragment[] getGroupMemberFragments(String groupID); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupSeqFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupSeqFragment.java new file mode 100644 index 000000000..614433eee --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDGroupSeqFragment.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDGroupSeqFragment extends IXSDGroupFragment { + public String createGroupSeqInstance(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDMapFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDMapFragment.java new file mode 100644 index 000000000..1a9fd3b9a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDMapFragment.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDMapFragment extends IXSDFragment { + public void setXSDToFragmentController(XSDToFragmentController controller); + public XSDToFragmentController getXSDToFragmentController(); + + public String createInstance(); + + public String[] getFragmentsOrder(); + public IXSDFragment getFragment(String id); + public IXSDFragment[] getFragments(String[] ids); + public IXSDFragment[] getAllFragments(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleAtomicFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleAtomicFragment.java new file mode 100644 index 000000000..33f97da25 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleAtomicFragment.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDSimpleAtomicFragment extends IXSDFragment { +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleListFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleListFragment.java new file mode 100644 index 000000000..00925a379 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleListFragment.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +public interface IXSDSimpleListFragment extends IXSDMapFragment { + public String createListInstance(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleUnionFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleUnionFragment.java new file mode 100644 index 000000000..ba86a1232 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/IXSDSimpleUnionFragment.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.xsd.XSDSimpleTypeDefinition; + +public interface IXSDSimpleUnionFragment extends IXSDMapFragment { + public XSDSimpleTypeDefinition[] getMemberTypeDefinitions(); + public String createUnionInstance(int memberTypeIndex); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDComplexTypeToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDComplexTypeToFragmentMapper.java new file mode 100644 index 000000000..7942721d8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDComplexTypeToFragmentMapper.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.XSDTypeDefinitionUtil; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComplexTypeContent; + +public class XSDComplexTypeToFragmentMapper extends XSDToFragmentMapper { + public XSDComplexTypeToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + super(controller, wsdlToXSDMapper); + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)config.getXSDComponent(); + if (complexType != null && complexType.isMixed()) + return getXSDDefaultFragment(config, id, name); + XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType); + if (complexTypeContent != null) + return getXSDComplexFragment(config, id, name); + else + return getXSDEmptyFragment(config, id, name); + } + + private IXSDFragment getXSDComplexFragment(XSDToFragmentConfiguration config, String id, String name) { + int minOccurs = config.getMinOccurs(); + int maxOccurs = config.getMaxOccurs(); + IXSDComplexFragment frag; + if (minOccurs == maxOccurs) + return new XSDComplexFixFragment(id, name, config, getController()); + else + return new XSDComplexRangeFragment(id, name, config, getController()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java new file mode 100644 index 000000000..bee204e91 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDElementDeclarationToFragmentMapper.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDConcreteComponent; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDTypeDefinition; + + +public class XSDElementDeclarationToFragmentMapper extends XSDToFragmentMapper { + public XSDElementDeclarationToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + super(controller, wsdlToXSDMapper); + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + XSDElementDeclaration element = (XSDElementDeclaration)config.getXSDComponent(); + if (element != null) { + XSDElementDeclaration resolvedElement = resolveXSDElementDeclaration(element); + XSDTypeDefinition typeDef = getXSDTypeDefinition(resolvedElement); + if (typeDef != null) { + int minOccurs = FragmentConstants.DEFAULT_MIN_OCCURS; + int maxOccurs = FragmentConstants.DEFAULT_MAX_OCCURS; + XSDConcreteComponent concreteComponent = element.getContainer(); + if (concreteComponent != null && concreteComponent instanceof XSDParticle) { + XSDParticle particle = (XSDParticle)concreteComponent; + if (particle.isSetMinOccurs()) + minOccurs = particle.getMinOccurs(); + if (particle.isSetMaxOccurs()) + maxOccurs = particle.getMaxOccurs(); + } + config.setMinOccurs(minOccurs); + config.setMaxOccurs(maxOccurs); + IXSDElementFragment elementFrag = new XSDElementFragment(id, resolvedElement.getName(), config); + elementFrag.setXSDTypeDefinition(typeDef); + XSDToFragmentConfiguration elementTypeConfig = new XSDToFragmentConfiguration(); + elementTypeConfig.setXSDComponent(typeDef); + elementTypeConfig.setMinOccurs(minOccurs); + elementTypeConfig.setMaxOccurs(maxOccurs); + elementTypeConfig.setStyle(config.getStyle()); + elementTypeConfig.setPartEncoding(config.getPartEncoding()); + elementTypeConfig.setWSDLPartName(config.getWSDLPartName()); + IXSDFragment xsdFragment = getController().getFragment(elementTypeConfig, elementFrag.genID(), resolvedElement.getName()); + elementFrag.setXSDDelegationFragment(xsdFragment); + return elementFrag; + } + } + return getXSDDefaultFragment(config, id, name); + } + + private XSDElementDeclaration resolveXSDElementDeclaration(XSDElementDeclaration element) { + // port to org.eclipse.xsd + if (element.getResolvedElementDeclaration() != null) + { + XSDElementDeclaration resolvedElement = element.getResolvedElementDeclaration(); + if (!isComponentResolvable(resolvedElement)) + { + XSDComponent resolvedComponent = getWSDLPartsToXSDTypeMapper().resolveXSDNamedComponent(resolvedElement); + if (resolvedComponent != null && (resolvedComponent instanceof XSDElementDeclaration)) + resolvedElement = (XSDElementDeclaration)resolvedComponent; + } + return resolvedElement; + } + else + return element; + } + + private XSDTypeDefinition getXSDTypeDefinition(XSDElementDeclaration element) { + // port to org.eclipse.xsd + if (element.getTypeDefinition() != null) + return element.getTypeDefinition(); + // port to org.eclipse.xsd + else if (element.getAnonymousTypeDefinition() != null) + return element.getAnonymousTypeDefinition(); + else + return null; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDLiteralXMLEncodingToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDLiteralXMLEncodingToFragmentMapper.java new file mode 100644 index 000000000..55e440883 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDLiteralXMLEncodingToFragmentMapper.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDParticleContent; + +public class XSDLiteralXMLEncodingToFragmentMapper extends XSDToFragmentMapper { + private XSDSimpleTypeToFragmentMapper xsdSimpleMapper_; + private XSDComplexTypeToFragmentMapper xsdComplexMapper_; + private XSDElementDeclarationToFragmentMapper xsdElementMapper_; + private XSDParticleToFragmentMapper xsdParticleMapper_; + + public XSDLiteralXMLEncodingToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + super(controller, wsdlToXSDMapper); + xsdSimpleMapper_ = null; + xsdComplexMapper_ = null; + xsdElementMapper_ = null; + xsdParticleMapper_= null; + } + + private XSDSimpleTypeToFragmentMapper getXSDSimpleMapper() { + if (xsdSimpleMapper_ == null) + xsdSimpleMapper_ = new XSDSimpleTypeToFragmentMapper(getController(), getWSDLPartsToXSDTypeMapper()); + return xsdSimpleMapper_; + } + + private XSDComplexTypeToFragmentMapper getXSDComplexMapper() { + if (xsdComplexMapper_ == null) + xsdComplexMapper_ = new XSDComplexTypeToFragmentMapper(getController(), getWSDLPartsToXSDTypeMapper()); + return xsdComplexMapper_; + } + + private XSDElementDeclarationToFragmentMapper getXSDElementMapper() { + if (xsdElementMapper_ == null) + xsdElementMapper_ = new XSDElementDeclarationToFragmentMapper(getController(), getWSDLPartsToXSDTypeMapper()); + return xsdElementMapper_; + } + + private XSDParticleToFragmentMapper getXSDParticleMapper() { + if (xsdParticleMapper_ == null) + xsdParticleMapper_ = new XSDParticleToFragmentMapper(getController(), getWSDLPartsToXSDTypeMapper()); + return xsdParticleMapper_; + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + config = resolveXSDComponent(config); + XSDComponent component = config.getXSDComponent(); + if (!isComponentResolvable(component)) + return getXSDDefaultFragment(config, id, name); + else if (component instanceof XSDElementDeclaration) + return getXSDElementMapper().getFragment(config, id, name); + else if (component instanceof XSDSimpleTypeDefinition) + return getXSDSimpleMapper().getFragment(config, id, name); + else if (component instanceof XSDComplexTypeDefinition) + return getXSDComplexMapper().getFragment(config, id, name); + else if (component instanceof XSDParticle) + return getXSDParticleMapper().getFragment(config, id, name); + else if (component instanceof XSDParticleContent) + return getXSDParticleMapper().getFragment(config, id, name); + else + return getXSDDefaultFragment(config, id, name); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDParticleToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDParticleToFragmentMapper.java new file mode 100644 index 000000000..dc956cc53 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDParticleToFragmentMapper.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDConcreteComponent; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDParticleContent; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDModelGroupDefinition; +import org.eclipse.xsd.XSDCompositor; +import org.eclipse.xsd.XSDWildcard; + + +public class XSDParticleToFragmentMapper extends XSDToFragmentMapper { + public XSDParticleToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + super(controller, wsdlToXSDMapper); + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + XSDComponent component = config.getXSDComponent(); + XSDParticleContent xsdParticleContent; + if (component instanceof XSDParticle) + xsdParticleContent = ((XSDParticle)component).getContent(); + else if (component instanceof XSDParticleContent) + xsdParticleContent = (XSDParticleContent)component; + else + xsdParticleContent = null; + if (xsdParticleContent != null) { + if (xsdParticleContent instanceof XSDModelGroupDefinition) + return getXSDModelGroupDefFragment(config, id, name, (XSDModelGroupDefinition)xsdParticleContent); + else if (xsdParticleContent instanceof XSDModelGroup) + return getXSDModelGroupFragment(config, id, name, (XSDModelGroup)xsdParticleContent); + else if (xsdParticleContent instanceof XSDWildcard) + return getXSDWildcardFragment(config, id, name, (XSDWildcard)xsdParticleContent); + else + return getXSDDefaultFragment(config, id, name); + } + else + return getXSDDefaultFragment(config, id, name); + } + + private IXSDFragment getXSDModelGroupDefFragment(XSDToFragmentConfiguration config, String id, String name, XSDModelGroupDefinition xsdModelGroupDef) { + XSDModelGroupDefinition resolvedXSDModelGroupDef = xsdModelGroupDef; + if (xsdModelGroupDef.isModelGroupDefinitionReference()) + resolvedXSDModelGroupDef = xsdModelGroupDef.getResolvedModelGroupDefinition(); + XSDModelGroup xsdModelGroup = resolvedXSDModelGroupDef.getModelGroup(); + if (xsdModelGroup == null) + return getXSDDefaultFragment(config, id, name); + else + return getXSDModelGroupFragment(config, id, name, xsdModelGroup); + } + + private IXSDFragment getXSDModelGroupFragment(XSDToFragmentConfiguration config, String id, String name, XSDModelGroup xsdModelGroup) { + int minOccurs = FragmentConstants.DEFAULT_MIN_OCCURS; + int maxOccurs = FragmentConstants.DEFAULT_MAX_OCCURS; + XSDConcreteComponent concreteComponent = xsdModelGroup.getContainer(); + if (concreteComponent != null && concreteComponent instanceof XSDParticle) { + XSDParticle particle = (XSDParticle)concreteComponent; + if (particle.isSetMinOccurs()) + minOccurs = particle.getMinOccurs(); + if (particle.isSetMaxOccurs()) + maxOccurs = particle.getMaxOccurs(); + } + config.setMinOccurs(minOccurs); + config.setMaxOccurs(maxOccurs); + IXSDGroupFragment groupFragment = null; + switch (xsdModelGroup.getCompositor().getValue()) { + case XSDCompositor.SEQUENCE: + if (minOccurs == maxOccurs) + return new XSDGroupSeqFixFragment(id, name, config, getController(), xsdModelGroup); + else + return new XSDGroupSeqRangeFragment(id, name, config, getController(), xsdModelGroup); + case XSDCompositor.CHOICE: + if (minOccurs == maxOccurs) + return new XSDGroupChoiceFixFragment(id, name, config, getController(), xsdModelGroup); + else + return new XSDGroupChoiceRangeFragment(id, name, config, getController(), xsdModelGroup); + case XSDCompositor.ALL: + return new XSDGroupAllFragment(id, name, config, getController(), xsdModelGroup); + default: + return getXSDDefaultFragment(config, id, name); + } + } + + private IXSDFragment getXSDWildcardFragment(XSDToFragmentConfiguration config, String id, String name, XSDWildcard xsdParticleContent) { + return getXSDDefaultFragment(config, id, name); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDSOAPEncodingToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDSOAPEncodingToFragmentMapper.java new file mode 100644 index 000000000..e43c8b802 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDSOAPEncodingToFragmentMapper.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.XSDTypeDefinitionUtil; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDParticleContent; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComplexTypeContent; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.XSDAttributeGroupContent; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.emf.common.util.EList; + +import org.w3c.dom.Element; + +public class XSDSOAPEncodingToFragmentMapper extends XSDToFragmentMapper { + private XSDLiteralXMLEncodingToFragmentMapper xsdLiteralMapper_; + private XSDComplexTypeToFragmentMapper xsdComplexMapper_; + + public XSDSOAPEncodingToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + super(controller, wsdlToXSDMapper); + xsdLiteralMapper_ = null; + xsdComplexMapper_ = null; + } + + private XSDLiteralXMLEncodingToFragmentMapper getXSDLiteralMapper() { + if (xsdLiteralMapper_ == null) + xsdLiteralMapper_ = new XSDLiteralXMLEncodingToFragmentMapper(getController(), getWSDLPartsToXSDTypeMapper()); + return xsdLiteralMapper_; + } + + private XSDComplexTypeToFragmentMapper getXSDComplexMapper() { + if (xsdComplexMapper_ == null) + xsdComplexMapper_ = new XSDComplexTypeToFragmentMapper(getController(), getWSDLPartsToXSDTypeMapper()); + return xsdComplexMapper_; + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + if (config.getIsWSDLPart()) { + ISOAPEncodingWrapperFragment wrapperFragment = new SOAPEncodingWrapperFragment(id, name, null); + String delegationFragId = wrapperFragment.genID(); + IXSDFragment delegationFragment = getFragmentDelegate(config, delegationFragId, name); + wrapperFragment.setXSDDelegationFragment(delegationFragment); + getController().addToCache(delegationFragId, delegationFragment); + return wrapperFragment; + } + else + return getFragmentDelegate(config, id, name); + } + + public IXSDFragment getFragmentDelegate(XSDToFragmentConfiguration config, String id, String name) { + config = resolveXSDComponent(config); + XSDComponent component = config.getXSDComponent(); + if (!isComponentResolvable(component)) + return getXSDDefaultFragment(config, id, name); + else if (component instanceof XSDComplexTypeDefinition) { + XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)component; + if (XSDTypeDefinitionUtil.isSoapEncArray(complexType)) + return getSOAPEncArrayFragment(config, id, name, complexType); + else + return getXSDComplexMapper().getFragment(config, id, name); + } + else + return getXSDLiteralMapper().getFragment(config, id, name); + } + + private IXSDFragment getSOAPEncArrayFragment(XSDToFragmentConfiguration config, String id, String name, XSDComplexTypeDefinition complexType) { + EList xsdAttrContents = complexType.getAttributeContents(); + for (int i = 0; i < xsdAttrContents.size(); i++) { + String soapEncArrayTypeNamespaceURI = null; + String soapEncArrayTypeLocalName = null; + int soapEncArrayDimension = 0; + XSDAttributeGroupContent xsdAttrContent = (XSDAttributeGroupContent)xsdAttrContents.get(i); + Element element = xsdAttrContent.getElement(); + String arrayTypeAttr = element.getAttributeNS(FragmentConstants.URI_WSDL, FragmentConstants.QNAME_LOCAL_NAME_ARRAY_TYPE); + if (arrayTypeAttr != null && arrayTypeAttr.length() > 0) { + int colon = arrayTypeAttr.indexOf(FragmentConstants.COLON); + String nsPrefix = (colon > 0) ? arrayTypeAttr.substring(0, colon) : null; + soapEncArrayTypeNamespaceURI = (String)xsdAttrContent.getSchema().getQNamePrefixToNamespaceMap().get(nsPrefix); + int dimensionIndex = arrayTypeAttr.indexOf(FragmentConstants.LEFT_SQUARE_BRACKET); + soapEncArrayTypeLocalName = arrayTypeAttr.substring(colon + 1, dimensionIndex); + String dimensionString = arrayTypeAttr.substring(dimensionIndex, arrayTypeAttr.length()); + for (int j = 0; j < dimensionString.length() - 1; j++) { + if (dimensionString.charAt(j) == FragmentConstants.LEFT_SQUARE_BRACKET.charAt(0) && dimensionString.charAt(j + 1) == FragmentConstants.RIGHT_SQUARE_BRACKET.charAt(0)) { + soapEncArrayDimension++; + j++; + } + else { + soapEncArrayDimension = 0; + break; + } + } + } + if (soapEncArrayTypeNamespaceURI != null && soapEncArrayTypeLocalName != null && soapEncArrayDimension == 1) { + XSDComponent soapEncArrayType = getWSDLPartsToXSDTypeMapper().getXSDTypeFromSchema(soapEncArrayTypeNamespaceURI, soapEncArrayTypeLocalName, false); + if (soapEncArrayType != null && soapEncArrayType instanceof XSDTypeDefinition) { + XSDModelGroup sequence = null; + XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType); + if (complexTypeContent != null && (complexTypeContent instanceof XSDParticle)) { + XSDParticleContent xsdParticleContent = ((XSDParticle)complexTypeContent).getContent(); + if (xsdParticleContent instanceof XSDModelGroup) + sequence = (XSDModelGroup)xsdParticleContent; + } + ISOAPEncArrayFragment frag; + if (config.getMinOccurs() == config.getMaxOccurs()) + frag = new SOAPEncArrayFixFragment(id, name, config, getController(), sequence); + else + frag = new SOAPEncArrayRangeFragment(id, name, config, getController(), sequence); + frag.setXSDTypeDefinition((XSDTypeDefinition)soapEncArrayType); + return frag; + } + } + } + return getXSDComplexMapper().getFragment(config, id, name); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDSimpleTypeToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDSimpleTypeToFragmentMapper.java new file mode 100644 index 000000000..0d9ed09b6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDSimpleTypeToFragmentMapper.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; +import org.eclipse.xsd.*; + +public class XSDSimpleTypeToFragmentMapper extends XSDToFragmentMapper { + public XSDSimpleTypeToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + super(controller, wsdlToXSDMapper); + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)config.getXSDComponent(); + if (simpleType != null && simpleType.getVariety() != null) { + switch (simpleType.getVariety().getValue()) { + case XSDVariety.ATOMIC: + return getXSDSimpleAtomicFragment(config, id, name); + case XSDVariety.LIST: + return getXSDSimpleListFragment(config, id, name); + case XSDVariety.UNION: + return getXSDSimpleUnionFragment(config, id, name); + default: + return getXSDDefaultFragment(config, id, name); + } + } + else + return getXSDDefaultFragment(config, id, name); + } + + private IXSDFragment getXSDSimpleAtomicFragment(XSDToFragmentConfiguration config, String id, String name) { + boolean isFixed = ((config.getMinOccurs() == config.getMaxOccurs()) && config.getMaxOccurs() != FragmentConstants.UNBOUNDED); + XSDSimpleTypeDefinition xsdSimpleTypeDef = (XSDSimpleTypeDefinition)config.getXSDComponent(); + XSDSimpleTypeDefinition xsdBaseSimpleTypeDef = (XSDSimpleTypeDefinition)XSDTypeDefinitionUtil.resolveToXSDBuiltInTypeDefinition(xsdSimpleTypeDef); + String baseSimpleTypeDefNS = null; + String baseSimpleTypeDefName = null; + if (xsdBaseSimpleTypeDef != null) + { + baseSimpleTypeDefNS = xsdBaseSimpleTypeDef.getTargetNamespace(); + baseSimpleTypeDefName = xsdBaseSimpleTypeDef.getName(); + } + boolean isEnum = isSimpleTypeEnumeration(xsdSimpleTypeDef); + if (FragmentConstants.URI_XSD.equals(baseSimpleTypeDefNS)) + { + if (baseSimpleTypeDefName.equals("date")) + return getXSDSimpleDateTimeFragment(id, name, config, ActionInputs.CALENDAR_TYPE_DATE,xsdSimpleTypeDef,isEnum,isFixed); + else if (baseSimpleTypeDefName.equals("dateTime")) + return getXSDSimpleDateTimeFragment(id, name, config, ActionInputs.CALENDAR_TYPE_DATETIME,xsdSimpleTypeDef,isEnum,isFixed); + else if (baseSimpleTypeDefName.equals("gYearMonth")) + return getXSDSimpleDateTimeFragment(id, name, config, ActionInputs.CALENDAR_TYPE_GYEARMONTH,xsdSimpleTypeDef,isEnum,isFixed); + else if (baseSimpleTypeDefName.equals("gMonthDay")) + return getXSDSimpleDateTimeFragment(id, name, config, ActionInputs.CALENDAR_TYPE_GMONTHDAY,xsdSimpleTypeDef,isEnum,isFixed); + else if (baseSimpleTypeDefName.equals("gDay")) + return getXSDSimpleGDayFragment(id, name, config, xsdSimpleTypeDef,isEnum,isFixed); + else if (baseSimpleTypeDefName.equals("boolean")) + return getXSDSimpleBooleanFragment(id, name, config, xsdSimpleTypeDef,isEnum,isFixed); + } + + if (isEnum) + { + if (isFixed) + return new XSDSimpleAtomicEnumFixFragment(id, name, config, xsdSimpleTypeDef.getEnumerationFacets()); + else + return new XSDSimpleAtomicEnumRangeFragment(id, name, config, xsdSimpleTypeDef.getEnumerationFacets()); + } + else + { + if (isFixed) + return new XSDSimpleAtomicFixFragment(id, name, config); + else + return new XSDSimpleAtomicRangeFragment(id, name, config); + } + } + + private XSDSimpleAtomicFragment getXSDSimpleDateTimeFragment(String id, String name, XSDToFragmentConfiguration config, int calendarType,XSDSimpleTypeDefinition xsdDateTimeType,boolean isEnum,boolean isFixed) + { + if (isEnum) + { + if (isFixed) + return new XSDSimpleAtomicEnumFixFragment(id, name, config, xsdDateTimeType.getEnumerationFacets()); + else + return new XSDSimpleAtomicEnumRangeFragment(id, name, config, xsdDateTimeType.getEnumerationFacets()); + } + else + { + if (isFixed) + return new XSDSimpleAtomicDateTimeFixFragment(id, name, config, calendarType); + else + return new XSDSimpleAtomicDateTimeRangeFragment(id, name, config, calendarType); + } + } + + private XSDSimpleAtomicFragment getXSDSimpleGDayFragment(String id, String name, XSDToFragmentConfiguration config, XSDSimpleTypeDefinition xsdDateTimeType,boolean isEnum,boolean isFixed) + { + if (isEnum) + return null; + OptionVector optionVector = new OptionVector(); + StringBuffer value = new StringBuffer(); + for (int i=1;i<=31;i++) + { + value.setLength(0); + value.append("---"); + if (i<10) + value.append(0); + value.append(i); + optionVector.addOption(String.valueOf(i),value.toString()); + } + if (isFixed) + return new XSDSimpleAtomicEnumFixFragment(id, name, config, optionVector); + else + return new XSDSimpleAtomicEnumRangeFragment(id, name, config, optionVector); + } + + private XSDSimpleAtomicFragment getXSDSimpleBooleanFragment(String id, String name, XSDToFragmentConfiguration config, XSDSimpleTypeDefinition xsdBooleanType,boolean isEnum,boolean isFixed) + { + if (isEnum) + return null; + OptionVector optionVector = new OptionVector(); + optionVector.addOption("true","true"); + optionVector.addOption("false","false"); + if (isFixed) + return new XSDSimpleAtomicEnumFixFragment(id, name, config, optionVector); + else + return new XSDSimpleAtomicEnumRangeFragment(id, name, config, optionVector); + } + + private IXSDFragment getXSDSimpleListFragment(XSDToFragmentConfiguration config, String id, String name) { + IXSDSimpleListFragment frag; + boolean isFixed = ((config.getMinOccurs() == config.getMaxOccurs()) && config.getMaxOccurs() != FragmentConstants.UNBOUNDED); + if (isFixed) + return new XSDSimpleListFixFragment(id, name, config, getController()); + else + return new XSDSimpleListRangeFragment(id, name, config, getController()); + } + + private IXSDFragment getXSDSimpleUnionFragment(XSDToFragmentConfiguration config, String id, String name) { + IXSDSimpleUnionFragment frag; + boolean isFixed = ((config.getMinOccurs() == config.getMaxOccurs()) && config.getMaxOccurs() != FragmentConstants.UNBOUNDED); + if (isFixed) + return new XSDSimpleUnionFixFragment(id, name, config, getController()); + else + return new XSDSimpleUnionRangeFragment(id, name, config, getController()); + } + + private boolean isSimpleTypeEnumeration(XSDSimpleTypeDefinition simpleType) { + EList e = simpleType.getEnumerationFacets(); + return (e != null && e.size() > 0); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentConfiguration.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentConfiguration.java new file mode 100644 index 000000000..0537da155 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentConfiguration.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.xsd.XSDComponent; + +public class XSDToFragmentConfiguration { + private XSDComponent component_; + private int minOccurs_; + private int maxOccurs_; + private int style_; + private int partEncoding_; + private boolean isWSDLPart_; + private String wsdlPartName_; + + public XSDToFragmentConfiguration() { + component_ = null; + minOccurs_ = FragmentConstants.DEFAULT_MIN_OCCURS; + maxOccurs_ = FragmentConstants.DEFAULT_MAX_OCCURS; + style_ = FragmentConstants.STYLE_DOCUMENT; + partEncoding_ = FragmentConstants.ENCODING_LITERAL; + isWSDLPart_ = false; + wsdlPartName_ = null; + } + + public void setXSDComponent(XSDComponent component) { + component_ = component; + } + + public XSDComponent getXSDComponent() { + return component_; + } + + public void setMinOccurs(int minOccurs) { + minOccurs_ = minOccurs; + } + + public int getMinOccurs() { + return minOccurs_; + } + + public void setMaxOccurs(int maxOccurs) { + maxOccurs_ = maxOccurs; + } + + public int getMaxOccurs() { + return maxOccurs_; + } + + public void setStyle(int style) { + style_ = style; + } + + public int getStyle() { + return style_; + } + + public void setPartEncoding(int partEncoding) { + partEncoding_ = partEncoding; + } + + public int getPartEncoding() { + return partEncoding_; + } + + public void setIsWSDLPart(boolean isWSDLPart) { + isWSDLPart_ = isWSDLPart; + } + + public boolean getIsWSDLPart() { + return isWSDLPart_; + } + + public void setWSDLPartName(String wsdlPartName) { + wsdlPartName_ = wsdlPartName; + } + + public String getWSDLPartName() { + return wsdlPartName_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentController.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentController.java new file mode 100644 index 000000000..e6f934247 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentController.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*; + +import java.util.Hashtable; + +public class XSDToFragmentController { + private WSDLPartsToXSDTypeMapper wsdlToXSDMapper_; + private XSDLiteralXMLEncodingToFragmentMapper xsdLiteralMapper_; + private XSDSOAPEncodingToFragmentMapper xsdSoapMapper_; + private Hashtable xsdToFragmentCache_; + + public XSDToFragmentController() { + wsdlToXSDMapper_ = null; + xsdLiteralMapper_ = null; + xsdSoapMapper_ = null; + xsdToFragmentCache_ = new Hashtable(); + } + + public void setWSDLPartsToXSDTypeMapper(WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + wsdlToXSDMapper_ = wsdlToXSDMapper; + } + + public WSDLPartsToXSDTypeMapper getWSDLPartsToXSDTypeMapper() { + return wsdlToXSDMapper_; + } + + private XSDLiteralXMLEncodingToFragmentMapper getXSDLiteralMapper() { + if (xsdLiteralMapper_ == null) + xsdLiteralMapper_ = new XSDLiteralXMLEncodingToFragmentMapper(this, wsdlToXSDMapper_); + return xsdLiteralMapper_; + } + + private XSDSOAPEncodingToFragmentMapper getXSDSOAPMapper() { + if (xsdSoapMapper_ == null) + xsdSoapMapper_ = new XSDSOAPEncodingToFragmentMapper(this, wsdlToXSDMapper_); + return xsdSoapMapper_; + } + + public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) { + IXSDFragment frag = getCachedFragment(id); + if (frag != null) + return frag; + frag = getNewFragment(config, id, name); + if (frag != null) + addToCache(id, frag); + return frag; + } + + public IXSDFragment getCachedFragment(String id) { + return (IXSDFragment)xsdToFragmentCache_.get(id); + } + + public IXSDFragment getNewFragment(XSDToFragmentConfiguration config, String id, String name) { + switch (config.getPartEncoding()) + { + case FragmentConstants.ENCODING_SOAP: + return getXSDSOAPMapper().getFragment(config,id,name); + case FragmentConstants.ENCODING_LITERAL: + case FragmentConstants.ENCODING_URL: + default: + return getXSDLiteralMapper().getFragment(config,id,name); + } + } + + public void addToCache(String id, IXSDFragment frag) { + xsdToFragmentCache_.put(id, frag); + } + + public void removeFromCache(String id) { + xsdToFragmentCache_.remove(id); + } + + public void emptyCache() { + xsdToFragmentCache_.clear(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentMapper.java new file mode 100644 index 000000000..afa1b10f8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/XSDToFragmentMapper.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.WSDLPartsToXSDTypeMapper; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDNamedComponent; +import org.eclipse.xsd.XSDSchema; + +public abstract class XSDToFragmentMapper { + private XSDToFragmentController controller_; + private WSDLPartsToXSDTypeMapper wsdlToXSDMapper_; + + public XSDToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + controller_ = controller; + wsdlToXSDMapper_ = wsdlToXSDMapper; + } + + public void setController(XSDToFragmentController controller) { + controller_ = controller; + } + + public XSDToFragmentController getController() { + return controller_; + } + + public void setWSDLPartsToXSDTypeMapper(WSDLPartsToXSDTypeMapper wsdlToXSDMapper) { + wsdlToXSDMapper_ = wsdlToXSDMapper; + } + + public WSDLPartsToXSDTypeMapper getWSDLPartsToXSDTypeMapper() { + return wsdlToXSDMapper_; + } + + protected IXSDFragment getXSDDefaultFragment(XSDToFragmentConfiguration config, String id, String name) { + XSDComponent xsdComponent = config.getXSDComponent(); + String componentName = name; + if (xsdComponent instanceof XSDNamedComponent) { + String componentNameCopy = ((XSDNamedComponent)xsdComponent).getName(); + if (componentNameCopy != null && componentNameCopy.length() > 0) + componentName = componentNameCopy; + } + return new XSDDefaultFragment(id, name, config); + } + + protected IXSDFragment getXSDEmptyFragment(XSDToFragmentConfiguration config, String id, String name) { + return new XSDEmptyFragment(id, name, config); + } + + public abstract IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name); + + protected XSDToFragmentConfiguration resolveXSDComponent(XSDToFragmentConfiguration config) + { + XSDComponent component = config.getXSDComponent(); + if (!isComponentResolvable(component) && (component instanceof XSDNamedComponent)) + { + XSDComponent resolvedComponent = getWSDLPartsToXSDTypeMapper().resolveXSDNamedComponent((XSDNamedComponent)component); + if (resolvedComponent != null) + config.setXSDComponent(resolvedComponent); + } + return config; + } + + protected boolean isComponentResolvable(XSDComponent component) + { + if (component == null) + return false; + XSDSchema schema = component.getSchema(); + if (schema == null) + return false; + if (schema.getTargetNamespace() == null) + return false; + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/Fragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/Fragment.java new file mode 100644 index 000000000..3217007dc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/Fragment.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IFragment; + +import java.util.Vector; +import java.util.Hashtable; +import java.util.Enumeration; + +public abstract class Fragment implements IFragment { + private String id_; + private String name_; + private Hashtable params_; + + public Fragment(String id, String name) { + id_ = id; + name_ = name; + params_ = new Hashtable(); + } + + public void setID(String id) { + id_ = id; + } + + public String getID() { + return id_; + } + + public void setName(String name) { + name_ = name; + } + + public String getName() { + return name_; + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + String[] params = parser.getParameterValues(getID()); + setParameterValues(getID(), params); + return validateAllParameterValues(); + } + + public void setParameterValues(String paramKey, String[] params) { + if (params == null) + params_.remove(paramKey); + else + params_.put(paramKey, params); + } + + public void setParameterValues(String paramKey, Vector params) { + if (params == null) + params_.remove(paramKey); + else { + String[] paramsArray = new String[params.size()]; + for (int i = 0; i < paramsArray.length; i++) { + paramsArray[i] = params.get(i).toString(); + } + setParameterValues(paramKey, paramsArray); + } + } + + public String[] getParameterValues(String paramKey) { + return (String[])params_.get(paramKey); + } + + public String getParameterValue(String paramKey, int paramIndex) { + String[] params = getParameterValues(paramKey); + if (params != null && paramIndex < params.length) + return params[paramIndex]; + else + return null; + } + + public boolean validateAllParameterValues() { + Enumeration paramKeys = params_.keys(); + while (paramKeys != null && paramKeys.hasMoreElements()) { + if (!validateParameterValues((String)paramKeys.nextElement())) + return false; + } + return true; + } + + public boolean validateParameterValues(String paramKey) { + String[] params = getParameterValues(paramKey); + for (int i = 0; params != null && i < params.length; i++) { + if (!validateParameterValue(paramKey, i)) + return false; + } + return true; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayFixFragment.java new file mode 100644 index 000000000..c6459dec5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayFixFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public class SOAPEncArrayFixFragment extends SOAPEncArrayFragment { + public SOAPEncArrayFixFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/SOAPEncArrayRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/SOAPEncArrayFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayFragment.java new file mode 100644 index 000000000..5d3c9e250 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayFragment.java @@ -0,0 +1,188 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.ISOAPEncArrayFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDParticleContent; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.emf.common.util.EList; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; +import java.util.Vector; +import java.util.Hashtable; + +public abstract class SOAPEncArrayFragment extends XSDGroupSeqFragment implements ISOAPEncArrayFragment +{ + public SOAPEncArrayFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) + { + super(id, name, config, controller, xsdModelGroup); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + Element[] instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocuments, getName()); + removeGroupIDs(); + boolean paramsValid = internalEquals(instanceDocumentsCopy, instanceDocuments); + for (int i = 0; i < instanceDocumentsCopy.length; i++) + { + IXSDFragment soapEncArrayTypeFrag = (getGroupMemberFragments(createSOAPEncArrayInstance()))[0]; + Vector instancesVector = new Vector(); + NodeList nl = instanceDocumentsCopy[i].getChildNodes(); + for (int j = 0; j < nl.getLength(); j++) + { + Node node = nl.item(j); + if (node instanceof Element) + instancesVector.add(node); + else + paramsValid = false; + } + Element[] childInstanceDocuments = new Element[instancesVector.size()]; + instancesVector.copyInto(childInstanceDocuments); + if (!soapEncArrayTypeFrag.setParameterValuesFromInstanceDocuments(setElementsTagName(childInstanceDocuments, soapEncArrayTypeFrag.getName()))) + paramsValid = false; + } + return paramsValid; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) + { + String[] groupIDs = getGroupIDs(); + Element[] instanceDocument = new Element[groupIDs.length]; + StringBuffer attrName = new StringBuffer(); + StringBuffer attrValue = new StringBuffer(); + StringBuffer attrArrayTypeName = new StringBuffer(); + StringBuffer attrArrayTypeValue = new StringBuffer(); + for (int i = 0; i < instanceDocument.length; i++) + { + int numInstances = 0; + instanceDocument[i] = doc.createElement(getInstanceDocumentTagName(namespaceTable)); + IXSDFragment fragment = (getGroupMemberFragments(groupIDs[i]))[0]; + Element[] fragmentInstanceDocuments = fragment.genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + for (int j = 0; j < fragmentInstanceDocuments.length; j++) + { + if (fragmentInstanceDocuments[j] != null) + instanceDocument[i].appendChild(fragmentInstanceDocuments[j]); + numInstances++; + } + String soapURI = FragmentConstants.URI_SOAP; + String soapPrefix = getPrefixFromNamespaceURI(soapURI, namespaceTable); + String soapEncArrayTypeURI = getXSDTypeDefinition().getTargetNamespace(); + String soapEncArrayTypePrefix = getPrefixFromNamespaceURI(soapEncArrayTypeURI, namespaceTable); + // Set the arrayType attribute + attrName.setLength(0); + attrName.setLength(0); + attrName.append(soapPrefix); + attrName.append(FragmentConstants.COLON); + attrName.append(FragmentConstants.SOAP_ENC_ARRAY_TYPE); + attrValue.setLength(0); + attrValue.append(soapEncArrayTypePrefix); + attrValue.append(FragmentConstants.COLON); + attrValue.append(getXSDTypeDefinition().getName()); + attrValue.append(FragmentConstants.LEFT_SQUARE_BRACKET); + attrValue.append(numInstances); + attrValue.append(FragmentConstants.RIGHT_SQUARE_BRACKET); + instanceDocument[i].setAttribute(attrName.toString(), attrValue.toString()); + } + if (genXSIType) + { +// TODO: Used to call the plugin's ignoreSchemaForSOAPArrays()method. + boolean ignoreSchemaForSOAPArrays = true; + if (ignoreSchemaForSOAPArrays) + { + for (int i = 0; i < instanceDocument.length; i++) + { + String xsiURI = FragmentConstants.URI_XSI; + String xsiPrefix = getPrefixFromNamespaceURI(xsiURI, namespaceTable); + String xsiTypeURI = FragmentConstants.URI_SOAP; + String xsiTypePrefix = getPrefixFromNamespaceURI(xsiTypeURI, namespaceTable); + attrName.setLength(0); + attrName.append(xsiPrefix).append(FragmentConstants.COLON).append(FragmentConstants.XSI_TYPE); + attrValue.setLength(0); + attrValue.append(xsiTypePrefix).append(FragmentConstants.COLON); + attrValue.append(FragmentConstants.QNAME_LOCAL_NAME_ARRAY); + instanceDocument[i].setAttribute(attrName.toString(), attrValue.toString()); + } + } + else + return addXSIType(instanceDocument, namespaceTable); + } + return instanceDocument; + } + + public String createSOAPEncArrayInstance() + { + if (getXSDTypeDefinition() != null) + { + String groupID = genID(); + String[] groupMemberID = {genID()}; + int minOccurs = 0; + int maxOccurs = FragmentConstants.UNBOUNDED; + XSDElementDeclaration elementDecl = null; + if (getXSDModelGroup() != null) + { + XSDParticle groupOwner = (XSDParticle)getXSDModelGroup().getContainer(); + int groupMin = groupOwner.getMinOccurs(); + int groupMax = groupOwner.getMaxOccurs(); + int elementMin = 0; + int elementMax = FragmentConstants.UNBOUNDED; + EList xsdParticles = getXSDModelGroup().getParticles(); + if (xsdParticles.size() > 0) + { + XSDParticleContent xsdParticleContent = ((XSDParticle)xsdParticles.get(0)).getContent(); + if (xsdParticleContent instanceof XSDElementDeclaration) + { + elementDecl = (XSDElementDeclaration)xsdParticleContent; + XSDParticle elementOwner = (XSDParticle)elementDecl.getContainer(); + elementMin = elementOwner.getMinOccurs(); + elementMax = elementOwner.getMaxOccurs(); + } + } + if (groupMin >= 0 && elementMin >= 0) + minOccurs = groupMin * elementMin; + if (groupMax >= 0 && groupMax != FragmentConstants.UNBOUNDED && elementMax >= 0 && elementMax != FragmentConstants.UNBOUNDED) + maxOccurs = groupMax * elementMax; + } + XSDToFragmentConfiguration thisConfig = getXSDToFragmentConfiguration(); + XSDToFragmentConfiguration xsdConfig = new XSDToFragmentConfiguration(); + xsdConfig.setXSDComponent(getXSDTypeDefinition()); + xsdConfig.setMinOccurs(minOccurs); + xsdConfig.setMaxOccurs(maxOccurs); + xsdConfig.setStyle(thisConfig.getStyle()); + xsdConfig.setPartEncoding(thisConfig.getPartEncoding()); + xsdConfig.setWSDLPartName(thisConfig.getWSDLPartName()); + String name = (elementDecl != null) ? elementDecl.getName() : getXSDTypeDefinition().getName(); + IXSDFragment frag = getXSDToFragmentController().getFragment(xsdConfig, groupMemberID[0], name); + addFragment(groupMemberID[0], frag); + setGroupMemberIDs(groupID, groupMemberID); + return groupID; + } + else + return null; + } + + public String createGroupSeqInstance() + { + return createSOAPEncArrayInstance(); + } + + public String createInstance() + { + return createSOAPEncArrayInstance(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayRangeFragment.java new file mode 100644 index 000000000..f177ee62b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncArrayRangeFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public class SOAPEncArrayRangeFragment extends SOAPEncArrayFragment { + public SOAPEncArrayRangeFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/SOAPEncArrayRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/SOAPEncArrayRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncodingWrapperFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncodingWrapperFragment.java new file mode 100644 index 000000000..324ed5e5b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/SOAPEncodingWrapperFragment.java @@ -0,0 +1,186 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.ISOAPEncodingWrapperFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.xsd.XSDTypeDefinition; + +import org.w3c.dom.*; +import java.util.Vector; +import java.util.Hashtable; + +public class SOAPEncodingWrapperFragment extends XSDDelegationFragment implements ISOAPEncodingWrapperFragment +{ + private static final String ID = "id"; + private static final String HREF = "href"; + private static final String POUND = "#"; + + private Hashtable uriReferenceTable_; + + public SOAPEncodingWrapperFragment(String id, String name, XSDToFragmentConfiguration config) + { + super(id, name, null); + uriReferenceTable_ = null; + } + + public void setXSDToFragmentConfiguration(XSDToFragmentConfiguration config) + { + getXSDDelegationFragment().setXSDToFragmentConfiguration(config); + } + + public XSDToFragmentConfiguration getXSDToFragmentConfiguration() + { + return getXSDDelegationFragment().getXSDToFragmentConfiguration(); + } + + public void setXSDTypeDefinition(XSDTypeDefinition typeDef) + { + getXSDDelegationFragment().setXSDTypeDefinition(typeDef); + } + + public XSDTypeDefinition getXSDTypeDefinition() + { + return getXSDDelegationFragment().getXSDTypeDefinition(); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + for (int i = 0; i < instanceDocuments.length; i++) + instanceDocuments[i] = resolveURIReferences(uriReferenceTable_, instanceDocuments[i]); + return getXSDDelegationFragment().setParameterValuesFromInstanceDocuments(instanceDocuments); + } + + public void setURIReferences(Hashtable uriReferences) + { + uriReferenceTable_ = uriReferences; + } + + public static Hashtable parseURIReferences(Element element, boolean overwrites) + { + Hashtable uriReferences = new Hashtable(); + parseURIReferences(uriReferences, element, overwrites); + return uriReferences; + } + + private static boolean parseURIReferences(Hashtable uriReferences, Element element, boolean overwrites) + { + boolean resolved = true; + if (element != null) + { + URIReference ref = null; + String id = element.getAttribute(ID); + resolved = !element.hasAttribute(HREF); + if (id != null && id.length() > 0 && (overwrites || !uriReferences.contains(id))) + { + ref = new URIReference(element, true); + uriReferences.put(id, ref); + } + NodeList nl = element.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) + { + Node node = nl.item(i); + if (node instanceof Element) + resolved = parseURIReferences(uriReferences, (Element)node, overwrites) && resolved; + } + if (ref != null) + ref.setResolved(resolved); + } + return resolved; + } + + public static Element resolveURIReferences(Hashtable uriReferences, Element element) + { + if (uriReferences != null && !uriReferences.isEmpty()) + return resolveURIReferences(uriReferences, element.getOwnerDocument(), element, new Vector()); + else + return element; + } + + private static Element resolveURIReferences(Hashtable uriReferences, Document doc, Element element, Vector usedIds) + { + String href = element.getAttribute(HREF); + Element resolvedElement = element; + boolean resolved = false; + if (href != null && href.length() > 0) + { + URIReference ref = null; + if (href.indexOf(POUND) != -1) + href = href.substring(1, href.length()); + if (!usedIds.contains(href)) + { + ref = (URIReference)uriReferences.get(href); + if (ref != null) + { + usedIds.add(href); + Element elementRef = ref.getRefElement(); + resolved = ref.getResolved(); + resolvedElement = doc.createElement(element.getTagName()); + NodeList nl = elementRef.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) + { + Node node = nl.item(i); + if (node != null) + resolvedElement.appendChild(doc.importNode(node, true)); + } + } + } + } + if (!resolved) + { + NodeList nl = resolvedElement.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) + { + Node node = nl.item(i); + if (node instanceof Element) + { + Element child = resolveURIReferences(uriReferences, resolvedElement.getOwnerDocument(), (Element)node, usedIds); + resolvedElement.replaceChild(child, node); + } + } + } + if (href != null) + usedIds.remove(href); + return resolvedElement; + } + + private static class URIReference + { + private Element ref_; + private boolean resolved_; + + public URIReference(Element ref, boolean resolved) + { + ref_ = ref; + resolved_ = resolved; + } + + public Element getRefElement() + { + return ref_; + } + + public void setRefElement(Element ref) + { + ref_ = ref; + } + + public boolean getResolved() + { + return resolved_; + } + + public void setResolved(boolean resolved) + { + resolved_ = resolved; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexFixFragment.java new file mode 100644 index 000000000..9b3fd0941 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexFixFragment.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +public class XSDComplexFixFragment extends XSDComplexFragment { + public XSDComplexFixFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDComplexRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDComplexFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexFragment.java new file mode 100644 index 000000000..ad97efdb7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexFragment.java @@ -0,0 +1,224 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDComplexFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.XSDTypeDefinitionUtil; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComplexTypeContent; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDComplexFinal; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDParticleContent; +import org.eclipse.xsd.XSDModelGroupDefinition; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import java.util.Vector; +import java.util.Hashtable; +import java.util.List; + +public abstract class XSDComplexFragment extends XSDMapFragment implements IXSDComplexFragment +{ + public XSDComplexFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) + { + super(id, name, config, controller); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + Element[] instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocuments, getName()); + boolean paramsValid = internalEquals(instanceDocumentsCopy, instanceDocuments); + XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)getXSDTypeDefinition(); + XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType); + if (complexTypeContent instanceof XSDTypeDefinition) + return setParamsForXSDTypeDef(instanceDocumentsCopy) && paramsValid; + else + return setParamsForXSDParticle(instanceDocumentsCopy) && paramsValid; + } + + private boolean setParamsForXSDTypeDef(Element[] instanceDocuments) + { + boolean paramsValid = true; + removeAllFragments(); + for (int i = 0; i < instanceDocuments.length; i++) + { + IXSDFragment childFrag = getFragment(createInstance()); + Element[] childInstanceDocuments = new Element[1]; + childInstanceDocuments[0] = instanceDocuments[i]; + if (!childFrag.setParameterValuesFromInstanceDocuments(setElementsTagName(childInstanceDocuments, childFrag.getName()))) + paramsValid = false; + } + return paramsValid; + } + + private boolean setParamsForXSDParticle(Element[] instanceDocuments) + { + boolean paramsValid = true; + removeAllFragments(); + for (int i = 0; i < instanceDocuments.length; i++) + { + IXSDFragment childFrag = getFragment(createInstance()); + Vector instancesVector = new Vector(); + NodeList nl = instanceDocuments[i].getChildNodes(); + for (int j = 0; j < nl.getLength(); j++) + { + Node node = nl.item(j); + if (node instanceof Element) + instancesVector.add(node); + else + paramsValid = false; + } + Element[] childInstanceDocuments = new Element[instancesVector.size()]; + instancesVector.copyInto(childInstanceDocuments); + if (!childFrag.setParameterValuesFromInstanceDocuments(childInstanceDocuments)) + paramsValid = false; + } + return paramsValid; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) + { + XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)getXSDTypeDefinition(); + XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType); + Element[] instanceDocuments; + String tagName = getInstanceDocumentTagName(namespaceTable); + if (complexTypeContent instanceof XSDTypeDefinition) + instanceDocuments = genInstancesForXSDTypeDef(genXSIType, namespaceTable, tagName, doc); + else + instanceDocuments = genInstancesForXSDParticle(genXSIType, namespaceTable, tagName, doc); + return (genXSIType ? addXSIType(instanceDocuments, namespaceTable) : instanceDocuments); + } + + private Element[] genInstancesForXSDTypeDef(boolean genXSIType, Hashtable namespaceTable, String tagName, Document doc) + { + IXSDFragment[] fragments = getAllFragments(); + Vector instanceDocumentsCopy = new Vector(); + for (int i = 0; i < fragments.length; i++) + { + Element[] fragmentInstances = fragments[i].genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + if (fragmentInstances.length > 0) + instanceDocumentsCopy.add(fragmentInstances[0]); + } + Element[] instanceDocuments = new Element[instanceDocumentsCopy.size()]; + for (int i = 0; i < instanceDocuments.length; i++) + { + instanceDocuments[i] = (Element)instanceDocumentsCopy.get(i); + } + return setElementsTagName(instanceDocuments, tagName); + } + + private Element[] genInstancesForXSDParticle(boolean genXSIType, Hashtable namespaceTable, String tagName, Document doc) + { + IXSDFragment[] childFrags = getAllFragments(); + Element[] instanceDocuments = new Element[childFrags.length]; + for (int i = 0; i < instanceDocuments.length; i++) + { + Element[] childInstances = childFrags[i].genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + Element instanceDocument = doc.createElement(tagName); + for (int j = 0; j < childInstances.length; j++) + { + if (childInstances[j] != null) + instanceDocument.appendChild(childInstances[j]); + } + instanceDocuments[i] = instanceDocument; + } + return instanceDocuments; + } + + private XSDModelGroup getXSDModelGroup(XSDParticle xsdParticle) + { + if (xsdParticle != null) + { + XSDParticleContent xsdParticleContent = xsdParticle.getContent(); + if (xsdParticleContent != null) + { + if (xsdParticleContent instanceof XSDModelGroupDefinition) + { + XSDModelGroupDefinition xsdModelGroupDef = (XSDModelGroupDefinition)xsdParticleContent; + if (xsdModelGroupDef.isModelGroupDefinitionReference()) + xsdModelGroupDef = xsdModelGroupDef.getResolvedModelGroupDefinition(); + return xsdModelGroupDef.getModelGroup(); + } + else if (xsdParticleContent instanceof XSDModelGroup) + return (XSDModelGroup)xsdParticleContent; + } + } + return null; + } + + private List getInheritedParticles(XSDComplexTypeDefinition complexType) + { + Vector v = new Vector(); + if (complexType.getDerivationMethod().getValue() == XSDComplexFinal.EXTENSION) + { + XSDTypeDefinition extType = complexType.getBaseType(); + if (extType != null && extType != complexType && extType instanceof XSDComplexTypeDefinition) + { + XSDComplexTypeContent extTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent((XSDComplexTypeDefinition)extType); + if (extTypeContent instanceof XSDParticle) + { + XSDModelGroup xsdModelGroup = getXSDModelGroup((XSDParticle)extTypeContent); + if (xsdModelGroup != null) + { + v.addAll(getInheritedParticles((XSDComplexTypeDefinition)extType)); + v.addAll(xsdModelGroup.getParticles()); + } + } + } + } + return v; + } + + private void gatherInheritedParticles(XSDComplexTypeDefinition complexType) + { + if (complexType.getDerivationMethod().getValue() == XSDComplexFinal.EXTENSION) + { + XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType); + if (complexTypeContent instanceof XSDParticle) + { + XSDModelGroup xsdModelGroup = getXSDModelGroup((XSDParticle)complexTypeContent); + if (xsdModelGroup != null) + { + List inheritedParticles = getInheritedParticles(complexType); + List particles = xsdModelGroup.getParticles(); + particles.addAll(0, inheritedParticles); + } + } + } + } + + public String createComplexInstance() + { + XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)getXSDTypeDefinition(); + gatherInheritedParticles(complexType); + XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType); + XSDToFragmentConfiguration thisConfig = getXSDToFragmentConfiguration(); + XSDToFragmentConfiguration xsdConfig = new XSDToFragmentConfiguration(); + xsdConfig.setXSDComponent(complexTypeContent); + xsdConfig.setStyle(thisConfig.getStyle()); + xsdConfig.setPartEncoding(thisConfig.getPartEncoding()); + xsdConfig.setWSDLPartName(thisConfig.getWSDLPartName()); + String newID = genID(); + addFragment(newID, getXSDToFragmentController().getFragment(xsdConfig, newID, newID)); + return newID; + } + + public String createInstance() + { + return createComplexInstance(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexRangeFragment.java new file mode 100644 index 000000000..c3453ce18 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDComplexRangeFragment.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +public class XSDComplexRangeFragment extends XSDComplexFragment { + public XSDComplexRangeFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDComplexRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDComplexRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDDefaultFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDDefaultFragment.java new file mode 100644 index 000000000..981aca99f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDDefaultFragment.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import java.util.Vector; +import java.util.Hashtable; + +public class XSDDefaultFragment extends XSDFragment { + public XSDDefaultFragment(String id, String name, XSDToFragmentConfiguration config) { + super(id, name, config); + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + String[] param = new String[1]; + param[0] = parser.getParameter(getID()); + setParameterValues(getID(), param); + return isElement(addRootElement(param[0])); + } + + private String addRootElement(String element) { + StringBuffer sb = new StringBuffer(); + sb.append(FragmentConstants.ROOT_ELEMENT_START_TAG); + sb.append(element); + sb.append(FragmentConstants.ROOT_ELEMENT_END_TAG); + return sb.toString(); + } + + private boolean isElement(String elementString) { + try { + return (XMLUtils.stringToElement(elementString) != null); + } + catch (Throwable t) { + return false; + } + } + + public boolean validateAllParameterValues() { + String param = getParameterValue(getID(), 0); + return (param == null || isElement(addRootElement(param))); + } + + public boolean validateParameterValues(String paramKey) { + String param = getParameterValue(getID(), 0); + return (param == null || isElement(addRootElement(param))); + } + + public boolean validateParameterValue(String paramKey, int paramIndex) { + String param = getParameterValue(getID(), 0); + return (param == null || isElement(addRootElement(param))); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) { + StringBuffer sb = new StringBuffer(); + boolean paramValid = true; + for (int i = 0; i < instanceDocuments.length; i++) { + String instanceString = XMLUtils.serialize(instanceDocuments[i], true); + if (instanceString != null && instanceString.length() > 0) + sb.append(instanceString); + else + paramValid = false; + } + String[] param = {sb.toString()}; + setParameterValues(getID(), param); + return paramValid; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) { + String param = getParameterValue(getID(), 0); + if (param == null) + return new Element[0]; + Element root; + try { + root = (Element)doc.importNode(XMLUtils.stringToElement(addRootElement(param)), true); + } + catch (Throwable t) { + return new Element[0]; + } + NodeList nl = root.getChildNodes(); + Vector instanceDocumentVector = new Vector(); + for (int i = 0; i < nl.getLength(); i++) { + Node node = nl.item(i); + if (node instanceof Element) + instanceDocumentVector.add(node); + } + Element[] instanceDocuments = new Element[instanceDocumentVector.size()]; + for (int i = 0; i < instanceDocuments.length; i++) { + instanceDocuments[i] = (Element)instanceDocumentVector.get(i); + } + return instanceDocuments; + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDDefaultRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDDefaultWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDDelegationFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDDelegationFragment.java new file mode 100644 index 000000000..dc03c29e2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDDelegationFragment.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDDelegationFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import java.util.Vector; +import java.util.Hashtable; + +public class XSDDelegationFragment extends XSDFragment implements IXSDDelegationFragment +{ + private IXSDFragment xsdFragment_; + + public XSDDelegationFragment(String id, String name, XSDToFragmentConfiguration config) + { + super(id, name, config); + xsdFragment_ = null; + } + + public void setName(String name) { + super.setName(name); + if (xsdFragment_ != null) + xsdFragment_.setName(name); + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException + { + return xsdFragment_.processParameterValues(parser); + } + + public void setParameterValues(String paramKey, String[] params) + { + xsdFragment_.setParameterValues(paramKey, params); + } + + public void setParameterValues(String paramKey, Vector params) + { + xsdFragment_.setParameterValues(paramKey, params); + } + + public String[] getParameterValues(String paramKey) + { + return xsdFragment_.getParameterValues(paramKey); + } + + public String getParameterValue(String paramKey, int paramIndex) + { + return xsdFragment_.getParameterValue(paramKey, paramIndex); + } + + public boolean validateAllParameterValues() + { + return xsdFragment_.validateAllParameterValues(); + } + + public boolean validateParameterValues(String paramKey) + { + return xsdFragment_.validateParameterValues(paramKey); + } + + public boolean validateParameterValue(String paramKey, int paramIndex) + { + return xsdFragment_.validateParameterValue(paramKey, paramIndex); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + return xsdFragment_.setParameterValuesFromInstanceDocuments(instanceDocuments); + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) + { + return xsdFragment_.genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + } + + public String getInformationFragment() + { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() + { + return "/wsdl/fragment/XSDDelegationRFragmentJSP.jsp"; + } + + public String getWriteFragment() + { + return "/wsdl/fragment/XSDDelegationWFragmentJSP.jsp"; + } + + public void setXSDDelegationFragment(IXSDFragment xsdFragment) + { + xsdFragment_ = xsdFragment; + } + + public IXSDFragment getXSDDelegationFragment() + { + return xsdFragment_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDElementFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDElementFragment.java new file mode 100644 index 000000000..1baaff75d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDElementFragment.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDElementFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDForm; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import java.util.Vector; +import java.util.Hashtable; + +public class XSDElementFragment extends XSDDelegationFragment implements IXSDElementFragment +{ + private int minOccurs_; + private int maxOccurs_; + + public XSDElementFragment(String id, String name, XSDToFragmentConfiguration config) + { + super(id, name, config); + if (config != null) + { + minOccurs_ = config.getMinOccurs(); + maxOccurs_ = config.getMaxOccurs(); + } + else + { + minOccurs_ = FragmentConstants.DEFAULT_MIN_OCCURS; + maxOccurs_ = FragmentConstants.DEFAULT_MAX_OCCURS; + } + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException + { + IXSDFragment elementTypeFragment = getXSDDelegationFragment(); + if (!elementTypeFragment.processParameterValues(parser)) + return false; + String[] params = getParameterValues(elementTypeFragment.getID()); + if (params != null && !withinRange(params.length)) + return false; + return true; + } + + public boolean validateAllParameterValues() + { + IXSDFragment elementTypeFragment = getXSDDelegationFragment(); + String[] params = getParameterValues(elementTypeFragment.getID()); + if (params != null && !withinRange(params.length)) + return false; + if (!elementTypeFragment.validateAllParameterValues()) + return false; + return true; + } + + public boolean validateParameterValues(String paramKey) + { + String[] params = getParameterValues(paramKey); + if (params != null && !withinRange(params.length)) + return false; + if (!getXSDDelegationFragment().validateParameterValues(paramKey)) + return false; + return true; + } + + public boolean validateParameterValue(String paramKey, int paramIndex) + { + if (!withinRange(paramIndex + 1)) + return false; + XSDElementDeclaration xsdElement = (XSDElementDeclaration)getXSDToFragmentConfiguration().getXSDComponent(); + String param = getParameterValue(paramKey, paramIndex); + if (param != null && param.length() <= 0 && !xsdElement.isNillable()) + return false; + if (!getXSDDelegationFragment().validateParameterValue(paramKey, paramIndex)) + return false; + return true; + } + + public void setXSDToFragmentConfiguration(XSDToFragmentConfiguration config) + { + super.setXSDToFragmentConfiguration(config); + minOccurs_ = config.getMinOccurs(); + maxOccurs_ = config.getMaxOccurs(); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + Element[] instanceDocumentsCopy = instanceDocuments; + XSDToFragmentConfiguration config = getXSDToFragmentConfiguration(); + String wsdlPartName = config.getWSDLPartName(); + if (config.getIsWSDLPart() && config.getStyle() == FragmentConstants.STYLE_RPC && wsdlPartName != null && wsdlPartName.length() > 0 && instanceDocumentsCopy.length == 1 && wsdlPartName.equals(instanceDocumentsCopy[0].getTagName())) + { + NodeList nl = instanceDocumentsCopy[0].getChildNodes(); + Vector childElements = new Vector(); + for (int i = 0; i < nl.getLength(); i++) + { + Node node = nl.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) + childElements.add(node); + } + instanceDocumentsCopy = (Element[])childElements.toArray(new Element[0]); + } + IXSDFragment elementTypeFragment = getXSDDelegationFragment(); + instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocumentsCopy, getName()); + return elementTypeFragment.setParameterValuesFromInstanceDocuments(setElementsTagName(instanceDocumentsCopy, elementTypeFragment.getName())); + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) + { + Element[] instanceDocuments = getXSDDelegationFragment().genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + instanceDocuments = setElementsTagName(instanceDocuments, getInstanceDocumentTagName(namespaceTable)); + XSDToFragmentConfiguration config = getXSDToFragmentConfiguration(); + String wsdlPartName = config.getWSDLPartName(); + if (config.getIsWSDLPart() && config.getStyle() == FragmentConstants.STYLE_RPC && wsdlPartName != null && wsdlPartName.length() > 0) + { + Element[] instanceDocumentsCopy = instanceDocuments; + instanceDocuments = new Element[1]; + instanceDocuments[0] = doc.createElement(wsdlPartName); + for (int i = 0; i < instanceDocumentsCopy.length; i++) + { + if (instanceDocumentsCopy[i] != null) + instanceDocuments[0].appendChild(instanceDocumentsCopy[i]); + } + } + return instanceDocuments; + } + + protected boolean isInstanceNamespaceQualified() + { + XSDToFragmentConfiguration config = getXSDToFragmentConfiguration(); + if (config.getPartEncoding() == FragmentConstants.ENCODING_LITERAL) + { + XSDElementDeclaration xsdElement = (XSDElementDeclaration)config.getXSDComponent(); + if (xsdElement.isGlobal()) + return true; + else + { + if (xsdElement.isSetForm()) + return (xsdElement.getForm().getValue() == XSDForm.QUALIFIED); + else + return (xsdElement.getSchema().getElementFormDefault().getValue() == XSDForm.QUALIFIED); + } + } + else + return false; + } + + protected String getInstanceDocumentTagName(Hashtable namespaceTable) + { + XSDToFragmentConfiguration config = getXSDToFragmentConfiguration(); + XSDElementDeclaration xsdElement = (XSDElementDeclaration)config.getXSDComponent(); + StringBuffer tagName = new StringBuffer(); + if (isInstanceNamespaceQualified()) + { + String nsURI = null; + // port to org.eclipse.xsd + if (xsdElement.getResolvedElementDeclaration() != null) + nsURI = xsdElement.getResolvedElementDeclaration().getTargetNamespace(); + else + nsURI = xsdElement.getTargetNamespace(); + if (nsURI != null && nsURI.length() > 0) + { + String prefix = getPrefixFromNamespaceURI(nsURI, namespaceTable); + tagName.append(prefix); + tagName.append(FragmentConstants.COLON); + } + } + String xsdElementName = xsdElement.getName(); + if (xsdElementName == null || xsdElementName.length() <= 0) + { + // port to org.eclipse.xsd + if (xsdElement.getResolvedElementDeclaration() != null) + xsdElementName = xsdElement.getResolvedElementDeclaration().getName(); + else + xsdElementName = getName(); + } + tagName.append(xsdElementName); + return tagName.toString(); + } + + private boolean withinRange(int size) + { + if (size < minOccurs_) + return false; + if (maxOccurs_ != FragmentConstants.UNBOUNDED && size > maxOccurs_) + return false; + return true; + } + + public void setMinOccurs(int minOccurs) + { + minOccurs_ = minOccurs; + } + + public int getMinOccurs() + { + return minOccurs_; + } + + public void setMaxOccurs(int maxOccurs) + { + maxOccurs_ = maxOccurs; + } + + public int getMaxOccurs() + { + return maxOccurs_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDEmptyFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDEmptyFragment.java new file mode 100644 index 000000000..0f164220e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDEmptyFragment.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import java.util.Vector; + +public class XSDEmptyFragment extends XSDFragment { + private int occurance_; + + public XSDEmptyFragment(String id, String name, XSDToFragmentConfiguration config) { + super(id, name, config); + occurance_ = 0; + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + String occurance = parser.getParameter(getID()); + try { + occurance_ = Integer.parseInt(occurance); + return validateAllParameterValues(); + } + catch (Throwable t) { + occurance_ = -1; + return false; + } + } + + public void setParameterValues(String paramKey, String[] params) { + } + + public void setParameterValues(String paramKey, Vector params) { + } + + public String[] getParameterValues(String paramKey) { + if (occurance_ < 0) + return null; + else { + String[] params = new String[occurance_]; + for (int i = 0; i < params.length; i++) { + params[i] = ""; + } + return params; + } + } + + public String getParameterValue(String paramKey, int paramIndex) { + if (paramIndex >= 0 && paramIndex < occurance_) + return ""; + else + return null; + } + + public boolean validateAllParameterValues() { + XSDToFragmentConfiguration xsdConfig = getXSDToFragmentConfiguration(); + int min = xsdConfig.getMinOccurs(); + int max = xsdConfig.getMaxOccurs(); + return (occurance_ >= 0 && occurance_ >= min && (max == FragmentConstants.UNBOUNDED || occurance_ <= max)); + } + + public boolean validateParameterValues(String paramKey) { + return validateAllParameterValues(); + } + + public boolean validateParameterValue(String paramKey, int paramIndex) { + return validateAllParameterValues(); + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) { + Element[] instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocuments, getName()); + boolean paramsValid = true; + for (int i = 0; i < instanceDocumentsCopy.length; i++) { + NodeList nodeList = instanceDocumentsCopy[i].getChildNodes(); + if (nodeList.getLength() > 1) + paramsValid = false; + else if (nodeList.getLength() != 0) { + Node node = nodeList.item(0); + if (node.getNodeType() != Node.TEXT_NODE || !isWhitespace(node.getNodeValue())) + paramsValid = false; + } + } + occurance_ = instanceDocumentsCopy.length; + return paramsValid && validateAllParameterValues(); + } + + private boolean isWhitespace(String s) { + char[] chars = s.toCharArray(); + for (int i = 0; i < chars.length; i++) { + if (!Character.isWhitespace(chars[i]) || !Character.isSpaceChar(chars[i])) + return false; + } + return true; + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDEmptyWFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDEmptyRFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java new file mode 100644 index 000000000..1a10ad60e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDFragment.java @@ -0,0 +1,317 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDNamedComponent; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.XSDForm; +import java.util.Vector; +import java.util.Hashtable; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Attr; + +public abstract class XSDFragment extends Fragment implements IXSDFragment +{ + private XSDToFragmentConfiguration config_; + private XSDTypeDefinition typeDef_; + private int seed_; + + public XSDFragment(String id, String name, XSDToFragmentConfiguration config) + { + super(id, name); + config_ = config; + if (config_ != null) + { + XSDComponent component = config.getXSDComponent(); + if (component instanceof XSDTypeDefinition) + typeDef_ = (XSDTypeDefinition)component; + else + typeDef_ = null; + } + seed_ = 0; + } + + public void setXSDToFragmentConfiguration(XSDToFragmentConfiguration config) + { + config_ = config; + if (config_ != null) + { + XSDComponent component = config.getXSDComponent(); + if (component instanceof XSDTypeDefinition) + setXSDTypeDefinition((XSDTypeDefinition)component); + } + } + + public XSDToFragmentConfiguration getXSDToFragmentConfiguration() + { + return config_; + } + + public void setXSDTypeDefinition(XSDTypeDefinition typeDef) + { + typeDef_ = typeDef; + } + + public XSDTypeDefinition getXSDTypeDefinition() + { + return typeDef_; + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + Element[] instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocuments, getName()); + String[] params = new String[instanceDocumentsCopy.length]; + boolean paramsValid = internalEquals(instanceDocumentsCopy, instanceDocuments); + for (int i = 0; i < instanceDocumentsCopy.length; i++) + { + params[i] = ""; + NodeList nodeList = instanceDocumentsCopy[i].getChildNodes(); + if (nodeList.getLength() > 0) + { + Node node = nodeList.item(0); + if (nodeList.getLength() > 1) + paramsValid = false; + if (node.getNodeType() != Node.TEXT_NODE) + paramsValid = false; + else + params[i] = node.getNodeValue(); + } + else + paramsValid = false; + } + setParameterValues(getID(), params); + return paramsValid && validateAllParameterValues(); + } + + protected Element[] getInstanceDocumentsByTagName(Element[] instanceDocuments, String tagName) + { + if (instanceDocuments == null) + return new Element[0]; + Vector instancesCopy = new Vector(); + for (int i = 0; i < instanceDocuments.length; i++) + { + if (instanceDocuments[i] == null) + continue; + String instanceTagName = trimPrefix(instanceDocuments[i].getTagName()); + if (instanceTagName.equals(tagName)) + instancesCopy.add(instanceDocuments[i]); + } + Element[] instances = new Element[instancesCopy.size()]; + instancesCopy.copyInto(instances); + return instances; + } + + protected String trimPrefix(String s) + { + String sCopy = new String(s); + int colonIndex = sCopy.indexOf(FragmentConstants.COLON); + if (colonIndex != -1 && colonIndex + 1 < sCopy.length() && !((String.valueOf(sCopy.charAt(colonIndex + 1))).equals(FragmentConstants.COLON))) + sCopy = sCopy.substring(colonIndex + 1, sCopy.length()); + return sCopy; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) + { + String[] params = getParameterValues(getID()); + if (params == null) + return new Element[0]; + Element[] instanceDocuments = new Element[params.length]; + String tagName = getInstanceDocumentTagName(namespaceTable); + for (int i = 0; i < instanceDocuments.length; i++) + { + Element instanceDocument = doc.createElement(tagName); + Node textNode = doc.createTextNode(params[i]); + instanceDocument.appendChild(textNode); + instanceDocuments[i] = instanceDocument; + } + return (genXSIType ? addXSIType(instanceDocuments, namespaceTable) : instanceDocuments); + } + + public String genID() + { + StringBuffer newID = new StringBuffer(); + newID.append(getID()); + newID.append(FragmentConstants.ID_SEPERATOR); + newID.append(seed_++); + return newID.toString(); + } + + protected boolean isInstanceNamespaceQualified() + { + XSDSchema xsdSchema = config_.getXSDComponent().getSchema(); + return (!config_.getIsWSDLPart() && config_.getPartEncoding() == FragmentConstants.ENCODING_LITERAL && xsdSchema.getElementFormDefault().getValue() == XSDForm.QUALIFIED); + } + + protected String getInstanceDocumentTagName(Hashtable namespaceTable) + { + StringBuffer tagName = new StringBuffer(); + if (isInstanceNamespaceQualified()) + { + String nsURI = config_.getXSDComponent().getSchema().getTargetNamespace(); + String prefix = getPrefixFromNamespaceURI(nsURI, namespaceTable); + tagName.append(prefix); + tagName.append(FragmentConstants.COLON); + } + tagName.append(getName()); + return tagName.toString(); + } + + protected Element[] addXSIType(Element[] instanceDocuments, Hashtable namespaceTable) + { + XSDComponent xsdComponent = config_.getXSDComponent(); + if (instanceDocuments != null && (xsdComponent instanceof XSDNamedComponent)) + { + String xsdComponentName = ((XSDNamedComponent)xsdComponent).getName(); + if (xsdComponentName != null && xsdComponentName.length() > 0) + { + for (int i = 0; i < instanceDocuments.length; i++) + { + if (instanceDocuments[i] == null) + continue; + String xsiURI = FragmentConstants.URI_XSI; + String xsiPrefix = getPrefixFromNamespaceURI(xsiURI, namespaceTable); + String xsiTypeURI = xsdComponent.getSchema().getTargetNamespace(); + String xsiTypePrefix = getPrefixFromNamespaceURI(xsiTypeURI, namespaceTable); + ; + StringBuffer attrName = new StringBuffer(); + attrName.append(xsiPrefix); + attrName.append(FragmentConstants.COLON); + attrName.append(FragmentConstants.XSI_TYPE); + StringBuffer attrValue = new StringBuffer(); + attrValue.append(xsiTypePrefix); + attrValue.append(FragmentConstants.COLON); + attrValue.append(xsdComponentName); + instanceDocuments[i].setAttribute(attrName.toString(), attrValue.toString()); + } + } + } + return instanceDocuments; + } + + public boolean validateAllParameterValues() + { + if (!super.validateAllParameterValues()) + return false; + String[] params = getParameterValues(getID()); + int length = (params != null) ? params.length : 0; + int min = config_.getMinOccurs(); + int max = config_.getMaxOccurs(); + return (length >= min && (max == FragmentConstants.UNBOUNDED || length <= max)); + } + + protected String getPrefixFromNamespaceURI(String nsURI, Hashtable namespaceTable) + { + String prefix = (String)namespaceTable.get(nsURI); + int i = 0; + while (prefix == null || prefix.length() <= 0) + { + StringBuffer prefixCopy = new StringBuffer(); + prefixCopy.append(FragmentConstants.QNAME_PREFIX); + prefixCopy.append(String.valueOf(i)); + i++; + if (!namespaceTable.contains(prefixCopy.toString())) + { + namespaceTable.put(nsURI, prefixCopy.toString()); + prefix = prefixCopy.toString(); + } + } + return prefix; + } + + private Element removeDupNSFromChildren(Element element, String[] nsNames, String[] nsValues) + { + NodeList children = element.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) + { + Node child = children.item(i); + if (child instanceof Element) + { + for (int j = 0; j < nsNames.length; j++) + { + String childNSValue = ((Element)child).getAttribute(nsNames[j]); + if (childNSValue != null && childNSValue.equals(nsValues[j])) + ((Element)child).removeAttribute(nsNames[j]); + } + } + } + return element; + } + + protected Element setElementTagName(Element e, String tagName) + { + if (!e.getTagName().equals(tagName)) + { + try + { + Document doc = e.getOwnerDocument(); + NodeList children = e.getChildNodes(); + NamedNodeMap attributes = e.getAttributes(); + Element eCopy = doc.createElement(tagName); + for (int i = 0; i < children.getLength(); i++) + { + Node child = children.item(i); + if (child != null) + { + eCopy.appendChild(child); + // When you append a node from one element to another, + // the original element will lose its reference to this node, + // therefore, the size of the node list will decrease by 1. + i--; + } + } + for (int j = 0; j < attributes.getLength(); j++) + { + Node attr = attributes.item(j); + if (attr != null && (attr instanceof Attr)) + { + Attr attribute = (Attr)attr; + eCopy.setAttribute(attribute.getName(), attribute.getValue()); + } + } + return eCopy; + } + catch (Exception exception) + { + } + } + return e; + } + + protected Element[] setElementsTagName(Element[] e, String tagName) + { + Element[] eCopy = new Element[e.length]; + for (int i = 0; i < eCopy.length; i++) + { + eCopy[i] = setElementTagName(e[i], tagName); + } + return eCopy; + } + + protected boolean internalEquals(Element[] instanceDocumentsCopy, Element[] instanceDocuments) + { + if (!config_.getIsWSDLPart()) + { + int length = (instanceDocuments != null) ? instanceDocuments.length : 0; + int lengthCopy = (instanceDocumentsCopy != null) ? instanceDocumentsCopy.length : 0; + return (length == lengthCopy); + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupAllFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupAllFragment.java new file mode 100644 index 000000000..414e3fe97 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupAllFragment.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDGroupAllFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +import org.w3c.dom.Element; +import java.util.Vector; + +public class XSDGroupAllFragment extends XSDGroupFragment implements IXSDGroupAllFragment { + private String groupID_; + + public XSDGroupAllFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + groupID_ = null; + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + String groupID = parser.getParameter(getID()); + if (groupID_ != null && groupID != null && groupID_.equals(groupID)) { + setGroupMemberIDsOrdering(parser.getParameterValues(groupID_)); + boolean valuesValid = true; + IXSDFragment[] groupMemberFragments = getGroupMemberFragments(groupID_); + for (int i = 0; i < groupMemberFragments.length; i++) { + if (groupMemberFragments[i] != null && !groupMemberFragments[i].processParameterValues(parser)) + valuesValid = false; + } + return valuesValid; + } + else { + groupID_ = null; + removeGroupIDs(); + return true; + } + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) { + removeGroupIDs(); + boolean paramsValid = true; + if (instanceDocuments != null && instanceDocuments.length > 0) { + groupID_ = createInstance(); + IXSDFragment[] groupMemberFrags = getGroupMemberFragments(groupID_); + String[] groupMemberIDsOrder = new String[groupMemberFrags.length]; + int orderIndex = 0; + for (int i = 0; i < instanceDocuments.length; i++) { + boolean paramsAssigned = false; + for (int j = 0; j < groupMemberFrags.length; j++) { + if (groupMemberFrags[j] != null && groupMemberFrags[j].getName().equals(trimPrefix(instanceDocuments[i].getTagName()))) { + Element[] childInstance = {instanceDocuments[i]}; + if (!groupMemberFrags[j].setParameterValuesFromInstanceDocuments(childInstance)) + paramsValid = false; + groupMemberIDsOrder[orderIndex] = groupMemberFrags[j].getID(); + orderIndex++; + paramsAssigned = true; + groupMemberFrags[j] = null; + break; + } + } + if (!paramsAssigned) + paramsValid = false; + } + for (int k = 0; k < groupMemberFrags.length; k++) { + if (groupMemberFrags[k] != null) { + groupMemberIDsOrder[orderIndex] = groupMemberFrags[k].getID(); + orderIndex++; + } + } + setGroupMemberIDsOrdering(groupMemberIDsOrder); + } + return paramsValid; + } + + public String getGroupAllInstance() { + if (groupID_ == null) + groupID_ = createGroupInstance(); + return groupID_; + } + + public String createInstance() { + return getGroupAllInstance(); + } + + public boolean setGroupMemberIDsOrdering(String[] groupMemberIDs) { + if (groupMemberIDs == null) + return false; + String[] existingGroupMemberIDs = getGroupMemberIDs(groupID_); + if (existingGroupMemberIDs.length != groupMemberIDs.length) + return false; + Vector existingGroupMemberIDsVector = new Vector(); + for (int i = 0; i < existingGroupMemberIDs.length; i++) { + existingGroupMemberIDsVector.add(existingGroupMemberIDs[i]); + } + for (int j = 0; j < groupMemberIDs.length; j++) { + if (!existingGroupMemberIDsVector.remove(groupMemberIDs[j])) + return false; + } + if (setFragmentsOrder(groupMemberIDs)) { + setGroupMemberIDs(groupID_, groupMemberIDs); + return true; + } + else + return false; + } + + public boolean moveUpGroupMemberID(String groupMemberID) { + String[] groupMemberIDs = getGroupMemberIDs(groupID_); + if (groupMemberID.equals(groupMemberIDs[0])) + return false; + for (int i = 1; i < groupMemberIDs.length; i++) { + if (groupMemberID.equals(groupMemberIDs[i])) { + groupMemberIDs[i] = groupMemberIDs[i - 1]; + groupMemberIDs[i - 1] = groupMemberID; + if (setFragmentsOrder(groupMemberIDs)) { + setGroupMemberIDs(groupID_, groupMemberIDs); + return true; + } + else + return false; + } + } + return false; + } + + public boolean moveDownGroupMemberID(String groupMemberID) { + String[] groupMemberIDs = getGroupMemberIDs(groupID_); + if (groupMemberID.equals(groupMemberIDs[groupMemberIDs.length - 1])) + return false; + for (int i = 0; i < groupMemberIDs.length - 1; i++) { + if (groupMemberID.equals(groupMemberIDs[i])) { + groupMemberIDs[i] = groupMemberIDs[i + 1]; + groupMemberIDs[i + 1] = groupMemberID; + if (setFragmentsOrder(groupMemberIDs)) { + setGroupMemberIDs(groupID_, groupMemberIDs); + return true; + } + else + return false; + } + } + return false; + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDGroupRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDGroupAllWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceFixFragment.java new file mode 100644 index 000000000..4f6d724cc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceFixFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public class XSDGroupChoiceFixFragment extends XSDGroupChoiceFragment { + public XSDGroupChoiceFixFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDGroupChoiceRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDGroupChoiceFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceFragment.java new file mode 100644 index 000000000..d755cf9e7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceFragment.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDGroupChoiceFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDModelGroup; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import java.util.Hashtable; +import java.util.Vector; + +public abstract class XSDGroupChoiceFragment extends XSDGroupFragment implements IXSDGroupChoiceFragment { + private XSDParticle[] choices_; + private Hashtable choiceIndexes_; + + public XSDGroupChoiceFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + choices_ = null; + choiceIndexes_ = new Hashtable(); + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + super.processParameterValues(parser); + String[] groupIDs = getGroupIDs(); + choiceIndexes_.clear(); + boolean paramsValid = true; + for (int i = 0; i < groupIDs.length; i++) { + String selectedChoiceFragID = parser.getParameter(groupIDs[i]); + int choiceIndex = 0; + IXSDFragment[] choiceFrags = getGroupMemberFragments(groupIDs[i]); + for (int j = 0; j < choiceFrags.length; j++) { + if (choiceFrags[j].getID().equals(selectedChoiceFragID)) { + choiceIndex = j; + paramsValid = (paramsValid && choiceFrags[j].validateAllParameterValues()); + break; + } + } + setChoiceIndex(groupIDs[i], choiceIndex); + } + return paramsValid; + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) { + removeGroupIDs(); + choiceIndexes_.clear(); + boolean paramsValid = true; + if (instanceDocuments != null) { + for (int i = 0; i < instanceDocuments.length; i++) { + String groupID = createGroupChoiceInstance(0); + IXSDFragment[] choiceFrags = getGroupMemberFragments(groupID); + for (int j = 0; j < choiceFrags.length; j++) { + if (choiceFrags[j].getName().equals(trimPrefix(instanceDocuments[i].getTagName()))) { + XSDToFragmentConfiguration xsdConfig = choiceFrags[j].getXSDToFragmentConfiguration(); + Element[] childInstances = getInstanceDocumentPartition(instanceDocuments, i, xsdConfig.getMinOccurs(), xsdConfig.getMaxOccurs()); + if (!choiceFrags[j].setParameterValuesFromInstanceDocuments(childInstances)) + paramsValid = false; + setChoiceIndex(groupID, j); + if (childInstances.length > 0) + i = i + childInstances.length - 1; // minus 1 because there's an i++ in the outer for loop + break; + } + } + } + } + return paramsValid; + } + + private Element[] getInstanceDocumentPartition(Element[] instanceDocuments, int start, int minSize, int maxSize) { + String tagName = instanceDocuments[start].getTagName(); + int size = 1; + for (int i = start + 1; i < instanceDocuments.length; i++) { + if (instanceDocuments[i].getTagName().equals(tagName)) + size++; + else + break; + } + if (maxSize != FragmentConstants.UNBOUNDED && size > maxSize) { + size = size - minSize; + if (size > maxSize) + size = maxSize; + } + Element[] subset = new Element[size]; + for (int j = 0; j < subset.length; j++) { + subset[j] = instanceDocuments[start + j]; + } + return subset; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) { + Vector instanceDocumentsCopy = new Vector(); + String[] groupIDs = getGroupIDs(); + for (int i = 0; i < groupIDs.length; i++) { + IXSDFragment[] choiceFrags = getGroupMemberFragments(groupIDs[i]); + int choiceIndex = getChoiceIndex(groupIDs[i]); + Element[] choiceFragInstances = choiceFrags[choiceIndex].genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + for (int j = 0; j < choiceFragInstances.length; j++) { + instanceDocumentsCopy.add(choiceFragInstances[j]); + } + } + Element[] instanceDocuments = new Element[instanceDocumentsCopy.size()]; + instanceDocumentsCopy.copyInto(instanceDocuments); + return instanceDocuments; + } + + public XSDParticle[] getChoices() { + if (choices_ == null) { + EList particles = getXSDModelGroup().getParticles(); + choices_ = new XSDParticle[particles.size()]; + for (int i = 0; i < choices_.length; i++) { + choices_[i] = (XSDParticle)particles.get(i); + } + } + return choices_; + } + + public String createGroupChoiceInstance(int choiceIndex) { + getChoices(); + if (choiceIndex < 0 || choiceIndex > choices_.length - 1) + return null; + String groupID = createGroupInstance(); + setChoiceIndex(groupID, choiceIndex); + return groupID; + } + + public String createInstance() { + return createGroupChoiceInstance(0); + } + + public int getChoiceIndex(String groupID) { + Integer index = (Integer)choiceIndexes_.get(groupID); + if (index != null) + return index.intValue(); + else + return 0; + } + + public void setChoiceIndex(String groupID, int choiceIndex) { + choiceIndexes_.put(groupID, new Integer(choiceIndex)); + } + + public boolean validateAllParameterValues() + { + String[] groupIDs = getGroupIDs(); + for (int i = 0; i < groupIDs.length; i++) + { + int selectionIndex = getChoiceIndex(groupIDs[i]); + if (!getGroupMemberFragments(groupIDs[i])[selectionIndex].validateAllParameterValues()) + return false; + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceRangeFragment.java new file mode 100644 index 000000000..ca3bffb4c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupChoiceRangeFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public class XSDGroupChoiceRangeFragment extends XSDGroupChoiceFragment { + public XSDGroupChoiceRangeFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDGroupChoiceRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDGroupChoiceRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupFragment.java new file mode 100644 index 000000000..485716ed5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupFragment.java @@ -0,0 +1,262 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + + +import org.eclipse.emf.common.util.EList; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDGroupFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDWildcard; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDParticleContent; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import java.util.Hashtable; +import java.util.Vector; + +public abstract class XSDGroupFragment extends XSDMapFragment implements IXSDGroupFragment { + private XSDModelGroup xsdModelGroup_; + private Vector groupIDsOrder_; + private Hashtable groupIDs_; + + public XSDGroupFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller); + xsdModelGroup_ = xsdModelGroup; + groupIDsOrder_ = new Vector(); + groupIDs_ = new Hashtable(); + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + boolean valuesValid = true; + String[] params = parser.getParameterValues(getID()); + Vector frags = new Vector(); + Vector groupIDsOrderCopy = new Vector(); + Hashtable groupIDsCopy = new Hashtable(); + for (int i = 0; params != null && i < params.length; i++) { + if (params[i] != null) { + groupIDsOrderCopy.add(params[i]); + groupIDsCopy.put(params[i], getGroupMemberIDs(params[i])); + IXSDFragment[] groupMemberFragments = getGroupMemberFragments(params[i]); + for (int j = 0; j < groupMemberFragments.length; j++) { + if (groupMemberFragments[j] != null) { + frags.add(groupMemberFragments[j]); + if (!groupMemberFragments[j].processParameterValues(parser)) + valuesValid = false; + } + } + } + } + groupIDsOrder_ = groupIDsOrderCopy; + groupIDs_ = groupIDsCopy; + removeAllFragments(); + addFragments(frags); + return valuesValid; + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) { + removeGroupIDs(); + boolean paramsValid = true; + String prevGroupID = null; + String currGroupID = null; + int groupMemberIndex = 0; + for (int i = 0; i < instanceDocuments.length; ) { + if (currGroupID == null) { + String newGroupID = createInstance(); + prevGroupID = currGroupID; + currGroupID = newGroupID; + } + Element[] instancePartition = null; + int j = groupMemberIndex; + boolean paramsAssigned = false; + int wildcardFragIndex = -1; + do { + IXSDFragment[] groupMemberFrags = getGroupMemberFragments(currGroupID); + XSDComponent xsdComponent = groupMemberFrags[j].getXSDToFragmentConfiguration().getXSDComponent(); + if (xsdComponent instanceof XSDWildcard) { + if (wildcardFragIndex < 0) + wildcardFragIndex = j; + } + else if (groupMemberFrags[j].getName().equals(trimPrefix(instanceDocuments[i].getTagName()))) { + instancePartition = getInstanceDocumentPartition(instanceDocuments, i, groupMemberFrags[j].getXSDToFragmentConfiguration().getMaxOccurs()); + if (!groupMemberFrags[j].setParameterValuesFromInstanceDocuments(instancePartition)) + paramsValid = false; + paramsAssigned = true; + } + if (j == groupMemberFrags.length - 1) { + j = 0; + String newGroupID; + if (!paramsAssigned) + newGroupID = createInstance(); + else + newGroupID = null; + prevGroupID = currGroupID; + currGroupID = newGroupID; + } + else + j++; + } while (!paramsAssigned && j != groupMemberIndex); + groupMemberIndex = j; + if (!paramsAssigned) { + instancePartition = getInstanceDocumentPartition(instanceDocuments, i, FragmentConstants.UNBOUNDED); + if (wildcardFragIndex >= 0) { + if (wildcardFragIndex >= groupMemberIndex) { + removeGroupID(currGroupID); + currGroupID = prevGroupID; + } + groupMemberIndex = wildcardFragIndex; + IXSDFragment[] groupMemberFrags = getGroupMemberFragments(currGroupID); + if (!groupMemberFrags[wildcardFragIndex].setParameterValuesFromInstanceDocuments(instancePartition)) + paramsValid = false; + paramsAssigned = true; + } + else if (currGroupID != null && (prevGroupID == null || !currGroupID.equals(prevGroupID))) { + paramsValid = false; + removeGroupID(currGroupID); + currGroupID = prevGroupID; + } + } + i = i + instancePartition.length; + } + return paramsValid; + } + + private Element[] getInstanceDocumentPartition(Element[] instanceDocuments, int start, int maxSize) { + String tagName = instanceDocuments[start].getTagName(); + int size = 1; + for (int i = start + 1; i < instanceDocuments.length; i++) { + if (maxSize != FragmentConstants.UNBOUNDED && size >= maxSize) + break; + else if (instanceDocuments[i].getTagName().equals(tagName)) + size++; + else + break; + } + Element[] subset = new Element[size]; + for (int j = 0; j < subset.length; j++) { + subset[j] = instanceDocuments[start + j]; + } + return subset; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) { + IXSDFragment[] groupMemberFragments = getAllFragments(); + Vector instanceDocumentsCopy = new Vector(); + for (int i = 0; i < groupMemberFragments.length; i++) { + Element[] fragmentInstances = groupMemberFragments[i].genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + for (int j = 0; j < fragmentInstances.length; j++) { + instanceDocumentsCopy.add(fragmentInstances[j]); + } + } + Element[] instanceDocuments = new Element[instanceDocumentsCopy.size()]; + for (int k = 0; k < instanceDocuments.length; k++) { + instanceDocuments[k] = (Element)instanceDocumentsCopy.get(k); + } + return instanceDocuments; + } + + public void setXSDModelGroup(XSDModelGroup xsdModelGroup) { + xsdModelGroup_ = xsdModelGroup; + } + + public XSDModelGroup getXSDModelGroup() { + return xsdModelGroup_; + } + + public String[] getGroupIDs() { + String[] groupIDs = new String[groupIDsOrder_.size()]; + for (int i = 0; i < groupIDs.length; i++) { + groupIDs[i] = (String)groupIDsOrder_.get(i); + } + return groupIDs; + } + + protected void removeGroupIDs() { + removeAllFragments(); + groupIDsOrder_.clear(); + groupIDs_.clear(); + } + + protected void removeGroupID(String groupID) { + String[] memberFragIDs = getGroupMemberIDs(groupID); + removeFragments(memberFragIDs); + groupIDsOrder_.remove(groupID); + groupIDs_.remove(groupID); + } + + protected void setGroupMemberIDs(String groupID, String[] groupMemberIDs) { + if (groupID != null) { + if (!groupIDsOrder_.contains(groupID)) + groupIDsOrder_.add(groupID); + if (groupMemberIDs != null) + groupIDs_.put(groupID, groupMemberIDs); + else + groupIDs_.put(groupID, new String[0]); + } + } + + protected void setGroupMemberFragments(String groupID, IXSDFragment[] groupMemberFragments) { + addFragments(groupMemberFragments); + String[] ids = new String[groupMemberFragments.length]; + for (int i = 0; i < ids.length; i++) { + ids[i] = groupMemberFragments[i].getID(); + } + setGroupMemberIDs(groupID, ids); + } + + public String[] getGroupMemberIDs(String groupID) { + if (groupID != null) { + String[] groupMemberIDs = (String[])groupIDs_.get(groupID); + if (groupMemberIDs != null) + return groupMemberIDs; + } + return new String[0]; + } + + public IXSDFragment[] getGroupMemberFragments(String groupID) { + String[] groupMemberIDs = getGroupMemberIDs(groupID); + IXSDFragment[] groupMemberFragments = new IXSDFragment[groupMemberIDs.length]; + for (int i = 0; i < groupMemberFragments.length; i++) { + groupMemberFragments[i] = getFragment(groupMemberIDs[i]); + } + return groupMemberFragments; + } + + protected String createGroupInstance() { + String groupID = genID(); + EList particles = getXSDModelGroup().getParticles(); + String[] groupMemberIDs = new String[particles.size()]; + for (int i = 0; i < particles.size(); i++) { + XSDParticle xsdParticle = (XSDParticle)particles.get(i); + XSDParticleContent xsdParticleContent = xsdParticle.getContent(); + XSDToFragmentConfiguration thisConfig = getXSDToFragmentConfiguration(); + XSDToFragmentConfiguration xsdConfig = new XSDToFragmentConfiguration(); + if (xsdParticleContent instanceof XSDComponent) + xsdConfig.setXSDComponent((XSDComponent)xsdParticleContent); + else + xsdConfig.setXSDComponent(null); + xsdConfig.setStyle(thisConfig.getStyle()); + xsdConfig.setPartEncoding(thisConfig.getPartEncoding()); + xsdConfig.setWSDLPartName(thisConfig.getWSDLPartName()); + groupMemberIDs[i] = genID(); + addFragment(groupMemberIDs[i], getXSDToFragmentController().getFragment(xsdConfig, groupMemberIDs[i], groupMemberIDs[i])); + } + setGroupMemberIDs(groupID, groupMemberIDs); + return groupID; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqFixFragment.java new file mode 100644 index 000000000..31a1a372c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqFixFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public class XSDGroupSeqFixFragment extends XSDGroupSeqFragment { + public XSDGroupSeqFixFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDGroupRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDGroupSeqFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqFragment.java new file mode 100644 index 000000000..e30813040 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqFragment.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDGroupSeqFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public abstract class XSDGroupSeqFragment extends XSDGroupFragment implements IXSDGroupSeqFragment { + public XSDGroupSeqFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String createGroupSeqInstance() { + return createGroupInstance(); + } + + public String createInstance() { + return createGroupSeqInstance(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqRangeFragment.java new file mode 100644 index 000000000..afb6a59fb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDGroupSeqRangeFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDModelGroup; + +public class XSDGroupSeqRangeFragment extends XSDGroupSeqFragment { + public XSDGroupSeqRangeFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller, XSDModelGroup xsdModelGroup) { + super(id, name, config, controller, xsdModelGroup); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDGroupRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDGroupSeqRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDMapFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDMapFragment.java new file mode 100644 index 000000000..1cd330cf1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDMapFragment.java @@ -0,0 +1,230 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDMapFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +import java.util.Vector; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Enumeration; + +public abstract class XSDMapFragment extends XSDFragment implements IXSDMapFragment { + private XSDToFragmentController controller_; + private Vector fragmentsOrder_; + private Hashtable fragments_; + + public XSDMapFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config); + controller_ = controller; + fragmentsOrder_ = new Vector(); + fragments_ = new Hashtable(); + } + + public boolean processParameterValues(MultipartFormDataParser parser) throws MultipartFormDataException { + boolean valuesValid = true; + String[] params = parser.getParameterValues(getID()); + Vector frags = new Vector(); + if (params != null) { + for (int i = 0; i < params.length; i++) { + if (params[i] != null) { + IXSDFragment frag = getFragment(params[i]); + if (frag != null) { + frags.add(frag); + if (!frag.processParameterValues(parser)) + valuesValid = false; + } + } + } + } + removeAllFragments(); + addFragments(frags); + return valuesValid; + } + + public void setParameterValues(String paramKey, String[] params) { + IXSDFragment frag = getFragment(paramKey); + if (frag != null) + frag.setParameterValues(paramKey, params); + } + + public String[] getParameterValues(String paramKey) { + IXSDFragment frag = getFragment(paramKey); + return (frag != null) ? frag.getParameterValues(paramKey) : null; + } + + public boolean validateAllParameterValues() { + IXSDFragment[] fragments = getAllFragments(); + for (int i = 0; i < fragments.length; i++) { + if (!fragments[i].validateAllParameterValues()) + return false; + } + return true; + } + + public boolean validateParameterValues(String paramKey) { + IXSDFragment frag = getFragment(paramKey); + return (frag != null) ? frag.validateParameterValues(paramKey) : true; + } + + public boolean validateParameterValue(String paramKey, int paramIndex) { + IXSDFragment frag = getFragment(paramKey); + return (frag != null) ? frag.validateParameterValue(paramKey, paramIndex) : true; + } + + public void setXSDToFragmentController(XSDToFragmentController controller) { + controller_ = controller; + } + + public XSDToFragmentController getXSDToFragmentController() { + return controller_; + } + + protected void addFragment(String id, IXSDFragment frag) { + addFragment(id, frag, true); + } + + protected void addFragments(String[] id, IXSDFragment[] frags) { + addFragments(id, frags, true); + } + + protected void addFragment(IXSDFragment frag) { + addFragment(frag, true); + } + + protected void addFragments(IXSDFragment[] frags) { + addFragments(frags, true); + } + + protected void addFragments(Vector frags) { + addFragments(frags, true); + } + + protected void addFragment(String id, IXSDFragment frag, boolean addToController) { + fragmentsOrder_.add(id); + fragments_.put(id, frag); + controller_.addToCache(id, frag); + } + + protected void addFragments(String[] id, IXSDFragment[] frags, boolean addToController) { + for (int i = 0; i < id.length && i < frags.length; i++) { + addFragment(id[i], frags[i], addToController); + } + } + + protected void addFragment(IXSDFragment frag, boolean addToController) { + addFragment(frag.getID(), frag, addToController); + } + + protected void addFragments(IXSDFragment[] frags, boolean addToController) { + for (int i = 0; i < frags.length; i++) { + addFragment(frags[i].getID(), frags[i], addToController); + } + } + + protected void addFragments(Vector frags, boolean addToController) { + Iterator it = frags.iterator(); + while (it.hasNext()) { + Object obj = it.next(); + if (obj instanceof IXSDFragment) { + IXSDFragment frag = (IXSDFragment)obj; + addFragment(frag.getID(), frag, addToController); + } + } + } + + public String[] getFragmentsOrder() { + String[] fragmentsOrder = new String[fragmentsOrder_.size()]; + for (int i = 0; i < fragmentsOrder.length; i++) { + fragmentsOrder[i] = (String)fragmentsOrder_.get(i); + } + return fragmentsOrder; + } + + protected boolean setFragmentsOrder(String[] fragmentsOrder) { + if (fragmentsOrder.length != fragmentsOrder_.size()) + return false; + Vector fragmentsOrderCopy = new Vector(fragmentsOrder_); + for (int i = 0; i < fragmentsOrder.length; i++) { + if (!fragmentsOrderCopy.remove(fragmentsOrder[i])) + return false; + } + fragmentsOrder_.clear(); + for (int j = 0; j < fragmentsOrder.length; j++) { + fragmentsOrder_.add(fragmentsOrder[j]); + } + return true; + } + + public IXSDFragment getFragment(String id) { + return (IXSDFragment)fragments_.get(id); + } + + public IXSDFragment[] getFragments(String[] ids) { + IXSDFragment[] frags = new IXSDFragment[ids.length]; + for (int i = 0; i < frags.length; i++) { + frags[i] = getFragment(ids[i]); + } + return frags; + } + + public IXSDFragment[] getAllFragments() { + IXSDFragment[] fragments = new IXSDFragment[fragmentsOrder_.size()]; + for (int i = 0; i < fragmentsOrder_.size(); i++) { + fragments[i] = getFragment((String)fragmentsOrder_.get(i)); + } + return fragments; + } + + protected void removeFragment(String id) { + removeFragment(id, true); + } + + protected void removeFragments(String[] ids) { + removeFragments(ids, true); + } + + protected void removeAllFragments() { + removeAllFragments(true); + } + + protected void removeFragment(String id, boolean removeFromController) { + fragmentsOrder_.remove(id); + fragments_.remove(id); + if (removeFromController) + controller_.removeFromCache(id); + } + + protected void removeFragments(String[] ids, boolean removeFromController) { + for (int i = 0; i < ids.length; i++) { + removeFragment(ids[i], removeFromController); + } + } + + protected void removeAllFragments(boolean removeFromController) { + if (removeFromController) + { + Enumeration ids = fragments_.keys(); + while (ids.hasMoreElements()) + { + String id = (String)ids.nextElement(); + controller_.removeFromCache(id); + } + } + fragmentsOrder_.clear(); + fragments_.clear(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicDateTimeFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicDateTimeFixFragment.java new file mode 100644 index 000000000..ebf6ba524 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicDateTimeFixFragment.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; + +public class XSDSimpleAtomicDateTimeFixFragment extends XSDSimpleAtomicFixFragment { + private int calendarType_; + public XSDSimpleAtomicDateTimeFixFragment(String id, String name, XSDToFragmentConfiguration config, int calendarType) { + super(id, name, config); + calendarType_ = calendarType; + } + + public String getWriteFragment() { + StringBuffer fragmentLink = new StringBuffer("/wsdl/fragment/XSDSimpleAtomicDateTimeFixWFragmentJSP.jsp?"); + fragmentLink.append(ActionInputs.CALENDAR_TYPE).append('=').append(calendarType_); + return fragmentLink.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicDateTimeRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicDateTimeRangeFragment.java new file mode 100644 index 000000000..add26d0af --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicDateTimeRangeFragment.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; + +public class XSDSimpleAtomicDateTimeRangeFragment extends XSDSimpleAtomicRangeFragment { + private int calendarType_; + public XSDSimpleAtomicDateTimeRangeFragment(String id, String name, XSDToFragmentConfiguration config, int calendarType) { + super(id, name, config); + calendarType_ = calendarType; + } + + public String getWriteFragment() { + StringBuffer fragmentLink = new StringBuffer("/wsdl/fragment/XSDSimpleAtomicDateTimeRangeWFragmentJSP.jsp?"); + fragmentLink.append(ActionInputs.CALENDAR_TYPE).append('=').append(calendarType_); + return fragmentLink.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumFixFragment.java new file mode 100644 index 000000000..1e0155eaa --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumFixFragment.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.*; +import org.eclipse.emf.common.util.EList; + +public class XSDSimpleAtomicEnumFixFragment extends XSDSimpleAtomicEnumFragment { + public XSDSimpleAtomicEnumFixFragment(String id, String name, XSDToFragmentConfiguration config, EList elist) { + super(id, name, config, elist); + } + + public XSDSimpleAtomicEnumFixFragment(String id, String name, XSDToFragmentConfiguration config, OptionVector v) + { + super(id, name, config, v); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDSimpleAtomicInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleAtomicRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleAtomicEnumFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumFragment.java new file mode 100644 index 000000000..919cd4af1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumFragment.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.*; +import org.eclipse.xsd.*; + +public abstract class XSDSimpleAtomicEnumFragment extends XSDSimpleAtomicFragment { + private OptionVector optionVector_; + public XSDSimpleAtomicEnumFragment(String id, String name, XSDToFragmentConfiguration config, EList elist) { + super(id, name, config); + optionVector_ = new OptionVector(); + for (int i=0;i<elist.size();i++) + { + String enumValue = ((XSDEnumerationFacet)elist.get(i)).getLexicalValue(); + optionVector_.addOption(enumValue,enumValue); + } + } + + public XSDSimpleAtomicEnumFragment(String id, String name, XSDToFragmentConfiguration config, OptionVector v) + { + super(id, name, config); + optionVector_ = new OptionVector(); + for (int i=0;i<v.size();i++) + optionVector_.addOption(v.getDisplayValue(i),v.getValue(i)); + } + + public final OptionVector getOptionVector() + { + return optionVector_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumRangeFragment.java new file mode 100644 index 000000000..5a74bbd62 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicEnumRangeFragment.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.*; +import org.eclipse.emf.common.util.EList; + +public class XSDSimpleAtomicEnumRangeFragment extends XSDSimpleAtomicEnumFragment { + public XSDSimpleAtomicEnumRangeFragment(String id, String name, XSDToFragmentConfiguration config, EList elist) { + super(id, name, config, elist); + } + + public XSDSimpleAtomicEnumRangeFragment(String id, String name, XSDToFragmentConfiguration config, OptionVector v) + { + super(id, name, config, v); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDSimpleAtomicInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleAtomicRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleAtomicEnumRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicFixFragment.java new file mode 100644 index 000000000..5c8dddfcf --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicFixFragment.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; + +public class XSDSimpleAtomicFixFragment extends XSDSimpleAtomicFragment { + public XSDSimpleAtomicFixFragment(String id, String name, XSDToFragmentConfiguration config) { + super(id, name, config); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDSimpleAtomicInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleAtomicRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleAtomicFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicFragment.java new file mode 100644 index 000000000..d82a1d83f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicFragment.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.*; +import org.eclipse.xsd.*; + +public abstract class XSDSimpleAtomicFragment extends XSDFragment implements IXSDSimpleAtomicFragment { + public XSDSimpleAtomicFragment(String id, String name, XSDToFragmentConfiguration config) { + super(id, name, config); + } + + public boolean validateParameterValue(String paramKey, int paramIndex) { + String param = getParameterValue(paramKey, paramIndex); + if (param != null && !((XSDSimpleTypeDefinition)getXSDTypeDefinition()).isValidLiteral(param)) + return false; + else + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicRangeFragment.java new file mode 100644 index 000000000..e3bbd7600 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleAtomicRangeFragment.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; + +public class XSDSimpleAtomicRangeFragment extends XSDSimpleAtomicFragment { + public XSDSimpleAtomicRangeFragment(String id, String name, XSDToFragmentConfiguration config) { + super(id, name, config); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDSimpleAtomicInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleAtomicRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleAtomicRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListFixFragment.java new file mode 100644 index 000000000..e265bac5b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListFixFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +public class XSDSimpleListFixFragment extends XSDSimpleListFragment { + public XSDSimpleListFixFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleListRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleListFixWFragmentJSP.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListFragment.java new file mode 100644 index 000000000..3246215df --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListFragment.java @@ -0,0 +1,149 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDSimpleListFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.XSDLengthFacet; +import org.eclipse.xsd.XSDMinLengthFacet; +import org.eclipse.xsd.XSDMaxLengthFacet; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import java.util.StringTokenizer; +import java.util.Hashtable; + +public abstract class XSDSimpleListFragment extends XSDMapFragment implements IXSDSimpleListFragment +{ + public XSDSimpleListFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) + { + super(id, name, config, controller); + } + + public void setName(String name) + { + super.setName(name); + IXSDFragment[] fragments = getAllFragments(); + for (int i = 0; i < fragments.length; i++) + { + fragments[i].setName(name); + } + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) + { + Element[] instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocuments, getName()); + String[] params = new String[instanceDocumentsCopy.length]; + boolean paramsValid = internalEquals(instanceDocumentsCopy, instanceDocuments); + for (int i = 0; i < instanceDocumentsCopy.length; i++) + { + params[i] = ""; + NodeList nodeList = instanceDocumentsCopy[i].getChildNodes(); + if (nodeList.getLength() > 0) + { + Node node = nodeList.item(0); + if (nodeList.getLength() > 1) + paramsValid = false; + if (node.getNodeType() != Node.TEXT_NODE) + paramsValid = false; + else + params[i] = node.getNodeValue(); + } + else + paramsValid = false; + } + removeAllFragments(); + for (int i = 0; i < params.length; i++) + { + IXSDFragment childFrag = getFragment(createListInstance()); + StringTokenizer st = new StringTokenizer(params[i].trim()); + String[] childParams = new String[st.countTokens()]; + for (int j = 0; j < childParams.length; j++) + { + childParams[j] = st.nextToken(); + } + childFrag.setParameterValues(childFrag.getID(), childParams); + paramsValid = paramsValid && childFrag.validateAllParameterValues(); + } + return paramsValid; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) + { + IXSDFragment[] fragments = getAllFragments(); + Element[] instanceDocuments = new Element[fragments.length]; + String tagName = getInstanceDocumentTagName(namespaceTable); + for (int i = 0; i < fragments.length; i++) + { + Element instanceDocument = doc.createElement(tagName); + StringBuffer listValue = new StringBuffer(); + String[] params = fragments[i].getParameterValues(fragments[i].getID()); + for (int j = 0; params != null && j < params.length; j++) + { + if (j != 0) + listValue.append(FragmentConstants.LIST_SEPERATOR); + listValue.append(params[j]); + } + Node textNode = doc.createTextNode(listValue.toString()); + instanceDocument.appendChild(textNode); + instanceDocuments[i] = instanceDocument; + } + return (genXSIType ? addXSIType(instanceDocuments, namespaceTable) : instanceDocuments); + } + + public String createListInstance() + { + String newID = genID(); + XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)getXSDTypeDefinition(); + int min = 0; + int max = FragmentConstants.UNBOUNDED; + XSDLengthFacet xsdLengthFacet = simpleType.getLengthFacet(); + // port to org.eclipse.xsd + if (xsdLengthFacet != null) + { + min = xsdLengthFacet.getValue(); + max = xsdLengthFacet.getValue(); + } + else + { + XSDMinLengthFacet xsdMinLengthFacet = simpleType.getMinLengthFacet(); + XSDMaxLengthFacet xsdMaxLengthFacet = simpleType.getMaxLengthFacet(); + // port to org.eclipse.xsd + if (xsdMinLengthFacet != null) + min = xsdMinLengthFacet.getValue(); + if (xsdMaxLengthFacet != null) + max = xsdMaxLengthFacet.getValue(); + } + XSDToFragmentConfiguration thisConfig = getXSDToFragmentConfiguration(); + XSDToFragmentConfiguration xsdConfig = new XSDToFragmentConfiguration(); + xsdConfig.setXSDComponent(simpleType.getItemTypeDefinition()); + xsdConfig.setStyle(thisConfig.getStyle()); + xsdConfig.setPartEncoding(thisConfig.getPartEncoding()); + xsdConfig.setWSDLPartName(thisConfig.getWSDLPartName()); + xsdConfig.setMinOccurs(min); + xsdConfig.setMaxOccurs(max); + IXSDFragment frag = getXSDToFragmentController().getFragment(xsdConfig, newID, getName()); + frag.setID(newID); + frag.setName(getName()); + addFragment(newID, frag); + return newID; + } + + public String createInstance() + { + return createListInstance(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListRangeFragment.java new file mode 100644 index 000000000..aeb95054f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleListRangeFragment.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +public class XSDSimpleListRangeFragment extends XSDSimpleListFragment { + public XSDSimpleListRangeFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleListRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleListRangeWFragmentJSP.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionFixFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionFixFragment.java new file mode 100644 index 000000000..b6c2242f8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionFixFragment.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +public class XSDSimpleUnionFixFragment extends XSDSimpleUnionFragment { + public XSDSimpleUnionFixFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleUnionRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleUnionFixWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionFragment.java new file mode 100644 index 000000000..a5a06a6c0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionFragment.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + + +import org.eclipse.emf.common.util.EList; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDSimpleUnionFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; +import org.eclipse.xsd.XSDSimpleTypeDefinition; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import java.util.Vector; +import java.util.Hashtable; + +public abstract class XSDSimpleUnionFragment extends XSDMapFragment implements IXSDSimpleUnionFragment { + private XSDSimpleTypeDefinition[] memberTypes_; + + public XSDSimpleUnionFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + memberTypes_ = null; + } + + public void setName(String name) { + super.setName(name); + IXSDFragment[] fragments = getAllFragments(); + for (int i = 0; i < fragments.length; i++) { + fragments[i].setName(name); + } + } + + public boolean setParameterValuesFromInstanceDocuments(Element[] instanceDocuments) { + Element[] instanceDocumentsCopy = getInstanceDocumentsByTagName(instanceDocuments, getName()); + int numTypes = getMemberTypeDefinitions().length; + boolean paramsValid = internalEquals(instanceDocumentsCopy, instanceDocuments); + Vector memberFragments = new Vector(); + for (int i = 0; i < instanceDocumentsCopy.length; i++) { + IXSDFragment compatibleFrag = null; + for (int j = 0; j < numTypes; j++) { + IXSDFragment memberFrag = getFragment(createUnionInstance(j)); + Element[] memberInstanceDocument = new Element[1]; + memberInstanceDocument[0] = setElementTagName(instanceDocumentsCopy[i], memberFrag.getName()); + if (memberFrag.setParameterValuesFromInstanceDocuments(memberInstanceDocument)) { + if (memberFrag.validateAllParameterValues()) { + compatibleFrag = memberFrag; + break; + } + else if (compatibleFrag == null) + compatibleFrag = memberFrag; + } + } + if (compatibleFrag != null) + memberFragments.add(compatibleFrag); + else + paramsValid = false; + } + removeAllFragments(); + addFragments(memberFragments); + return paramsValid; + } + + public Element[] genInstanceDocumentsFromParameterValues(boolean genXSIType, Hashtable namespaceTable, Document doc) { + IXSDFragment[] fragments = getAllFragments(); + Vector instanceDocumentsCopy = new Vector(); + for (int i = 0; i < fragments.length; i++) { + Element[] fragmentInstances = fragments[i].genInstanceDocumentsFromParameterValues(genXSIType, namespaceTable, doc); + if (fragmentInstances.length > 0) + instanceDocumentsCopy.add(fragmentInstances[0]); + } + Element[] instanceDocuments = new Element[instanceDocumentsCopy.size()]; + for (int i = 0; i < instanceDocuments.length; i++) { + instanceDocuments[i] = (Element)instanceDocumentsCopy.get(i); + } + return setElementsTagName(instanceDocuments, getInstanceDocumentTagName(namespaceTable)); + } + + public XSDSimpleTypeDefinition[] getMemberTypeDefinitions() { + if (memberTypes_ == null) { + EList memberTypes = ((XSDSimpleTypeDefinition)getXSDTypeDefinition()).getMemberTypeDefinitions(); + memberTypes_ = new XSDSimpleTypeDefinition[memberTypes.size()]; + for (int i = 0; i < memberTypes_.length; i++) { + memberTypes_[i] = (XSDSimpleTypeDefinition)memberTypes.get(i); + } + } + return memberTypes_; + } + + public String createUnionInstance(int memberTypeIndex) { + getMemberTypeDefinitions(); + if (memberTypeIndex < 0 || memberTypeIndex > memberTypes_.length - 1) + return null; + String newID = genID(); + XSDToFragmentConfiguration thisConfig = getXSDToFragmentConfiguration(); + XSDToFragmentConfiguration xsdConfig = new XSDToFragmentConfiguration(); + xsdConfig.setXSDComponent(memberTypes_[memberTypeIndex]); + xsdConfig.setStyle(thisConfig.getStyle()); + xsdConfig.setPartEncoding(thisConfig.getPartEncoding()); + xsdConfig.setWSDLPartName(thisConfig.getWSDLPartName()); + IXSDFragment frag = getXSDToFragmentController().getFragment(xsdConfig, newID, getName()); + frag.setID(newID); + frag.setName(getName()); + addFragment(newID, frag); + return newID; + } + + public String createInstance() { + return createUnionInstance(0); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionRangeFragment.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionRangeFragment.java new file mode 100644 index 000000000..ec2bb8d02 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/impl/XSDSimpleUnionRangeFragment.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentConfiguration; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.XSDToFragmentController; + +public class XSDSimpleUnionRangeFragment extends XSDSimpleUnionFragment { + public XSDSimpleUnionRangeFragment(String id, String name, XSDToFragmentConfiguration config, XSDToFragmentController controller) { + super(id, name, config, controller); + } + + public String getInformationFragment() { + return "/wsdl/fragment/XSDDefaultInfoFragmentJSP.jsp"; + } + + public String getReadFragment() { + return "/wsdl/fragment/XSDSimpleUnionRFragmentJSP.jsp"; + } + + public String getWriteFragment() { + return "/wsdl/fragment/XSDSimpleUnionRangeWFragmentJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/HTTPUtil.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/HTTPUtil.java new file mode 100644 index 000000000..5519e744d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/HTTPUtil.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util; + +import java.util.Hashtable; + +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.axis.Constants; +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDSimpleAtomicFragment; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDSimpleListFragment; +import org.w3c.dom.Element; + +public class HTTPUtil +{ + private HTTPUtil() + { + } + + public static String genURLEncodedParameters(IXSDFragment fragment) + { + if (fragment instanceof IXSDSimpleListFragment) + return genURLEncodedParamsFromListFragment((IXSDSimpleListFragment)fragment); + else if (fragment instanceof IXSDSimpleAtomicFragment) + return genURLEncodedParamsFromAtomicFragment((IXSDSimpleAtomicFragment)fragment); + else + return genURLEncodedXMLParameters(fragment); + } + + private static String genURLEncodedParamsFromAtomicFragment(IXSDSimpleAtomicFragment fragment) + { + StringBuffer urlEncodedParam = new StringBuffer(); + String[] params = fragment.getParameterValues(fragment.getID()); + for (int i = 0; i < params.length; i++) + { + urlEncodedParam.append(URLUtils.encode(fragment.getName())); + urlEncodedParam.append("="); + urlEncodedParam.append(URLUtils.encode(params[i])); + if (i < params.length - 1) + urlEncodedParam.append("&"); + } + return urlEncodedParam.toString(); + } + + private static String genURLEncodedParamsFromListFragment(IXSDSimpleListFragment fragment) + { + StringBuffer urlEncodedParam = new StringBuffer(); + IXSDFragment[] childFrags = fragment.getAllFragments(); + for (int i = 0; i < childFrags.length; i++) + { + urlEncodedParam.append(URLUtils.encode(fragment.getName())); + urlEncodedParam.append("="); + String[] params = childFrags[i].getParameterValues(childFrags[i].getID()); + StringBuffer paramBuffer = new StringBuffer(); + for (int j = 0; j < params.length; j++) + { + paramBuffer.append(params[j]); + if (j < params.length - 1) + paramBuffer.append(FragmentConstants.LIST_SEPERATOR); + } + urlEncodedParam.append(URLUtils.encode(paramBuffer.toString())); + if (i < childFrags.length - 1) + urlEncodedParam.append("&"); + } + return urlEncodedParam.toString(); + } + + private static String genURLEncodedXMLParameters(IXSDFragment fragment) + { + StringBuffer urlEncodedParam = new StringBuffer(); + Hashtable soapEnvelopeNamespaceTable = new Hashtable(); + soapEnvelopeNamespaceTable.put(Constants.URI_SOAP11_ENV, Constants.NS_PREFIX_SOAP_ENV); + soapEnvelopeNamespaceTable.put(Constants.URI_2001_SCHEMA_XSI, Constants.NS_PREFIX_SCHEMA_XSI); + soapEnvelopeNamespaceTable.put(Constants.URI_2001_SCHEMA_XSD, Constants.NS_PREFIX_SCHEMA_XSD); + Element[] instanceDocuments = new Element[0]; + try + { + instanceDocuments = fragment.genInstanceDocumentsFromParameterValues(true, soapEnvelopeNamespaceTable, XMLUtils.createNewDocument(null)); + } + catch (ParserConfigurationException pce) + { + } + for (int i = 0; i < instanceDocuments.length; i++) + { + urlEncodedParam.append(URLUtils.encode(fragment.getName())); + urlEncodedParam.append("="); + urlEncodedParam.append(URLUtils.encode(XMLUtils.serialize(instanceDocuments[i], true))); + if (i < instanceDocuments.length - 1) + urlEncodedParam.append("&"); + } + return urlEncodedParam.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/OptionVector.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/OptionVector.java new file mode 100644 index 000000000..1d165c097 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/OptionVector.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util; + +import java.util.*; + +public class OptionVector +{ + private Vector options_; + + public OptionVector() + { + options_ = new Vector(); + } + + public void addOption(String displayValue,String value) + { + options_.addElement(new Option(displayValue,value)); + } + + public String getDisplayValue(int position) + { + Option option = (Option)options_.elementAt(position); + return option.getDisplayValue(); + } + + public String getValue(int position) + { + Option option = (Option)options_.elementAt(position); + return option.getValue(); + } + + public int size() + { + return options_.size(); + } + + private final class Option + { + private String displayValue_; + private String value_; + public Option(String displayValue,String value) + { + displayValue_ = displayValue; + value_ = value; + } + + public final String getDisplayValue() + { + return displayValue_; + } + + public final String getValue() + { + return value_; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/XSDTypeDefinitionUtil.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/XSDTypeDefinitionUtil.java new file mode 100644 index 000000000..ed9622d2d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/fragment/util/XSDTypeDefinitionUtil.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util; + +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComplexTypeContent; + +public class XSDTypeDefinitionUtil { + private XSDTypeDefinitionUtil() { + } + + public static boolean isXSDBuiltInTypeDefinition(XSDTypeDefinition type) { + if (type == null) + return false; + String ns = type.getTargetNamespace(); + return (ns != null && ns.equals(FragmentConstants.URI_XSD)); + } + + public static boolean isRootTypeDefinition(XSDTypeDefinition type) { + if (type == null) + return true; + XSDTypeDefinition baseType = type.getBaseType(); + if (baseType == null) + return true; + String typeNS = type.getTargetNamespace(); + String baseTypeNS = baseType.getTargetNamespace(); + String typeName = type.getName(); + String baseTypeName = baseType.getName(); + boolean sameNS; + boolean sameName; + if (typeNS == null && baseTypeNS == null) + sameNS = true; + else if (typeNS != null && baseTypeNS != null && typeNS.equals(baseTypeNS)) + sameNS = true; + else + sameNS = false; + if (typeName == null && baseTypeName == null) + sameName = true; + else if (typeName != null && baseTypeName != null && typeName.equals(baseTypeName)) + sameName = true; + else + sameName = false; + return (sameNS && sameName); + } + + public static XSDTypeDefinition resolveToXSDBuiltInTypeDefinition(XSDTypeDefinition type) { + if (type == null) + return null; + XSDTypeDefinition currType = type; + while (!isXSDBuiltInTypeDefinition(currType)) { + if (isRootTypeDefinition(currType)) + return null; + currType = currType.getBaseType(); + } + return currType; + } + + public static boolean isSoapEncArray(XSDTypeDefinition type) { + XSDTypeDefinition currType = type; + if (currType != null) + while(currType != null) { + String ns = currType.getTargetNamespace(); + String name = currType.getName(); + if (FragmentConstants.URI_SOAP.equals(ns) && FragmentConstants.QNAME_LOCAL_NAME_ARRAY.equals(name)) + return true; + else if (isRootTypeDefinition(currType)) + return false; + else + currType = currType.getBaseType(); + } + return false; + } + + /** + * Returns the complex type content given a complex type. + * If complexType is a user defined type: + * This method will return the user defined complex content of this type or the content of the extended + * or derived type iff the extended or derived type is not a built-in XSD type (for example, xsd:anyType). + * If complexType is a built-in XSD type: + * It will return the complex content of this built-in XSD complex type. It will not return the + * complex content of its extended or derived type. + * @param complexType XSDComplexTypeDefinition complex type. + * @return XSDComplexTypeContent XSDComplexTypeContent the resolved complex type content. + **/ + public static XSDComplexTypeContent getXSDComplexTypeContent(XSDComplexTypeDefinition complexType) + { + if (!isXSDBuiltInTypeDefinition(complexType)) + { + XSDTypeDefinition type = complexType; + while (!isXSDBuiltInTypeDefinition(type) && (type instanceof XSDComplexTypeDefinition)) + { + XSDComplexTypeContent complexTypeContent = ((XSDComplexTypeDefinition)type).getContent(); + if (complexTypeContent != null) + return complexTypeContent; + if (isRootTypeDefinition(type)) + return null; + type = type.getBaseType(); + } + return null; + } + else + return complexType.getContent(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/DetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/DetailsTool.java new file mode 100644 index 000000000..e60ca2e9a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/DetailsTool.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SelectWSDLPropertiesToolAction; + +public abstract class DetailsTool extends FormTool { + + public String formLink_; + + public DetailsTool(ToolManager toolManager, String alt, String formLink) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + formLink_ = formLink; + } + + protected void initDefaultProperties() { + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return formLink_; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/InvokeWSDLOperationTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/InvokeWSDLOperationTool.java new file mode 100644 index 000000000..77c8ef9f4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/InvokeWSDLOperationTool.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.*; + +public class InvokeWSDLOperationTool extends FormTool { + + private String fragmentViewID_; + private String fragmentNameAnchorID_; + private String endPoint_; + + public InvokeWSDLOperationTool(ToolManager toolManager, String alt) { + super(toolManager, "wsdl/images/invoke_wsdl_operation_enabled.gif", "wsdl/images/invoke_wsdl_operation_highlighted.gif", alt); + fragmentViewID_ = FragmentConstants.FRAGMENT_VIEW_SWITCH_SOURCE_TO_FORM; + fragmentNameAnchorID_ = null; + endPoint_ = null; + } + + protected void initDefaultProperties() { + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + StringBuffer formLink = new StringBuffer(); + formLink.append("wsdl/forms/InvokeWSDLOperationForm.jsp"); + String nameAnchorID = getFragmentNameAnchorID(); + if (nameAnchorID != null && nameAnchorID.length() > 0) { + formLink.append("#"); + formLink.append(nameAnchorID); + setFragmentNameAnchorID(null); + } + return formLink.toString(); + } + + public String getFormActionLink(int operationType,String fragmentViewID) + { + switch (operationType) + { + case WSDLOperationElement.OPERATION_TYPE_SOAP: + if (fragmentViewID.equals(FragmentConstants.FRAGMENT_VIEW_SWITCH_FORM_TO_SOURCE)) + return "wsdl/actions/InvokeWSDLSOAPOperationSourceActionJSP.jsp"; + else + return "wsdl/actions/InvokeWSDLSOAPOperationFormActionJSP.jsp"; + case WSDLOperationElement.OPERATION_TYPE_HTTP_GET: + return "wsdl/actions/InvokeWSDLHttpGetOperationFormActionJSP.jsp"; + case WSDLOperationElement.OPERATION_TYPE_HTTP_POST: + default: + return "wsdl/actions/InvokeWSDLHttpPostOperationFormActionJSP.jsp"; + } + } + + public String getFragmentViewID() { + return fragmentViewID_; + } + + public void setFragmentViewID(String fragmentViewID) { + fragmentViewID_ = fragmentViewID; + } + + public String getFragmentNameAnchorID() { + return fragmentNameAnchorID_; + } + + public void setFragmentNameAnchorID(String fragmentNameAnchorID) { + fragmentNameAnchorID_ = fragmentNameAnchorID; + } + + public String getEndPoint() + { + return endPoint_; + } + + public void setEndPoint(String endPoint) + { + endPoint_ = endPoint; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/OpenWSDLTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/OpenWSDLTool.java new file mode 100644 index 000000000..d352109b5 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/OpenWSDLTool.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SelectWSDLPropertiesToolAction; + +public class OpenWSDLTool extends FormTool { + + public OpenWSDLTool(ToolManager toolManager, String alt) { + super(toolManager, "wsdl/images/open_wsdl_enabled.gif", "wsdl/images/open_wsdl_highlighted.gif", alt); + } + + protected void initDefaultProperties() { + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "wsdl/forms/OpenWSDLForm.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/SOAPMessageQueue.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/SOAPMessageQueue.java new file mode 100644 index 000000000..470babde4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/SOAPMessageQueue.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +import java.util.*; + +public class SOAPMessageQueue extends MessageQueue +{ + private Vector cachedMessageList_; + + public SOAPMessageQueue() + { + super(); + cachedMessageList_ = new Vector(); + } + + public void clear() + { + cachedMessageList_.removeAllElements(); + messageList_.removeAllElements(); + } + + public String getMessagesFromList() + { + if (messageList_.size() == 0) + copyMessages(cachedMessageList_,messageList_); + else + copyMessages(messageList_,cachedMessageList_); + return super.getMessagesFromList(); + } + + private final void copyMessages(Vector sourceList,Vector destList) + { + for (int i=0;i<sourceList.size();i++) + destList.addElement(sourceList.elementAt(i)); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLAddToFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLAddToFavoritesTool.java new file mode 100644 index 000000000..271d671b7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLAddToFavoritesTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SelectWSDLPropertiesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.WSDLAddToFavoritesAction; + +public class WSDLAddToFavoritesTool extends ActionTool { + public WSDLAddToFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/favorites_enabled.gif", "images/favorites_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return WSDLAddToFavoritesAction.getActionLink(selectedNode.getNodeId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLBindingDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLBindingDetailsTool.java new file mode 100644 index 000000000..4b90d81e6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLBindingDetailsTool.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class WSDLBindingDetailsTool extends DetailsTool { + + public WSDLBindingDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, alt, "wsdl/forms/WSDLBindingDetailsForm.jsp"); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLBindingNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLBindingNode.java new file mode 100644 index 000000000..f3315139e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLBindingNode.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +// WSDL binding node for the WSDL Navigator Tree View +public class WSDLBindingNode extends WSDLNavigatorNode +{ + public WSDLBindingNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"wsdl/images/wsdl_binding_node.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(WSDLModelConstants.REL_WSDL_OPERATION)) { + WSDLOperationNode wsdlOperationNode = new WSDLOperationNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(wsdlOperationNode); + } + } + + public void relRemoved(RelRemoveEvent event) + { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(WSDLModelConstants.REL_WSDL_OPERATION)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(WSDLModelConstants.REL_WSDL_OPERATION)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + setVisibilityOfChildren(false); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); + new WSDLBindingDetailsTool(toolManager_, wsdlPerspective.getMessage("ALT_WSDL_BINDING_DETAILS")); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLDetailsTool.java new file mode 100644 index 000000000..279eadff7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLDetailsTool.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class WSDLDetailsTool extends DetailsTool { + + public static final int FORM_VIEW_ID = 0; + public static final int SOURCE_VIEW_ID = 1; + + private int viewId_; + + public WSDLDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, alt, "wsdl/forms/WSDLDetailsForm.jsp"); + viewId_ = FORM_VIEW_ID; + } + + public int getViewId() { + return viewId_; + } + + public void setViewId(int viewId) { + if (viewId == FORM_VIEW_ID || viewId == SOURCE_VIEW_ID) + viewId_ = viewId; + } + + public void toggleViewId() { + if (viewId_ == FORM_VIEW_ID) + viewId_ = SOURCE_VIEW_ID; + else + viewId_ = FORM_VIEW_ID; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLImportWSDLToFileSystemTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLImportWSDLToFileSystemTool.java new file mode 100644 index 000000000..3b191a3b4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLImportWSDLToFileSystemTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToFileSystemTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SelectWSDLPropertiesToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.WSDLImportWSDLToFileSystemAction; + +public class WSDLImportWSDLToFileSystemTool extends ImportToFileSystemTool { + public WSDLImportWSDLToFileSystemTool(ToolManager toolManager,String alt) { + super(toolManager,alt); + } + + public final String getSelectToolActionHref(boolean forHistory) { + Node node = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public final String getActionLink() { + Node node = toolManager_.getNode(); + return WSDLImportWSDLToFileSystemAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLImportWSDLToWorkbenchTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLImportWSDLToWorkbenchTool.java new file mode 100644 index 000000000..5dccc9500 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLImportWSDLToWorkbenchTool.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToWorkbenchTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SelectWSDLPropertiesToolAction; + +public class WSDLImportWSDLToWorkbenchTool extends ImportToWorkbenchTool { + public WSDLImportWSDLToWorkbenchTool(ToolManager toolManager,String alt) { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node node = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public final String getFormLink() { + return "wsdl/forms/WSDLImportWSDLToWorkbenchForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLLaunchWebServiceWizardTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLLaunchWebServiceWizardTool.java new file mode 100644 index 000000000..36f9780eb --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLLaunchWebServiceWizardTool.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.LaunchWebServiceWizardTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SelectWSDLPropertiesToolAction; + +public class WSDLLaunchWebServiceWizardTool extends LaunchWebServiceWizardTool { + public WSDLLaunchWebServiceWizardTool(ToolManager toolManager,String alt) { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node node = toolManager_.getNode(); + return SelectWSDLPropertiesToolAction.getActionLink(node.getNodeId(),toolId_,node.getViewId(),node.getViewToolId(),forHistory); + } + + public final String getFormLink() { + return "wsdl/forms/WSDLLaunchWebServiceWizardForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLMainNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLMainNode.java new file mode 100644 index 000000000..39af7e79c --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLMainNode.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +// Root node for the WSDL Navigator Tree View +public class WSDLMainNode extends WSDLNavigatorNode +{ + public WSDLMainNode(TreeElement element,NodeManager nodeManager) + { + super(element,nodeManager,1,"images/root_main.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(WSDLModelConstants.REL_WSDL)) { + WSDLNode wsdlNode = new WSDLNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(wsdlNode); + } + } + + public void relRemoved(RelRemoveEvent event) + { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(WSDLModelConstants.REL_WSDL)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(WSDLModelConstants.REL_WSDL)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); + new OpenWSDLTool(toolManager_, wsdlPerspective.getMessage("ALT_OPEN_WSDL")); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLNavigatorNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLNavigatorNode.java new file mode 100644 index 000000000..45db89bb7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLNavigatorNode.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.*; + +public abstract class WSDLNavigatorNode extends Node +{ + public WSDLNavigatorNode(TreeElement element,NodeManager nodeManager,int nodeDepth,String imagePath) + { + super(element,nodeManager,nodeDepth,imagePath); + } + + // wsdl/actions/ToggleWSDLNavigatorNodeAction.jsp?nodeId=... + public final String getToggleNodeActionHref() + { + return ToggleWSDLNavigatorNodeAction.getActionLink(nodeId_,isOpen_); + } + + // wsdl/actions/SelectWSDLNavigatorNodeAction.jsp?nodeId=... + public final String getLinkActionHref() + { + return SelectWSDLNavigatorNodeAction.getActionLink(nodeId_,false); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLNode.java new file mode 100644 index 000000000..c5ffb765f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLNode.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +// WSDL node for the WSDL Navigator Tree View +public class WSDLNode extends WSDLNavigatorNode +{ + public WSDLNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"images/wsdl.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(WSDLModelConstants.REL_WSDL_SERVICE)) { + WSDLServiceNode wsdlServiceNode = new WSDLServiceNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(wsdlServiceNode); + } + } + + public void relRemoved(RelRemoveEvent event) + { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(WSDLModelConstants.REL_WSDL_SERVICE)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(WSDLModelConstants.REL_WSDL_SERVICE)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + setVisibilityOfChildren(false); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); + new WSDLDetailsTool(toolManager_, wsdlPerspective.getMessage("ALT_WSDL_DETAILS")); + new WSDLImportWSDLToWorkbenchTool(toolManager_, controller.getMessage("ALT_IMPORT_WSDL_TO_WORKBENCH")); + new WSDLImportWSDLToFileSystemTool(toolManager_, controller.getMessage("ALT_WSDL_IMPORT_TO_FS")); + new WSDLLaunchWebServiceWizardTool(toolManager_, controller.getMessage("ALT_LAUNCH_WEB_SERVICE_WIZARD")); + new WSDLAddToFavoritesTool(toolManager_, wsdlPerspective.getMessage("ALT_ADD_WSDL_TO_FAVORITES")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLOperationNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLOperationNode.java new file mode 100644 index 000000000..611c96efd --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLOperationNode.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +// WSDL operation node for the WSDL Navigator Tree View +public class WSDLOperationNode extends WSDLNavigatorNode +{ + public WSDLOperationNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"wsdl/images/wsdl_operation_node.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + } + + public void relRemoved(RelRemoveEvent event) + { + } + }); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); + new InvokeWSDLOperationTool(toolManager_, wsdlPerspective.getMessage("ALT_INVOKE_WSDL_OPERATION")); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLPerspective.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLPerspective.java new file mode 100644 index 000000000..51782d049 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLPerspective.java @@ -0,0 +1,369 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; + +import javax.servlet.ServletContext; +import javax.wsdl.Service; + +import org.eclipse.emf.ecore.impl.EcorePackageImpl; +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl; +import org.eclipse.wst.ws.internal.datamodel.BasicModel; +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Perspective; +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.OpenWSDLAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.SwitchPerspectiveFromWSDLAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.UpdateWSDLBindingAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.BindingTypes; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.WSDLActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLBindingElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLServiceElement; +import org.eclipse.xsd.impl.XSDPackageImpl; +import org.eclipse.xsd.util.XSDResourceFactoryImpl; + +public class WSDLPerspective extends Perspective +{ + public static final int STATUS_CONTENT_DEFAULT = 0; + public static final int STATUS_CONTENT_RESULT_FORM = 1; + public static final int STATUS_CONTENT_RESULT_SOURCE = 2; + + private BasicModel model_; + private NodeManager nodeManager_; + private String perspectiveContentFramesetCols_; + private String savedPerspectiveContentFramesetCols_; + private String actionsContainerFramesetRows_; + private String savedActionsContainerFramesetRows_; + private int statusContentType_; + + private SOAPMessageQueue soapRequestQueue_; + private SOAPMessageQueue soapResponseQueue_; + private Node operationNode_; + + static + { + // Initialize the XSD subsystem. + (new ResourceFactoryRegistryImpl()).getExtensionToFactoryMap().put("xsd",new XSDResourceFactoryImpl()); + // port to org.eclipse.xsd + // Init.init(); + EcorePackageImpl.init(); + XSDPackageImpl.init(); + } + + public WSDLPerspective(Controller controller) + { + super("wsdl",controller); + } + + public final void initPerspective(ServletContext application) + { + model_ = new BasicModel("wsdlModel"); + TreeElement treeElement = new TreeElement(getMessage("NODE_NAME_WSDL_MAIN"), model_); + model_.setRootElement(treeElement); + nodeManager_ = new NodeManager(controller_); + WSDLMainNode wsdlMainNode = new WSDLMainNode(treeElement, nodeManager_); + nodeManager_.setRootNode(wsdlMainNode); + + // Starting frameset sizes. + perspectiveContentFramesetCols_ = "30%,*"; + savedPerspectiveContentFramesetCols_ = perspectiveContentFramesetCols_; + actionsContainerFramesetRows_ = "75%,*"; + savedActionsContainerFramesetRows_ = actionsContainerFramesetRows_; + + // Message status pane + statusContentType_ = STATUS_CONTENT_DEFAULT; + soapRequestQueue_ = new SOAPMessageQueue(); + soapResponseQueue_ = new SOAPMessageQueue(); + operationNode_ = null; + } + + public final void preloadWSDL(String[] wsdlURLs) { + if (wsdlURLs != null) { + for (int i = 0; i < wsdlURLs.length; i++) { + OpenWSDLAction openWSDLAction = new OpenWSDLAction(controller_); + Hashtable propertyTable = openWSDLAction.getPropertyTable(); + String decodedWSDLURL = URLUtils.decode(wsdlURLs[i]); + propertyTable.put(ActionInputs.QUERY_INPUT_WSDL_URL, decodedWSDLURL); + openWSDLAction.run(); + } + if (wsdlURLs.length > 0) + controller_.setCurrentPerspective(ActionInputs.PERSPECTIVE_WSDL); + } + } + + public final void preloadEndpoints(String[] wsdlURLs, String[] endpoints) + { + if (wsdlURLs != null && wsdlURLs.length > 0 && endpoints != null && endpoints.length > 0) + { + String wsdlURL = wsdlURLs[0]; + Vector wsdlNodes = nodeManager_.getRootNode().getChildNodes(); + for (Iterator wsdlNodesIterator = wsdlNodes.iterator(); wsdlNodesIterator.hasNext();) + { + Node wsdlNode = (Node)wsdlNodesIterator.next(); + if (wsdlNode.getNodeName().equals(wsdlURL)) + { + Vector serviceNodes = wsdlNode.getChildNodes(); + for (Iterator serviceNodesIterator = serviceNodes.iterator(); serviceNodesIterator.hasNext();) + { + Node serviceNode = (Node)serviceNodesIterator.next(); + Vector bindingNodes = serviceNode.getChildNodes(); + String[] nodeIds = new String[bindingNodes.size()]; + for (int i = 0; i < nodeIds.length; i++) + nodeIds[i] = String.valueOf(((Node)bindingNodes.get(i)).getNodeId()); + UpdateWSDLBindingAction action = new UpdateWSDLBindingAction(controller_); + Hashtable propertyTable = new Hashtable(); + propertyTable.put(ActionInputs.NODEID, nodeIds); + propertyTable.put(WSDLActionInputs.END_POINT, endpoints); + action.setPropertyTable(propertyTable); + action.execute(false); + } + return; + } + } + } + } + + public final void preselectServiceOrBinding(String[] wsdlURLs,String[] serviceQNameStrings,String[] bindingNameStrings) + { + if (wsdlURLs != null && wsdlURLs.length > 0) + { + String wsdlURL = wsdlURLs[0]; + Vector wsdlNodes = nodeManager_.getRootNode().getChildNodes(); + if (serviceQNameStrings != null && serviceQNameStrings.length > 0) + preselectService(wsdlURL,serviceQNameStrings[0]); + else + { + if (bindingNameStrings != null && bindingNameStrings.length > 0) + preselectBinding(wsdlURL,bindingNameStrings[0]); + } + } + } + + private final void preselectService(String wsdlURL,String serviceQNameString) + { + Vector wsdlNodes = nodeManager_.getRootNode().getChildNodes(); + for (int i=0;i<wsdlNodes.size();i++) + { + Node wsdlNode = (Node)wsdlNodes.elementAt(i); + if (wsdlNode.getNodeName().equals(wsdlURL)) + { + Vector serviceNodes = wsdlNode.getChildNodes(); + for (int j=0;j<serviceNodes.size();j++) + { + Node serviceNode = (Node)serviceNodes.elementAt(j); + WSDLServiceElement serviceElement = (WSDLServiceElement)serviceNode.getTreeElement(); + Service service = serviceElement.getService(); + if (service.getQName().toString().equals(serviceQNameString)) + { + nodeManager_.setSelectedNodeId(serviceNode.getNodeId()); + nodeManager_.makeSelectedNodeVisible(); + controller_.setCurrentPerspective(ActionInputs.PERSPECTIVE_WSDL); + return; + } + } + } + } + } + + private final void preselectBinding(String wsdlURL,String bindingNameString) + { + Vector wsdlNodes = nodeManager_.getRootNode().getChildNodes(); + for (int i=0;i<wsdlNodes.size();i++) + { + Node wsdlNode = (Node)wsdlNodes.elementAt(i); + if (wsdlNode.getNodeName().equals(wsdlURL)) + { + Vector serviceNodes = wsdlNode.getChildNodes(); + for (int j=0;j<serviceNodes.size();j++) + { + Node serviceNode = (Node)serviceNodes.elementAt(j); + Vector bindingNodes = serviceNode.getChildNodes(); + for (int k=0;k<bindingNodes.size();k++) + { + Node bindingNode = (Node)bindingNodes.elementAt(k); + WSDLBindingElement bindingElement = (WSDLBindingElement)bindingNode.getTreeElement(); + if (bindingElement.getBinding().getQName().toString().equals(bindingNameString)) + { + nodeManager_.setSelectedNodeId(bindingNode.getNodeId()); + nodeManager_.makeSelectedNodeVisible(); + controller_.setCurrentPerspective(ActionInputs.PERSPECTIVE_WSDL); + return; + } + } + } + } + } + } + + public NodeManager getNodeManager() + { + return nodeManager_; + } + + public String getPerspectiveContentPage() + { + return "wsdl/wsdl_perspective_content.jsp"; + } + + public int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSDL; + } + + public String getPanesFile() + { + return "wsdl/scripts/wsdlpanes.jsp"; + } + + public String getFramesetsFile() + { + return "wsdl/scripts/wsdlframesets.jsp"; + } + + public String getProcessFramesetsForm() + { + return "wsdl/forms/ProcessWSDLFramesetsForm.jsp"; + } + + public String getTreeContentVar() + { + return "wsdlNavigatorContent"; + } + + public String getTreeContentPage() + { + return "wsdl/wsdl_navigator_content.jsp"; + } + + public String getPropertiesContainerVar() + { + return "wsdlPropertiesContainer"; + } + + public String getPropertiesContainerPage() + { + return "wsdl/wsdl_properties_container.jsp"; + } + + public String getStatusContentVar() + { + return "wsdlStatusContent"; + } + + public String getStatusContentPage() + { + return "wsdl/wsdl_status_content.jsp"; + } + + public final String getPerspectiveContentFramesetCols() + { + return perspectiveContentFramesetCols_; + } + + public final void setPerspectiveContentFramesetCols(String cols) + { + perspectiveContentFramesetCols_ = cols; + } + + public final void setSavedPerspectiveContentFramesetCols(String cols) + { + savedPerspectiveContentFramesetCols_ = cols; + } + + public final String getSavedPerspectiveContentFramesetCols() + { + return savedPerspectiveContentFramesetCols_; + } + + public final String getActionsContainerFramesetRows() + { + return actionsContainerFramesetRows_; + } + + public final void setActionsContainerFramesetRows(String rows) + { + actionsContainerFramesetRows_ = rows; + } + + public final void setSavedActionsContainerFramesetRows(String rows) + { + savedActionsContainerFramesetRows_ = rows; + } + + public final String getSavedActionsContainerFramesetRows() + { + return savedActionsContainerFramesetRows_; + } + + public final String getSwitchPerspectiveFormActionLink(int targetPerspectiveId,boolean forHistory) + { + return SwitchPerspectiveFromWSDLAction.getFormActionLink(targetPerspectiveId,forHistory); + } + + public final int getStatusContentType() + { + return statusContentType_; + } + + public final void setStatusContentType(int statusContentType) + { + statusContentType_ = statusContentType; + } + + public final SOAPMessageQueue getSOAPRequestQueue() + { + return soapRequestQueue_; + } + + public final SOAPMessageQueue getSOAPResponseQueue() + { + return soapResponseQueue_; + } + + public final Node getOperationNode() + { + return operationNode_; + } + + public final void setOperationNode(Node operationNode) + { + operationNode_ = operationNode; + } + + public final String getSOAPEnvelopeXMLLink(int soapEnvelopeType) + { + StringBuffer link = new StringBuffer("wsdl/soap_envelope_xml.jsp?"); + link.append(WSDLActionInputs.SOAP_ENVELOPE_TYPE).append('=').append(soapEnvelopeType); + return link.toString(); + } + + public final String getBindingTypeString(int bindingType) + { + switch (bindingType) + { + case BindingTypes.SOAP: + return getMessage("FORM_LABEL_BINDING_TYPE_SOAP"); + case BindingTypes.HTTP_GET: + return getMessage("FORM_LABEL_BINDING_TYPE_HTTP_GET"); + case BindingTypes.HTTP_POST: + return getMessage("FORM_LABEL_BINDING_TYPE_HTTP_POST"); + default: + return getMessage("FORM_LABEL_BINDING_TYPE_UNSUPPORTED"); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLServiceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLServiceDetailsTool.java new file mode 100644 index 000000000..457fe9b61 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLServiceDetailsTool.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; + +public class WSDLServiceDetailsTool extends DetailsTool { + + public WSDLServiceDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, alt, "wsdl/forms/WSDLServiceDetailsForm.jsp"); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLServiceNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLServiceNode.java new file mode 100644 index 000000000..5937378b8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/perspective/WSDLServiceNode.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.*; + +// WSDL service node for the WSDL Navigator Tree View +public class WSDLServiceNode extends WSDLNavigatorNode +{ + public WSDLServiceNode(TreeElement element,NodeManager nodeManager,int nodeDepth) + { + super(element,nodeManager,nodeDepth,"wsdl/images/wsdl_service_node.gif"); + element.addListener(new ElementAdapter() + { + public void relAdded(RelAddEvent event) + { + String rel = event.getOutBoundRelName(); + if (rel.equals(WSDLModelConstants.REL_WSDL_BINDING)) { + WSDLBindingNode wsdlBindingNode = new WSDLBindingNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(wsdlBindingNode); + } + } + + public void relRemoved(RelRemoveEvent event) + { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(WSDLModelConstants.REL_WSDL_BINDING)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(WSDLModelConstants.REL_WSDL_BINDING)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + setVisibilityOfChildren(false); + } + + protected final void initTools() + { + Controller controller = nodeManager_.getController(); + WSDLPerspective wsdlPerspective = controller.getWSDLPerspective(); + new WSDLServiceDetailsTool(toolManager_, wsdlPerspective.getMessage("ALT_WSDL_SERVICE_DETAILS")); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transformer/FragmentTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transformer/FragmentTransformer.java new file mode 100644 index 000000000..8b85259db --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transformer/FragmentTransformer.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transformer; + +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; +import javax.wsdl.Part; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.constants.FragmentConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.IXSDFragment; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class FragmentTransformer implements ITransformer +{ + protected Controller controller; + + public FragmentTransformer(Controller controller) + { + this.controller = controller; + } + + public Hashtable normalize(Hashtable properties) + { + StringBuffer sb = new StringBuffer(); + sb.append("<root>"); + WSDLOperationElement operElement = (WSDLOperationElement)controller.getWSDLPerspective().getNodeManager().getSelectedNode().getTreeElement(); + Iterator it = operElement.getOrderedBodyParts().iterator(); + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = (IXSDFragment)operElement.getFragment(part); + Element[] elements = new Element[0]; + try + { + elements = frag.genInstanceDocumentsFromParameterValues(!operElement.isUseLiteral(), new Hashtable(), XMLUtils.createNewDocument(null)); + } + catch (ParserConfigurationException pce) + { + } + for (int i = 0; i < elements.length; i++) + sb.append(XMLUtils.serialize(elements[i], true)); + } + sb.append("</root>"); + properties.put(FragmentConstants.SOURCE_CONTENT, sb.toString()); + return properties; + } + + public Hashtable deNormalize(Hashtable properties) + { + String source = (String) properties.get(FragmentConstants.SOURCE_CONTENT); + if (source != null) + { + try + { + Element root = XMLUtils.stringToElement(source); + if (root != null) + { + NodeList childNodes = root.getChildNodes(); + Vector childrenVector = new Vector(); + for (int i = 0; i < childNodes.getLength(); i++) + { + Node child = childNodes.item(i); + if (child instanceof Element) + childrenVector.add(child); + } + Element[] children = (Element[])childrenVector.toArray(new Element[0]); + WSDLOperationElement operElement = (WSDLOperationElement) controller.getWSDLPerspective().getNodeManager().getSelectedNode().getTreeElement(); + Iterator it = operElement.getOrderedBodyParts().iterator(); + while (it.hasNext()) + { + Part part = (Part)it.next(); + IXSDFragment frag = (IXSDFragment)operElement.getFragment(part); + frag.setParameterValuesFromInstanceDocuments(children); + } + } + } + catch (Throwable t) + { + } + } + return properties; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/ChunkedInputStream.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/ChunkedInputStream.java new file mode 100644 index 000000000..8f610328f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/ChunkedInputStream.java @@ -0,0 +1,192 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +public class ChunkedInputStream extends FilterInputStream +{ + protected long chunkSize = 0l; + protected volatile boolean closed = false; + private static final int maxCharLong = (Long.toHexString(Long.MAX_VALUE)).toString().length(); + + private ChunkedInputStream() + { + super(null); + } + + public ChunkedInputStream(InputStream is) + { + super(is); + } + + public int read() throws IOException + { + byte[] d = new byte[1]; + int rc = read(d, 0, 1); + return rc > 0 ? (d[0] & 0xFF) : rc; + } + + public int read(byte[] b) throws IOException + { + return read(b, 0, b.length); + } + + public synchronized int read(byte[] b, int off, int len) throws IOException + { + if (closed) + return -1; + int cs = (int) Math.min(Integer.MAX_VALUE, chunkSize); + int totalread = 0; + int bytesread = 0; + try + { + do + { + if (chunkSize < 1L) + { + if (0l == getChunked()) + { + if (totalread == 0) + return -1; + else + return totalread; + } + } + bytesread = in.read(b, off + totalread, Math.min(len - totalread, (int) Math.min(chunkSize, Integer.MAX_VALUE))); + if (bytesread > 0) + { + totalread += bytesread; + chunkSize -= bytesread; + } + } + while (len - totalread > 0 && bytesread > -1); + } + catch (IOException e) + { + closed = true; + throw e; + } + return totalread; + } + + public long skip(final long n) throws IOException + { + if (closed) + return 0; + long skipped = 0l; + byte[] b = new byte[1024]; + int bread = -1; + do + { + bread = read(b, 0, b.length); + if (bread > 0) + skipped += bread; + } + while (bread != -1 && skipped < n); + return skipped; + } + + public int available() throws IOException + { + if (closed) + return 0; + int rc = (int) Math.min(chunkSize, Integer.MAX_VALUE); + return Math.min(rc, in.available()); + } + + protected long getChunked() throws IOException + { + //StringBuffer buf= new StringBuffer(1024); + byte[] buf = new byte[maxCharLong + 2]; + int bufsz = 0; + chunkSize = -1L; + int c = -1; + do + { + c = in.read(); + if (c > -1) + { + if (c != '\r' && c != '\n' && c != ' ' && c != '\t') + { + buf[bufsz++] = ((byte) c); + } + } + } + while (c > -1 && (c != '\n' || bufsz == 0) && bufsz < buf.length); + if (c < 0) + { + closed = true; + } + String sbuf = new String(buf, 0, bufsz); + if (bufsz > maxCharLong) + { + closed = true; + throw new IOException("Chunked input stream failed to receive valid chunk size:" + sbuf); + } + try + { + chunkSize = Long.parseLong(sbuf, 16); + } + catch (NumberFormatException ne) + { + closed = true; + throw new IOException("'" + sbuf + "' " + ne.getMessage()); + } + if (chunkSize < 1L) + closed = true; + if (chunkSize != 0L && c < 0) + { + //If chunk size is zero try and be tolerant that there maybe no cr or lf + // at the end. + throw new IOException("HTTP Chunked stream closed in middle of chunk."); + } + if (chunkSize < 0L) + throw new IOException("HTTP Chunk size received " + chunkSize + " is less than zero."); + return chunkSize; + } + + public void close() throws IOException + { + synchronized (this) + { + if (closed) + return; + closed = true; + } + byte[] b = new byte[1024]; + int bread = -1; + do + { + bread = read(b, 0, b.length); + } + while (bread != -1); + } + + /* + * public void mark(int readlimit) + * { + * } + */ + + public void reset() throws IOException + { + throw new IOException("Don't support marked streams"); + } + + public boolean markSupported() + { + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java new file mode 100644 index 000000000..28588328d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPException.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; + +import java.util.Map; + +public class HTTPException extends RuntimeException +{ + /** + * Comment for <code>serialVersionUID</code> + */ + private static final long serialVersionUID = 3256438105900134961L; +private int statusCode; + private String statusMessage; + private Map headers; + + public HTTPException(int statusCode, String statusMessage, Map headers) + { + super(statusMessage); + this.statusCode = statusCode; + this.statusMessage = statusMessage; + this.headers = headers; + } + + public int getStatusCode() + { + return statusCode; + } + + public String getStatusMessage() + { + return statusMessage; + } + + public Map getHeaders() + { + return headers; + } + + public String getHeader(String key) + { + Object value = headers.get(key); + if (value != null) + return value.toString(); + else + return null; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPResponse.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPResponse.java new file mode 100644 index 000000000..65b61afd4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPResponse.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; + +import java.util.Hashtable; +import java.util.Map; + +public class HTTPResponse +{ + private boolean statusSet; + private int statusCode; + private String statusMessage; + private Hashtable headers; + private byte[] payload; + + public HTTPResponse() + { + reset(); + } + + public void reset() + { + statusSet = false; + statusCode = -1; + statusMessage = null; + if (headers != null) + headers.clear(); + else + headers = new Hashtable(); + payload = new byte[0]; + } + + public boolean isStatusSet() + { + return statusSet; + } + + public int getStatusCode() + { + return statusCode; + } + + public void setStatusCode(int statusCode) + { + statusSet = true; + this.statusCode = statusCode; + } + + public String getStatusMessage() + { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) + { + this.statusMessage = statusMessage; + } + + public void addHeader(String key, String value) + { + headers.put(key, value); + } + + public String getHeader(String key) + { + return (String) headers.get(key); + } + + public Map getHeaders() + { + return headers; + } + + public byte[] getPayload() + { + return payload; + } + + public void setPayload(byte[] payload) + { + this.payload = payload; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java new file mode 100644 index 000000000..ab48e3e64 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/transport/HTTPTransport.java @@ -0,0 +1,495 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; + +import org.eclipse.wst.ws.internal.explorer.platform.util.XMLUtils; + +import sun.misc.BASE64Encoder; + +import org.w3c.dom.Element; + +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.UnknownHostException; +import java.util.Hashtable; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import javax.net.ssl.SSLSocketFactory; + +public class HTTPTransport +{ + private final String SYS_PROP_HTTPS_PROXY_HOST = "https.proxyHost"; + private final String SYS_PROP_HTTPS_PROXY_PORT = "https.proxyPort"; + private final String SYS_PROP_HTTP_PROXY_HOST = "http.proxyHost"; + private final String SYS_PROP_HTTP_PROXY_PORT = "http.proxyPort"; + private final String SYS_PROP_HTTP_PROXY_USER_NAME = "http.proxyUserName"; + private final String SYS_PROP_HTTP_PROXY_PASSWORD = "http.proxyPassword"; + + private final String HTTP_METHOD = "POST"; + private final String HTTP_VERSION = "HTTP/1.1"; + private final String HTTP_HEADER_SOAP_ACTION = "SOAPAction"; + public static final String HTTP_HEADER_AUTH = "Authorization"; + public static final String HTTP_HEADER_WWW_AUTH = "WWW-Authenticate"; + private final String HTTP_HEADER_PROXY_AUTH = "Proxy-authorization"; + private final String HTTP_HEADER_COOKIE = "Cookie"; + private final String HTTP_HEADER_COOKIE2 = "Cookie2"; + private final String HTTP_HEADER_HOST = "Host"; + private final String HTTP_HEADER_CONTENT_TYPE = "Content-Type"; + public static final String HTTP_HEADER_CONTENT_LENGTH = "Content-Length"; + private final String HTTP_HEADER_ACCEPT = "Accept"; + private final String HTTP_HEADER_USER_AGENT = "User-Agent"; + private final String HTTP_HEADER_CACHE_CONTROL = "Cache-Control"; + private final String HTTP_HEADER_PRAGMA = "Pragma"; + private final String HTTP_HEADER_TRANSFER_ENCODEING = "Transfer-Encoding"; + private final String HTTP_HEADER_CONNECTION = "Connection"; + + private final int HTTP_CODE_CONTINUE = 100; + private final int HTTP_CODE_OK = 200; + private final int HTTP_CODE_EXCEPTION = 300; + + private final String IBM_WEB_SERVICES_EXPLORER = "IBM Web Services Explorer"; + private final String TEXT_XML = "text/xml"; + private final String CONTENT_TYPE_VALUE = "text/xml; charset=utf-8"; + private final String ACCEPT_VALUE = "application/soap+xml, application/dime, multipart/related, text/*"; + public static final String BASIC = "Basic"; + private final String NO_CACHE = "no-cache"; + private final String CHUNKED = "chunked"; + private final String CLOSE = "close"; + private final String HTTPS = "https"; + private final char QUOTE = '\"'; + public static final char COLON = ':'; + private final char SPACE = ' '; + private final char TAB = '\t'; + private final char R = '\r'; + private final char N = '\n'; + private final char ROOT = '/'; + private final String NEW_LINE = "\r\n"; + private final String EMPTY_STRING = ""; + + private final int DEFAULT_HTTP_PORT = 80; + private final int DEFAULT_HTTPS_PORT = 443; + private final String DEFAULT_SOAP_ENCODING = "UTF-8"; + private final String DEFAULT_HTTP_HEADER_ENCODING = "iso-8859-1"; + + private String httpBasicAuthUsername; + private String httpBasicAuthPassword; + private boolean maintainSession = false; + private String cookie; + private String cookie2; + private boolean useChunked = false; + private HTTPResponse httpResponse; + + public String getHttpBasicAuthUsername() + { + return httpBasicAuthUsername; + } + + public void setHttpBasicAuthUsername(String httpBasicAuthUsername) + { + this.httpBasicAuthUsername = httpBasicAuthUsername; + } + + public String getHttpBasicAuthPassword() + { + return httpBasicAuthPassword; + } + + public void setHttpBasicAuthPassword(String httpBasicAuthPassword) + { + this.httpBasicAuthPassword = httpBasicAuthPassword; + } + + private String getMethod(URL url) + { + StringBuffer sb = new StringBuffer(HTTP_METHOD); + sb.append(SPACE); + String httpProxyHost = System.getProperty(SYS_PROP_HTTP_PROXY_HOST); + String httpsProxyHost = System.getProperty(SYS_PROP_HTTPS_PROXY_HOST); + if (httpProxyHost != null && httpProxyHost.length() > 0 && httpsProxyHost != null && httpsProxyHost.length() > 0) + sb.append(url.toString()); + else + { + String file = url.getFile(); + if (file != null && file.length() > 0) + sb.append(file); + else + sb.append(ROOT); + } + sb.append(SPACE); + sb.append(HTTP_VERSION); + sb.append(NEW_LINE); + return sb.toString(); + } + + private String getHost(URL url) + { + StringBuffer sb = new StringBuffer(HTTP_HEADER_HOST); + sb.append(COLON); + sb.append(SPACE); + sb.append(url.getHost()); + sb.append(COLON); + int port = url.getPort(); + if (port > 0) + sb.append(String.valueOf(port)); + else if (url.getProtocol().equalsIgnoreCase(HTTPS)) + sb.append(DEFAULT_HTTPS_PORT); + else + sb.append(DEFAULT_HTTP_PORT); + sb.append(NEW_LINE); + return sb.toString(); + } + + private String getContentType() + { + return getHTTPHeader(HTTP_HEADER_CONTENT_TYPE, CONTENT_TYPE_VALUE); + } + + private String getContentLength(String payload) + { + return getHTTPHeader(HTTP_HEADER_CONTENT_LENGTH, String.valueOf(payload.length())); + } + + private String getSOAPAction(String soapAction) + { + StringBuffer sb = new StringBuffer(HTTP_HEADER_SOAP_ACTION); + sb.append(COLON); + sb.append(SPACE); + sb.append(QUOTE); + if (soapAction != null) + sb.append(soapAction); + sb.append(QUOTE); + sb.append(NEW_LINE); + return sb.toString(); + } + + private String getCookie() + { + if (maintainSession) + return getHTTPHeader(HTTP_HEADER_COOKIE, cookie); + else + return EMPTY_STRING; + } + + private String getCookie2() + { + if (maintainSession) + return getHTTPHeader(HTTP_HEADER_COOKIE2, cookie2); + else + return EMPTY_STRING; + } + + private String getWWWAuthentication() + { + if (httpBasicAuthUsername != null && httpBasicAuthPassword != null) + { + StringBuffer sb = new StringBuffer(httpBasicAuthUsername); + sb.append(COLON); + sb.append(httpBasicAuthPassword); + BASE64Encoder encoder = new BASE64Encoder(); + String encodedUserNamePassword = encoder.encode(sb.toString().getBytes()); + sb.setLength(0); + sb.append(HTTP_HEADER_AUTH); + sb.append(COLON); + sb.append(SPACE); + sb.append(BASIC); + sb.append(SPACE); + sb.append(encodedUserNamePassword); + sb.append(NEW_LINE); + return sb.toString(); + } + else + return EMPTY_STRING; + } + + private String getProxyAuthentication() + { + String proxyUserName = System.getProperty(SYS_PROP_HTTP_PROXY_USER_NAME); + String proxyPassword = System.getProperty(SYS_PROP_HTTP_PROXY_PASSWORD); + if (proxyUserName != null && proxyPassword != null) + { + StringBuffer sb = new StringBuffer(proxyUserName); + sb.append(COLON); + sb.append(proxyPassword); + BASE64Encoder encoder = new BASE64Encoder(); + String encodedUserNamePassword = encoder.encode(sb.toString().getBytes()); + sb.setLength(0); + sb.append(HTTP_HEADER_PROXY_AUTH); + sb.append(COLON); + sb.append(SPACE); + sb.append(BASIC); + sb.append(SPACE); + sb.append(encodedUserNamePassword); + sb.append(NEW_LINE); + return sb.toString(); + } + else + return EMPTY_STRING; + } + + private String getAccept() + { + return getHTTPHeader(HTTP_HEADER_ACCEPT, ACCEPT_VALUE); + } + + private String getUserAgent() + { + return getHTTPHeader(HTTP_HEADER_USER_AGENT, IBM_WEB_SERVICES_EXPLORER); + } + + private String getCacheControl() + { + return getHTTPHeader(HTTP_HEADER_CACHE_CONTROL, NO_CACHE); + } + + private String getPragma() + { + return getHTTPHeader(HTTP_HEADER_PRAGMA, NO_CACHE); + } + + private String getConnection() + { + return getHTTPHeader(HTTP_HEADER_CONNECTION, CLOSE); + } + + private String getHTTPHeader(String key, String value) + { + if (value != null) + { + StringBuffer sb = new StringBuffer(key); + sb.append(COLON); + sb.append(SPACE); + sb.append(value); + sb.append(NEW_LINE); + return sb.toString(); + } + else + return EMPTY_STRING; + } + + public void send(URL url, String soapAction, String payload) throws UnknownHostException, IOException + { + StringBuffer httpHeader = new StringBuffer(); + httpHeader.append(getMethod(url)); + httpHeader.append(getHost(url)); + httpHeader.append(getContentType()); + httpHeader.append(getContentLength(payload)); + httpHeader.append(getAccept()); + httpHeader.append(getUserAgent()); + httpHeader.append(getCacheControl()); + httpHeader.append(getPragma()); + httpHeader.append(getSOAPAction(soapAction)); + httpHeader.append(getWWWAuthentication()); + httpHeader.append(getProxyAuthentication()); + httpHeader.append(getCookie()); + httpHeader.append(getCookie2()); + httpHeader.append(getConnection()); + httpHeader.append(NEW_LINE); // new line between the HTTP header and the payload + Socket socket = buildSocket(url); + InputStream is = socket.getInputStream(); + OutputStream os = socket.getOutputStream(); + os.write(httpHeader.toString().getBytes(DEFAULT_HTTP_HEADER_ENCODING)); + os.write(payload.getBytes(DEFAULT_SOAP_ENCODING)); + os.flush(); + httpResponse = new HTTPResponse(); + readHTTPResponseHeader(is, httpResponse); + int code = httpResponse.getStatusCode(); + if (code == HTTP_CODE_CONTINUE) + { + httpResponse.reset(); + readHTTPResponseHeader(is, httpResponse); + } + readHTTPResponsePayload(is, httpResponse); + os.close(); + is.close(); + socket.close(); + code = httpResponse.getStatusCode(); + String contentType = httpResponse.getHeader(HTTP_HEADER_CONTENT_TYPE.toLowerCase()); + if (code >= HTTP_CODE_EXCEPTION && (contentType == null || contentType.toLowerCase().indexOf(TEXT_XML.toLowerCase()) == -1)) + throw new HTTPException(code, httpResponse.getStatusMessage(), httpResponse.getHeaders()); + } + + private void readHTTPResponseHeader(InputStream is, HTTPResponse resp) throws IOException + { + byte b = 0; + int len = 0; + int colonIndex = -1; + String key; + String value; + boolean readTooMuch = false; + ByteArrayOutputStream baos; + for (baos = new ByteArrayOutputStream(4096);;) + { + if (!readTooMuch) + b = (byte)is.read(); + if (b == -1) + break; + readTooMuch = false; + if ((b != R) && (b != N)) + { + if ((b == COLON) && (colonIndex == -1)) + colonIndex = len; + len++; + baos.write(b); + } + else if (b == R) + continue; + else // b == N + { + if (len == 0) + break; + b = (byte)is.read(); + readTooMuch = true; + // A space or tab at the begining of a line means the header continues. + if ((b == SPACE) || (b == TAB)) + continue; + baos.close(); + byte[] bArray = baos.toByteArray(); + baos.reset(); + if (colonIndex != -1) + { + key = new String(bArray, 0, colonIndex, DEFAULT_HTTP_HEADER_ENCODING); + value = new String(bArray, colonIndex + 1, len - 1 - colonIndex, DEFAULT_HTTP_HEADER_ENCODING); + colonIndex = -1; + } + else + { + key = new String(bArray, 0, len, DEFAULT_HTTP_HEADER_ENCODING); + value = EMPTY_STRING; + } + if (!resp.isStatusSet()) + { + // Reader status code + int start = key.indexOf(SPACE) + 1; + String s = key.substring(start).trim(); + int end = s.indexOf(SPACE); + if (end != -1) + s = s.substring(0, end); + try + { + resp.setStatusCode(Integer.parseInt(s)); + } + catch (NumberFormatException nfe) + { + resp.setStatusCode(-1); + } + resp.setStatusMessage(key.substring(start + end + 1)); + } + else + resp.addHeader(key.toLowerCase().trim(), value.trim()); + len = 0; + } + } + baos.close(); + } + + private void readHTTPResponsePayload(InputStream is, HTTPResponse resp) throws IOException + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try + { + byte b = (byte)is.read(); + while (b != -1) + { + baos.write(b); + b = (byte)is.read(); + } + } + catch (SocketTimeoutException ste) + { + } + baos.close(); + resp.setPayload(baos.toByteArray()); + } + + public BufferedReader receive() + { + if (httpResponse != null) + { + try + { + byte[] payload = httpResponse.getPayload(); + Element soapEnvelope = null; + if (CHUNKED.equalsIgnoreCase(httpResponse.getHeader(HTTP_HEADER_TRANSFER_ENCODEING.toLowerCase()))) + { + ByteArrayInputStream bais = new ByteArrayInputStream(payload); + ChunkedInputStream cis = new ChunkedInputStream(bais); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte b; + while ((b = (byte)cis.read()) != -1) + baos.write(b); + baos.close(); + cis.close(); + bais.close(); + soapEnvelope = XMLUtils.byteArrayToElement(baos.toByteArray(), false); + } + else + { + soapEnvelope = XMLUtils.byteArrayToElement(payload, false); + } + // remove XML namespace declaration + if (soapEnvelope != null) + return new BufferedReader(new InputStreamReader(new ByteArrayInputStream(XMLUtils.serialize(soapEnvelope, true).getBytes(DEFAULT_SOAP_ENCODING)))); + } + catch (Throwable t) + { + } + } + return null; + } + + public Hashtable getHeaders() + { + Hashtable headers = new Hashtable(); + if (httpResponse != null) + headers.putAll(httpResponse.getHeaders()); + return headers; + } + + private Socket buildSocket(URL url) throws UnknownHostException, IOException + { + Socket s = null; + String host = url.getHost(); + int port = url.getPort(); + String proxyHost = System.getProperty(SYS_PROP_HTTP_PROXY_HOST); + int proxyPort = Integer.getInteger(SYS_PROP_HTTP_PROXY_PORT, DEFAULT_HTTP_PORT).intValue(); + String proxyUserName = System.getProperty(SYS_PROP_HTTP_PROXY_USER_NAME); + String proxyPassword = System.getProperty(SYS_PROP_HTTP_PROXY_PASSWORD); + if (url.getProtocol().equalsIgnoreCase(HTTPS)) + { + proxyHost = System.getProperty(SYS_PROP_HTTPS_PROXY_HOST); + proxyPort = Integer.getInteger(SYS_PROP_HTTPS_PROXY_PORT, DEFAULT_HTTPS_PORT).intValue(); + if (proxyHost != null && proxyHost.length() > 0) + { + // TODO: + // SSL with proxy server + } + else + s = SSLSocketFactory.getDefault().createSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT)); + // Removing dependency on soap.jar + // s = SSLUtils.buildSSLSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT), proxyHost, proxyPort); + // TODO: + // Build an SSL socket that supports proxyUser and proxyPassword, + // as demonstrated in the following (original) line of code: + // s = SSLUtils.buildSSLSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT), proxyHost, proxyPort, proxyUserName, proxyPassword); + } + else if (proxyHost != null && proxyHost.length() > 0) + s = new Socket(proxyHost, proxyPort); + else + s = new Socket(host, (port > 0 ? port : DEFAULT_HTTP_PORT)); + return s; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java new file mode 100644 index 000000000..96259e20e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/util/SoapHelper.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.util; + +import org.eclipse.wst.ws.internal.explorer.platform.util.URLUtils; + +import java.util.Enumeration; +import java.util.Hashtable; + +import org.apache.axis.Constants; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class SoapHelper +{ + private static Hashtable defaultSoapEnvelopeNamespaces_ = null; + + private static final void initDefaultSoapEnvelopeNamespaces() + { + defaultSoapEnvelopeNamespaces_ = new Hashtable(); + defaultSoapEnvelopeNamespaces_.put(Constants.URI_SOAP11_ENV,Constants.NS_PREFIX_SOAP_ENV); + defaultSoapEnvelopeNamespaces_.put(Constants.URI_2001_SCHEMA_XSI,Constants.NS_PREFIX_SCHEMA_XSI); + defaultSoapEnvelopeNamespaces_.put(Constants.URI_2001_SCHEMA_XSD,Constants.NS_PREFIX_SCHEMA_XSD); + } + + public static final void addDefaultSoapEnvelopeNamespaces(Hashtable soapEnvelopeNamespaces) + { + if (defaultSoapEnvelopeNamespaces_ == null) + initDefaultSoapEnvelopeNamespaces(); + Enumeration defaultSoapEnvelopeNamespaceURIs = defaultSoapEnvelopeNamespaces_.keys(); + while (defaultSoapEnvelopeNamespaceURIs.hasMoreElements()) + { + String defaultSoapEnvelopeNamespaceURI = (String)defaultSoapEnvelopeNamespaceURIs.nextElement(); + soapEnvelopeNamespaces.put(defaultSoapEnvelopeNamespaceURI,(String)defaultSoapEnvelopeNamespaces_.get(defaultSoapEnvelopeNamespaceURI)); + } + } + + public static final boolean isDefaultSoapEnvelopeNamespace(String namespaceURI,String namespacePrefix) + { + if (defaultSoapEnvelopeNamespaces_ == null) + initDefaultSoapEnvelopeNamespaces(); + if (defaultSoapEnvelopeNamespaces_.get(namespaceURI) != null) + return true; + return false; + } + + public static final Element createSoapEnvelopeElement(Document doc,Hashtable soapEnvelopeNamespaceTable) + { + Element soapEnvelopeElement = doc.createElement("soapenv:Envelope"); + Enumeration e = soapEnvelopeNamespaceTable.keys(); + while (e.hasMoreElements()) + { + String soapEnvelopeNamespaceURI = (String)e.nextElement(); + StringBuffer soapEnvelopeNamespaceAttr = new StringBuffer("xmlns:"); + soapEnvelopeNamespaceAttr.append((String)soapEnvelopeNamespaceTable.get(soapEnvelopeNamespaceURI)); + soapEnvelopeElement.setAttribute(soapEnvelopeNamespaceAttr.toString(),soapEnvelopeNamespaceURI); + } + return soapEnvelopeElement; + } + + public static final Element createSoapBodyElement(Document doc) + { + return doc.createElement("soapenv:Body"); + } + + public static final Element createRPCWrapperElement(Document doc,Hashtable soapEnvelopeNamespaceTable,String encodingNamespaceURI,String operationName, String encodingStyle) + { + int nsId = 0; + StringBuffer wrapperElementName = new StringBuffer(); + String encodingNamespacePrefix = (String)soapEnvelopeNamespaceTable.get(encodingNamespaceURI); + if (encodingNamespacePrefix != null) + wrapperElementName.append(encodingNamespacePrefix); + else + { + // Loop until we generate a unique prefix. + do + { + wrapperElementName.setLength(0); + wrapperElementName.append("ns").append(nsId); + if (!soapEnvelopeNamespaceTable.containsValue(wrapperElementName.toString())) + break; + nsId++; + } while (true); + } + String wrapperElementNamePrefix = wrapperElementName.toString(); + wrapperElementName.append(':').append(operationName); + Element wrapperElement = doc.createElement(wrapperElementName.toString()); + StringBuffer namespaceAttrName = new StringBuffer("xmlns:"); + namespaceAttrName.append(wrapperElementNamePrefix); + wrapperElement.setAttribute(namespaceAttrName.toString(),encodingNamespaceURI); + if (encodingStyle != null) + wrapperElement.setAttribute("soapenv:encodingStyle",encodingStyle); + return wrapperElement; + } + + public static final String encodeNamespaceDeclaration(String prefix, String uri) + { + StringBuffer sb = new StringBuffer(); + sb.append(prefix); + sb.append(" "); + sb.append(uri); + String result = URLUtils.encode(sb.toString()); + return result; + } + + public static final String[] decodeNamespaceDeclaration(String s) + { + String sCopy = URLUtils.decode(s); + int index = sCopy.indexOf(" "); + String[] nsDecl = new String[2]; + if (index != -1) + { + nsDecl[0] = sCopy.substring(0, index); + nsDecl[1] = sCopy.substring(index+1, sCopy.length()); + } + else + { + nsDecl[0] = null; + nsDecl[1] = sCopy; + } + return nsDecl; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/xsd/WSDLPartsToXSDTypeMapper.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/xsd/WSDLPartsToXSDTypeMapper.java new file mode 100644 index 000000000..e570d6ba3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/xsd/WSDLPartsToXSDTypeMapper.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2002, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd; + +import org.eclipse.xsd.*; + +import javax.xml.namespace.QName; +import javax.wsdl.*; + +import java.util.*; + +public class WSDLPartsToXSDTypeMapper +{ + private final char POUND = '#'; + private Vector xsdSchemaList_; + private Hashtable partToXSDCache_; + + public WSDLPartsToXSDTypeMapper() { + xsdSchemaList_ = new Vector(); + partToXSDCache_ = new Hashtable(); + } + + public void addSchemas(Vector schemaList) { + for (int i=0;i<schemaList.size();i++) { + Object schema = schemaList.elementAt(i); + if (schema != null) + xsdSchemaList_.addElement(schema); + } + } + + public XSDNamedComponent getXSDType(Part part, String id) { + XSDNamedComponent component = getXSDTypeFromCache(id); + if (component != null) + return component; + component = getXSDTypeFromSchema(part); + if (component != null) + addToCache(id, component); + return component; + } + + public XSDNamedComponent getXSDTypeFromCache(String id) { + return (XSDNamedComponent)partToXSDCache_.get(id); + } + + public XSDNamedComponent getXSDTypeFromSchema(Part part) { + boolean isElementDeclaration = (part.getTypeName() == null); + QName qName = isElementDeclaration ? part.getElementName() : part.getTypeName(); + return getXSDTypeFromSchema(qName.getNamespaceURI(), qName.getLocalPart(), isElementDeclaration); + } + + public XSDNamedComponent getXSDTypeFromSchema(String namespaceURI, String localName, boolean isElementDeclaration) { + for (int i = 0; i < xsdSchemaList_.size(); i++) { + XSDSchema xsdSchema = (XSDSchema)xsdSchemaList_.elementAt(i); + Vector components = new Vector(); + if (isElementDeclaration) + components.addAll(xsdSchema.getElementDeclarations()); + else + components.addAll(xsdSchema.getTypeDefinitions()); + for (Iterator it = components.iterator(); it.hasNext(); ) { + XSDNamedComponent component = (XSDNamedComponent)it.next(); + String compNSURI = component.getTargetNamespace(); + String compLocalname = component.getName(); + if (compNSURI != null && compLocalname != null && compNSURI.equals(namespaceURI) && compLocalname.equals(localName)) + return component; + } + } + return null; + } + + public XSDNamedComponent resolveXSDNamedComponent(XSDNamedComponent component) + { + if (component != null) + { + String uri = component.getURI(); + String qname = component.getQName(); + for (int i = 0; i < xsdSchemaList_.size(); i++) + { + XSDSchema xsdSchema = (XSDSchema)xsdSchemaList_.elementAt(i); + if (xsdSchema != null && xsdSchema.getTargetNamespace().equals(trimQName(uri, qname))) + { + XSDNamedComponent resolvedComponent = null; + if (component instanceof XSDTypeDefinition) + resolvedComponent = xsdSchema.resolveTypeDefinition(qname); + else if (component instanceof XSDElementDeclaration) + resolvedComponent = xsdSchema.resolveElementDeclaration(qname); + else if (component instanceof XSDModelGroupDefinition) + resolvedComponent = xsdSchema.resolveModelGroupDefinition(qname); + if (isComponentResolvable(resolvedComponent)) + return resolvedComponent; + } + } + } + return null; + } + + private String trimQName(String uri, String qname) + { + int index = uri.indexOf(qname); + if (index != -1) + { + String ns = uri.substring(0, index); + if (ns.charAt(index-1) == POUND) + return ns.substring(0, index-1); + else + return ns; + } + else + return uri; + } + + private void addToCache(String id, XSDNamedComponent component) { + partToXSDCache_.put(id,component); + } + + protected boolean isComponentResolvable(XSDComponent component) + { + if (component == null) + return false; + XSDSchema schema = component.getSchema(); + if (schema == null) + return false; + if (schema.getTargetNamespace() == null) + return false; + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddBusinessToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddBusinessToFavoritesAction.java new file mode 100644 index 000000000..ad2960429 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddBusinessToFavoritesAction.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.FavoritesModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class AddBusinessToFavoritesAction extends AddToFavoritesAction +{ + public AddBusinessToFavoritesAction(Controller controller) + { + super(controller); + } + + public boolean favoriteExists() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement selectedElement = (WsilElement) selectedNode.getTreeElement(); + Object obj = selectedElement.getAllUDDILinks().getElementWithViewId(viewID).getObject(); + WsilUddiBusinessElement wsilUddiBusinessElement = (WsilUddiBusinessElement) obj; + String businessName = wsilUddiBusinessElement.getName(); + String inquiryAPI = wsilUddiBusinessElement.getUDDILinkInquiryAPI(); + String businessKey = wsilUddiBusinessElement.getUDDILinkBusinessKey(); + if (businessName == null) + businessName = businessKey; + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_NAME, businessName); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_INQUIRY_API, inquiryAPI); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_KEY, businessKey); + return favoriteExists(table, FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_UDDI_LINKS, ActionInputs.VIEWID, WSILViewSelectionTransformer.UDDI_BUSINESS); + return transformers; + } + + public boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement selectedElement = (WsilElement) selectedNode.getTreeElement(); + Object obj = selectedElement.getAllUDDILinks().getElementWithViewId(viewID).getObject(); + WsilUddiBusinessElement wsilUddiBusinessElement = (WsilUddiBusinessElement) obj; + String businessName = wsilUddiBusinessElement.getName(); + String inquiryAPI = wsilUddiBusinessElement.getUDDILinkInquiryAPI(); + String businessKey = wsilUddiBusinessElement.getUDDILinkBusinessKey(); + if (businessName == null) + businessName = businessKey; + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_NAME, businessName); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_INQUIRY_API, inquiryAPI); + table.put(FavoritesModelConstants.PROP_UDDI_BUSINESS_KEY, businessKey); + if (isMultipleLinkAction() && favoriteExists(table, FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_FAVORITES_ALREADY_EXISTS", businessName)); + return false; + } + if (addToFavorites(table, FavoritesModelConstants.REL_UDDI_BUSINESS_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_TO_FAVORITES_SUCCESSFUL", businessName)); + return true; + } + else + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_TO_FAVORITES", businessName)); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddBusinessToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddBusinessToUDDIPerspectiveAction.java new file mode 100644 index 000000000..22b34b0b9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddBusinessToUDDIPerspectiveAction.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.RegFindBusinessUUIDAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class AddBusinessToUDDIPerspectiveAction extends AddToUDDIPerspectiveAction +{ + public AddBusinessToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_UDDI_LINKS, ActionInputs.VIEWID, WSILViewSelectionTransformer.UDDI_BUSINESS); + return transformers; + } + + public boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = wsilPerspective.getNodeManager().getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + String inquiryURL = null; + String businessKey = null; + String businessName = null; + if (selectedElement instanceof WsilElement) + { + ListElement le = ((WsilElement) selectedElement).getAllUDDILinks().getElementWithViewId(viewID); + WsilUddiBusinessElement wsilUddiBusinessElement = (WsilUddiBusinessElement) le.getObject(); + inquiryURL = wsilUddiBusinessElement.getUDDILinkInquiryAPI(); + businessKey = wsilUddiBusinessElement.getUDDILinkBusinessKey(); + businessName = wsilUddiBusinessElement.getName(); + if (businessName == null) + businessName = businessKey; + } + else + return false; + // return false if unable to find or create a registry node/element in the + // UDDI perspective + if (!createRegistryInUDDIPerspective(inquiryURL, null, inquiryURL)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_TO_UDDI_PERSPECTIVE", businessName)); + return false; + } + // prepare the action + RegFindBusinessUUIDAction action = new RegFindBusinessUUIDAction(controller_); + // populate property table + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_BUSINESS_KEY, businessKey); + propertyTable.put(UDDIActionInputs.QUERY_NAME, businessName); + // run the action + if (!action.run()) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_BUSINESS_NOT_FOUND", businessName)); + return false; + } + else + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_TO_UDDI_PERSPECTIVE_SUCCESSFUL", businessName)); + return true; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddServiceToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddServiceToFavoritesAction.java new file mode 100644 index 000000000..62a754662 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddServiceToFavoritesAction.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.FavoritesModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class AddServiceToFavoritesAction extends AddToFavoritesAction +{ + public AddServiceToFavoritesAction(Controller controller) + { + super(controller); + } + + public boolean favoriteExists() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement selectedElement = (WsilElement) selectedNode.getTreeElement(); + Object obj = selectedElement.getAllUDDIServices().getElementWithViewId(viewID).getObject(); + WsilUddiServiceElement wsilUddiServiceElement = (WsilUddiServiceElement) obj; + String serviceName = wsilUddiServiceElement.getName(); + String inquiryAPI = wsilUddiServiceElement.getUDDIServiceInquiryAPI(); + String serviceKey = wsilUddiServiceElement.getUDDIServiceKey(); + if (serviceName == null) + serviceName = serviceKey; + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_NAME, serviceName); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INQUIRY_API, inquiryAPI); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_KEY, serviceKey); + return favoriteExists(table, FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_UDDI_SERVICES, ActionInputs.VIEWID, WSILViewSelectionTransformer.UDDI_SERVICE); + return transformers; + } + + public boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement selectedElement = (WsilElement) selectedNode.getTreeElement(); + Object obj = selectedElement.getAllUDDIServices().getElementWithViewId(viewID).getObject(); + WsilUddiServiceElement wsilUddiServiceElement = (WsilUddiServiceElement) obj; + String serviceName = wsilUddiServiceElement.getName(); + String inquiryAPI = wsilUddiServiceElement.getUDDIServiceInquiryAPI(); + String serviceKey = wsilUddiServiceElement.getUDDIServiceKey(); + if (serviceName == null) + serviceName = serviceKey; + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_NAME, serviceName); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_INQUIRY_API, inquiryAPI); + table.put(FavoritesModelConstants.PROP_UDDI_SERVICE_KEY, serviceKey); + if (isMultipleLinkAction() && favoriteExists(table, FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_FAVORITES_ALREADY_EXISTS", serviceName)); + return false; + } + if (addToFavorites(table, FavoritesModelConstants.REL_UDDI_SERVICE_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_TO_FAVORITES_SUCCESSFUL", serviceName)); + return true; + } + else + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_TO_FAVORITES", serviceName)); + return false; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddServiceToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddServiceToUDDIPerspectiveAction.java new file mode 100644 index 000000000..621f73d71 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddServiceToUDDIPerspectiveAction.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.RegFindServiceUUIDAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class AddServiceToUDDIPerspectiveAction extends AddToUDDIPerspectiveAction +{ + public AddServiceToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_UDDI_SERVICES, ActionInputs.VIEWID, WSILViewSelectionTransformer.UDDI_SERVICE); + return transformers; + } + + public boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = wsilPerspective.getNodeManager().getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + String inquiryURL = null; + String serviceKey = null; + String serviceName = null; + if (selectedElement instanceof WsilElement) + { + ListElement le = ((WsilElement) selectedElement).getAllUDDIServices().getElementWithViewId(viewID); + WsilUddiServiceElement wsilUddiServiceElement = (WsilUddiServiceElement) le.getObject(); + inquiryURL = wsilUddiServiceElement.getUDDIServiceInquiryAPI(); + serviceKey = wsilUddiServiceElement.getUDDIServiceKey(); + serviceName = wsilUddiServiceElement.getName(); + if (serviceName == null) + serviceName = serviceKey; + } + else + return false; + // return false if unable to find or create a registry node/element in the + // UDDI perspective + if (!createRegistryInUDDIPerspective(inquiryURL, null, inquiryURL)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_TO_UDDI_PERSPECTIVE", serviceName)); + return false; + } + // prepare the action + RegFindServiceUUIDAction action = new RegFindServiceUUIDAction(controller_); + // populate property table + Hashtable propertyTable = action.getPropertyTable(); + propertyTable.put(UDDIActionInputs.QUERY_INPUT_UUID_SERVICE_KEY, serviceKey); + propertyTable.put(UDDIActionInputs.QUERY_NAME, serviceName); + // run the action + if (!action.run()) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_SERVICE_NOT_FOUND", serviceName)); + return false; + } + else + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_TO_UDDI_PERSPECTIVE_SUCCESSFUL", serviceName)); + return true; + } + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddToFavoritesAction.java new file mode 100644 index 000000000..9808c3ff8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddToFavoritesAction.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.datamodel.FavoritesFolderElement; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.perspective.FavoritesPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +import java.util.Enumeration; +import java.util.Hashtable; +import javax.servlet.http.*; + +public abstract class AddToFavoritesAction extends MultipleLinkAction { + protected NodeManager nodeManager_; + + public AddToFavoritesAction(Controller controller) + { + super(controller); + nodeManager_ = controller.getWSILPerspective().getNodeManager(); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/WsilCheckFavoriteExistsActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() { + return "wsil/actions/WsilCheckFavoriteExistsActionJSP.jsp"; + } + + public static AddToFavoritesAction newAction(HttpServletRequest request, Controller controller) { + String nodeID = request.getParameter(ActionInputs.NODEID); + NodeManager nodeManager = controller.getWSILPerspective().getNodeManager(); + Tool selectedTool = nodeManager.getNode(Integer.parseInt(nodeID)).getToolManager().getSelectedTool(); + if (selectedTool instanceof ListWSDLServicesTool) + return new AddWSDLServiceToFavoritesAction(controller); + else if (selectedTool instanceof ListUDDIServicesTool) + return new AddServiceToFavoritesAction(controller); + else if (selectedTool instanceof ListUDDIBusinessTool) + return new AddBusinessToFavoritesAction(controller); + else + return new AddWSILToFavoritesAction(controller); + } + + protected boolean addToFavorites(Hashtable table, String rel) { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager favNodeManager = favPerspective.getNodeManager(); + TreeElement favRootElement = favNodeManager.getRootNode().getTreeElement(); + Enumeration e = favRootElement.getElements(rel); + if (!e.hasMoreElements()) return false; + FavoritesFolderElement favFolderElement = (FavoritesFolderElement)e.nextElement(); + return favFolderElement.addFavorite(table); + } + + protected boolean favoriteExists(Hashtable table, String rel) { + FavoritesPerspective favPerspective = controller_.getFavoritesPerspective(); + NodeManager favNodeManager = favPerspective.getNodeManager(); + TreeElement favRootElement = favNodeManager.getRootNode().getTreeElement(); + Enumeration e = favRootElement.getElements(rel); + if (!e.hasMoreElements()) return false; + FavoritesFolderElement favFolderElement = (FavoritesFolderElement)e.nextElement(); + return favFolderElement.favoriteExists(table); + } + + public abstract boolean favoriteExists(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddToUDDIPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddToUDDIPerspectiveAction.java new file mode 100644 index 000000000..a3572247b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddToUDDIPerspectiveAction.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.Action; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.actions.OpenRegistryAction; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.constants.UDDIActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.datamodel.RegistryElement; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.RegistryNode; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.perspective.UDDIMainNode; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +import java.util.Hashtable; +import java.util.Vector; +import javax.servlet.http.*; + +public abstract class AddToUDDIPerspectiveAction extends MultipleLinkAction +{ + public AddToUDDIPerspectiveAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/WsilAddToUDDIPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "wsil/actions/WsilAddToUDDIPerspectiveActionJSP.jsp"; + } + + public static Action newAction(HttpServletRequest request, Controller controller) + { + String nodeID = request.getParameter(ActionInputs.NODEID); + NodeManager nodeManager = controller.getWSILPerspective().getNodeManager(); + Tool selectedTool = nodeManager.getNode(Integer.parseInt(nodeID)).getToolManager().getSelectedTool(); + if (selectedTool instanceof ListUDDIServicesTool) + return new AddServiceToUDDIPerspectiveAction(controller); + else if (selectedTool instanceof ListUDDIBusinessTool) + return new AddBusinessToUDDIPerspectiveAction(controller); + else + return new NullAction(); + } + + protected boolean createRegistryInUDDIPerspective(String inquiryAPI, String publishAPI, String registryName) + { + Vector registryNodes = getRegistryNodesByInquiryURL(inquiryAPI); + if (registryNodes != null) + { + // Always attempt to use an existing registry. + Node registryNode = (Node) registryNodes.elementAt(0); + NodeManager nodeManager = registryNode.getNodeManager(); + nodeManager.setSelectedNodeId(registryNode.getNodeId()); + return true; + } + // open the registry if it is not already opened in the UDDI perspective + OpenRegistryAction openRegAction = new OpenRegistryAction(controller_); + // populate the property table + Hashtable propertyTable = openRegAction.getPropertyTable(); + if (Validator.validateString(registryName)) + propertyTable.put(UDDIActionInputs.REGISTRY_NAME, registryName); + else + return false; + if (Validator.validateURL(inquiryAPI)) + propertyTable.put(UDDIActionInputs.INQUIRY_URL, inquiryAPI); + else + return false; + // run the action + if (!openRegAction.run()) + return false; + return true; + } + + protected Vector getRegistryNodesByInquiryURL(String inquiryURL) + { + Vector registryNodes = null; + NodeManager navigatorManager = controller_.getUDDIPerspective().getNavigatorManager(); + UDDIMainNode uddiMainNode = (UDDIMainNode) (navigatorManager.getRootNode()); + Vector childNodes = uddiMainNode.getChildNodes(); + for (int i = 0; i < childNodes.size(); i++) + { + Node childNode = (Node) childNodes.elementAt(i); + if (childNode instanceof RegistryNode) + { + RegistryElement regElement = (RegistryElement) childNode.getTreeElement(); + if (regElement.getInquiryURL().equals(inquiryURL)) + { + if (registryNodes == null) + registryNodes = new Vector(); + registryNodes.addElement(childNode); + } + } + } + return registryNodes; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddWSDLServiceToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddWSDLServiceToFavoritesAction.java new file mode 100644 index 000000000..9fa0a0f4e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddWSDLServiceToFavoritesAction.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.FavoritesModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class AddWSDLServiceToFavoritesAction extends AddToFavoritesAction +{ + public AddWSDLServiceToFavoritesAction(Controller controller) + { + super(controller); + } + + public boolean favoriteExists() + { + String wsdlURL = getWsdlUrl(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_WSDL_URL, wsdlURL); + return favoriteExists(table, FavoritesModelConstants.REL_WSDL_SERVICE_FOLDER_NODE); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_WSDL_SERVICES, ActionInputs.VIEWID, WSILViewSelectionTransformer.WSDL_SERVICE); + return transformers; + } + + public boolean executeSingleLinkAction() + { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + String wsdlURL = getWsdlUrl(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_WSDL_URL, wsdlURL); + if (isMultipleLinkAction() && favoriteExists(table, FavoritesModelConstants.REL_WSDL_SERVICE_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_FAVORITES_ALREADY_EXISTS", wsdlURL)); + return false; + } + if (addToFavorites(table, FavoritesModelConstants.REL_WSDL_SERVICE_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_TO_FAVORITES_SUCCESSFUL", wsdlURL)); + return true; + } + else + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_TO_FAVORITES", wsdlURL)); + return false; + } + } + + private String getWsdlUrl() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement selectedElement = (WsilElement) selectedNode.getTreeElement(); + WsilWsdlServiceElement wsilWsdlServiceElement; + Object obj = selectedElement.getAllWSDLServices().getElementWithViewId(viewID).getObject(); + wsilWsdlServiceElement = (WsilWsdlServiceElement) obj; + return wsilWsdlServiceElement.getWSDLServiceURL(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddWSILToFavoritesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddWSILToFavoritesAction.java new file mode 100644 index 000000000..bb622d690 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/AddWSILToFavoritesAction.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.favorites.constants.FavoritesModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; + +import java.util.Hashtable; + +public class AddWSILToFavoritesAction extends AddToFavoritesAction +{ + public AddWSILToFavoritesAction(Controller controller) + { + super(controller); + } + + public boolean favoriteExists() + { + String wsilURL = getWsilUrl(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_WSIL_URL, wsilURL); + return favoriteExists(table, FavoritesModelConstants.REL_WSIL_FOLDER_NODE); + } + + public boolean executeSingleLinkAction() + { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + String wsilURL = getWsilUrl(); + Hashtable table = new Hashtable(); + table.put(FavoritesModelConstants.PROP_WSIL_URL, wsilURL); + if (isMultipleLinkAction() && favoriteExists(table, FavoritesModelConstants.REL_WSIL_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_FAVORITES_ALREADY_EXISTS", wsilURL)); + return false; + } + if (addToFavorites(table, FavoritesModelConstants.REL_WSIL_FOLDER_NODE)) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_TO_FAVORITES_SUCCESSFUL", wsilURL)); + return true; + } + else + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_TO_FAVORITES", wsilURL)); + return false; + } + } + + private String getWsilUrl() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement selectedElement = (WsilElement) selectedNode.getTreeElement(); + return selectedElement.getWsilUrl(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ClearWSILAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ClearWSILAction.java new file mode 100644 index 000000000..3615086cc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ClearWSILAction.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ClearNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class ClearWSILAction extends ClearNodeAction { + + public ClearWSILAction(Controller controller) + { + super(controller, controller.getWSILPerspective().getNodeManager()); + propertyTable_.put(ActionInputs.NODEID, String.valueOf(controller.getWSILPerspective().getNodeManager().getSelectedNodeId())); + } + + public static String getActionLink(int nodeID) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/ClearWSILActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + return actionLink.toString(); + } + + public String getTreeContentVar() { + return "wsilNavigatorContent"; + } + + public String getTreeContentPage() { + return "wsil/wsil_navigator_content.jsp"; + } + + public String getPropertiesContainerVar() { + return "wsilPropertiesContainer"; + } + + public String getPropertiesContainerPage() { + return "wsil/wsil_properties_container.jsp"; + } + + public String getStatusContentVar() { + return "wsilStatusContent"; + } + + public String getStatusContentPage() { + return "wsil/wsil_status_content.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ImportWSDLToFileSystemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ImportWSDLToFileSystemAction.java new file mode 100644 index 000000000..f6e63c7c7 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ImportWSDLToFileSystemAction.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +import java.io.OutputStream; +import javax.wsdl.Definition; +import org.uddi4j.client.UDDIProxy; + +public class ImportWSDLToFileSystemAction extends ImportToFileSystemAction +{ + private Definition def_; + private String wsdlFileName_; + private NodeManager nodeManager_; + + public ImportWSDLToFileSystemAction(Controller controller) + { + super(controller); + nodeManager_ = controller.getWSILPerspective().getNodeManager(); + } + + public static final String getActionLink(int nodeId, int toolId, int viewId, int viewToolId) + { + return ImportToFileSystemAction.getActionLink(nodeId, toolId, viewId, viewToolId, "wsil/actions/ImportWSDLToFileSystemActionJSP.jsp"); + } + + public boolean write(OutputStream os) + { + if (def_ != null) + { + return writeWSDLDefinition(os, def_); + } + else + { + return false; + } + } + + public String getDefaultFileName() + { + return wsdlFileName_; + } + + private boolean getWSDLFromURL() + { + int nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String)propertyTable_.get(ActionInputs.VIEWID)); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement wsilElement = (WsilElement)selectedNode.getTreeElement(); + ListManager wsilServices = wsilElement.getAllWSDLServices(); + ListElement le = wsilServices.getElementWithViewId(viewID); + WsilWsdlServiceElement service = (WsilWsdlServiceElement)le.getObject(); + String wsdlURL = service.getWSDLServiceURL(); + wsdlFileName_ = WSDLFileNameHelper.getWSDLFileName(wsdlURL); + try + { + def_ = (new Uddi4jHelper()).getWSDLDefinition(wsdlURL); + } + catch (Exception e) + { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + wsilPerspective.getMessageQueue().addMessage(e.getMessage()); + return false; + } + return true; + } + + private boolean getWSDLFromUDDIRegistry() + { + int nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String)propertyTable_.get(ActionInputs.VIEWID)); + Node selectedNode = nodeManager_.getNode(nodeID); + WsilElement wsilElement = (WsilElement)selectedNode.getTreeElement(); + ListManager wsilServices = wsilElement.getAllUDDIServices(); + ListElement le = wsilServices.getElementWithViewId(viewID); + WsilUddiServiceElement service = (WsilUddiServiceElement)le.getObject(); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + wsdlFileName_ = service.getName() + ".wsdl"; + Uddi4jHelper uddi4jHelper = new Uddi4jHelper(); + try + { + UDDIProxy proxy = null; + String inquiryURL = service.getUDDIServiceInquiryAPI(); + if (inquiryURL != null) + { + proxy = new UDDIProxy(); + proxy.setInquiryURL(inquiryURL); + } + def_ = uddi4jHelper.getWSDLDefinition(uddi4jHelper.getWSDL(service.getServiceDefinition(), proxy)); + } + catch (Exception e) + { + // the wsdl representing this service is unreachable through the UDDI + // registry. We will try using the discovery URL instead. + try + { + def_ = uddi4jHelper.getWSDLDefinition(service.getUDDIServiceDiscoveryURL()); + return true; + } + catch (Exception e2) + { + } + // if the discoveryURL also fails, return an error + wsilPerspective.getMessageQueue().addMessage(e.getMessage()); + return false; + } + return true; + } + + public boolean run() + { + int nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + Node selectedNode = nodeManager_.getNode(nodeID); + Tool selectedTool = selectedNode.getToolManager().getSelectedTool(); + if (selectedTool instanceof ListWSDLServicesTool) + return getWSDLFromURL(); + else if (selectedTool instanceof ListUDDIServicesTool) + return getWSDLFromUDDIRegistry(); + else + return false; + } + + public final String getStatusContentVar() + { + return controller_.getWSILPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getWSILPerspective().getStatusContentPage(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ImportWSILToFileSystemAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ImportWSILToFileSystemAction.java new file mode 100644 index 000000000..14ed0c31b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ImportWSILToFileSystemAction.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement; + +import org.apache.wsil.WSILDocument; +import java.io.OutputStream; + +public class ImportWSILToFileSystemAction extends ImportToFileSystemAction { + private WSILDocument wsilDoc_; + private WsilElement wsilElement_; + private NodeManager nodeManager_; + + public ImportWSILToFileSystemAction(Controller controller) { + super(controller); + nodeManager_ = controller.getWSILPerspective().getNodeManager(); + } + + public static final String getActionLink(int nodeId,int toolId,int viewId,int viewToolId) + { + return ImportToFileSystemAction.getActionLink(nodeId,toolId,viewId,viewToolId,"wsil/actions/ImportWSILToFileSystemActionJSP.jsp"); + } + + public boolean write(OutputStream os) { + if (wsilDoc_ != null) { + return writeWSILDocument(os, wsilDoc_); + } + else { + return false; + } + } + + public String getDefaultFileName() { + String wsilFileName = wsilElement_.getWsilUrl(); + return wsilFileName.substring(wsilFileName.lastIndexOf('/') + 1, wsilFileName.length()); + } + + public boolean run() { + int nodeID = Integer.parseInt((String)propertyTable_.get(ActionInputs.NODEID)); + + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + if (selectedElement instanceof WsilElement) { + wsilElement_ = (WsilElement)selectedElement; + wsilDoc_ = ((WsilElement)selectedElement).getWSILDocument(); + return true; + } + else { + return false; + } + } + + public final String getStatusContentVar() + { + return controller_.getWSILPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getWSILPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/MultipleLinkAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/MultipleLinkAction.java new file mode 100644 index 000000000..b2b89c441 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/MultipleLinkAction.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LinkAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; + +import javax.servlet.http.*; + +public abstract class MultipleLinkAction extends LinkAction +{ + public MultipleLinkAction(Controller controller) + { + super(controller); + } + + protected boolean processLinkParameters(HttpServletRequest request) + { + String isMultipleLinkAction = request.getParameter(WsilActionInputs.MULTIPLE_LINK_ACTION); + if (isMultipleLinkAction != null) + { + propertyTable_.put(WsilActionInputs.MULTIPLE_LINK_ACTION, isMultipleLinkAction); + return processMultipleLinkActionParameters(request); + } + else + { + propertyTable_.remove(WsilActionInputs.MULTIPLE_LINK_ACTION); + String nodeIDString = request.getParameter(ActionInputs.NODEID); + String toolIDString = request.getParameter(ActionInputs.TOOLID); + String viewIDString = request.getParameter(ActionInputs.VIEWID); + String viewToolIDString = request.getParameter(ActionInputs.VIEWTOOLID); + if (nodeIDString != null) + propertyTable_.put(ActionInputs.NODEID, nodeIDString); + if (toolIDString != null) + propertyTable_.put(ActionInputs.TOOLID, toolIDString); + if (viewIDString != null) + propertyTable_.put(ActionInputs.VIEWID, viewIDString); + if (viewToolIDString != null) + propertyTable_.put(ActionInputs.VIEWTOOLID, viewToolIDString); + return true; + } + } + + protected boolean processMultipleLinkActionParameters(HttpServletRequest request) + { + String nodeID = request.getParameter(ActionInputs.NODEID); + String[] viewIDs = request.getParameterValues(ActionInputs.VIEWID); + propertyTable_.put(ActionInputs.NODEID, nodeID); + propertyTable_.put(ActionInputs.VIEWID, viewIDs); + if (viewIDs.length == 0) + return false; + else + return true; + } + + protected boolean isMultipleLinkAction() + { + return propertyTable_.containsKey(WsilActionInputs.MULTIPLE_LINK_ACTION); + } + + protected String[] getViewIds() + { + Object object = propertyTable_.get(ActionInputs.VIEWID); + if (object == null) + return new String[0]; + else if (object.getClass().isArray()) + return (String[])object; + else + return new String[] {(String)object}; + } + + public boolean run() + { + return (isMultipleLinkAction()) ? executeMultipleLinkAction() : executeSingleLinkAction(); + } + + protected boolean executeMultipleLinkAction() + { + boolean result = false; + String[] viewIds = getViewIds(); + if (viewIds != null && viewIds.length > 0) + { + for (int i = 0; i < viewIds.length; i++) + { + propertyTable_.put(ActionInputs.VIEWID, viewIds[i]); + if (executeSingleLinkAction()) + result = true; + } + } + propertyTable_.put(ActionInputs.VIEWID, viewIds); + return result; + } + + protected abstract boolean executeSingleLinkAction(); +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/NullAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/NullAction.java new file mode 100644 index 000000000..ce471544b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/NullAction.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.Action; + +import javax.servlet.http.*; + +public class NullAction extends Action +{ + public NullAction() + { + } + + public boolean populatePropertyTable(HttpServletRequest request) + { + return true; + } + + public boolean run() + { + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/OpenWSILAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/OpenWSILAction.java new file mode 100644 index 000000000..5ce265676 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/OpenWSILAction.java @@ -0,0 +1,180 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.FormAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataException; +import org.eclipse.wst.ws.internal.explorer.platform.util.MultipartFormDataParser; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt; +import org.eclipse.wst.ws.internal.parser.wsil.WebServiceEntity; +import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; + +import org.apache.wsil.WSILDocument; + +import java.util.Enumeration; +import java.util.List; +import java.util.Iterator; + +public class OpenWSILAction extends FormAction +{ + + public OpenWSILAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String wsilURL = parser.getParameter(WsilActionInputs.WSIL_URL); + String inspectionType = parser.getParameter(WsilActionInputs.WSIL_INSPECTION_TYPE); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + MessageQueue messageQueue = wsilPerspective.getMessageQueue(); + FormTool formTool = getSelectedFormTool(); + propertyTable_.put(WsilActionInputs.WSIL_URL, wsilURL); + if (inspectionType != null && inspectionType.length() > 0) + propertyTable_.put(WsilActionInputs.WSIL_INSPECTION_TYPE, inspectionType); + formTool.updatePropertyTable(propertyTable_); + return true; + } + + public FormTool getSelectedFormTool() + { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + return (FormTool)wsilPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public boolean run() + { + String wsilURL = (String)propertyTable_.get(WsilActionInputs.WSIL_URL); + int inspectionType = Integer.parseInt((String)propertyTable_.get(WsilActionInputs.WSIL_INSPECTION_TYPE)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + MessageQueue msgQueue = wsilPerspective.getMessageQueue(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node rootNode = nodeManager.getRootNode(); + TreeElement root = rootNode.getTreeElement(); + WsilElement wsilElement = getOpenedWSIL(root, wsilURL); + if (wsilElement == null) + { + WebServicesParserExt parser = new WebServicesParserExt(wsilURL); + try + { + parser.parse(WebServicesParser.PARSE_NONE); + WebServiceEntity wsEntity = parser.getWebServiceEntityByURI(wsilURL); + int type = wsEntity.getType(); + if (type == WebServiceEntity.TYPE_HTML) + return openHTML(wsEntity.getChildren(), inspectionType); + else if (type == WebServiceEntity.TYPE_WSIL) + return openWSIL(wsilURL, parser.getWSILDocument(wsilURL), inspectionType); + else + msgQueue.addMessage(wsilPerspective.getMessage("MSG_ERROR_INVALID_WSIL_URL", wsilURL)); + } + catch (Throwable t) + { + msgQueue.addMessage(t.getMessage()); + } + return false; + } + else + { + preselectWSILNode(nodeManager, rootNode.getChildNode(wsilElement).getNodeId(), inspectionType); + msgQueue.addMessage(wsilPerspective.getMessage("MSG_ERROR_WSIL_ALREADY_OPENED", wsilURL)); + return true; + } + } + + private boolean openHTML(List wsils, int inspectionType) + { + int nodeId = -1; + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + MessageQueue msgQueue = wsilPerspective.getMessageQueue(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node rootNode = nodeManager.getRootNode(); + TreeElement root = rootNode.getTreeElement(); + for (Iterator it = wsils.iterator(); it.hasNext();) + { + WebServiceEntity wsilEntity = (WebServiceEntity)it.next(); + String wsilURL = wsilEntity.getURI(); + WsilElement wsilElement = getOpenedWSIL(root, wsilURL); + if (wsilElement == null) + { + try + { + WSILDocument wsilDoc = WSILDocument.newInstance(); + wsilDoc.read(wsilURL); + wsilElement = new WsilElement(wsilURL, root.getModel(), wsilDoc, wsilURL); + root.connect(wsilElement, WsilModelConstants.REL_WSIL, ModelConstants.REL_OWNER); + nodeId = rootNode.getChildNode(wsilElement).getNodeId(); + msgQueue.addMessage(wsilPerspective.getMessage("MSG_INFO_OPEN_WSIL_SUCCESSFUL", wsilURL)); + } + catch (Throwable t) + { + msgQueue.addMessage(t.getMessage()); + } + } + else + { + msgQueue.addMessage(wsilPerspective.getMessage("MSG_ERROR_WSIL_ALREADY_OPENED", wsilURL)); + nodeId = rootNode.getChildNode(wsilElement).getNodeId(); + } + } + if (nodeId != -1) + { + preselectWSILNode(nodeManager, nodeId, inspectionType); + return true; + } + else + return false; + } + + private boolean openWSIL(String wsilURL, WSILDocument wsilDoc, int inspectionType) + { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + MessageQueue msgQueue = wsilPerspective.getMessageQueue(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node rootNode = nodeManager.getRootNode(); + TreeElement root = rootNode.getTreeElement(); + WsilElement wsilElement = new WsilElement(wsilURL, root.getModel(), wsilDoc, wsilURL); + root.connect(wsilElement, WsilModelConstants.REL_WSIL, ModelConstants.REL_OWNER); + int nodeId = rootNode.getChildNode(wsilElement).getNodeId(); + msgQueue.addMessage(wsilPerspective.getMessage("MSG_INFO_OPEN_WSIL_SUCCESSFUL", wsilURL)); + preselectWSILNode(nodeManager, nodeId, inspectionType); + return true; + } + + private void preselectWSILNode(NodeManager nodeManager, int nodeId, int inspectionType) + { + nodeManager.setSelectedNodeId(nodeId); + Node selectedNode = nodeManager.getNode(nodeId); + selectedNode.setViewId(ActionInputs.VIEWTOOLID_DEFAULT); + ToolManager toolManager = selectedNode.getToolManager(); + toolManager.setSelectedToolId(inspectionType); + addToHistory(ActionInputs.PERSPECTIVE_WSIL, SelectWSILToolAction.getActionLink(nodeId, inspectionType, ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT, true)); + } + + private WsilElement getOpenedWSIL(TreeElement root, String wsilURL) + { + Enumeration e = root.getElements(WsilModelConstants.REL_WSIL); + while (e.hasMoreElements()) + { + WsilElement wsilElement = (WsilElement)e.nextElement(); + if (wsilElement.getWsilUrl().equals(wsilURL)) + return wsilElement; + } + return null; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/OpenWSILLinkAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/OpenWSILLinkAction.java new file mode 100644 index 000000000..4c9fe13a1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/OpenWSILLinkAction.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class OpenWSILLinkAction extends MultipleLinkAction +{ + public OpenWSILLinkAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/OpenWSILLinkActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "wsil/actions/OpenWSILLinkActionJSP.jsp"; + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_WSIL_LINKS, ActionInputs.VIEWID, WSILViewSelectionTransformer.WSIL_LINK); + return transformers; + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node selectedNode = nodeManager.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + if (!(selectedElement instanceof WsilElement)) + return false; + ListElement le = ((WsilElement) selectedElement).getAllWSILLinks().getElementWithViewId(viewID); + WsilWsilLinkElement link = (WsilWsilLinkElement) le.getObject(); + String wsilURL = link.getWSILLinkLocation(); + // populate and run the OpenWSILAction + OpenWSILAction action = new OpenWSILAction(controller_); + Hashtable table = action.getPropertyTable(); + table.put(WsilActionInputs.WSIL_URL, wsilURL); + table.put(WsilActionInputs.WSIL_INSPECTION_TYPE, String.valueOf(WsilActionInputs.WSIL_DETAILS)); + return action.run(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshAction.java new file mode 100644 index 000000000..216ee1705 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshAction.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.Action; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +import javax.servlet.http.*; + +public abstract class RefreshAction extends MultipleLinkAction +{ + protected NodeManager nodeManager_; + + public RefreshAction(Controller controller) + { + super(controller); + nodeManager_ = controller.getWSILPerspective().getNodeManager(); + } + + public static Action newAction(HttpServletRequest request, Controller controller) + { + NodeManager nodeManager = controller.getWSILPerspective().getNodeManager(); + String nodeIDString = request.getParameter(ActionInputs.NODEID); + String viewIDString = request.getParameter(ActionInputs.VIEWID); + int nodeID; + try + { + nodeID = Integer.parseInt(nodeIDString); + } + catch (NumberFormatException nfe) + { + nodeID = nodeManager.getSelectedNodeId(); + } + Node selectedNode = controller.getWSILPerspective().getNodeManager().getNode(nodeID); + if (selectedNode == null || !(selectedNode instanceof WsilNode)) + return new NullAction(); + else + { + Tool selectedTool = selectedNode.getToolManager().getSelectedTool(); + RefreshAction action; + if (viewIDString == null) + action = new RefreshWSILAction(controller); + else if (selectedTool instanceof ListUDDIServicesTool) + action = new RefreshUDDIServiceAction(controller); + else if (selectedTool instanceof ListUDDIBusinessTool) + action = new RefreshUDDIBusinessAction(controller); + else + return new NullAction(); + action.getPropertyTable().put(ActionInputs.NODEID, String.valueOf(nodeID)); + return action; + } + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/RefreshActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "wsil/actions/RefreshActionJSP.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshUDDIBusinessAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshUDDIBusinessAction.java new file mode 100644 index 000000000..2596cc824 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshUDDIBusinessAction.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.RefreshAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Vector; +import java.util.Iterator; + +public class RefreshUDDIBusinessAction extends RefreshAction +{ + public RefreshUDDIBusinessAction(Controller controller) + { + super(controller); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_UDDI_LINKS, ActionInputs.VIEWID, WSILViewSelectionTransformer.UDDI_BUSINESS); + return transformers; + } + + public boolean run() + { + return executeSingleLinkAction(); + } + + protected boolean executeMultipleLinkAction() + { + return executeSingleLinkAction(); + } + + public boolean executeSingleLinkAction() + { + boolean result = true; + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + MessageQueue messageQueue = wsilPerspective.getMessageQueue(); + if (selectedElement instanceof WsilElement) + { + WsilElement wsilElement = (WsilElement) selectedElement; + ListManager lm = wsilElement.getAllUDDILinks(); + Vector uddiBusinessElements = new Vector(); + String[] viewIDs = getViewIds(); + for (int i = 0; i < viewIDs.length; i++) + { + int viewID = Integer.parseInt(viewIDs[i]); + WsilUddiBusinessElement uddiBusinessElement = (WsilUddiBusinessElement) lm.getElementWithViewId(viewID).getObject(); + uddiBusinessElements.add(uddiBusinessElement); + } + wsilElement.refreshServiceProvidersFromRegistry(uddiBusinessElements); + for (Iterator it = uddiBusinessElements.iterator(); it.hasNext();) + { + WsilUddiBusinessElement uddiBusinessElement = (WsilUddiBusinessElement) it.next(); + String name = uddiBusinessElement.getName(); + if (name == null || name.length() <= 0) + name = uddiBusinessElement.getUDDILinkBusinessKey(); + if (uddiBusinessElement.getServiceProvider() != null) + messageQueue.addMessage(wsilPerspective.getMessage("MSG_INFO_REFRESH_SUCCESSFUL", name)); + else + { + messageQueue.addMessage(wsilPerspective.getMessage("MSG_ERROR_BUSINESS_NOT_FOUND", name)); + result = false; + } + } + } + else + result = false; + return result; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshUDDIServiceAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshUDDIServiceAction.java new file mode 100644 index 000000000..587b8e57b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshUDDIServiceAction.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.RefreshAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Vector; +import java.util.Iterator; + +public class RefreshUDDIServiceAction extends RefreshAction +{ + public RefreshUDDIServiceAction(Controller controller) + { + super(controller); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_UDDI_SERVICES, ActionInputs.VIEWID, WSILViewSelectionTransformer.UDDI_SERVICE); + return transformers; + } + + public boolean run() + { + return executeSingleLinkAction(); + } + + protected boolean executeMultipleLinkAction() + { + return executeSingleLinkAction(); + } + + public boolean executeSingleLinkAction() + { + boolean result = true; + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + MessageQueue messageQueue = wsilPerspective.getMessageQueue(); + if (selectedElement instanceof WsilElement) + { + WsilElement wsilElement = (WsilElement) selectedElement; + ListManager lm = wsilElement.getAllUDDIServices(); + Vector uddiServiceElements = new Vector(); + String[] viewIDs = getViewIds(); + for (int i = 0; i < viewIDs.length; i++) + { + int viewID = Integer.parseInt(viewIDs[i]); + WsilUddiServiceElement uddiServiceElement = (WsilUddiServiceElement) lm.getElementWithViewId(viewID).getObject(); + uddiServiceElements.add(uddiServiceElement); + } + wsilElement.refreshServiceDefinitionsFromRegistry(uddiServiceElements); + for (Iterator it = uddiServiceElements.iterator(); it.hasNext();) + { + WsilUddiServiceElement uddiServiceElement = (WsilUddiServiceElement) it.next(); + String name = uddiServiceElement.getName(); + if (name == null || name.length() <= 0) + name = uddiServiceElement.getUDDIServiceKey(); + if (uddiServiceElement.getServiceDefinition() != null) + messageQueue.addMessage(wsilPerspective.getMessage("MSG_INFO_REFRESH_SUCCESSFUL", name)); + else + { + messageQueue.addMessage(wsilPerspective.getMessage("MSG_ERROR_SERVICE_NOT_FOUND", name)); + result = false; + } + } + } + else + result = false; + return result; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshWSILAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshWSILAction.java new file mode 100644 index 000000000..1b3c6340b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/RefreshWSILAction.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.RefreshAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; + +public class RefreshWSILAction extends RefreshAction +{ + public RefreshWSILAction(Controller controller) + { + super(controller); + } + + public boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + Node selectedNode = nodeManager_.getNode(nodeID); + TreeElement selectedElement = selectedNode.getTreeElement(); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + if (selectedElement instanceof WsilElement) + { + String wsilURL = ((WsilElement) selectedElement).getWsilUrl(); + if (((WsilElement) selectedElement).refresh()) + { + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_REFRESH_SUCCESSFUL", wsilURL)); + return true; + } + else + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_WSIL_NOT_FOUND", wsilURL)); + } + return false; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ResizeWSILFramesAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ResizeWSILFramesAction.java new file mode 100644 index 000000000..a7b438755 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/ResizeWSILFramesAction.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +public class ResizeWSILFramesAction extends ResizeFramesAction +{ + public ResizeWSILFramesAction(Controller controller) + { + super(controller); + } + + protected boolean processOthers(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(WsilActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(WsilActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(WsilActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(WsilActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + // Save the current frameset sizes. + String frameName = (String)propertyTable_.get(ActionInputs.FRAME_NAME); + String perspectiveContentFramesetCols = (String)propertyTable_.get(WsilActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(WsilActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + + // Set the new frameset sizes. + boolean saveFrameSettings = false; + if (frameName.equals(WsilFrameNames.WSIL_NAVIGATOR_CONTAINER)) + { + wsilPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + wsilPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + if (perspectiveContentFramesetCols.startsWith("100%")) + { + // Restore. + wsilPerspective.setPerspectiveContentFramesetCols(wsilPerspective.getSavedPerspectiveContentFramesetCols()); + } + else + { + // Maximize. + wsilPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsilPerspective.setPerspectiveContentFramesetCols("100%,0%"); + } + } + else if (frameName.equals(WsilFrameNames.WSIL_PROPERTIES_CONTAINER)) + { + if (actionsContainerFramesetRows.startsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + wsilPerspective.setPerspectiveContentFramesetCols(wsilPerspective.getSavedPerspectiveContentFramesetCols()); + wsilPerspective.setActionsContainerFramesetRows(wsilPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + wsilPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsilPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsilPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + wsilPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsilPerspective.setActionsContainerFramesetRows("100%,0%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + wsilPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsilPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + else if (frameName.equals(WsilFrameNames.WSIL_STATUS_CONTAINER)) + { + if (actionsContainerFramesetRows.endsWith("100%")) + { + if (perspectiveContentFramesetCols.endsWith("100%")) + { + // Restore. + wsilPerspective.setPerspectiveContentFramesetCols(wsilPerspective.getSavedPerspectiveContentFramesetCols()); + wsilPerspective.setActionsContainerFramesetRows(wsilPerspective.getSavedActionsContainerFramesetRows()); + } + else + { + // Maximize. + wsilPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsilPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsilPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + else + { + // Maximize. + wsilPerspective.setSavedActionsContainerFramesetRows(actionsContainerFramesetRows); + wsilPerspective.setActionsContainerFramesetRows("0%,100%"); + if (!perspectiveContentFramesetCols.endsWith("100%")) + { + wsilPerspective.setSavedPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + wsilPerspective.setPerspectiveContentFramesetCols("0%,100%"); + } + } + } + return true; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SelectWSILNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SelectWSILNodeAction.java new file mode 100644 index 000000000..f064d57d1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SelectWSILNodeAction.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.SelectNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class SelectWSILNodeAction extends SelectNodeAction +{ + public SelectWSILNodeAction(Controller controller) + { + super(controller, controller.getWSILPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeID, boolean keepHistory) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/SelectWSILNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + if (keepHistory) { + actionLink.append('&'); + actionLink.append(ActionInputs.ISHISTORY); + actionLink.append("=1"); + } + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + Node selectedNode = getSelectedNode(); + Tool selectedTool = selectedNode.getToolManager().getSelectedTool(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedTool.getToolId(), selectedNode.getViewId(), selectedNode.getViewToolId(), true); + else + return getActionLink(selectedNode.getNodeId(), true); + } + + public final String getTreeContentVar() { + return "wsilNavigatorContent"; + } + + public final String getTreeContentPage() { + return "wsil/wsil_navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() { + return "wsilPropertiesContainer"; + } + + public final String getPropertiesContainerPage() { + return "wsil/wsil_properties_container.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSIL; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SelectWSILToolAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SelectWSILToolAction.java new file mode 100644 index 000000000..dd54b1ee0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SelectWSILToolAction.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.SelectNodeToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +public class SelectWSILToolAction extends SelectNodeToolAction +{ + public SelectWSILToolAction(Controller controller) + { + super(controller, controller.getWSILPerspective().getNodeManager()); + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length + 1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length - 1] = new WSILViewSelectionTransformer(controller_); + return transformers; + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID, boolean keepHistory) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/SelectWSILToolActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + if (viewID != ActionInputs.VIEWID_DEFAULT) + { + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + } + if (keepHistory) + { + actionLink.append('&'); + actionLink.append(ActionInputs.ISHISTORY); + actionLink.append("=1"); + } + return actionLink.toString(); + } + + protected String getActionLinkForHistory() + { + boolean keepHistory = false; + Node selectedNode = getSelectedNode(); + Tool selectedTool = getSelectedTool(); + int toolType = getSelectedTool().getToolType(); + if (toolType == ToolTypes.FORM) + keepHistory = true; + else if (toolType == ToolTypes.VIEW) + { + int viewID = selectedNode.getViewId(); + if (viewID == ActionInputs.VIEWID_DEFAULT) + keepHistory = true; + else + { + if (((ViewTool) selectedTool).getToolManager(viewID).getTool(selectedNode.getViewToolId()).getToolType() != ToolTypes.ACTION) + keepHistory = true; + } + } + if (keepHistory) + { + return getActionLink(selectedNode.getNodeId(), selectedTool.getToolId(), selectedNode.getViewId(), selectedNode.getViewToolId(), true); + } + else + return null; + } + + public final String getTreeContentVar() + { + return "wsilNavigatorContent"; + } + + public final String getTreeContentPage() + { + return "wsil/wsil_navigator_content.jsp"; + } + + public final String getPropertiesContainerVar() + { + return "wsilPropertiesContainer"; + } + + public final String getPropertiesContainerPage() + { + return "wsil/wsil_properties_container.jsp"; + } + + public final String getPropertiesContentVar() + { + return "wsilPropertiesContent"; + } + + public final String getPropertiesContentPage() + { + return "wsil/wsil_properties_content.jsp"; + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSIL; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SwitchPerspectiveFromWSILAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SwitchPerspectiveFromWSILAction.java new file mode 100644 index 000000000..15cfc9e6d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/SwitchPerspectiveFromWSILAction.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +public final class SwitchPerspectiveFromWSILAction extends ShowPerspectiveAction +{ + public SwitchPerspectiveFromWSILAction(Controller controller) + { + super(controller); + } + + protected boolean processParsedResults(MultipartFormDataParser parser) throws MultipartFormDataException + { + String perspectiveContentFramesetCols = parser.getParameter(WsilActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = parser.getParameter(WsilActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + if (perspectiveContentFramesetCols != null && actionsContainerFramesetRows != null) + { + propertyTable_.put(WsilActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT,perspectiveContentFramesetCols); + propertyTable_.put(WsilActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER,actionsContainerFramesetRows); + return true; + } + return false; + } + + public final boolean run() + { + String perspectiveContentFramesetCols = (String)propertyTable_.get(WsilActionInputs.FRAMESET_COLS_PERSPECTIVE_CONTENT); + String actionsContainerFramesetRows = (String)propertyTable_.get(WsilActionInputs.FRAMESET_ROWS_ACTIONS_CONTAINER); + + // Save the frameset sizes iff no frame is maximized. + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + if (!perspectiveContentFramesetCols.startsWith("100%") && !perspectiveContentFramesetCols.endsWith("100%")) + wsilPerspective.setPerspectiveContentFramesetCols(perspectiveContentFramesetCols); + + if (!actionsContainerFramesetRows.startsWith("100%") && !actionsContainerFramesetRows.endsWith("100%")) + wsilPerspective.setActionsContainerFramesetRows(actionsContainerFramesetRows); + + return super.run(); + } + + public static final String getFormActionLink(int targetPerspectiveId,boolean forHistory) + { + StringBuffer formLink = new StringBuffer("wsil/actions/SwitchPerspectiveFromWSILActionJSP.jsp?"); + formLink.append(ActionInputs.PERSPECTIVE).append('=').append(targetPerspectiveId); + if (forHistory) + formLink.append('&').append(ActionInputs.ISHISTORY).append("=1"); + return formLink.toString(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WSILImportWSILToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WSILImportWSILToWorkbenchAction.java new file mode 100644 index 000000000..537435b38 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WSILImportWSILToWorkbenchAction.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToWorkbenchAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; + +import java.util.Hashtable; + +public class WSILImportWSILToWorkbenchAction extends ImportToWorkbenchAction +{ + public WSILImportWSILToWorkbenchAction(Controller controller) + { + super(controller); + } + + public FormTool getSelectedFormTool() + { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + return (FormTool)wsilPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public ImportToFileSystemAction newImportToFileSystemAction() + { + ImportWSILToFileSystemAction action = new ImportWSILToFileSystemAction(controller_); + Hashtable table = action.getPropertyTable(); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + table.put(ActionInputs.NODEID, String.valueOf(selectedNode.getNodeId())); + return action; + } + + public final String getStatusContentVar() + { + return controller_.getWSILPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getWSILPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilAddToWSDLPerspectiveAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilAddToWSDLPerspectiveAction.java new file mode 100644 index 000000000..a08386e36 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilAddToWSDLPerspectiveAction.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ITransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions.OpenWSDLAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.WsilModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilWsdlServiceElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer.WSILViewSelectionTransformer; + +import java.util.Hashtable; + +public class WsilAddToWSDLPerspectiveAction extends MultipleLinkAction +{ + public WsilAddToWSDLPerspectiveAction(Controller controller) + { + super(controller); + } + + public static String getActionLink(int nodeID, int toolID, int viewID, int viewToolID) + { + StringBuffer actionLink = new StringBuffer("wsil/actions/WsilAddToWSDLPerspectiveActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeID); + actionLink.append('&'); + actionLink.append(ActionInputs.TOOLID); + actionLink.append('='); + actionLink.append(toolID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWID); + actionLink.append('='); + actionLink.append(viewID); + actionLink.append('&'); + actionLink.append(ActionInputs.VIEWTOOLID); + actionLink.append('='); + actionLink.append(viewToolID); + return actionLink.toString(); + } + + public static String getBaseActionLink() + { + return "wsil/actions/WsilAddToWSDLPerspectiveActionJSP.jsp"; + } + + public ITransformer[] getTransformers() + { + ITransformer[] parentTransformers = super.getTransformers(); + ITransformer[] transformers = new ITransformer[parentTransformers.length+1]; + System.arraycopy(parentTransformers, 0, transformers, 0, parentTransformers.length); + transformers[transformers.length-1] = new WSILViewSelectionTransformer(controller_, WsilModelConstants.LIST_MANAGER_WSDL_SERVICES, ActionInputs.VIEWID, WSILViewSelectionTransformer.WSDL_SERVICE); + return transformers; + } + + protected boolean executeSingleLinkAction() + { + int nodeID = Integer.parseInt((String) propertyTable_.get(ActionInputs.NODEID)); + int viewID = Integer.parseInt((String) propertyTable_.get(ActionInputs.VIEWID)); + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + Node selectedNode = wsilPerspective.getNodeManager().getNode(nodeID); + WsilElement wsilElement = (WsilElement) selectedNode.getTreeElement(); + WsilWsdlServiceElement wsilWsdlServiceElement = (WsilWsdlServiceElement) wsilElement.getAllWSDLServices().getElementWithViewId(viewID).getObject(); + String wsdlUrl = wsilWsdlServiceElement.getWSDLServiceURL(); + OpenWSDLAction openWSDLAction = new OpenWSDLAction(controller_); + Hashtable propertyTable = openWSDLAction.getPropertyTable(); + propertyTable.put(ActionInputs.QUERY_INPUT_WSDL_URL, wsdlUrl); + boolean actionResult = openWSDLAction.run(); + if (actionResult) + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_INFO_ADD_WSDL_TO_WSDL_PERSPECTIVE_SUCCESSFUL", wsdlUrl)); + else + wsilPerspective.getMessageQueue().addMessage(wsilPerspective.getMessage("MSG_ERROR_ADD_WSDL_TO_WSDL_PERSPECTIVE", wsdlUrl)); + return actionResult; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilImportWSDLToWorkbenchAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilImportWSDLToWorkbenchAction.java new file mode 100644 index 000000000..f5da54a97 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilImportWSDLToWorkbenchAction.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.actions.ImportToWorkbenchAction; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WSILPerspective; + +import java.util.Hashtable; + +public class WsilImportWSDLToWorkbenchAction extends ImportToWorkbenchAction { + public WsilImportWSDLToWorkbenchAction(Controller controller) { + super(controller); + } + + public FormTool getSelectedFormTool() { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + return (FormTool)wsilPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public ImportToFileSystemAction newImportToFileSystemAction() { + ImportWSDLToFileSystemAction action = new ImportWSDLToFileSystemAction(controller_); + Hashtable table = action.getPropertyTable(); + + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + + table.put(ActionInputs.NODEID, String.valueOf(selectedNode.getNodeId())); + table.put(ActionInputs.TOOLID, String.valueOf(selectedNode.getToolManager().getSelectedToolId())); + table.put(ActionInputs.VIEWID, String.valueOf(selectedNode.getViewId())); + + return action; + } + + public final String getStatusContentVar() + { + return controller_.getWSILPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getWSILPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilLaunchWebServiceWizardAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilLaunchWebServiceWizardAction.java new file mode 100644 index 000000000..5bd264a13 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilLaunchWebServiceWizardAction.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.LaunchWebServiceWizardAction; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.*; + +public class WsilLaunchWebServiceWizardAction extends LaunchWebServiceWizardAction { + public WsilLaunchWebServiceWizardAction(Controller controller) { + super(controller); + } + + public static LaunchWebServiceWizardAction newAction(Controller controller) { + return new WsilLaunchWebServiceWizardAction(controller); + } + + public FormTool getSelectedFormTool() { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + return (FormTool)wsilPerspective.getNodeManager().getSelectedNode().getToolManager().getSelectedTool(); + } + + public boolean run() { + WSILPerspective wsilPerspective = controller_.getWSILPerspective(); + NodeManager nodeManager = wsilPerspective.getNodeManager(); + Node selectedNode = nodeManager.getSelectedNode(); + TreeElement selectedElement = selectedNode.getTreeElement(); + Tool selectedTool = selectedNode.getToolManager().getSelectedTool(); + int viewID = selectedNode.getViewId(); + + ListElement le = null; + String url = null; + if (selectedTool instanceof ListWSDLServicesTool) { + le = ((WsilElement)selectedElement).getAllWSDLServices().getElementWithViewId(viewID); + url = ((WsilWsdlServiceElement)le.getObject()).getWSDLServiceURL(); + } + else if (selectedTool instanceof ListUDDIServicesTool) { + le = ((WsilElement)selectedElement).getAllUDDIServices().getElementWithViewId(viewID); + url = ((WsilUddiServiceElement)le.getObject()).getWsdlUrl(); + } + else + return false; + return launchWizard(url); + } + + public final String getStatusContentVar() + { + return controller_.getWSILPerspective().getStatusContentVar(); + } + + public final String getStatusContentPage() + { + return controller_.getWSILPerspective().getStatusContentPage(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilToggleNodeAction.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilToggleNodeAction.java new file mode 100644 index 000000000..d9b4f0942 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/actions/WsilToggleNodeAction.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.actions; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; + +public class WsilToggleNodeAction extends ToggleNodeAction { + public WsilToggleNodeAction(Controller controller) { + super(controller, controller.getFavoritesPerspective().getNodeManager()); + } + + public static String getActionLink(int nodeId, boolean open) { + StringBuffer actionLink = new StringBuffer("wsil/actions/WsilToggleNodeActionJSP.jsp?"); + actionLink.append(ActionInputs.NODEID); + actionLink.append('='); + actionLink.append(nodeId); + actionLink.append('&'); + actionLink.append(ActionInputs.OPEN); + actionLink.append('='); + if (open) + actionLink.append(ActionInputs.OPEN_NODE); + else + actionLink.append(ActionInputs.CLOSE_NODE); + return actionLink.toString(); + } + + public final String getActionLinkForHistory() { + ToolManager toolManager = toggledNode_.getToolManager(); + Tool selectedTool = toolManager.getSelectedTool(); + int nodeId = toggledNode_.getNodeId(); + int toolId = selectedTool.getToolId(); + int viewId = toggledNode_.getViewId(); + int viewToolId = toggledNode_.getViewToolId(); + if (selectedTool.getToolType() != ToolTypes.ACTION) + return SelectWSILToolAction.getActionLink(nodeId, toolId, viewId, viewToolId, true); + else + return SelectWSILNodeAction.getActionLink(nodeId, true); + } + + public final String getTreeContentVar() + { + return controller_.getWSILPerspective().getTreeContentVar(); + } + + public final String getTreeContentPage() + { + return controller_.getWSILPerspective().getTreeContentPage(); + } + + public final String getPropertiesContainerVar() + { + return controller_.getWSILPerspective().getPropertiesContainerVar(); + } + + public final String getPropertiesContainerPage() + { + return controller_.getWSILPerspective().getPropertiesContainerPage(); + } + + public final int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSIL; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilActionInputs.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilActionInputs.java new file mode 100644 index 000000000..aeb3c55b6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilActionInputs.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.constants; + +public class WsilActionInputs +{ + // open WSIL form + public final static String WSIL_URL = "wsilURL"; + public final static String WSIL_INSPECTION_TYPE = "wsilInspectionType"; + public final static int WSIL_DETAILS = 0; + public final static int WSDL_SERVICES = 1; + public final static int UDDI_SERVICES = 2; + public final static int UDDI_BUSINESSES = 3; + public final static int WSIL_LINKS = 4; + + // mass action + public final static String MULTIPLE_LINK_ACTION = "multipleLinkAction"; + + // resize WSIL frames action + public final static String FRAMESET_COLS_PERSPECTIVE_CONTENT = "framesetColsPerspectiveContent"; + public final static String FRAMESET_ROWS_ACTIONS_CONTAINER = "framesetRowsActionsContainer"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilFrameNames.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilFrameNames.java new file mode 100644 index 000000000..be2d25c31 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilFrameNames.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.constants; + +public class WsilFrameNames +{ + public final static String WSIL_NAVIGATOR_CONTAINER = "wsil_navigator_container"; + public final static String WSIL_NAVIGATOR_TOOLBAR = "wsil_navigator_toolbar"; + public final static String WSIL_NAVIGATOR_CONTENT = "wsil_navigator_content"; + public final static String WSIL_ACTIONS_CONTAINER = "wsil_actions_container"; + public final static String WSIL_PROPERTIES_CONTAINER = "wsil_properties_container"; + public final static String WSIL_PROPERTIES_TOOLBAR = "wsil_properties_toolbar"; + public final static String WSIL_PROPERTIES_CONTENT = "wsil_properties_content"; + public final static String WSIL_STATUS_CONTAINER = "wsil_status_container"; + public final static String WSIL_STATUS_TOOLBAR = "wsil_status_toolbar"; + public final static String WSIL_STATUS_CONTENT = "wsil_status_content"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilModelConstants.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilModelConstants.java new file mode 100644 index 000000000..5bb694b82 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/constants/WsilModelConstants.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.constants; + +public class WsilModelConstants +{ + // Relation + public final static String REL_WSIL = "relWSIL"; + + // List Managers for WsilElement + public final static String LIST_MANAGER_WSDL_SERVICES = "wsdlServices"; + public final static String LIST_MANAGER_UDDI_SERVICES = "uddiServices"; + public final static String LIST_MANAGER_UDDI_LINKS = "uddiLinks"; + public final static String LIST_MANAGER_WSIL_LINKS = "wsilLinks"; +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilCommonElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilCommonElement.java new file mode 100644 index 000000000..52d28de68 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilCommonElement.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.BasicElement; +import org.eclipse.wst.ws.internal.datamodel.Model; + +public class WsilCommonElement extends BasicElement +{ + private String baseWsilURL; + private String relativeURIBase; + + public WsilCommonElement(String name, Model model) + { + super(name, model); + } + + public String getBaseWsilURL() + { + return baseWsilURL; + } + + public void setBaseWsilURL(String baseWsilURL) + { + this.baseWsilURL = baseWsilURL; + } + + private final char FWD_SLASH = '/'; + private final char BWD_SLASH = '\\'; + private final char PROTOCOL_INDICATOR = ':'; + + public String makeAbsolute(String uri) + { + if (baseWsilURL != null && uri != null && uri.indexOf(PROTOCOL_INDICATOR) == -1) + { + if (relativeURIBase == null) + { + relativeURIBase = baseWsilURL.replace(BWD_SLASH, FWD_SLASH); + int index = relativeURIBase.lastIndexOf(FWD_SLASH); + relativeURIBase = baseWsilURL.substring(0, index + 1); + } + StringBuffer sb = new StringBuffer(relativeURIBase); + sb.append(uri); + return sb.toString(); + } + return uri; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilElement.java new file mode 100644 index 000000000..ccd109261 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilElement.java @@ -0,0 +1,453 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import java.util.Vector; +import java.util.Iterator; +import java.util.HashMap; +import java.util.Properties; +import java.net.URL; +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.Validator; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.*; +import org.apache.wsil.*; +import org.uddi4j.client.UDDIProxy; +import org.uddi4j.datatype.business.BusinessEntity; +import org.uddi4j.datatype.service.BusinessService; + +/** + * The data model element that represents a WSIL document + */ +public class WsilElement extends TreeElement +{ + private WSILDocument wsilDoc_; + private String thisWsilUrl_; + /** ****************** Namespace ********** */ + private static final String NAMESPACE_WSDL = "http://schemas.xmlsoap.org/wsdl/"; + private static final String NAMESPACE_UDDI_V1 = "urn:uddi-org:api"; + private static final String NAMESPACE_UDDI_V2 = "urn:uddi-org:api_v2"; + private static final String NAMESPACE_UDDI_BINDING = "http://schemas.xmlsoap.org/ws/2001/10/inspection/uddi/"; + private static final String NAMESPACE_WSIL_INSPECTION = "http://schemas.xmlsoap.org/ws/2001/10/inspection/"; + /** ****************** Rels **************** */ + // Relation for a WSIL doucment and its link nodes + public static final String REL_WSIL_LINK = "wsil link nodes"; + + public WsilElement(String name, Model model, WSILDocument wsilDocument, String wsilURL) + { + super(name, model); + wsilDoc_ = wsilDocument; + thisWsilUrl_ = wsilURL; + ListManager wsdlServices_ = null; + ListManager uddiServices_ = null; + ListManager wsilLinks_ = null; + ListManager uddiLinks_ = null; + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSDL_SERVICES, wsdlServices_); + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_SERVICES, uddiServices_); + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_LINKS, wsilLinks_); + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSIL_LINKS, uddiLinks_); + } + + /* + * Refresh the WSIL document + */ + public boolean refresh() + { + try + { + WSILDocument newWSILDoc = WSILDocument.newInstance(); + newWSILDoc.read(getWsilUrl()); + wsilDoc_ = newWSILDoc; + ListManager wsdlServices_ = null; + ListManager uddiServices_ = null; + ListManager wsilLinks_ = null; + ListManager uddiLinks_ = null; + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSDL_SERVICES, wsdlServices_); + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_SERVICES, uddiServices_); + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_LINKS, wsilLinks_); + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSIL_LINKS, uddiLinks_); + return true; + } + catch (Exception e) + { + return false; + } + } + + /* + * Returns the WSIL's URL + */ + public String getWsilUrl() + { + return thisWsilUrl_; + } + + /* + * Returns the WSIL document + */ + public WSILDocument getWSILDocument() + { + return wsilDoc_; + } + + /* + * Returns all abstract languages + */ + public Vector getWSILAbstractLangs() + { + Vector v = new Vector(); + Abstract[] abstracts = wsilDoc_.getInspection().getAbstracts(); + for (int i = 0; i < abstracts.length; i++) + { + v.add(abstracts[i].getLang()); + } + return v; + } + + /* + * Returns all abstracts + */ + public Vector getWSILAbstracts() + { + Vector v = new Vector(); + Abstract[] abstracts = wsilDoc_.getInspection().getAbstracts(); + for (int i = 0; i < abstracts.length; i++) + { + v.add(abstracts[i].getText()); + } + return v; + } + + public ListManager getAllWSDLServices() + { + ListManager wsdlServices_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSDL_SERVICES); + if (wsdlServices_ == null) + { + initAllWSDLServices(); + wsdlServices_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSDL_SERVICES); + } + return wsdlServices_; + } + + public ListManager getAllUDDIServices() + { + ListManager uddiServices_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_SERVICES); + if (uddiServices_ == null) + { + initAllUDDIServices(); + uddiServices_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_SERVICES); + } + return uddiServices_; + } + + private void initAllWSDLServices() + { + ListManager wsdlServices_ = new ListManager(); + Inspection inspection = wsilDoc_.getInspection(); + Service[] serviceList = inspection.getServices(); + for (int i = 0; i < serviceList.length; i++) + { + // skip any service without a wsdl namespace + // and invalid descriptions + Description[] descList = serviceList[i].getDescriptions(); + if (descList.length < 1) + continue; + String namespace = descList[0].getReferencedNamespace(); + if (namespace == null) + continue; + else if (namespace.equals(NAMESPACE_WSDL)) + { + WsilWsdlServiceElement wsdlServiceElement = new WsilWsdlServiceElement(namespace, getModel(), serviceList[i]); + wsdlServiceElement.setBaseWsilURL(getWsilUrl()); + if (wsdlServiceElement.validateWSDLService()) + { + wsdlServiceElement.setName(wsdlServiceElement.getWSDLServiceURL()); + wsdlServices_.add(new ListElement(wsdlServiceElement)); + } + } + } + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSDL_SERVICES, wsdlServices_); + } + + private void initAllUDDIServices() + { + ListManager uddiServices_ = new ListManager(); + Inspection inspection = wsilDoc_.getInspection(); + Service[] serviceList = inspection.getServices(); + Vector uddiServiceElements = new Vector(); + for (int i = 0; i < serviceList.length; i++) + { + // skip any service without a wsdl namespace + // and invalid descriptions + Description[] descList = serviceList[i].getDescriptions(); + if (descList.length < 1) + continue; + String namespace = descList[0].getReferencedNamespace(); + if (namespace == null) + continue; + else if ((namespace.equals(NAMESPACE_UDDI_V1) || namespace.equals(NAMESPACE_UDDI_V2))) + { + WsilUddiServiceElement uddiServiceElement = new WsilUddiServiceElement(namespace, getModel(), serviceList[i]); + uddiServiceElement.setBaseWsilURL(getWsilUrl()); + if (uddiServiceElement.validateUDDIService()) + { + uddiServiceElement.setName(uddiServiceElement.getName()); + uddiServiceElements.add(uddiServiceElement); + } + } + } + refreshServiceDefinitionsFromRegistry(uddiServiceElements); + for (Iterator it = uddiServiceElements.iterator(); it.hasNext();) + { + uddiServices_.add(new ListElement(it.next())); + } + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_SERVICES, uddiServices_); + } + + public void refreshServiceDefinitionsFromRegistry(Vector uddiServiceElements) + { + HashMap inquiryAPIToServices = new HashMap(); + for (int i = 0; i < uddiServiceElements.size(); i++) + { + WsilUddiServiceElement uddiServiceElement = (WsilUddiServiceElement) uddiServiceElements.get(i); + String inquiryAPI = uddiServiceElement.getUDDIServiceInquiryAPI(); + if (Validator.validateURL(inquiryAPI)) + { + Vector services = (Vector) inquiryAPIToServices.get(inquiryAPI); + if (services == null) + { + services = new Vector(); + inquiryAPIToServices.put(inquiryAPI, services); + } + services.add(uddiServiceElement); + } + else + uddiServiceElement.setServiceDefinition(null); + } + for (Iterator it = inquiryAPIToServices.keySet().iterator(); it.hasNext();) + { + String inquiryAPI = (String) it.next(); + Vector services = (Vector) inquiryAPIToServices.get(inquiryAPI); + UDDIProxy proxy; + try + { + Properties props = new Properties(); + props.put(ActionInputs.TRANSPORT_CLASS_NAME, ActionInputs.TRASPORT_CLASS); + proxy = new UDDIProxy(props); + proxy.setInquiryURL(new URL(inquiryAPI)); + } + catch (Throwable t) + { + for (int j = 0; j < services.size(); j++) + { + WsilUddiServiceElement uddiServiceElement = (WsilUddiServiceElement) services.get(j); + uddiServiceElement.setServiceDefinition(null); + } + continue; + } + Vector serviceKeys = new Vector(); + for (int j = 0; j < services.size(); j++) + { + serviceKeys.add(((WsilUddiServiceElement) services.get(j)).getUDDIServiceKey()); + } + Vector businessServices; + try + { + businessServices = proxy.get_serviceDetail(serviceKeys).getBusinessServiceVector(); + } + catch (Exception ex) + { + businessServices = new Vector(); + if (serviceKeys.size() > 1) + { + for (int k = 0; k < serviceKeys.size(); k++) + { + try + { + businessServices.add((BusinessService) proxy.get_serviceDetail((String) serviceKeys.get(k)).getBusinessServiceVector().get(0)); + } + catch (Exception exception) + { + businessServices.add(null); + } + } + } + else + businessServices.add(null); + } + for (int k = 0; k < services.size(); k++) + { + BusinessService bs = (BusinessService) businessServices.get(k); + WsilUddiServiceElement uddiServiceElement = (WsilUddiServiceElement) services.get(k); + uddiServiceElement.setServiceDefinition(bs); + } + } + } + + public ListManager getAllWSILLinks() + { + ListManager wsilLinks_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSIL_LINKS); + if (wsilLinks_ == null) + { + initAllWSILLinks(); + wsilLinks_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSIL_LINKS); + } + return wsilLinks_; + } + + public ListManager getAllUDDILinks() + { + ListManager uddiLinks_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_LINKS); + if (uddiLinks_ == null) + { + initAllUDDILinks(); + uddiLinks_ = (ListManager) getPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_LINKS); + } + return uddiLinks_; + } + + private void initAllUDDILinks() + { + ListManager uddiLinks_ = new ListManager(); + Inspection inspection = wsilDoc_.getInspection(); + Link[] linkList = inspection.getLinks(); + Vector uddiBusinessElements = new Vector(); + for (int i = 0; i < linkList.length; i++) + { + // process any links with UDDI namespace + String namespace = linkList[i].getReferencedNamespace(); + if (namespace == null) + continue; + else if ((namespace.equals(NAMESPACE_UDDI_V1) || namespace.equals(NAMESPACE_UDDI_V2))) + { + WsilUddiBusinessElement uddiBusinessElement = new WsilUddiBusinessElement(namespace, getModel(), linkList[i]); + uddiBusinessElement.setBaseWsilURL(getWsilUrl()); + if (uddiBusinessElement.validateUDDILink()) + { + uddiBusinessElement.setName(uddiBusinessElement.getName()); + uddiBusinessElements.add(uddiBusinessElement); + } + } + } + refreshServiceProvidersFromRegistry(uddiBusinessElements); + for (Iterator it = uddiBusinessElements.iterator(); it.hasNext();) + { + uddiLinks_.add(new ListElement(it.next())); + } + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_UDDI_LINKS, uddiLinks_); + } + + public void refreshServiceProvidersFromRegistry(Vector uddiBusinessElements) + { + HashMap inquiryAPIToBusinesses = new HashMap(); + for (int i = 0; i < uddiBusinessElements.size(); i++) + { + WsilUddiBusinessElement uddiBusinessElement = (WsilUddiBusinessElement) uddiBusinessElements.get(i); + String inquiryAPI = uddiBusinessElement.getUDDILinkInquiryAPI(); + if (Validator.validateURL(inquiryAPI)) + { + Vector businesses = (Vector) inquiryAPIToBusinesses.get(inquiryAPI); + if (businesses == null) + { + businesses = new Vector(); + inquiryAPIToBusinesses.put(inquiryAPI, businesses); + } + businesses.add(uddiBusinessElement); + } + else + uddiBusinessElement.setServiceProvider(null); + } + for (Iterator it = inquiryAPIToBusinesses.keySet().iterator(); it.hasNext();) + { + String inquiryAPI = (String) it.next(); + Vector businesses = (Vector) inquiryAPIToBusinesses.get(inquiryAPI); + UDDIProxy proxy; + try + { + Properties props = new Properties(); + props.put(ActionInputs.TRANSPORT_CLASS_NAME, ActionInputs.TRASPORT_CLASS); + proxy = new UDDIProxy(props); + proxy.setInquiryURL(new URL(inquiryAPI)); + } + catch (Exception e) + { + for (int j = 0; j < businesses.size(); j++) + { + WsilUddiBusinessElement uddiBusinessElement = (WsilUddiBusinessElement) businesses.get(j); + uddiBusinessElement.setServiceProvider(null); + } + continue; + } + Vector businessKeys = new Vector(); + for (int j = 0; j < businesses.size(); j++) + { + businessKeys.add(((WsilUddiBusinessElement) businesses.get(j)).getUDDILinkBusinessKey()); + } + Vector businessEntities; + try + { + businessEntities = proxy.get_businessDetail(businessKeys).getBusinessEntityVector(); + } + catch (Exception ex) + { + businessEntities = new Vector(); + if (businessKeys.size() > 1) + { + for (int k = 0; k < businessKeys.size(); k++) + { + try + { + businessEntities.add((BusinessEntity) proxy.get_businessDetail((String) businessKeys.get(k)).getBusinessEntityVector().get(0)); + } + catch (Exception exception) + { + businessEntities.add(null); + } + } + } + else + businessEntities.add(null); + } + for (int k = 0; k < businesses.size(); k++) + { + BusinessEntity be = (BusinessEntity) businessEntities.get(k); + WsilUddiBusinessElement uddiBusinessElement = (WsilUddiBusinessElement) businesses.get(k); + uddiBusinessElement.setServiceProvider(be); + } + } + } + + private void initAllWSILLinks() + { + ListManager wsilLinks_ = new ListManager(); + Inspection inspection = wsilDoc_.getInspection(); + Link[] linkList = inspection.getLinks(); + for (int i = 0; i < linkList.length; i++) + { + // process any links with UDDI namespace + String namespace = linkList[i].getReferencedNamespace(); + if (namespace == null) + continue; + else if (namespace.equals(NAMESPACE_WSIL_INSPECTION)) + { + WsilWsilLinkElement wsilLinkElement = new WsilWsilLinkElement(namespace, getModel(), linkList[i]); + wsilLinkElement.setBaseWsilURL(getWsilUrl()); + if (wsilLinkElement.validateWSILLink()) + { + wsilLinkElement.setName(wsilLinkElement.getWSILLinkLocation()); + wsilLinks_.add(new ListElement(wsilLinkElement)); + } + } + } + setPropertyAsObject(WsilModelConstants.LIST_MANAGER_WSIL_LINKS, wsilLinks_); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilLinkElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilLinkElement.java new file mode 100644 index 000000000..a8e35bd0a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilLinkElement.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.Model; + +import java.util.Vector; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL Link +*/ +public class WsilLinkElement extends WsilCommonElement +{ + protected Link link_; + + public WsilLinkElement(String name, Model model, Link link) + { + super(name, model); + link_ = link; + } + + public Vector getLinkAbstractLangs() + { + Vector v = new Vector(); + Abstract[] abstracts = link_.getAbstracts(); + for (int i = 0; i < abstracts.length; i++) + { + v.add(abstracts[i].getLang()); + } + return v; + } + + public Vector getLinkAbstracts() + { + Vector v = new Vector(); + Abstract[] abstracts = link_.getAbstracts(); + for (int i = 0; i < abstracts.length; i++) + { + v.add(abstracts[i].getText()); + } + return v; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilServiceElement.java new file mode 100644 index 000000000..035888c6f --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilServiceElement.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.Model; + +import java.util.Vector; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL Service +*/ +public class WsilServiceElement extends WsilCommonElement +{ + protected Service service_; + + public WsilServiceElement(String name, Model model, Service service) { + super(name, model); + service_ = service; + } + + public Vector getServiceNameLangs() { + Vector v = new Vector(); + ServiceName[] serviceNames = service_.getServiceNames(); + for (int i = 0; i < serviceNames.length; i++) { + v.add(serviceNames[i].getLang()); + } + return v; + } + + public Vector getServiceNames() { + Vector v = new Vector(); + ServiceName[] serviceNames = service_.getServiceNames(); + for (int i = 0; i < serviceNames.length; i++) { + v.add(serviceNames[i].getText()); + } + return v; + } + + public Vector getServiceAbstractLangs() { + Vector v = new Vector(); + Abstract[] abstracts = service_.getAbstracts(); + for (int i = 0; i < abstracts.length; i++) { + v.add(abstracts[i].getLang()); + } + return v; + } + + public Vector getServiceAbstracts() { + Vector v = new Vector(); + Abstract[] abstracts = service_.getAbstracts(); + for (int i = 0; i < abstracts.length; i++) { + v.add(abstracts[i].getText()); + } + return v; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilUddiBusinessElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilUddiBusinessElement.java new file mode 100644 index 000000000..d4630dff4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilUddiBusinessElement.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.util.Validator; + +import org.apache.wsil.*; +import org.apache.wsil.extension.*; +import org.apache.wsil.extension.uddi.*; + +import org.uddi4j.util.DiscoveryURL; +import org.uddi4j.datatype.business.BusinessEntity; + +/** +* The data model element that represents +* a UDDI service in a WSIL document +*/ +public class WsilUddiBusinessElement extends WsilLinkElement +{ + private BusinessEntity busEntity_; + + public WsilUddiBusinessElement(String name, Model model, Link link) { + super(name, model, link); + busEntity_ = null; + } + + public void setServiceProvider(BusinessEntity be) { + busEntity_ = be; + } + + public BusinessEntity getServiceProvider() { + return busEntity_; + } + + public String getName() { + return (busEntity_ == null) ? null : busEntity_.getDefaultNameString(); + } + + public String getDescription() { + return (busEntity_ == null) ? null : busEntity_.getDefaultDescriptionString(); + } + + public String getUDDILinkInquiryAPI() { + BusinessDescription bd = getValidUDDIBusinessDescription(); + return (bd == null) ? null : bd.getLocation(); + } + + public String getUDDILinkBusinessKey() { + BusinessDescription bd = getValidUDDIBusinessDescription(); + return (bd == null) ? null : bd.getBusinessKey().getText(); + } + + public String getUDDILinkDiscoveryURL() { + BusinessDescription bd = getValidUDDIBusinessDescription(); + if (bd == null) + return null; + else { + DiscoveryURL discoveryURL = bd.getDiscoveryURL(); + return (discoveryURL == null) ? null : discoveryURL.getText(); + } + } + + public boolean validateUDDILink() { + BusinessDescription bd = getValidUDDIBusinessDescription(); + return (bd != null); + } + + private BusinessDescription getValidUDDIBusinessDescription() { + ExtensionElement extElement = link_.getExtensionElement(); + // The extension element of a UDDI link + // must be a BusinessDescription element + if (!(extElement instanceof BusinessDescription)) + return null; + // A valid BusinessDescription must have an inquiry API + String inquiryAPI = ((BusinessDescription)extElement).getLocation(); + if (!Validator.validateURL(inquiryAPI)) + return null; + // A valid BusinessDescription must have a business key + String businessKey = ((BusinessDescription)extElement).getBusinessKey().getText(); + if (businessKey == null || businessKey.length() <= 0) + return null; + return (BusinessDescription)extElement; + } + + public String toString() { + return getName(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilUddiServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilUddiServiceElement.java new file mode 100644 index 000000000..900f76b26 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilUddiServiceElement.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.uddi.util.Uddi4jHelper; +import org.eclipse.wst.ws.internal.explorer.platform.util.Validator; + +import org.apache.wsil.*; +import org.apache.wsil.extension.*; +import org.apache.wsil.extension.uddi.*; + +import org.uddi4j.util.DiscoveryURL; +import org.uddi4j.datatype.service.BusinessService; + +/** +* The data model element that represents +* a UDDI service in a WSIL document +*/ +public class WsilUddiServiceElement extends WsilServiceElement +{ + private BusinessService busService_; + + public WsilUddiServiceElement(String name, Model model, Service service) { + super(name, model, service); + busService_ = null; + } + + public void setServiceDefinition(BusinessService busService) { + busService_ = busService; + } + + public BusinessService getServiceDefinition() { + return busService_; + } + + public String getName() { + return (busService_ == null) ? null : busService_.getDefaultNameString(); + } + + public String getDescription() { + return (busService_ == null) ? null : busService_.getDefaultDescriptionString(); + } + + public String getUDDIServiceInquiryAPI() { + ServiceDescription sd = getValidUDDIServiceDescription(); + return (sd == null) ? null : sd.getLocation(); + } + + public String getUDDIServiceKey() { + ServiceDescription sd = getValidUDDIServiceDescription(); + return (sd == null) ? null : sd.getServiceKey().getText(); + } + + public String getUDDIServiceDiscoveryURL() { + ServiceDescription sd = getValidUDDIServiceDescription(); + if (sd == null) + return null; + else { + DiscoveryURL discoveryURL = sd.getDiscoveryURL(); + return (discoveryURL == null) ? null : discoveryURL.getText(); + } + } + + private ServiceDescription getValidUDDIServiceDescription() { + Description[] descList = service_.getDescriptions(); + for (int i = 0; i < descList.length; i++) { + ExtensionElement extElement = descList[i].getExtensionElement(); + // The extension element of a UDDI service description + // must be a ServiceDescription element + if (!(extElement instanceof ServiceDescription)) + continue; + // A valid ServiceDescription must have an inquiry API + if (!Validator.validateURL(((ServiceDescription)extElement).getLocation())) + continue; + // A valid ServiceDescription must have a service key + String serviceKey = ((ServiceDescription)extElement).getServiceKey().getText(); + if (serviceKey == null || serviceKey.length() <= 0) + continue; + return (ServiceDescription)extElement; + } + return null; + } + + public boolean validateUDDIService() { + ServiceDescription sd = getValidUDDIServiceDescription(); + return (sd != null); + } + + public String getWsdlUrl() { + return (new Uddi4jHelper()).getWSDL(getServiceDefinition(), null); + } + + public String toString() { + return getName(); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilWsdlServiceElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilWsdlServiceElement.java new file mode 100644 index 000000000..5ed15e27e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilWsdlServiceElement.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import java.util.Vector; + +import org.eclipse.wst.ws.internal.datamodel.*; + +import org.apache.wsil.*; +import org.apache.wsil.extension.*; +import org.apache.wsil.extension.wsdl.*; + +/** +* The data model element that represents +* a WSDL service in a WSIL document +*/ +public class WsilWsdlServiceElement extends WsilServiceElement +{ + public WsilWsdlServiceElement(String name, Model model, Service service) { + super(name, model, service); + } + + public String getWSDLServiceURL() { + Description desc = getValidWSDLDescription(); + return (desc == null) ? null : makeAbsolute(desc.getLocation()); + } + + public Vector getWSDLBinding() { + Vector v = new Vector(); + Description[] descList = service_.getDescriptions(); + for (int i = 0; i < descList.length; i++) { + ExtensionElement extElement = descList[i].getExtensionElement(); + if (extElement != null && extElement instanceof Reference) { + ReferencedService refService = ((Reference)extElement).getReferencedService(); + if (refService != null) { + v.add(refService.getReferencedServiceName()); + } + ImplementedBinding[] implBindingList = ((Reference)extElement).getImplementedBindings(); + for (int j = 0; j < implBindingList.length; j++) { + v.add(implBindingList[j].getBindingName()); + } + } + } + return v; + } + + private Description getValidWSDLDescription() { + Description[] descList = service_.getDescriptions(); + for (int i = 0; i < descList.length; i++) { + // skip this description if the locatioin attribute is a malformed URL + String location = descList[i].getLocation(); + if (location == null || location.length() <= 0) + continue; + // skip this description if the extension element indicates + // that the description's location contains only the wsdl binding + ExtensionElement extElement = descList[i].getExtensionElement(); + if (extElement != null && extElement instanceof Reference) { + Boolean endpointPresent = ((Reference)extElement).getEndpointPresent(); + if (endpointPresent != null && endpointPresent.booleanValue() == false) + continue; + } + // a valid description is found + return descList[i]; + } + // no valid description is found for this service + return null; + } + + public boolean validateWSDLService() { + Description desc = getValidWSDLDescription(); + return (desc != null); + } + + public String toString() { + return getWSDLServiceURL(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilWsilLinkElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilWsilLinkElement.java new file mode 100644 index 000000000..da1e92fd9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/datamodel/WsilWsilLinkElement.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.apache.wsil.*; + +/** +* The data model element that represents +* a WSIL link in a WSIL document +*/ +public class WsilWsilLinkElement extends WsilLinkElement +{ + public WsilWsilLinkElement(String name, Model model, Link link) + { + super(name, model, link); + } + + public String getWSILLinkLocation() + { + return makeAbsolute(link_.getLocation()); + } + + public boolean validateWSILLink() + { + return (link_.getLocation() != null); + } + + public String toString() + { + return getWSILLinkLocation(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddBusinessToFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddBusinessToFavoritesTool.java new file mode 100644 index 000000000..f924206e6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddBusinessToFavoritesTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.AddToFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class AddBusinessToFavoritesTool extends ActionTool { + public AddBusinessToFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/favorites_enabled.gif", "images/favorites_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddToFavoritesAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddBusinessToUDDIPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddBusinessToUDDIPerspectiveTool.java new file mode 100644 index 000000000..d89451d1d --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddBusinessToUDDIPerspectiveTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.AddBusinessToUDDIPerspectiveAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class AddBusinessToUDDIPerspectiveTool extends ActionTool { + public AddBusinessToUDDIPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/add_to_UDDI_perspective_enabled.gif", "wsil/images/add_to_UDDI_perspective_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddBusinessToUDDIPerspectiveAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddServiceToFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddServiceToFavoritesTool.java new file mode 100644 index 000000000..b98c2c6e3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddServiceToFavoritesTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.AddToFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class AddServiceToFavoritesTool extends ActionTool { + public AddServiceToFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/favorites_enabled.gif", "images/favorites_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddToFavoritesAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddServiceToUDDIPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddServiceToUDDIPerspectiveTool.java new file mode 100644 index 000000000..c4a921ce8 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddServiceToUDDIPerspectiveTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.AddServiceToUDDIPerspectiveAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class AddServiceToUDDIPerspectiveTool extends ActionTool { + public AddServiceToUDDIPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/add_to_UDDI_perspective_enabled.gif", "wsil/images/add_to_UDDI_perspective_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddServiceToUDDIPerspectiveAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddWSDLServiceToFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddWSDLServiceToFavoritesTool.java new file mode 100644 index 000000000..5f0316a91 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddWSDLServiceToFavoritesTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.AddToFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class AddWSDLServiceToFavoritesTool extends ActionTool { + public AddWSDLServiceToFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/favorites_enabled.gif", "images/favorites_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddToFavoritesAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddWSILToFavoritesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddWSILToFavoritesTool.java new file mode 100644 index 000000000..da3cb45ce --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/AddWSILToFavoritesTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.AddToFavoritesAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class AddWSILToFavoritesTool extends ActionTool { + public AddWSILToFavoritesTool(ToolManager toolManager, String alt) { + super(toolManager, "images/favorites_enabled.gif", "images/favorites_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return AddToFavoritesAction.getActionLink(selectedNode.getNodeId(), toolId_, ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ClearWSILTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ClearWSILTool.java new file mode 100644 index 000000000..4acc5fdbc --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ClearWSILTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.ClearWSILAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class ClearWSILTool extends ActionTool { + public ClearWSILTool(ToolManager toolManager, String alt) { + super(toolManager, "images/clear_enabled.gif", "images/clear_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + return ClearWSILAction.getActionLink(toolManager_.getNode().getNodeId()); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ImportWSDLToFileSystemTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ImportWSDLToFileSystemTool.java new file mode 100644 index 000000000..b871050e3 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ImportWSDLToFileSystemTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToFileSystemTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.ImportWSDLToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class ImportWSDLToFileSystemTool extends ImportToFileSystemTool { + public ImportWSDLToFileSystemTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return ImportWSDLToFileSystemAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ImportWSILToFileSystemTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ImportWSILToFileSystemTool.java new file mode 100644 index 000000000..dd00c2820 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ImportWSILToFileSystemTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToFileSystemTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.ImportWSILToFileSystemAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class ImportWSILToFileSystemTool extends ImportToFileSystemTool { + public ImportWSILToFileSystemTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + return ImportWSILToFileSystemAction.getActionLink(toolManager_.getNode().getNodeId(), toolId_, ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListUDDIBusinessTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListUDDIBusinessTool.java new file mode 100644 index 000000000..1498669b0 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListUDDIBusinessTool.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ViewTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class ListUDDIBusinessTool extends ViewTool { + public ListUDDIBusinessTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/list_business_enabled.gif", "wsil/images/list_business_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + protected void addSetDefaultViewTool(ToolManager viewToolManager, int index) { + new WsilSetDefaultViewTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getMessage("ALT_BACK_TO_TOP")); + } + + protected void addTools(ToolManager viewToolManager, int index) { + new UddiBusinessDetailsTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getWSILPerspective().getMessage("ALT_UDDI_LINK_DETAILS")); + new AddBusinessToUDDIPerspectiveTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getWSILPerspective().getMessage("ALT_ADD_BUSINESS_TO_UDDI_PERSPECTIVE")); + new AddBusinessToFavoritesTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getWSILPerspective().getMessage("ALT_ADD_UDDI_BUSINESS_TO_FAVORITES")); + new RefreshUDDIBusinessTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getWSILPerspective().getMessage("ALT_REFRESH_UDDI_BUSINESS")); + } + + public String getFormLink() { + return ProxyLoadPageAction.getActionLink("wsil/views/UddiBusinessView.jsp"); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListUDDIServicesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListUDDIServicesTool.java new file mode 100644 index 000000000..c65bc1680 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListUDDIServicesTool.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.actions.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ViewTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WsilSetDefaultViewTool; + +public class ListUDDIServicesTool extends ViewTool { + public ListUDDIServicesTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/list_UDDI_service_enabled.gif", "wsil/images/list_UDDI_service_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + protected void addSetDefaultViewTool(ToolManager viewToolManager, int index) { + new WsilSetDefaultViewTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getMessage("ALT_BACK_TO_TOP")); + } + + protected void addTools(ToolManager viewToolManager, int index) { + Controller controller = toolManager_.getNode().getNodeManager().getController(); + WSILPerspective wsilPerspective = controller.getWSILPerspective(); + new UddiServiceDetailsTool(viewToolManager, wsilPerspective.getMessage("ALT_WSIL_SERVICE_DETAILS")); + new WsilImportWSDLToWorkbenchTool(viewToolManager, controller.getMessage("ALT_IMPORT_WSDL_TO_WORKBENCH")); + new ImportWSDLToFileSystemTool(viewToolManager, controller.getMessage("ALT_WSDL_IMPORT_TO_FS")); + new WsilLaunchWebServiceWizardTool(viewToolManager, controller.getMessage("ALT_LAUNCH_WEB_SERVICE_WIZARD")); + new AddServiceToUDDIPerspectiveTool(viewToolManager, wsilPerspective.getMessage("ALT_ADD_SERVICE_TO_UDDI_PERSPECTIVE")); + new AddServiceToFavoritesTool(viewToolManager, wsilPerspective.getMessage("ALT_ADD_SERVICE_TO_FAVORITES")); + new RefreshUDDIServiceTool(viewToolManager, wsilPerspective.getMessage("ALT_REFRESH_UDDI_SERVICE")); + } + + public String getFormLink() { + return ProxyLoadPageAction.getActionLink("wsil/views/UddiServicesView.jsp"); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListWSDLServicesTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListWSDLServicesTool.java new file mode 100644 index 000000000..5e51f1900 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListWSDLServicesTool.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ViewTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.WsilSetDefaultViewTool; + +public class ListWSDLServicesTool extends ViewTool { + public ListWSDLServicesTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/list_WSDL_service_enabled.gif", "wsil/images/list_WSDL_service_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + protected void addSetDefaultViewTool(ToolManager viewToolManager, int index) { + new WsilSetDefaultViewTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getMessage("ALT_BACK_TO_TOP")); + } + + protected void addTools(ToolManager viewToolManager, int index) { + Controller controller = toolManager_.getNode().getNodeManager().getController(); + WSILPerspective wsilPerspective = controller.getWSILPerspective(); + new WsdlServiceDetailsTool(viewToolManager, wsilPerspective.getMessage("ALT_WSIL_SERVICE_DETAILS")); + new WsilImportWSDLToWorkbenchTool(viewToolManager, controller.getMessage("ALT_IMPORT_WSDL_TO_WORKBENCH")); + new ImportWSDLToFileSystemTool(viewToolManager, controller.getMessage("ALT_WSDL_IMPORT_TO_FS")); + new WsilLaunchWebServiceWizardTool(viewToolManager, controller.getMessage("ALT_LAUNCH_WEB_SERVICE_WIZARD")); + new WsilAddToWSDLPerspectiveTool(viewToolManager, wsilPerspective.getMessage("ALT_ADD_WSDL_TO_WSDL_PERSPECTIVE")); + new AddWSDLServiceToFavoritesTool(viewToolManager, wsilPerspective.getMessage("ALT_ADD_WSDL_SERVICE_TO_FAVORITES")); + } + + public String getFormLink() { + return "wsil/views/WsdlServicesView.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListWSILLinksTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListWSILLinksTool.java new file mode 100644 index 000000000..3ae52fb46 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/ListWSILLinksTool.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ViewTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class ListWSILLinksTool extends ViewTool { + public ListWSILLinksTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/list_WSIL_enabled.gif", "wsil/images/list_WSIL_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + protected void addSetDefaultViewTool(ToolManager viewToolManager, int index) { + new WsilSetDefaultViewTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getMessage("ALT_BACK_TO_TOP")); + } + + protected void addTools(ToolManager viewToolManager, int index) { + new WsilLinkDetailsTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getWSILPerspective().getMessage("ALT_WSIL_LINK_DETAILS")); + new OpenWSILLinkTool(viewToolManager, toolManager_.getNode().getNodeManager().getController().getWSILPerspective().getMessage("ALT_OPEN_WSIL_LINK")); + } + + public String getFormLink() { + return "wsil/views/WsilLinksView.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/OpenWSILLinkTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/OpenWSILLinkTool.java new file mode 100644 index 000000000..c0c61fba4 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/OpenWSILLinkTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.OpenWSILLinkAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class OpenWSILLinkTool extends ActionTool { + public OpenWSILLinkTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/open_wsil_enabled.gif", "wsil/images/open_wsil_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return OpenWSILLinkAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/OpenWSILTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/OpenWSILTool.java new file mode 100644 index 000000000..d9d500934 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/OpenWSILTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class OpenWSILTool extends FormTool { + public OpenWSILTool(ToolManager toolManager, String alt) { + super(toolManager, "wsil/images/open_wsil_enabled.gif", "wsil/images/open_wsil_highlighted.gif", alt); + } + + protected void initDefaultProperties() { + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "wsil/forms/OpenWSILForm.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshUDDIBusinessTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshUDDIBusinessTool.java new file mode 100644 index 000000000..5b22a8612 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshUDDIBusinessTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.RefreshAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class RefreshUDDIBusinessTool extends ActionTool { + public RefreshUDDIBusinessTool(ToolManager toolManager, String alt) { + super(toolManager, "images/refresh_enabled.gif", "images/refresh_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return RefreshAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshUDDIServiceTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshUDDIServiceTool.java new file mode 100644 index 000000000..cc98791be --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshUDDIServiceTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.RefreshAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class RefreshUDDIServiceTool extends ActionTool { + public RefreshUDDIServiceTool(ToolManager toolManager, String alt) { + super(toolManager, "images/refresh_enabled.gif", "images/refresh_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return RefreshAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshWSILTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshWSILTool.java new file mode 100644 index 000000000..00a3c5b3a --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/RefreshWSILTool.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ActionTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.RefreshAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class RefreshWSILTool extends ActionTool { + public RefreshWSILTool(ToolManager toolManager, String alt) { + super(toolManager, "images/refresh_enabled.gif", "images/refresh_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getActionLink() { + return RefreshAction.getActionLink(toolManager_.getNode().getNodeId(), toolId_, ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/UddiBusinessDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/UddiBusinessDetailsTool.java new file mode 100644 index 000000000..f9db177b6 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/UddiBusinessDetailsTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class UddiBusinessDetailsTool extends FormTool { + public UddiBusinessDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getFormLink() { + return "wsil/forms/UddiBusinessDetailsPage.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/UddiServiceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/UddiServiceDetailsTool.java new file mode 100644 index 000000000..5d3f5cdc1 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/UddiServiceDetailsTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class UddiServiceDetailsTool extends FormTool { + public UddiServiceDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getFormLink() { + return "wsil/forms/UddiServiceDetailsPage.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WSILImportWSILToWorkbenchTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WSILImportWSILToWorkbenchTool.java new file mode 100644 index 000000000..be28ec8e2 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WSILImportWSILToWorkbenchTool.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToWorkbenchTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WSILImportWSILToWorkbenchTool extends ImportToWorkbenchTool +{ + public WSILImportWSILToWorkbenchTool(ToolManager toolManager, String alt) + { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) + { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public final String getFormLink() + { + return "wsil/forms/WSILImportWSILToWorkbenchForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WSILPerspective.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WSILPerspective.java new file mode 100644 index 000000000..e51268641 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WSILPerspective.java @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.datamodel.BasicModel; +import org.eclipse.wst.ws.internal.explorer.platform.constants.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.*; + +import javax.servlet.*; + +public class WSILPerspective extends Perspective +{ + private BasicModel model_; + private NodeManager nodeManager_; + private String perspectiveContentFramesetCols_; + private String savedPerspectiveContentFramesetCols_; + private String actionsContainerFramesetRows_; + private String savedActionsContainerFramesetRows_; + + public WSILPerspective(Controller controller) + { + super("wsil",controller); + } + + public final void initPerspective(ServletContext application) + { + model_ = new BasicModel("WsilModel"); + TreeElement treeElement = new TreeElement(getMessage("WSIL_MAIN_NODE"), model_); + model_.setRootElement(treeElement); + nodeManager_ = new NodeManager(controller_); + WsilMainNode wsilMainNode = new WsilMainNode(treeElement, nodeManager_); + nodeManager_.setRootNode(wsilMainNode); + + // Starting frameset sizes. + perspectiveContentFramesetCols_ = "30%,*"; + savedPerspectiveContentFramesetCols_ = perspectiveContentFramesetCols_; + actionsContainerFramesetRows_ = "75%,*"; + savedActionsContainerFramesetRows_ = actionsContainerFramesetRows_; + } + + public NodeManager getNodeManager() { + return nodeManager_; + } + + public String getPerspectiveContentPage() + { + return "wsil/wsil_perspective_content.jsp"; + } + + public int getPerspectiveId() + { + return ActionInputs.PERSPECTIVE_WSIL; + } + + public String getPanesFile() { + return "wsil/scripts/wsilPanes.jsp"; + } + + public String getFramesetsFile() + { + return "wsil/scripts/wsilframesets.jsp"; + } + + public String getProcessFramesetsForm() + { + return "wsil/forms/ProcessWSILFramesetsForm.jsp"; + } + + public String getTreeContentVar() { + return "wsilNavigatorContent"; + } + + public String getTreeContentPage() { + return "wsil/wsil_navigator_content.jsp"; + } + + public String getPropertiesContainerVar() { + return "wsilPropertiesContainer"; + } + + public String getPropertiesContainerPage() { + return "wsil/wsil_properties_container.jsp"; + } + + public String getStatusContentVar() { + return "wsilStatusContent"; + } + + public String getStatusContentPage() { + return "wsil/wsil_status_content.jsp"; + } + + public final String getPerspectiveContentFramesetCols() + { + return perspectiveContentFramesetCols_; + } + + public final void setPerspectiveContentFramesetCols(String cols) + { + perspectiveContentFramesetCols_ = cols; + } + + public final String getSavedPerspectiveContentFramesetCols() + { + return savedPerspectiveContentFramesetCols_; + } + + public final void setSavedPerspectiveContentFramesetCols(String cols) + { + savedPerspectiveContentFramesetCols_ = cols; + } + + public final String getActionsContainerFramesetRows() + { + return actionsContainerFramesetRows_; + } + + public final void setActionsContainerFramesetRows(String rows) + { + actionsContainerFramesetRows_ = rows; + } + + public final String getSavedActionsContainerFramesetRows() + { + return savedActionsContainerFramesetRows_; + } + + public final void setSavedActionsContainerFramesetRows(String rows) + { + savedActionsContainerFramesetRows_ = rows; + } + + public final String getSwitchPerspectiveFormActionLink(int targetPerspectiveId,boolean forHistory) + { + return SwitchPerspectiveFromWSILAction.getFormActionLink(targetPerspectiveId,forHistory); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsdlServiceDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsdlServiceDetailsTool.java new file mode 100644 index 000000000..7efdfe6de --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsdlServiceDetailsTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WsdlServiceDetailsTool extends FormTool { + public WsdlServiceDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getFormLink() { + return "wsil/forms/WsdlServiceDetailsPage.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilAddToWSDLPerspectiveTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilAddToWSDLPerspectiveTool.java new file mode 100644 index 000000000..a7bcaa5ad --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilAddToWSDLPerspectiveTool.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.*; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.*; + +public class WsilAddToWSDLPerspectiveTool extends AddToWSDLPerspectiveTool { + + public WsilAddToWSDLPerspectiveTool(ToolManager toolManager, String alt) { + super(toolManager,alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return WsilAddToWSDLPerspectiveAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilDetailsTool.java new file mode 100644 index 000000000..caecb8d96 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilDetailsTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WsilDetailsTool extends FormTool { + public WsilDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), toolId_, selectedNode.getViewId(), selectedNode.getViewToolId(), forHistory); + } + + public String getFormLink() { + return "wsil/forms/WsilDetailsPage.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilImportWSDLToWorkbenchTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilImportWSDLToWorkbenchTool.java new file mode 100644 index 000000000..0371249ec --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilImportWSDLToWorkbenchTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ImportToWorkbenchTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WsilImportWSDLToWorkbenchTool extends ImportToWorkbenchTool { + public WsilImportWSDLToWorkbenchTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public final String getFormLink() + { + return "wsil/forms/WsilImportWSDLToWorkbenchForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilLaunchWebServiceWizardTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilLaunchWebServiceWizardTool.java new file mode 100644 index 000000000..cd3110a6b --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilLaunchWebServiceWizardTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.LaunchWebServiceWizardTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WsilLaunchWebServiceWizardTool extends LaunchWebServiceWizardTool { + public WsilLaunchWebServiceWizardTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public final String getFormLink() + { + return "wsil/forms/WsilLaunchWebServiceWizardForm.jsp"; + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilLinkDetailsTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilLinkDetailsTool.java new file mode 100644 index 000000000..786540471 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilLinkDetailsTool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.perspective.FormTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WsilLinkDetailsTool extends FormTool { + public WsilLinkDetailsTool(ToolManager toolManager, String alt) { + super(toolManager, "images/details_enabled.gif", "images/details_highlighted.gif", alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), selectedNode.getViewId(), toolId_, forHistory); + } + + public String getFormLink() { + return "wsil/forms/WsilLinkDetailsPage.jsp"; + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilMainNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilMainNode.java new file mode 100644 index 000000000..428929bde --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilMainNode.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.datamodel.*; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.WsilModelConstants; + +public class WsilMainNode extends WsilNavigatorNode { + + public WsilMainNode(TreeElement treeElement, NodeManager nodeManager) { + super(treeElement, nodeManager, 1, "images/root_main.gif"); + treeElement.addListener(new ElementAdapter() { + public void relAdded(RelAddEvent event) { + String rel = event.getOutBoundRelName(); + if (rel.equals(WsilModelConstants.REL_WSIL)) { + WsilNode wsilNode = new WsilNode((TreeElement)event.getParentElement(), nodeManager_, nodeDepth_ + 1); + addChild(wsilNode); + } + } + + public void relRemoved(RelRemoveEvent event) { + TreeElement childElement = null; + if (event.getInBoundRelName().equals(WsilModelConstants.REL_WSIL)) { + childElement = (TreeElement)event.getInboundElement(); + } + if (event.getOutBoundRelName().equals(WsilModelConstants.REL_WSIL)) { + childElement = (TreeElement)event.getOutBoundElement(); + } + removeChildNode(childElement); + } + }); + } + + protected void initTools() { + WSILPerspective wsilPerspective = nodeManager_.getController().getWSILPerspective(); + new OpenWSILTool(toolManager_, wsilPerspective.getMessage("ALT_OPEN_WSIL")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilNavigatorNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilNavigatorNode.java new file mode 100644 index 000000000..6a22957ee --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilNavigatorNode.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILNodeAction; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.WsilToggleNodeAction; + +public abstract class WsilNavigatorNode extends Node { + + public WsilNavigatorNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth, String imagePath) { + super(treeElement, nodeManager, nodeDepth, imagePath); + } + + protected String getToggleNodeActionHref() { + return WsilToggleNodeAction.getActionLink(nodeId_,isOpen_); + } + + protected String getLinkActionHref() { + return SelectWSILNodeAction.getActionLink(nodeId_, false); + } + +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilNode.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilNode.java new file mode 100644 index 000000000..aa869edff --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilNode.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.NodeManager; + +public class WsilNode extends WsilNavigatorNode { + + public WsilNode(TreeElement treeElement, NodeManager nodeManager, int nodeDepth) { + super(treeElement, nodeManager, nodeDepth, "wsil/images/wsil_node.gif"); + } + + protected void initTools() { + Controller controller = nodeManager_.getController(); + WSILPerspective wsilPerspective = controller.getWSILPerspective(); + new WsilDetailsTool(toolManager_, wsilPerspective.getMessage("ALT_WSIL_DETAILS")); + new ListWSDLServicesTool(toolManager_, wsilPerspective.getMessage("ALT_LIST_WSDL_SERVICES")); + new ListUDDIServicesTool(toolManager_, wsilPerspective.getMessage("ALT_LIST_UDDI_SERVICES")); + new ListUDDIBusinessTool(toolManager_, wsilPerspective.getMessage("ALT_LIST_UDDI_LINKS")); + new ListWSILLinksTool(toolManager_, wsilPerspective.getMessage("ALT_LIST_WSIL_LINKS")); + new WSILImportWSILToWorkbenchTool(toolManager_, wsilPerspective.getMessage("ATL_IMPORT_WSIL_TO_WORKBENCH")); + new ImportWSILToFileSystemTool(toolManager_, controller.getMessage("ALT_WSIL_IMPORT_TO_FS")); + new AddWSILToFavoritesTool(toolManager_, wsilPerspective.getMessage("ALT_ADD_WSIL_TO_FAVORITES")); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilSetDefaultViewTool.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilSetDefaultViewTool.java new file mode 100644 index 000000000..39f63382e --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/perspective/WsilSetDefaultViewTool.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.SetDefaultViewTool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.actions.SelectWSILToolAction; + +public class WsilSetDefaultViewTool extends SetDefaultViewTool { + public WsilSetDefaultViewTool(ToolManager toolManager, String alt) { + super(toolManager, alt); + } + + public String getSelectToolActionHref(boolean forHistory) { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT, forHistory); + } + + public String getActionLink() { + Node selectedNode = toolManager_.getNode(); + return SelectWSILToolAction.getActionLink(selectedNode.getNodeId(), selectedNode.getToolManager().getSelectedToolId(), ActionInputs.VIEWID_DEFAULT, ActionInputs.VIEWTOOLID_DEFAULT, false); + } +} diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/transformer/WSILViewSelectionTransformer.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/transformer/WSILViewSelectionTransformer.java new file mode 100644 index 000000000..b265d2813 --- /dev/null +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsil/transformer/WSILViewSelectionTransformer.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.ws.internal.explorer.platform.wsil.transformer; + +import java.util.Hashtable; + +import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs; +import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement; +import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ViewSelectionTransformer; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.Tool; +import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.WsilModelConstants; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListUDDIBusinessTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListUDDIServicesTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListWSDLServicesTool; +import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListWSILLinksTool; + +public class WSILViewSelectionTransformer extends ViewSelectionTransformer +{ + public static final byte NONE = 0; + public static final byte WSDL_SERVICE = 1; + public static final byte UDDI_SERVICE = 2; + public static final byte UDDI_BUSINESS = 3; + public static final byte WSIL_LINK = 4; + public static final byte FROM_TOOLID = 5; + private byte type; + + public WSILViewSelectionTransformer(Controller controller) + { + this(controller, "", ActionInputs.VIEWID, FROM_TOOLID); + } + + public WSILViewSelectionTransformer(Controller controller, String listManagerKey, String viewKey, byte type) + { + super(controller, listManagerKey, viewKey); + this.type = type; + } + + public Hashtable normalize(Hashtable properties) + { + if (type == FROM_TOOLID) + { + Node currNode = controller.getCurrentPerspective().getNodeManager().getSelectedNode(); + if (currNode != null) + { + try + { + int toolId = Integer.parseInt((String) properties.get(ActionInputs.TOOLID)); + ToolManager toolManager = currNode.getToolManager(); + Tool tool = toolManager.getTool(toolId); + if (tool instanceof ListWSDLServicesTool) + listManagerKey = WsilModelConstants.LIST_MANAGER_WSDL_SERVICES; + else if (tool instanceof ListUDDIServicesTool) + listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_SERVICES; + else if (tool instanceof ListUDDIBusinessTool) + listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_LINKS; + else if (tool instanceof ListWSILLinksTool) + listManagerKey = WsilModelConstants.LIST_MANAGER_WSIL_LINKS; + } + catch (NumberFormatException nfe) + { + } + } + } + return super.normalize(properties); + } + + public Hashtable deNormalize(Hashtable properties) + { + Node currNode = controller.getCurrentPerspective().getNodeManager().getSelectedNode(); + if (currNode != null) + { + TreeElement currElement = currNode.getTreeElement(); + if (currElement instanceof WsilElement) + { + WsilElement wsilElement = (WsilElement) currElement; + switch (type) + { + case WSDL_SERVICE : + wsilElement.getAllWSDLServices(); + break; + case UDDI_SERVICE : + wsilElement.getAllUDDIServices(); + break; + case UDDI_BUSINESS : + wsilElement.getAllUDDILinks(); + break; + case WSIL_LINK : + wsilElement.getAllWSILLinks(); + break; + case FROM_TOOLID : + try + { + int toolId = Integer.parseInt((String) properties.get(ActionInputs.TOOLID)); + ToolManager toolManager = currNode.getToolManager(); + Tool tool = toolManager.getTool(toolId); + if (tool instanceof ListWSDLServicesTool) + { + listManagerKey = WsilModelConstants.LIST_MANAGER_WSDL_SERVICES; + wsilElement.getAllWSDLServices(); + } + else if (tool instanceof ListUDDIServicesTool) + { + listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_SERVICES; + wsilElement.getAllUDDIServices(); + } + else if (tool instanceof ListUDDIBusinessTool) + { + listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_LINKS; + wsilElement.getAllUDDILinks(); + } + else if (tool instanceof ListWSILLinksTool) + { + listManagerKey = WsilModelConstants.LIST_MANAGER_WSIL_LINKS; + wsilElement.getAllWSILLinks(); + } + } + catch (NumberFormatException nfe) + { + } + break; + default : + break; + } + } + } + return super.deNormalize(properties); + } +}
\ No newline at end of file |