use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class MSIServiceImpl method isMSIAPICompatibleInResc.
@Override
public boolean isMSIAPICompatibleInResc(String resource) throws DataGridConnectionRefusedException {
if (servers == null || servers.isEmpty())
getMSIInfoForAllServers();
DataGridServer server = null;
for (DataGridServer s : servers) {
for (DataGridResource dgResc : s.getResources()) {
if (resource.equals(dgResc.getName())) {
server = s;
break;
}
}
if (server != null)
break;
}
String apiVersionSupported = DataGridCoreUtils.getAPIVersion(configService.getMsiAPIVersionSupported());
String apiVersionInstalled = server != null ? DataGridCoreUtils.getAPIVersion(server.getMSIVersion()) : "";
return apiVersionSupported.equalsIgnoreCase(apiVersionInstalled);
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class TestRuleService method setUp.
@Before
public void setUp() throws JargonException, DataGridException, URISyntaxException, IOException {
// partial mocking
ruleService = spy(RuleServiceImpl.class);
MockitoAnnotations.initMocks(this);
when(configService.getIrodsHost()).thenReturn("icat.test.com");
when(configService.getMsiAPIVersionSupported()).thenReturn(msiVersion);
DataGridResource resc = new DataGridResource(1, RESOURCE, "zone", "unixfilesystem", "/test/resc/path");
resc.setHost("icat.test.com");
when(resourceService.find(anyString())).thenReturn(resc);
when(ruleService.executeRule(anyString())).thenReturn(new HashMap<>());
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class BrowseController method getAvailableRescForPath.
/**
* Get a list of resources in which an object doesn't have replicas
*
* @param model
* @return list of resources in which an object can be replicated
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "getAvailableRescForPath/")
public String getAvailableRescForPath(final Model model, @RequestParam("isUpload") final boolean isUpload) throws DataGridConnectionRefusedException {
logger.info("getAvailableRescForPath()");
Map<DataGridCollectionAndDataObject, DataGridResource> replicasMap = null;
List<DataGridResource> resources = resourceService.findFirstLevelResources();
if (!isUpload) {
for (String path : sourcePaths) {
replicasMap = cs.listReplicasByResource(path);
for (DataGridResource resc : replicasMap.values()) {
if (resources.contains(resc)) {
resources.remove(resc);
}
}
}
}
model.addAttribute("resources", resources);
return "collections/collectionsResourcesForReplica";
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceController method getResourcesMap.
private void getResourcesMap(Model model, boolean isDashboard) throws JSONException, DataGridConnectionRefusedException {
// JSON object that will have all data of resources to be displayed as a tree
logger.debug("Building JSON Tree");
JSONArray treeData = new JSONArray();
JSONObject root = new JSONObject();
root.put("name", zoneName);
root.put("icon", isDashboard ? treeImagePathForDashboard : treeImagePath);
JSONArray childrenOfRoot = new JSONArray();
dataGridResources = resourceService.findAll();
Map<String, DataGridResource> dataGridResourcesMap = buildDataGridResourcesMap(dataGridResources);
for (DataGridResource resc : dataGridResources) {
if (resc.getParent().equals(zoneName)) {
addParentToJSON(resc, root, childrenOfRoot, dataGridResourcesMap, isDashboard);
}
}
treeData.put(root);
logger.debug("JSON Tree finished");
model.addAttribute("treeData", treeData.toString());
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceController method addResource.
/**
* Add a resource to the data grid
*
* @return the template that renders the add resource from
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "/add/action/")
public String addResource(@ModelAttribute ResourceForm resourceForm, HttpServletRequest httpServletRequest, RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
String[] resourceType = httpServletRequest.getParameterMap().get("resourceType");
String[] resourceParent = httpServletRequest.getParameterMap().get("resourceParent");
String[] previousPage = httpServletRequest.getParameterMap().get("previousPage");
String type = resourceType[0];
String parent = null;
if (resourceParent != null) {
parent = resourceParent[0];
resourceForm.setParent(parent);
}
resourceForm.setType(type);
DataGridResource newDataGridResource = getDataGridResource(resourceForm);
boolean resourceCreatedSuccessfully = resourceService.createResource(newDataGridResource);
// a parent resource can be any other existing resource, but it can also be set
// as
// the zone, which means a resource has no parent.
boolean isParentSetAndDifferentFromZone = false;
if (parent != null && parent.compareTo(irodsServices.getCurrentUserZone()) != 0) {
isParentSetAndDifferentFromZone = true;
}
// child of another resource B
if (resourceCreatedSuccessfully) {
String child = newDataGridResource.getName();
if (isParentSetAndDifferentFromZone) {
resourceService.addChildToResource(parent, child);
}
}
redirectAttributes.addFlashAttribute("resourceAddedSuccessfully", resourceForm.getName());
if (previousPage[0].contains("map")) {
return "redirect:/resources/map/";
}
return "redirect:/resources/";
}
Aggregations