// Path: src/main/java/net/imagej/server/WebCommandInfo.java
// public class WebCommandInfo extends CommandInfo {
// 
// 	private final Module relatedModule;
// 
// 	public WebCommandInfo(CommandInfo commandInfo, Module module) {
// 		super(commandInfo);
// 		relatedModule = module;
// 	}
// 
// 	@Override
// 	public Iterable<ModuleItem<?>> inputs() {
// 
// 		final List<WebCommandModuleItem<?>> checkedInputs = new ArrayList<>();
// 		for (final ModuleItem<?> input : super.inputs()) {
// 			if (input instanceof CommandModuleItem) {
// 				final WebCommandModuleItem<Object> webCommandModuleItem =
// 					new WebCommandModuleItem<>(this, ((CommandModuleItem<?>) input)
// 						.getField());
// 				final String name = input.getName();
// 
// 				final boolean isResolved = relatedModule.isInputResolved(name);
// 
// 				// Include resolved status in the JSON feed.
// 				// This is handy for judiciously overwriting already-resolved inputs,
// 				// particularly the "active image" inputs, which will be reported as
// 				// resolved, but not necessarily match what's selected on the client
// 				// side.
// 				webCommandModuleItem.isResolved = isResolved;
// 
// 				// If the input is not resolved, include startingValue in the JSON feed.
// 				// This is useful for populating the dialog.
// 				webCommandModuleItem.startingValue = (!isResolved) ? relatedModule
// 					.getInput(name) : null;
// 
// 				checkedInputs.add(webCommandModuleItem);
// 			}
// 		}
// 
// 		return Collections.unmodifiableList(checkedInputs);
// 	}
// }
// 
// Path: src/main/java/net/imagej/server/services/JsonService.java
// public interface JsonService {
// 
// 	/**
// 	 * Adds a deserializer to a given {@link ObjectMapper} to modify the default
// 	 * behavior.
// 	 * 
// 	 * @param objectMapper
// 	 */
// 	void addDeserializerTo(final ObjectMapper objectMapper);
// 
// 	/**
// 	 * Parses the given Object.
// 	 * 
// 	 * @param obj Object to be parsed.
// 	 * @return a JSON format String of the parsed Object
// 	 * @throws JsonProcessingException
// 	 */
// 	String parseObject(final Object obj) throws JsonProcessingException;
// }


import com.codahale.metrics.annotation.Timed;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response.Status;
import net.imagej.ops.Initializable;
import net.imagej.server.WebCommandInfo;
import net.imagej.server.services.JsonService;
import org.scijava.Context;
import org.scijava.Identifiable;
import org.scijava.Priority;
import org.scijava.command.CommandInfo;
import org.scijava.module.Module;
import org.scijava.module.ModuleInfo;
import org.scijava.module.ModuleService;
import org.scijava.module.process.AbstractPreprocessorPlugin;
import org.scijava.module.process.ModulePreprocessor;
import org.scijava.module.process.PreprocessorPlugin;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.plugin.PluginInfo;
import org.scijava.plugin.PluginService;
import org.scijava.widget.InputHarvester;
/*
 * #%L
 * ImageJ server for RESTful access to ImageJ.
 * %%
 * Copyright (C) 2013 - 2016 Board of Regents of the University of
 * Wisconsin-Madison.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package net.imagej.server.resources;






/**
 * Server resource that manages module operations.
 *
 * @author Leon Yang
 */
@Path("/modules")
@Singleton
@Produces(MediaType.APPLICATION_JSON)
public class ModulesResource {

	@Parameter
	private ModuleService moduleService;

	@Parameter
	private PluginService pluginService;

	@Inject
// Path: src/main/java/net/imagej/server/WebCommandInfo.java
// public class WebCommandInfo extends CommandInfo {
// 
// 	private final Module relatedModule;
// 
// 	public WebCommandInfo(CommandInfo commandInfo, Module module) {
// 		super(commandInfo);
// 		relatedModule = module;
// 	}
// 
// 	@Override
// 	public Iterable<ModuleItem<?>> inputs() {
// 
// 		final List<WebCommandModuleItem<?>> checkedInputs = new ArrayList<>();
// 		for (final ModuleItem<?> input : super.inputs()) {
// 			if (input instanceof CommandModuleItem) {
// 				final WebCommandModuleItem<Object> webCommandModuleItem =
// 					new WebCommandModuleItem<>(this, ((CommandModuleItem<?>) input)
// 						.getField());
// 				final String name = input.getName();
// 
// 				final boolean isResolved = relatedModule.isInputResolved(name);
// 
// 				// Include resolved status in the JSON feed.
// 				// This is handy for judiciously overwriting already-resolved inputs,
// 				// particularly the "active image" inputs, which will be reported as
// 				// resolved, but not necessarily match what's selected on the client
// 				// side.
// 				webCommandModuleItem.isResolved = isResolved;
// 
// 				// If the input is not resolved, include startingValue in the JSON feed.
// 				// This is useful for populating the dialog.
// 				webCommandModuleItem.startingValue = (!isResolved) ? relatedModule
// 					.getInput(name) : null;
// 
// 				checkedInputs.add(webCommandModuleItem);
// 			}
// 		}
// 
// 		return Collections.unmodifiableList(checkedInputs);
// 	}
// }
// 
// Path: src/main/java/net/imagej/server/services/JsonService.java
// public interface JsonService {
// 
// 	/**
// 	 * Adds a deserializer to a given {@link ObjectMapper} to modify the default
// 	 * behavior.
// 	 * 
// 	 * @param objectMapper
// 	 */
// 	void addDeserializerTo(final ObjectMapper objectMapper);
// 
// 	/**
// 	 * Parses the given Object.
// 	 * 
// 	 * @param obj Object to be parsed.
// 	 * @return a JSON format String of the parsed Object
// 	 * @throws JsonProcessingException
// 	 */
// 	String parseObject(final Object obj) throws JsonProcessingException;
// }


// Path: src/main/java/net/imagej/server/resources/ModulesResource.java
import com.codahale.metrics.annotation.Timed;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response.Status;
import net.imagej.ops.Initializable;
import net.imagej.server.WebCommandInfo;
import net.imagej.server.services.JsonService;
import org.scijava.Context;
import org.scijava.Identifiable;
import org.scijava.Priority;
import org.scijava.command.CommandInfo;
import org.scijava.module.Module;
import org.scijava.module.ModuleInfo;
import org.scijava.module.ModuleService;
import org.scijava.module.process.AbstractPreprocessorPlugin;
import org.scijava.module.process.ModulePreprocessor;
import org.scijava.module.process.PreprocessorPlugin;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.plugin.PluginInfo;
import org.scijava.plugin.PluginService;
import org.scijava.widget.InputHarvester;

/*
 * #%L
 * ImageJ server for RESTful access to ImageJ.
 * %%
 * Copyright (C) 2013 - 2016 Board of Regents of the University of
 * Wisconsin-Madison.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package net.imagej.server.resources;






/**
 * Server resource that manages module operations.
 *
 * @author Leon Yang
 */
@Path("/modules")
@Singleton
@Produces(MediaType.APPLICATION_JSON)
public class ModulesResource {

	@Parameter
	private ModuleService moduleService;

	@Parameter
	private PluginService pluginService;

	@Inject
	private JsonService jsonService;