use of com.emc.storageos.api.service.impl.response.SearchedResRepList in project coprhd-controller by CoprHD.
the class FileSnapshotService method getProjectSearchResults.
/**
* Get search results by project alone.
*
* @return SearchedResRepList
*/
@Override
protected SearchedResRepList getProjectSearchResults(URI projectId) {
SearchedResRepList resRepList = new SearchedResRepList(getResourceType());
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getProjectFileSnapshotConstraint(projectId), resRepList);
return resRepList;
}
use of com.emc.storageos.api.service.impl.response.SearchedResRepList in project coprhd-controller by CoprHD.
the class IpInterfaceService method getOtherSearchResults.
/**
* parameter: 'ip_address' The ip address of the ipInterface
*
* @return Return a list of ipinterfaces that contains the ip address specified
* or an empty list if no match was found.
*/
@Override
protected SearchResults getOtherSearchResults(Map<String, List<String>> parameters, boolean authorized) {
SearchResults result = new SearchResults();
if (!parameters.containsKey("ip_address")) {
throw APIException.badRequests.invalidParameterSearchMissingParameter(getResourceClass().getName(), "ip_address");
}
for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
if (!entry.getKey().equals("ip_address")) {
throw APIException.badRequests.parameterForSearchCouldNotBeCombinedWithAnyOtherParameter(getResourceClass().getName(), "ip_address", entry.getKey());
}
}
String ip = parameters.get("ip_address").get(0);
// Validate that the ip_address value is not empty
ArgValidator.checkFieldNotEmpty(ip, "ip_address");
// Validate the format of the initiator port.
if (!EndpointUtility.isValidEndpoint(ip, EndpointType.IP)) {
throw APIException.badRequests.invalidParameterInvalidIP("ip_address", ip);
}
SearchedResRepList resRepList = new SearchedResRepList(getResourceType());
// Finds the IpInterface that includes the ip address specified, if any.
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getIpInterfaceIpAddressConstraint(ip), resRepList);
// Filter list based on permission
if (!authorized) {
Iterator<SearchResultResourceRep> _queryResultIterator = resRepList.iterator();
ResRepFilter<SearchResultResourceRep> resRepFilter = (ResRepFilter<SearchResultResourceRep>) getPermissionFilter(getUserFromContext(), _permissionsHelper);
SearchedResRepList filteredResRepList = new SearchedResRepList();
filteredResRepList.setResult(new FilterIterator<SearchResultResourceRep>(_queryResultIterator, resRepFilter));
result.setResource(filteredResRepList);
} else {
result.setResource(resRepList);
}
return result;
}
use of com.emc.storageos.api.service.impl.response.SearchedResRepList in project coprhd-controller by CoprHD.
the class InitiatorService method getOtherSearchResults.
/**
* parameter: 'initiator_port' The identifier of the initiator port.
*
* @return Return a list of initiator that containts the initiator port specified
* or an empty list if no match was found.
*/
@Override
protected SearchResults getOtherSearchResults(Map<String, List<String>> parameters, boolean authorized) {
SearchResults result = new SearchResults();
if (!parameters.containsKey("initiator_port")) {
throw APIException.badRequests.invalidParameterSearchMissingParameter(getResourceClass().getName(), "initiator_port");
}
for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
if (!entry.getKey().equals("initiator_port")) {
throw APIException.badRequests.parameterForSearchCouldNotBeCombinedWithAnyOtherParameter(getResourceClass().getName(), "initiator_port", entry.getKey());
}
}
String port = parameters.get("initiator_port").get(0);
// Validate that the initiator_port value is not empty
ArgValidator.checkFieldNotEmpty(port, "initiator_port");
// Validate the format of the initiator port.
if (!EndpointUtility.isValidEndpoint(port, EndpointType.SAN)) {
throw APIException.badRequests.initiatorPortNotValid();
}
SearchedResRepList resRepList = new SearchedResRepList(getResourceType());
// Finds the Initiator that includes the initiator port specified, if any.
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getInitiatorPortInitiatorConstraint(port), resRepList);
// Filter list based on permission
if (!authorized) {
Iterator<SearchResultResourceRep> _queryResultIterator = resRepList.iterator();
ResRepFilter<SearchResultResourceRep> resRepFilter = (ResRepFilter<SearchResultResourceRep>) getPermissionFilter(getUserFromContext(), _permissionsHelper);
SearchedResRepList filteredResRepList = new SearchedResRepList();
filteredResRepList.setResult(new FilterIterator<SearchResultResourceRep>(_queryResultIterator, resRepFilter));
result.setResource(filteredResRepList);
} else {
result.setResource(resRepList);
}
return result;
}
use of com.emc.storageos.api.service.impl.response.SearchedResRepList in project coprhd-controller by CoprHD.
the class ExportService method searchInDb.
// Sometimes there are multiple entries for the same initiator
// and so we return a list here
private Boolean searchInDb(String port, List<Initiator> list, String protocol) {
SearchedResRepList resRepList = new SearchedResRepList(ResourceTypeEnum.INITIATOR);
Boolean found = false;
String formattedStr = "";
if (protocol.equalsIgnoreCase(Protocol.FC.name())) {
int index = 0;
while (index < (port.length())) {
formattedStr += port.substring(index, index + 2).toUpperCase();
index = index + 2;
if (index < (port.length())) {
formattedStr += ":";
}
}
} else if (protocol.equalsIgnoreCase(Protocol.iSCSI.name())) {
formattedStr = port;
}
// Finds the Initiator that includes the initiator port specified, if any.
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getInitiatorPortInitiatorConstraint(formattedStr), resRepList);
if (resRepList.iterator() != null) {
for (SearchResultResourceRep res : resRepList) {
Initiator initiator = _dbClient.queryObject(Initiator.class, res.getId());
if ((initiator != null) && !(initiator.getInactive())) {
list.add(initiator);
_log.info("Found initiator in DB for port = {}", port);
found = true;
}
}
}
return found;
}
use of com.emc.storageos.api.service.impl.response.SearchedResRepList in project coprhd-controller by CoprHD.
the class TaggedResource method getNamedSearchResults.
/**
* Get search results by name in zone (default) or in a specific project.
*
* @return SearchedResRepList
*/
protected SearchedResRepList getNamedSearchResults(String name, URI projectId) {
SearchedResRepList resRepList = null;
if (projectId == null) {
resRepList = new SearchedResRepList(getResourceType());
_dbClient.queryByConstraint(PrefixConstraint.Factory.getLabelPrefixConstraint(getResourceClass(), name), resRepList);
} else {
throw APIException.badRequests.parameterNotSupportedFor("project-level search", MessageFormat.format("{0} search", getResourceClass().getName()));
}
return resRepList;
}
Aggregations