From eb3a4d26cd5243c49ffdf97ae5febdcd04d8a0d6 Mon Sep 17 00:00:00 2001 From: Alex McCaskey Date: Wed, 22 Apr 2015 13:25:35 -0400 Subject: [PATCH] Committing ComponentContext NullPointerException fix to the Core. Added private startHttpService that creates the actual http connection, and invoked it from the start method. Tested this with the new python connection script. Also cleaned up all the old UML generated stuff. Signed-off-by: Alex McCaskey --- src/org.eclipse.ice.core/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 17 +- .../src/org/eclipse/ice/core/iCore/ICore.java | 225 ++------------- .../internal/BasicAuthSecuredContext.java | 4 + .../org/eclipse/ice/core/internal/Core.java | 261 ++---------------- 5 files changed, 55 insertions(+), 454 deletions(-) diff --git a/src/org.eclipse.ice.core/.classpath b/src/org.eclipse.ice.core/.classpath index ad32c83a7..098194ca4 100644 --- a/src/org.eclipse.ice.core/.classpath +++ b/src/org.eclipse.ice.core/.classpath @@ -1,6 +1,6 @@ - + diff --git a/src/org.eclipse.ice.core/.settings/org.eclipse.jdt.core.prefs b/src/org.eclipse.ice.core/.settings/org.eclipse.jdt.core.prefs index 267f57538..838bd9d69 100644 --- a/src/org.eclipse.ice.core/.settings/org.eclipse.jdt.core.prefs +++ b/src/org.eclipse.ice.core/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,11 @@ -#Mon Nov 12 15:21:45 EST 2012 -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/iCore/ICore.java b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/iCore/ICore.java index aa4b163d2..045571b8d 100644 --- a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/iCore/ICore.java +++ b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/iCore/ICore.java @@ -35,173 +35,103 @@ import javax.ws.rs.core.MediaType; /** - * - *

* ICore is an interface that is realized by Core and used by clients that * connect to the Core. It describes the services and data available upon * request from the server. - *

- *

+ * * The Connect() operation must be called to obtain a unique identification * number for the client. After that, all of the other operations on this * interface will be available. - *

- *

+ * * Realizations of ICore are intended to be used as web-APIs and, to that end, * many of the arguments in the operations are Strings that should be safe to * cast to integers. - *

- *

- *

