Commit da6b9799 authored by amccaskey's avatar amccaskey
Browse files

Committing fix to http update on MOOSE.



Committing fix where job launch directory wasn't being correctly
received. Fixed build for client.widgets.moose, it wasn't including
OSGI-INF for VizServiceFactory reference. 
Signed-off-by: default avataramccaskey <mccaskeyaj@ornl.gov>
parent 24e74d0f
......@@ -4,5 +4,6 @@ bin.includes = META-INF/,\
pom.xml,\
plugin.xml,\
build.properties,\
icons/
icons/,\
OSGI-INF/
source.. = src/
......@@ -172,8 +172,7 @@ public class Core extends Application implements ICore, BundleActivator {
// Set the project location
if (!setupProjectLocation()) {
throw new RuntimeException(
"ICore Message: Unable to load workspace!");
throw new RuntimeException("ICore Message: Unable to load workspace!");
}
// Set the update lock
......@@ -194,8 +193,7 @@ public class Core extends Application implements ICore, BundleActivator {
// Set the project location
if (!setupProjectLocation()) {
throw new RuntimeException(
"ICore Message: Unable to load workspace!");
throw new RuntimeException("ICore Message: Unable to load workspace!");
}
// Set the update lock
......@@ -269,11 +267,9 @@ public class Core extends Application implements ICore, BundleActivator {
if (bundleContext != null) {
// Grab the service interface
matDBServiceRef = bundleContext
.getServiceReference(IMaterialsDatabase.class);
matDBServiceRef = bundleContext.getServiceReference(IMaterialsDatabase.class);
// Get the service
IMaterialsDatabase database = bundleContext
.getService(matDBServiceRef);
IMaterialsDatabase database = bundleContext.getService(matDBServiceRef);
// This should probably be delegated through the ItemManager.
AbstractModelBuilder.setMaterialsDatabase(database);
}
......@@ -322,10 +318,8 @@ public class Core extends Application implements ICore, BundleActivator {
extensionPoints.add("org.eclipse.ice.core.persistenceProvider");
extensionPoints.add("org.eclipse.ice.datastructures.jaxbClassProvider");
for (String extensionPointName : extensionPoints) {
IExtensionPoint point = Platform.getExtensionRegistry()
.getExtensionPoint(extensionPointName);
logger.debug(
"##### Extensions for: " + extensionPointName + " #####");
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(extensionPointName);
logger.debug("##### Extensions for: " + extensionPointName + " #####");
if (point != null) {
IExtension[] extensions = point.getExtensions();
for (IExtension extension : extensions) {
......@@ -350,8 +344,7 @@ public class Core extends Application implements ICore, BundleActivator {
// Register the builder with the ItemManager so long as it is not null
if (itemBuilder != null) {
logger.info("ICore Message: Item " + itemBuilder.getItemName()
+ " registered with Core.");
logger.info("ICore Message: Item " + itemBuilder.getItemName() + " registered with Core.");
itemManager.registerBuilder(itemBuilder);
}
......@@ -368,8 +361,7 @@ public class Core extends Application implements ICore, BundleActivator {
// Register the builder with the ItemManager so long as it is not null
if (builder != null) {
logger.info("ICore Message: Composite Item " + builder.getItemName()
+ " registered with Core.");
logger.info("ICore Message: Composite Item " + builder.getItemName() + " registered with Core.");
itemManager.registerCompositeBuilder(builder);
}
......@@ -393,8 +385,7 @@ public class Core extends Application implements ICore, BundleActivator {
@Override
public String createItem(String itemType) {
// This operation retrieves the default "itemDB
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject("itemDB");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("itemDB");
return createItem(itemType, project);
}
......@@ -416,8 +407,7 @@ public class Core extends Application implements ICore, BundleActivator {
if (itemType != null && project != null) {
newItemId = itemManager.createItem(itemType, project);
} else {
logger.error("Unable to create Item in the core! Type = " + itemType
+ " , project = " + project);
logger.error("Unable to create Item in the core! Type = " + itemType + " , project = " + project);
}
return String.valueOf(newItemId);
......@@ -505,8 +495,7 @@ public class Core extends Application implements ICore, BundleActivator {
* @see ICore#processItem(int itemId, String actionName, int uniqueClientId)
*/
@Override
public FormStatus processItem(int itemId, String actionName,
int uniqueClientId) {
public FormStatus processItem(int itemId, String actionName, int uniqueClientId) {
// Local Declarations
FormStatus status = FormStatus.InfoError;
......@@ -611,18 +600,15 @@ public class Core extends Application implements ICore, BundleActivator {
// Grab PSF or XML file
if (filename.endsWith(".psf") | filename.endsWith(".xml")) {
// Get the file
file = project.getFile(
currentResource.getProjectRelativePath());
file = project.getFile(currentResource.getProjectRelativePath());
try {
// Load the SerializedItemBuilder
builder = new SerializedItemBuilder(
file.getContents());
builder = new SerializedItemBuilder(file.getContents());
// Register the builder
itemManager.registerBuilder(builder);
} catch (IOException e) {
// TODO Auto-generated catch block
logger.error(getClass().getName() + " Exception!",
e);
logger.error(getClass().getName() + " Exception!", e);
status = false;
}
}
......@@ -661,8 +647,7 @@ public class Core extends Application implements ICore, BundleActivator {
// are no longer using Declarative Services.
if (bundleContext != null) {
// Grab the service reference and the service
httpServiceRef = bundleContext
.getServiceReference(HttpService.class);
httpServiceRef = bundleContext.getServiceReference(HttpService.class);
// If it is good to go, start up the webserver
if (httpServiceRef != null) {
......@@ -674,8 +659,7 @@ public class Core extends Application implements ICore, BundleActivator {
httpService = bundleContext.getService(httpServiceRef);
// Set the parameters
servletParams.put("javax.ws.rs.Application",
Core.class.getName());
servletParams.put("javax.ws.rs.Application", Core.class.getName());
// Register the service
try {
......@@ -684,8 +668,7 @@ public class Core extends Application implements ICore, BundleActivator {
bundle = bundleContext.getBundle();
// Make sure we got a valid bundle
if (bundle == null) {
logger.info(
"ICE Core Bundle was null! No web service started.");
logger.info("ICE Core Bundle was null! No web service started.");
return;
}
......@@ -695,14 +678,10 @@ public class Core extends Application implements ICore, BundleActivator {
// Resolve the URLs to be absolute
resourceURL = FileLocator.resolve(resourceURL);
configFileURL = FileLocator.resolve(configFileURL);
HttpContext httpContext = new BasicAuthSecuredContext(
resourceURL, configFileURL,
HttpContext httpContext = new BasicAuthSecuredContext(resourceURL, configFileURL,
"ICE Core Server Configuration");
httpService.registerServlet("/ice",
new ServletContainer(this), servletParams,
httpContext);
} catch (ServletException | NamespaceException
| IOException e) {
httpService.registerServlet("/ice", new ServletContainer(this), servletParams, httpContext);
} catch (ServletException | NamespaceException | IOException e) {
logger.error(getClass().getName() + " Exception!", e);
}
logger.info("ICE Core Server loaded and web service started!");
......@@ -763,8 +742,7 @@ public class Core extends Application implements ICore, BundleActivator {
// If the project does not exist, create it
if (!project.exists()) {
// Create the project description
IProjectDescription desc = ResourcesPlugin.getWorkspace()
.newProjectDescription(defaultProjectName);
IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(defaultProjectName);
// Create the project
project.create(desc, null);
}
......@@ -868,13 +846,11 @@ public class Core extends Application implements ICore, BundleActivator {
JsonObject messageJsonObject = messageJson.getAsJsonObject();
// Get the Item id from the json
JsonPrimitive itemIdJson = messageJsonObject
.getAsJsonPrimitive("item_id");
JsonPrimitive itemIdJson = messageJsonObject.getAsJsonPrimitive("item_id");
int itemId = itemIdJson.getAsInt();
// Get the array of posts from the message
JsonArray jsonMessagesList = messageJsonObject
.getAsJsonArray("posts");
JsonArray jsonMessagesList = messageJsonObject.getAsJsonArray("posts");
// Load the list
for (int i = 0; i < jsonMessagesList.size(); i++) {
......@@ -883,14 +859,15 @@ public class Core extends Application implements ICore, BundleActivator {
// Marshal it into a message
Message tmpMessage = gson.fromJson(jsonMessage, Message.class);
// Set the item id
tmpMessage.setItemId(itemId);
// Put it in the list
messages.add(tmpMessage);
if (tmpMessage != null) {
tmpMessage.setItemId(itemId);
// Put it in the list
messages.add(tmpMessage);
}
}
} catch (JsonParseException e) {
// Log the message
String err = "Core Message: " + "JSON parsing failed for message "
+ messageString;
String err = "Core Message: " + "JSON parsing failed for message " + messageString;
logger.error(getClass().getName() + " Exception!", e);
logger.error(err);
}
......@@ -914,9 +891,8 @@ public class Core extends Application implements ICore, BundleActivator {
// Print the message if debugging is enabled
// if (debuggingEnabled) {
logger.info(
"Core Message: " + "Update received with message: " + message);
// }
logger.info("Core Message: " + "Update received with message: " + message);
// }
// Only process the message if it exists and is not empty
if (message != null && !message.isEmpty() && message.contains("=")) {
......@@ -925,8 +901,7 @@ public class Core extends Application implements ICore, BundleActivator {
String[] messageParts = message.split("=");
if (messageParts.length > 1) {
// Get the message object.
ArrayList<Message> msgList = buildMessagesFromString(
messageParts[1]);
ArrayList<Message> msgList = buildMessagesFromString(messageParts[1]);
// Post the messages if there are any. Fail otherwise.
if (!msgList.isEmpty()) {
for (int i = 0; i < msgList.size(); i++) {
......@@ -960,8 +935,7 @@ public class Core extends Application implements ICore, BundleActivator {
* java.lang.String, org.eclipse.core.resources.IProject)
*/
@Override
public String importFileAsItem(URI file, String itemType,
IProject project) {
public String importFileAsItem(URI file, String itemType, IProject project) {
// Local Declarations
int newItemId = -1;
......@@ -972,8 +946,7 @@ public class Core extends Application implements ICore, BundleActivator {
importFile(file, project);
// Get the name of the file. This is only created to get the short
// name of the file. Then create the Item
newItemId = itemManager.createItem(new File(file).getName(),
itemType, project);
newItemId = itemManager.createItem(new File(file).getName(), itemType, project);
}
return String.valueOf(newItemId);
......@@ -990,8 +963,7 @@ public class Core extends Application implements ICore, BundleActivator {
// This is an IFile, meaning it came from an existing
// IProject, call importFileAsItem with the file URI and its
// corresponding IProject
return importFileAsItem(file.getLocationURI(), itemType,
file.getProject());
return importFileAsItem(file.getLocationURI(), itemType, file.getProject());
}
/**
......@@ -1001,11 +973,9 @@ public class Core extends Application implements ICore, BundleActivator {
* java.lang.String, java.lang.String)
*/
@Override
public String importFileAsItem(URI file, String itemType,
String projectName) {
public String importFileAsItem(URI file, String itemType, String projectName) {
// Get the project associated with the project name
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectName);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
// Import it as normal
return importFileAsItem(file, itemType, project);
......@@ -1034,13 +1004,12 @@ public class Core extends Application implements ICore, BundleActivator {
@Override
public void importFile(URI file, String projectName) {
// Local Declarations
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectName);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (project != null) {
importFile(file, project);
} else {
logger.info("File could not be imported into project " + projectName
+ " because the project does not exist.");
logger.info(
"File could not be imported into project " + projectName + " because the project does not exist.");
}
}
......@@ -1060,8 +1029,7 @@ public class Core extends Application implements ICore, BundleActivator {
IFile fileInProject = project.getFile(path.lastSegment());
// Get the paths and convert them to strings
IPath fullPathInProject = fileInProject.getLocation();
String path1 = path.toString(),
path2 = fullPathInProject.toString();
String path1 = path.toString(), path2 = fullPathInProject.toString();
// Remove devices ids and other such things from the path strings
path1 = path1.substring(path1.lastIndexOf(":") + 1);
path2 = path2.substring(path2.lastIndexOf(":") + 1);
......@@ -1077,16 +1045,14 @@ public class Core extends Application implements ICore, BundleActivator {
fileInProject.delete(true, null);
} catch (CoreException e) {
// Complain and don't do anything else.
logger.info(
"Core Message: " + "Unable to import file.");
logger.info("Core Message: " + "Unable to import file.");
logger.error(getClass().getName() + " Exception!", e);
return;
}
}
try {
// Open a stream of the file
FileInputStream fileStream = new FileInputStream(
new File(file));
FileInputStream fileStream = new FileInputStream(new File(file));
// Import the file
fileInProject.create(fileStream, true, null);
} catch (FileNotFoundException e) {
......@@ -1106,12 +1072,10 @@ public class Core extends Application implements ICore, BundleActivator {
// Drop some debug info.
if (System.getProperty("DebugICE") != null) {
logger.info(
"Core Message: " + "Imported file " + file.toString());
logger.info("Core Message: " + "Imported file " + file.toString());
}
} else {
logger.info(
"File could not be imported into project because the File URI was not valid.");
logger.info("File could not be imported into project because the File URI was not valid.");
}
}
......
......@@ -1905,12 +1905,8 @@ public class JobLauncher extends Item {
*
* @return directory The directory where the job is launched from.
*/
protected String getWorkingDirectory() {
if (actionDataMap != null) {
return actionDataMap.get("workingDir");
} else {
return null;
}
public IFolder getJobLaunchFolder() {
return currentJobFolder;
}
/**
......
......@@ -808,23 +808,17 @@ public class MOOSE extends Item {
Double value = Double.valueOf(data[2]);
// We need the jobLaunch directory to create new VizResources
String directory = mooseLauncher.getJobLaunchDirectory();
if (directory == null) {
IFolder directory = mooseLauncher.getJobLaunchFolder();
if (directory == null || !directory.exists()) {
logger.info("MOOSE Job Launch directory was null or did not exist. Cannot show real-time plots.");
return false;
}
// Refresh the project space
refreshProjectSpace();
// Get this job launch folder
IFolder jobFolder = project.getFolder("jobs")
.getFolder(directory.substring(directory.lastIndexOf("/") + 1, directory.length()));
if (!jobFolder.exists()) {
return false;
}
// Grab the new Postprocessor CSV file
IFile dataFile = jobFolder.getFile(name + ".csv");
IFile dataFile = directory.getFile(name + ".csv");
// Get a reference to the ResourceComponent
ResourceComponent comp = (ResourceComponent) form.getComponent(3);
......
......@@ -524,9 +524,9 @@ public class MOOSELauncher extends SuiteLauncher implements IUpdateableListener
*
* @return
*/
public String getJobLaunchDirectory() {
return getWorkingDirectory();
}
// public String getJobLaunchDirectory() {
// return getWorkingDirectory();
// }
/*
* (non-Javadoc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment