diff --git a/README.md b/README.md index 51d22e6d0d373937f8b85165e58b39dd7a2d3432..83165442c8a8f2bf892f53932fbe900d2ae4dd19 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ You can build with a simple Gradle command: gradle clean war ``` -You may need to build the [XNAT Gradle plugin](https://bitbucket.org/xnatdev/gradle-xnat-plugin) first, although it should be available on the XNAT Maven repository. +You may need to build the [XDAT Data Builder Gradle plugin](https://bitbucket.org/xnatdev/xdat-data-builder) and [XNAT Data Models library](https://bitbucket.org/xnatdev/xnat-data-models) first, although it should be available on the XNAT Maven repository. This will create your deployable web application in the location: @@ -57,10 +57,10 @@ gradle clean jar publishToMavenLocal You can perform a build deploying to the XNAT Maven repository like this: ```bash -gradle clean jar publishToMavenLocal publishMavenJavaPublicationToMavenRepository +gradle clean jar publishToMavenLocal publish ``` -For this last one, the values set for **repoUsername** and **repoPassword** must be valid credentials for pushing artifacts to the Maven server. +For this last one, the values set for **repoUsername** and **repoPassword** must be valid credentials for pushing artifacts to the Maven server. The *publish* task actually comprises a number of other tasks, which will publish all available artifacts to each repository defined in the *repositories* configuration in the *build.gradle* file. Practically speaking this means that *publish* is an alias for the *publishMavenJavaPublicationToMavenRepository* task. You can specify the name of the generated WAR file (and thus the application context of the application within the Tomcat server) from the command line or a properties file. @@ -85,8 +85,7 @@ Note that **gradle.properties** is in this repository's **.gitignore** file, so You must perform a couple of configuration steps in your run-time environment (e.g. your local development workstation, a Vagrant VM, etc.) in order for XNAT to run properly: * In your Tomcat start-up configuration, add **-Dxnat.home=<path>** where **<path>** is some writeable location. This is where XNAT will look for its configuration and logs folders, e.g. **${xnat.home}/config** and **${xnat.home}/logs**. -* Copy **services.properties** into the **config** folder underneath the path you specified for **xnat.home**. For example, I set **xnat.home** to **~/xnat**. Under that I have the folder **config**, which contains **services.properties** (you don't have to create **logs**: log4j will create it if it doesn't exist). -* Open **InstanceSettings.xml** and modify the settings in there to reflect your configuration. You must do this before the build. This is an annoying but temporary requirement. +* Copy **xnat-conf.properties** into the **config** folder underneath the path you specified for **xnat.home**. For example, I set **xnat.home** to **~/xnat**. Under that I have the folder **config**, which contains **xnat-conf.properties** (you don't have to create **logs**: log4j will create it if it doesn't exist). # Running XNAT # diff --git a/build.gradle b/build.gradle index 4b09cd3fa576ec7a942091539a1175956596d26a..5e30a2fb60f35e41bf8848389bc61eee625d55bf 100644 --- a/build.gradle +++ b/build.gradle @@ -123,6 +123,14 @@ cargo { } } +if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } +} + task sourceJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource } @@ -170,7 +178,6 @@ publishing { } } repositories { - mavenLocal() maven { credentials { // These properties must be set in the ~/.gradle/gradle.properties file or passed on the Gradle command diff --git a/src/main/java/org/nrg/xnat/restlet/actions/AutomationBasedImporter.java b/src/main/java/org/nrg/xnat/restlet/actions/AutomationBasedImporter.java index 929f86edf0e8725e786d06cfba63301aecc2a74d..b4f92dd04b4302aae130625d52f5ca13073cce3b 100644 --- a/src/main/java/org/nrg/xnat/restlet/actions/AutomationBasedImporter.java +++ b/src/main/java/org/nrg/xnat/restlet/actions/AutomationBasedImporter.java @@ -8,7 +8,8 @@ package org.nrg.xnat.restlet.actions; * * Released under the Simplified BSD. * - * Last modified 7/10/13 9:04 PM + * Last modified 4/25/16 9:04 PM + * @author Mike Hodge <hodgem@mir.wustl.edu> */ import java.io.File; @@ -78,17 +79,13 @@ import org.nrg.xft.utils.zip.TarUtils; import org.nrg.xft.utils.zip.ZipI; import org.nrg.xft.utils.zip.ZipUtils; -/** - * The Class AutomationBasedImporter. - * - * @author Mike Hodge <hodgem@mir.wustl.edu> - */ @ImporterHandler(handler = "automation", allowCallsWithoutFiles = true, callPartialUriWrap = false) public class AutomationBasedImporter extends ImporterHandlerA implements Callable<List<String>> { /** The Constant ZIP_EXT. */ static final String[] ZIP_EXT = { ".zip", ".jar", ".rar", ".ear", ".gar", ".xar" }; + /** The Constant STATUS_COMPLETE. */ private static final String STATUS_COMPLETE = "Complete"; /** The Constant CACHE_CONSTANT. */ @@ -125,7 +122,14 @@ public class AutomationBasedImporter extends ImporterHandlerA implements Callabl /** The configured resource. */ private String configuredResource; - /** The send admin email. */ + /** + * The send admin email. + * + * @param listenerControl the listener control + * @param u the u + * @param fw the fw + * @param params the params + */ // Is this useful? Do we want it to be configurable? // private boolean sendAdminEmail = false; @@ -258,6 +262,7 @@ public class AutomationBasedImporter extends ImporterHandlerA implements Callabl /** * Return list to html string. * + * @param string the string * @return the string */ /* @@ -703,7 +708,17 @@ public class AutomationBasedImporter extends ImporterHandlerA implements Callabl } - private PersistentWorkflowI buildWorkflow(XnatProjectdata proj,XnatSubjectdata subj,XnatExperimentdata exp, Map<String, Object> passMap,String eventText) { + /** + * Builds the workflow. + * + * @param proj the proj + * @param subj the subj + * @param exp the exp + * @param passMap the pass map + * @param eventText the event text + * @return the persistent workflow i + */ + private PersistentWorkflowI buildWorkflow(XnatProjectdata proj,XnatSubjectdata subj,XnatExperimentdata exp, Map<String, Object> passMap,String eventText) { final PersistentWorkflowI wrk; try { returnList.add("Building workflow entry for configured resource / event handler - " + eventText); diff --git a/src/main/java/org/nrg/xnat/restlet/resources/ScriptTriggerResource.java b/src/main/java/org/nrg/xnat/restlet/resources/ScriptTriggerResource.java index 0b8330d3595a63e3263031b99cb4169f928293e4..16cde120fbc64aaaa3d8de3c16b97734dfe3dc86 100644 --- a/src/main/java/org/nrg/xnat/restlet/resources/ScriptTriggerResource.java +++ b/src/main/java/org/nrg/xnat/restlet/resources/ScriptTriggerResource.java @@ -26,8 +26,19 @@ import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.*; +/** + * The Class ScriptTriggerResource. + */ public class ScriptTriggerResource extends AutomationResource { + /** + * Instantiates a new script trigger resource. + * + * @param context the context + * @param request the request + * @param response the response + * @throws ResourceException the resource exception + */ public ScriptTriggerResource(Context context, Request request, Response response) throws ResourceException { super(context, request, response); @@ -103,26 +114,41 @@ public class ScriptTriggerResource extends AutomationResource { } } + /* (non-Javadoc) + * @see org.nrg.xnat.restlet.resources.AutomationResource#getResourceType() + */ @Override protected String getResourceType() { return ScriptTrigger.class.getSimpleName(); } + /* (non-Javadoc) + * @see org.nrg.xnat.restlet.resources.AutomationResource#getResourceId() + */ @Override protected String getResourceId() { return _trigger == null ? null : _trigger.getEvent(); } + /* (non-Javadoc) + * @see org.restlet.resource.Resource#allowPut() + */ @Override public boolean allowPut() { return true; } + /* (non-Javadoc) + * @see org.restlet.resource.Resource#allowDelete() + */ @Override public boolean allowDelete() { return true; } + /* (non-Javadoc) + * @see org.restlet.resource.Resource#represent(org.restlet.resource.Variant) + */ @Override public Representation represent(Variant variant) throws ResourceException { final MediaType mediaType = overrideVariant(variant); @@ -140,6 +166,9 @@ public class ScriptTriggerResource extends AutomationResource { } } + /* (non-Javadoc) + * @see org.restlet.resource.Resource#handlePut() + */ @Override public void handlePut() { try { @@ -152,6 +181,9 @@ public class ScriptTriggerResource extends AutomationResource { } } + /* (non-Javadoc) + * @see org.restlet.resource.Resource#handleDelete() + */ @Override public void handleDelete() { if (_log.isDebugEnabled()) { @@ -163,6 +195,12 @@ public class ScriptTriggerResource extends AutomationResource { recordAutomationEvent(triggerId, containerId, "Delete", ScriptTrigger.class); } + /** + * Map trigger. + * + * @param trigger the trigger + * @return the map + */ private Map<String, String> mapTrigger(final ScriptTrigger trigger) { final Map<String, String> association = Scope.decode(trigger.getAssociation()); @@ -181,6 +219,7 @@ public class ScriptTriggerResource extends AutomationResource { /** * Lists the script triggers with the specified scope and entity ID and event. * + * @param mediaType the media type * @return A representation of the script triggers available for the specified scope, entity ID (if specified), and event. */ private Representation listScriptTriggers(final MediaType mediaType) { @@ -245,6 +284,12 @@ public class ScriptTriggerResource extends AutomationResource { return representTable(table, mediaType, params); } + /** + * Put script trigger. + * + * @throws ClientException the client exception + * @throws ServerException the server exception + */ private void putScriptTrigger() throws ClientException, ServerException { // TODO: this needs to properly handle a PUT to an existing script as well as an existing but disabled script. final Representation entity = getRequest().getEntity(); @@ -357,6 +402,12 @@ public class ScriptTriggerResource extends AutomationResource { } } + /** + * Gets the event filters. + * + * @param filters the filters + * @return the event filters + */ @SuppressWarnings("unused") private Set<EventFilters> getEventFilters(Map<String, List<String>> filters) { final Set<EventFilters> eventSet = Sets.newHashSet(); @@ -367,6 +418,11 @@ public class ScriptTriggerResource extends AutomationResource { return eventSet; } + /** + * Format scope entity id and event. + * + * @return the string + */ private String formatScopeEntityIdAndEvent() { final StringBuilder buffer = new StringBuilder(); if (_trigger != null) { @@ -396,64 +452,137 @@ public class ScriptTriggerResource extends AutomationResource { return buffer.toString(); } + /** + * The Class JsonResults. + */ @SuppressWarnings("unused") private class JsonResults { - private String event; + + /** The event. */ + private String event; + + /** The event class. */ private String eventClass; + + /** The script id. */ private String scriptId; + + /** The description. */ private String description; - private Map<String,List<String>> filters; - public String getEvent() { + /** The filters. */ + private Map<String,List<String>> filters; + + /** + * Gets the event. + * + * @return the event + */ + public String getEvent() { return event; } + /** + * Sets the event. + * + * @param event the new event + */ public void setEvent(String event) { this.event = event; } - public String getEventClass() { + /** + * Gets the event class. + * + * @return the event class + */ + public String getEventClass() { return eventClass; } + /** + * Sets the event class. + * + * @param eventClass the new event class + */ public void setEventClass(String eventClass) { this.eventClass = eventClass; } + /** + * Gets the script id. + * + * @return the script id + */ public String getScriptId() { return scriptId; } + /** + * Sets the script id. + * + * @param scriptId the new script id + */ public void setScriptId(String scriptId) { this.scriptId = scriptId; } - public String getDescription() { + /** + * Gets the description. + * + * @return the description + */ + public String getDescription() { return description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the filters. + * + * @return the filters + */ public Map<String, List<String>> getFilters() { return filters; } + /** + * Sets the filters. + * + * @param filters the filters + */ public void setFilters(Map<String, List<String>> filters) { this.filters = filters; } } + /** The Constant _log. */ private static final Logger _log = LoggerFactory.getLogger(ScriptTriggerResource.class); + /** The Constant EVENT_ID. */ private static final String EVENT_ID = "EVENT_ID"; + + /** The Constant TRIGGER_ID. */ private static final String TRIGGER_ID = "TRIGGER_ID"; + + /** The Constant ID. */ private static final String ID = "ID"; + /** The _script trigger service. */ private final ScriptTriggerService _scriptTriggerService; + /** The _event id. */ private final String _eventId; + + /** The _trigger. */ private final ScriptTrigger _trigger; } diff --git a/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequest.java b/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequest.java index 3937cfadfe8d3af9a7b2e68fcc1b8c2f8371ee41..1512ed44f62fc7e25bf70c2e19683be229d2565d 100644 --- a/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequest.java +++ b/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequest.java @@ -8,21 +8,57 @@ import com.google.common.collect.Maps; import java.io.Serializable; import java.util.Map; +/** + * The Class AutomatedScriptRequest. + */ public class AutomatedScriptRequest implements Serializable { + /** The Constant serialVersionUID. */ private static final long serialVersionUID = -5425712284737600869L; + /** The _src event id. */ private final String _srcEventId; + + /** The _src event class. */ private final String _srcEventClass; + + /** The _user. */ private final UserI _user; + + /** The _script id. */ private final String _scriptId; + + /** The _event. */ private final String _event; + + /** The _script workflow id. */ private final String _scriptWorkflowId; + + /** The _external id. */ private final String _externalId; + + /** The _data type. */ private final String _dataType; + + /** The _data id. */ private final String _dataId; + + /** The _argument map. */ private final Map<String,Object> _argumentMap = Maps.newHashMap(); + /** + * Instantiates a new automated script request. + * + * @param srcEventId the src event id + * @param srcEventClass the src event class + * @param user the user + * @param scriptId the script id + * @param event the event + * @param scriptWorkflow the script workflow + * @param dataType the data type + * @param dataId the data id + * @param externalId the external id + */ public AutomatedScriptRequest(final String srcEventId, final String srcEventClass, final UserI user, final String scriptId, final String event, final String scriptWorkflow, final String dataType, final String dataId, final String externalId) { _srcEventId = srcEventId; _srcEventClass = srcEventClass; @@ -35,51 +71,120 @@ public class AutomatedScriptRequest implements Serializable { _externalId = externalId; } + /** + * Instantiates a new automated script request. + * + * @param srcEventId the src event id + * @param srcEventClass the src event class + * @param user the user + * @param scriptId the script id + * @param event the event + * @param scriptWorkflow the script workflow + * @param dataType the data type + * @param dataId the data id + * @param externalId the external id + * @param argumentMap the argument map + */ public AutomatedScriptRequest(final String srcEventId, final String srcEventClass, final UserI user, final String scriptId, final String event, final String scriptWorkflow, final String dataType, final String dataId, final String externalId, Map<String,Object> argumentMap) { this(srcEventId, srcEventClass, user, scriptId, event, scriptWorkflow, dataType, dataId, externalId); _argumentMap.putAll(argumentMap); } + /** + * Gets the src event id. + * + * @return the src event id + */ public String getSrcEventId() { return _srcEventId; } + /** + * Gets the src event class. + * + * @return the src event class + */ public String getSrcEventClass() { return _srcEventClass; } + /** + * Gets the user. + * + * @return the user + */ public UserI getUser() { return _user; } + /** + * Gets the script id. + * + * @return the script id + */ public String getScriptId() { return _scriptId; } + /** + * Gets the event. + * + * @return the event + */ public String getEvent() { return _event; } + /** + * Gets the script workflow id. + * + * @return the script workflow id + */ public String getScriptWorkflowId() { return _scriptWorkflowId; } + /** + * Gets the external id. + * + * @return the external id + */ public String getExternalId() { return _externalId; } + /** + * Gets the data type. + * + * @return the data type + */ public String getDataType() { return _dataType; } + /** + * Gets the data id. + * + * @return the data id + */ public String getDataId() { return _dataId; } + /** + * Gets the argument map. + * + * @return the argument map + */ public Map<String,Object> getArgumentMap() { return _argumentMap; } + /** + * Gets the argument json. + * + * @return the argument json + */ public String getArgumentJson() { return new JSONObject(_argumentMap).toString(); } diff --git a/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequestListener.java b/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequestListener.java index 6b93b22ffba2151b0fba3e3464dff36fd30952c5..27386704d0be736bee76639627c865dae5039e6f 100644 --- a/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequestListener.java +++ b/src/main/java/org/nrg/xnat/services/messaging/automation/AutomatedScriptRequestListener.java @@ -13,8 +13,25 @@ import javax.inject.Inject; import java.util.HashMap; import java.util.Map; +/** + * The listener interface for receiving automatedScriptRequest events. + * The class that is interested in processing a automatedScriptRequest + * event implements this interface, and the object created + * with that class is registered with a component using the + * component's <code>addAutomatedScriptRequestListener<code> method. When + * the automatedScriptRequest event occurs, that object's appropriate + * method is invoked. + * + * @see AutomatedScriptRequestEvent + */ public class AutomatedScriptRequestListener { + /** + * On request. + * + * @param request the request + * @throws Exception the exception + */ public void onRequest(final AutomatedScriptRequest request) throws Exception { final PersistentWorkflowI workflow = WorkflowUtils.getUniqueWorkflow(request.getUser(), request.getScriptWorkflowId()); workflow.setStatus(PersistentWorkflowUtils.IN_PROGRESS); @@ -58,8 +75,10 @@ public class AutomatedScriptRequestListener { } } + /** The Constant logger. */ private static final Logger logger = LoggerFactory.getLogger(AutomatedScriptRequestListener.class); + /** The _service. */ @Inject private ScriptRunnerService _service; }