- * * * @author Jay Jay Billings - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ @Path("/") public interface ICore { /** - * - *

* This operation "connects" a client to the ICore. The connection in this * case is represented by a unique client id that is returned from this * operation. It is safe to parse this id as an integer and that integer * should always be greater than 0. - *

- * * - * @return

- * The unique client identification number that has been assigned to + * @return The unique client identification number that has been assigned to * the client that made the request. It is safe to parse this string * as an integer. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ @GET @Produces("text/plain") public String connect(); /** - * - *

* This operation will disconnect a client from the remote server if it is * connected. - *

- * * * @param uniqueClientId - *

* The unique client identification number of the client that * would like to disconnect. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void disconnect(int uniqueClientId); /** - * - *

* This operation retrieves the workspace file system available to the * ICEUser. It returns a Form that contains the directory structure. - *

- * * * @param uniqueClientID - *

* The unique ID of the Client calling the operation. - *

- * @return

- * A Form that contains a description of the workspace file system + * @return A Form that contains a description of the workspace file system * available to the ICEUser. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public Form getFileSystem(int uniqueClientID); /** - * - *

* This operation registers an ItemBuilder and thereby a particular Item * class with the Core. This operation is primarily used by the underlying * OSGi framework to publish available Item types to ICE. - *

- * * * @param itemBuilder - *

* An instance of ItemBuilder for a particular Item that is * available to the Core. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void registerItem(ItemBuilder itemBuilder); /** - * - *

* This operation registers a composite Item with the ICore. Composite Items * are Items that depend on other Items to function. This operation is * primarily used by the underlying OSGi framework to publish available Item * types to ICE. - *

- * * * @param builder - *

* The ICompositeItemBuilder that will build the composite Item. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void registerCompositeItem(ICompositeItemBuilder builder); /** - * - *

* This operation unregisters an ItemBuilder and thereby a particular Item * class with the Core. This operation is primarily used by the underlying * OSGi framework to notify ICE if or when a particular type of Item, which * is stored in an OSGi bundle, becomes unavailable. - *

- * * * @param itemBuilder - *

* An instance of ItemBuilder for a particular Item that is now * unavailable to the Core. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void unregisterItem(ItemBuilder itemBuilder); /** - * - *

* This operation directs ICE to create a new Item. If the Item is * successfully created, it returns the identification number of the new * Item. The caller of this operation should immediately inquire after the * status of the Item that was created using the getItemStatus() operation * to determine if more information is required to make the Item usable. - *

- * * * @param itemType - *

* The type of Item to create. - *

- * @return

- * The identification number given as a String of the newly created + * @return The identification number given as a String of the newly created * Item or -1 if it was unable to create the Item. It is safe to * parse this string as an integer. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ @POST @Path("items/create") @@ -209,69 +139,40 @@ public interface ICore { public String createItem(String itemType); /** - * - *

* This operation directs the ICore to permanently delete an Item. Again: * this is permanent! - *

- * * * @param itemId - *

* The identification number of the Item that should be deleted * given as a String. It is safe to parse this string as an * integer. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void deleteItem(String itemId); /** - * - *

* This operation returns the status an Item. - *

- * * * @param id - *

* The identification number of the Item that should be checked. - *

- * @return

- * The status of the Item. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * @return The status of the Item. */ public FormStatus getItemStatus(Integer id); /** - * - *

* This operation returns the representational state, a Form, of an Item * that is managed by the ICore to the caller. - *

- *

+ * * If this operation is called immediately after processItem() with the same * Item id and the call to processItem() returns FormStatus.NeedsInfo, then * this operation will return a simple Form composed of a single * DataComponent with Entries for all of the additional required * information. The smaller Form is created by the Action that is executed * during the call to processItem(). - *

- * * * @param itemId - *

* The identification number of the Item that should be * retrieved. - *

- * @return

- * A Form that represents the Item managed by the core. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * @return A Form that represents the Item managed by the core. */ @GET @Path("items/{id}") @@ -279,21 +180,13 @@ public interface ICore { public Form getItem(@PathParam("id") int itemId); /** - * - *

* This operation returns a list of the available Item types that can be * created by ICE or null if no Items are registered with the Core. It * returns an ICEList of Strings, (i.e. - ICEList<Strings> in Java). - *

- * * - * @return

- * The list of ItemTypes that can be created by ICE. This list is + * @return The list of ItemTypes that can be created by ICE. This list is * determined by the Items that are currently registered with the * running realization of ICore. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ @GET @Path("items") @@ -301,91 +194,57 @@ public interface ICore { public ICEList getAvailableItemTypes(); /** - * - *

* This operation posts an updated Form to the Core so that the updated * information can be processed by the appropriate Item. - *

- * * * @param form - *

* The Form that carries new information for an Item. - *

* @param uniqueClientId - *

* The unique client id the IClient that is making the update * request. - *

- * @return

- * The status of the updated Item. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * @return The status of the updated Item. */ public FormStatus updateItem(Form form, int uniqueClientId); /** - * - *

* This operation directs the Core to process the Item with the specified id * by performing the specific action. The action name must be one of the set * of actions from the Form that represents the Item with the specified id. - *

- *

+ * * It is possible that ICE may require information in addition to that which * was requested in the original Form, such as for a username and password * for a remote machine. If this is the case, processItem will return * FormStatus.NeedsInfo and a new, temporary Form will be available for the * Item by calling getItem(). Once this new Form is submitted (by calling * updateItem() with the completed Form), the Item will finish processing. - *

- * * * @param itemId - *

* The item id for the Item that should be processed with the * specified action. - *

+ * * @param actionName - *

* The action that should be performed on the Item. - *

+ * * @param uniqueClientId - *

* The unique identification number of the client making the * request. - *

- * @return

- * The status of the Item after the action was performed. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * + * @return The status of the Item after the action was performed. */ public FormStatus processItem(int itemId, String actionName, int uniqueClientId); /** - * - *

* This operation returns the list of Items that have been created in ICE. * It returns a list of ICEObjects that represent those Items and provide * the name, description and identification number. This operation is only * meant to provide information about the Items. - *

- * * - * @return

- * The list of Identifiables that represent the Items. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * @return The list of Identifiables that represent the Items. */ public ArrayList getItemList(); /** - * - *

* This operation returns a file handle to the output file for the Item with * the specified id. It returns a handle to the file whether or not it * actually exists and clients should check the File.exists() operation @@ -394,106 +253,66 @@ public FormStatus processItem(int itemId, String actionName, * returned is the real file handle and can be written, but clients * should be careful to only read from the file. It will return null if an * Item with the specified id does not exist. - *

- * * * @param id - *

* The id of the Item. - *

- * @return

- * The output file for the specified Item, thoroughly documented + * @return The output file for the specified Item, thoroughly documented * elsewhere. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public File getItemOutputFile(int id); /** - * - *

* This operation cancels the process with the specified name for the Item * identified. - *

- * * * @param itemId - *

* The id of the Item whose process should be canceled. - *

* @param actionName - *

* The name of the action that should be canceled for the * specified Item. - *

- * @return

- * The status - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * @return The status */ public FormStatus cancelItemProcess(int itemId, String actionName); /** - * - *

* This operation directs the core to import a file into its workspace. - *

- * * * @param file - *

* The file that should be imported. Nothing will happen if this * argument is null. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void importFile(URI file); /** - * - *

* This operation directs the core to import a file into its workspace and * load that file as an input for the specified Item type. It returns the id * of the newly created Item. - *

- * * * @param file - *

* The file that should be imported. Nothing will happen if this * argument is null. - *

* @param itemType - *

* The type of Item to create. - *

- * @return

+ * @return * The identification number given as a String of the newly created * Item or -1 if it was unable to create the Item. It is safe to * parse this string as an integer. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public String importFileAsItem(URI file, String itemType); /** * This operation posts a message containing an update to the ICE Item * designated in the body of the message. - *

+ * * This operation is primarily used by the ICE Updater to post messages to * the Core from remote processes. The message format can be found in the * documentation for the Updater. - *

+ * * @param message * The message that should be passed on to the specified Item. * This string must be in JSON and conform to the message format * of the ICE Updater. - * @return - * "OK" if the post was successful, null if not to conform to JAX-RS + * @return "OK" if the post was successful, null if not to conform to JAX-RS * HTTP 200/204 return code conversion. */ @POST diff --git a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/BasicAuthSecuredContext.java b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/BasicAuthSecuredContext.java index 54b2c80e6..52ed56f53 100644 --- a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/BasicAuthSecuredContext.java +++ b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/BasicAuthSecuredContext.java @@ -150,6 +150,7 @@ public boolean handleSecurity(HttpServletRequest request, // Make sure an authorization header is available String auth = request.getHeader("Authorization"); + // Fail if not if (auth == null) { return failAuthorization(request, response); @@ -157,14 +158,17 @@ public boolean handleSecurity(HttpServletRequest request, // Determine the authentication schemed StringTokenizer tokens = new StringTokenizer(auth); String authscheme = tokens.nextToken(); + // Fail if HTTP Basic authentication is not used if (!("Basic".equals(authscheme))) { return failAuthorization(request, response); } + // Decode the credentials, which are encoded in Base64 String base64credentials = tokens.nextToken(); String credentials = new String(Base64.decodeBase64(base64credentials .getBytes())); + // The userid is on the left side of the colon and the password on the // right int colon = credentials.indexOf(':'); diff --git a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java index 3fc334007..2188a005b 100644 --- a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java +++ b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java @@ -76,74 +76,43 @@ import com.sun.jersey.spi.container.servlet.ServletContainer; /** - * - *

* The Core class is responsible for implementing and/or managing all of the * data and workflow management capabilities of ICE. It implements the ICore * interface and provides additional administration operations not found on * ICore. Most of the operations performed for managing Items are forwarded * directly to the ItemManager class. - *

- * * * @author Jay Jay Billings - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ @ApplicationPath("/ice") public class Core extends Application implements ICore { /** - * - * - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * Reference to the ItemManager responsible for creating, querying, and + * updating available Items. */ private ItemManager itemManager; /** - * - *

* The component context for the ICE Core OSGi component. - *

- * * - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ private ComponentContext componentContext; /** - * - *

* The master table of IProject Eclipse projects, keyed by username. - *

- * */ private Hashtable projectTable; /** - * - *

* The OSGi HTTP Service used by the Core to publish itself. - *

- * - * - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ private HttpService httpService; /** - * - *

* The persistence provided by the osgi. This piece is set by the * setPersistenceProvider method. This piece is passed to the ItemManager to * be used for persisting Items. - *

- * * - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ private IPersistenceProvider provider; @@ -160,22 +129,13 @@ public class Core extends Application implements ICore { private AtomicBoolean updateLock; /** - * - *

* An alternative constructor that allows the Core to be constructed with a * particular ItemManager. This is used for testing. - *

- * * * @param manager - *

* The alternative ItemManager. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public Core(ItemManager manager) { - // begin-user-code // Setup the ItemManager and the project table itemManager = manager; @@ -195,26 +155,16 @@ public Core(ItemManager manager) { updateLock = new AtomicBoolean(false); return; - // end-user-code } /** - * - *

* This operation starts the Core, sets the component context and starts the * web client if the HTTP service is available. - *

- * * * @param context - *

* The bundle context for this OSGi bundle. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void start(ComponentContext context) { - // begin-user-code // Store the component's context componentContext = context; @@ -229,42 +179,27 @@ public void start(ComponentContext context) { // Tell the ItemManager to suit up. It's time to rock and roll. itemManager.loadItems(projectTable.get("defaultUser")); + // Start the webservice! + startHttpService(); + return; - // end-user-code } /** - * - *

* This operation stops the Core. - *

- * * - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void stop() { - // begin-user-code - // Update everything in the ItemManager that requires it itemManager.persistItems(); - - // end-user-code } /** - * - *

* The Constructor - *

- * * - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public Core() { - // begin-user-code // Setup the ItemManager and the project table itemManager = new ItemManager(); @@ -284,31 +219,23 @@ public Core() { updateLock = new AtomicBoolean(false); return; - // end-user-code } /** * (non-Javadoc) * * @see ICore#getFileSystem(int uniqueClientID) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public Form getFileSystem(int uniqueClientID) { - // begin-user-code return new Form(); - // end-user-code } /** * (non-Javadoc) * * @see ICore#registerItem(ItemBuilder itemBuilder) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void registerItem(ItemBuilder itemBuilder) { - // begin-user-code // Register the builder with the ItemManager so long as it is not null if (itemBuilder != null) { @@ -318,18 +245,14 @@ public void registerItem(ItemBuilder itemBuilder) { } return; - // end-user-code } /** * (non-Javadoc) * * @see ICore#registerCompositeItem(ICompositeItemBuilder builder) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void registerCompositeItem(ICompositeItemBuilder builder) { - // begin-user-code // Register the builder with the ItemManager so long as it is not null if (builder != null) { @@ -339,32 +262,22 @@ public void registerCompositeItem(ICompositeItemBuilder builder) { } return; - // end-user-code } /** * (non-Javadoc) * * @see ICore#unregisterItem(ItemBuilder itemBuilder) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void unregisterItem(ItemBuilder itemBuilder) { - // begin-user-code - // TODO Auto-generated method stub - - // end-user-code } /** * (non-Javadoc) * * @see ICore#createItem(String itemType) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public String createItem(String itemType) { - // begin-user-code // Local Declarations int newItemId = -1; @@ -378,62 +291,46 @@ public String createItem(String itemType) { return String.valueOf(newItemId); - // end-user-code } /** * (non-Javadoc) * * @see ICore#deleteItem(String itemId) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void deleteItem(String itemId) { - // begin-user-code // Forward the call to the ItemManager if the String is OK if (itemId != null) { itemManager.deleteItem(Integer.parseInt(itemId)); } - // end-user-code } /** * (non-Javadoc) * * @see ICore#getItemStatus(Integer id) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public FormStatus getItemStatus(Integer id) { - // begin-user-code return itemManager.getItemStatus(id); - // end-user-code } /** * (non-Javadoc) * * @see ICore#getItem(int itemId) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public Form getItem(int itemId) { - // begin-user-code return itemManager.retrieveItem(itemId); - // end-user-code } /** * (non-Javadoc) * * @see ICore#getAvailableItemTypes() - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public ICEList getAvailableItemTypes() { - // begin-user-code // Local Declarations ArrayList types = itemManager.getAvailableBuilders(); @@ -446,19 +343,14 @@ public ICEList getAvailableItemTypes() { retList.setList(types); return retList; - - // end-user-code } /** * (non-Javadoc) * * @see ICore#updateItem(Form form, int uniqueClientId) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public FormStatus updateItem(Form form, int uniqueClientId) { - // begin-user-code // Local Declarations FormStatus status = FormStatus.InfoError; @@ -470,19 +362,15 @@ public FormStatus updateItem(Form form, int uniqueClientId) { status = itemManager.updateItem(form); return status; - // end-user-code } /** * (non-Javadoc) * * @see ICore#processItem(int itemId, String actionName, int uniqueClientId) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public FormStatus processItem(int itemId, String actionName, int uniqueClientId) { - // begin-user-code // Local Declarations FormStatus status = FormStatus.InfoError; @@ -494,59 +382,41 @@ public FormStatus processItem(int itemId, String actionName, } return status; - // end-user-code } /** * (non-Javadoc) * * @see ICore#getItemList() - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public ArrayList getItemList() { - // begin-user-code return itemManager.retrieveItemList(); - // end-user-code } /** * (non-Javadoc) * * @see ICore#getItemOutputFile(int id) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public File getItemOutputFile(int id) { - // begin-user-code return itemManager.getOutputFile(id); - // end-user-code } /** * (non-Javadoc) * * @see ICore#cancelItemProcess(int itemId, String actionName) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public FormStatus cancelItemProcess(int itemId, String actionName) { - // begin-user-code - // TODO Auto-generated method stub return itemManager.cancelItemProcess(itemId, actionName); - // end-user-code } /** * (non-Javadoc) * * @see ICore#importFile(URI file) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void importFile(URI file) { - // begin-user-code - // Local Declarations IProject project = projectTable.get("defaultUser"); @@ -611,50 +481,27 @@ public void importFile(URI file) { } return; - // end-user-code } /** - * - *

* This operation publishes a message to a publicly available log that may * be consumed by clients. - *

- * * * @param message - *

* The message that should be published. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ private void publishMessage(String message) { - // begin-user-code - - // TODO Auto-generated method stub - - // end-user-code } /** - * - *

* This operation scans the default project area for SerializedItems and * loads them into the Core. It returns false if it encounters and error and * true if it is successful. - *

- * * - * @return

- * True if the SerializedItems stored in the default project area + * @return True if the SerializedItems stored in the default project area * were loaded successfully, false otherwise. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ private boolean loadDefaultAreaItems() { - // begin-user-code // Local Declarations boolean status = false; @@ -706,36 +553,30 @@ private boolean loadDefaultAreaItems() { project.getFolder("jobProfiles").create(true, true, null); } } catch (CoreException e) { - // TODO Auto-generated catch block e.printStackTrace(); } return status; - // end-user-code } /** - * - *

* This operation sets the HTTP service that should be used by the Core to * publish itself. - *

- * * * @param service - *

* The HTTP service. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void setHttpService(HttpService service) { - // begin-user-code // Set the webservice reference httpService = service; System.out.println("ICore Message: Web service set!"); + } + /** + * Private method used by Core.start() method to start the HttpService. + */ + private void startHttpService() { // If it is good to go, start up the webserver if (httpService != null) { @@ -748,18 +589,14 @@ public void setHttpService(HttpService service) { // Register the service try { // Get the bundle - Bundle bundle = null; - if (componentContext != null) { - bundle = componentContext.getBundleContext().getBundle(); - } else { - return; - } - + Bundle bundle = componentContext.getBundleContext().getBundle(); // Make sure we got a valid bundle if (bundle == null) { + System.out + .println("ICore Message: Could not get a valid reference to the Bundle. Start Http Service Failed."); return; } - + // Find the root location and the jaas_config file URL resourceURL = bundle.getEntry(""); URL configFileURL = bundle.getEntry("jaas_config.txt"); @@ -771,14 +608,7 @@ public void setHttpService(HttpService service) { "ICE Core Server Configuration"); httpService.registerServlet("/ice", new ServletContainer(this), servletParams, httpContext); - } catch (ServletException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NamespaceException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block + } catch (ServletException | NamespaceException | IOException e) { e.printStackTrace(); } System.out.println("ICore Message: ICE Core Server loaded and web " @@ -791,49 +621,28 @@ public void setHttpService(HttpService service) { } /** - * - *

* This operation returns the current instance of the ICE core to the HTTP * service so that it can be published. It overrides * Application.getSingletons(). - *

- * * - * @return

- * The set of "singletons" - in this case just the running instance + * @return The set of "singletons" - in this case just the running instance * of the Core. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public Set getSingletons() { - // begin-user-code - // Create a set that just points to this class as the servlet Set result = new HashSet(); result.add(this); return result; - - // end-user-code } /** - * - *

* This private operation configures the project area for the Core. It uses * the Eclipse Resources Plugin and behaves differently based on the value - * of the osgi.instance.area system property. - *

- * + * of the osgi.instance.area system property.

* - * @return

- * True if the setup operation was successful and false otherwise. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" + * @return True if the setup operation was successful and false otherwise. */ private boolean setupProjectLocation() { - // begin-user-code // Local Declarations IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); @@ -882,72 +691,47 @@ private boolean setupProjectLocation() { status = loadDefaultAreaItems(); } return status; - // end-user-code } /** - * - *

* This operation sets the persistence provider from the * IPersistenceProvider interface. This is picked up via OSGI. - *

- * * * @param provider - *

* The persistence provider. - *

- * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void setPersistenceProvider(IPersistenceProvider provider) { - // begin-user-code // If the provider is not null, store the reference and log a message. if (provider != null) { System.out.println("ICore Message: PersistenceProvider set!"); this.provider = provider; } - - // end-user-code } /** * (non-Javadoc) * * @see ICore#connect() - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public String connect() { - // begin-user-code return "1"; - // end-user-code } /** * (non-Javadoc) * * @see ICore#disconnect(int uniqueClientId) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public void disconnect(int uniqueClientId) { - // begin-user-code - // TODO Auto-generated method stub - - // end-user-code } /** * (non-Javadoc) * * @see ICore#importFileAsItem(URI file, String itemType) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public String importFileAsItem(URI file, String itemType) { - // begin-user-code // Local Declarations int newItemId = -1; @@ -966,7 +750,6 @@ public String importFileAsItem(URI file, String itemType) { } return String.valueOf(newItemId); - // end-user-code } /** @@ -977,7 +760,7 @@ public String importFileAsItem(URI file, String itemType) { * * @param messageString * The original message, as a string - * @return + * @return list list of built messages. */ private ArrayList buildMessagesFromString(String messageString) { @@ -1030,11 +813,8 @@ private ArrayList buildMessagesFromString(String messageString) { * (non-Javadoc) * * @see ICore#postUpdateMessage(String message) - * @generated - * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)" */ public String postUpdateMessage(String message) { - // begin-user-code // Lock the operation updateLock.set(true); @@ -1070,6 +850,5 @@ public String postUpdateMessage(String message) { // Unlock the operation and return safely return (updateLock.getAndSet(false)) ? retVal : null; - // end-user-code } } \ No newline at end of file