syncControllers.add(aggregationSyncController);
} catch (Exception exc) {
-
- exc.printStackTrace();
-
LOG.error(AaiUiMsgs.ERROR_GENERIC,
"Failed to build aggregation sync controller. Error : " + exc.getMessage());
}
import com.fasterxml.jackson.databind.node.ArrayNode;
/**
- * The Class AutosuggestionSynchronizer.
+ * The Class AggregationSynchronizer.
*/
public class AggregationSynchronizer extends AbstractEntitySynchronizer
implements IndexSynchronizer {
* syncs
*/
retryLimitTracker.clear();
-
+ } catch (InterruptedException e) {
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
} catch (Exception exc) {
// TODO -> LOG, waht should be logged here?
}
boolean isRetryAllowed = true;
if (retryLimitTracker.get(id) != null) {
Integer currentCount = retryLimitTracker.get(id);
- if (currentCount.intValue() >= RETRY_COUNT_PER_ENTITY_LIMIT.intValue()) {
+ if (currentCount >= RETRY_COUNT_PER_ENTITY_LIMIT) {
isRetryAllowed = false;
String message = "Aggregation entity re-sync limit reached for " + id
+ ", re-sync will no longer be attempted for this entity";
LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
} else {
- Integer newCount = new Integer(currentCount.intValue() + 1);
+ Integer newCount = currentCount + 1;
retryLimitTracker.put(id, newCount);
}
} else {
- Integer firstRetryCount = new Integer(1);
+ Integer firstRetryCount = 1;
retryLimitTracker.put(id, firstRetryCount);
}
* syncs
*/
retryLimitTracker.clear();
-
+ } catch (InterruptedException e) {
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
} catch (Exception exc) {
LOG.error(AaiUiMsgs.ERROR_GENERIC,
"An error occurred while performing the sync. Error: " + exc.getMessage());
syncEntity();
}
Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
} catch (Exception exc) {
// We don't care about this exception
}
* syncs
*/
retryLimitTracker.clear();
-
+ } catch (InterruptedException e) {
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
} catch (Exception exc) {
LOG.error(AaiUiMsgs.ERROR_GENERIC,
"An error occurred during entity synchronization. Error: " + exc.getMessage());
// package protected for test classes instead of private
OperationResult queryActiveInventory(String url, String acceptContentType, String uiRequestType) {
- if (uiRequestType == UI_REQUEST_TYPE) {
+ if (UI_REQUEST_TYPE.equals(uiRequestType)) {
messageHeaders = getMessageHeaders();
} else {
messageHeaders = getSyncMessageHeaders();
* @throws IOException if the properties failed to load.
*/
private void setConfigurationProperties(FilterConfig filterConfig) throws IOException {
- InputStream inputStream = new FileInputStream(SparkyConstants.CONFIG_HOME
- + filterConfig.getInitParameter(FILTER_PARAMETER_CONFIG));
- Properties cspProperties = new Properties();
- cspProperties.load(inputStream);
- globalLoginUrl = cspProperties.getProperty(PROPERTY_GLOBAL_LOGIN_URL);
- applicationId = cspProperties.getProperty(PROPERTY_APPLICATION_ID);
- gateKeeperEnvironment = cspProperties.getProperty(PROPERTY_GATEKEEPER_ENVIRONMENT);
- redirectDomains = Arrays.asList(cspProperties.getProperty(PROPERTY_REDIRECT_DOMAINS).split(","));
+ try (InputStream inputStream = new FileInputStream(SparkyConstants.CONFIG_HOME
+ + filterConfig.getInitParameter(FILTER_PARAMETER_CONFIG))) {
+ Properties cspProperties = new Properties();
+ cspProperties.load(inputStream);
+ globalLoginUrl = cspProperties.getProperty(PROPERTY_GLOBAL_LOGIN_URL);
+ applicationId = cspProperties.getProperty(PROPERTY_APPLICATION_ID);
+ gateKeeperEnvironment = cspProperties.getProperty(PROPERTY_GATEKEEPER_ENVIRONMENT);
+ redirectDomains =
+ Arrays.asList(cspProperties.getProperty(PROPERTY_REDIRECT_DOMAINS).split(","));
+ }
}
/**
public void editUser(String loginId, EcompUser user) throws PortalAPIException {
LOG.debug("Edit user [loginId:" + loginId + "]");
- userManager.getUser(loginId).orElseThrow(() -> {
+ EcompUser eUser = userManager.getUser(loginId).orElseThrow(() -> {
String message = getMessage(ERROR_MESSAGE, "edit", loginId) + ", unknown user";
LOG.error(message);
return new PortalAPIException(message);
lic.setMessageType(subscriptionConf.getLaunchOIMessageType());
} catch (Exception e) {
// TODO Auto-generated catch block
- e.printStackTrace();
- }
+ }
}
}
* @throws Exception the exception
*/
public static Properties loadConfig(String fileName) throws Exception {
-
String basePath = System.getProperty("user.dir");
- InputStream fileInputStream = new FileInputStream(basePath + "//" + fileName);
-
- Properties props = new Properties();
- props.load(fileInputStream);
-
- return props;
+ try (InputStream fileInputStream = new FileInputStream(basePath + "//" + fileName)) {
+ Properties props = new Properties();
+ props.load(fileInputStream);
+ return props;
+ }
}
/**
public static Properties loadConfigFromExplicitPath(String fileName) {
Properties props = new Properties();
-
- try {
- InputStream fileInputStream = new FileInputStream(fileName);
+ try (InputStream fileInputStream = new FileInputStream(fileName)) {
props.load(fileInputStream);
} catch (Exception exc) {
LOG.warn(AaiUiMsgs.CONFIG_NOT_FOUND_VERBOSE, fileName, exc.getLocalizedMessage());
}
-
return props;
}
public class Encryptor {
private static final Logger LOG = LoggerFactory.getInstance().getLogger(Encryptor.class);
- private static final String PWD_OBFUSCATION_PATTERN = "OBF:";
+ private static final String START_OBFUSCATION_PATTERN = "OBF:";
/**
* Instantiates a new encryptor.
public String decryptValue(String value) {
String decyptedValue = "";
try {
- decyptedValue = value.startsWith(PWD_OBFUSCATION_PATTERN)? Password.deobfuscate(value) : value;
+ decyptedValue = value.startsWith(START_OBFUSCATION_PATTERN)? Password.deobfuscate(value) : value;
} catch (Exception exc) {
LOG.error(AaiUiMsgs.DECRYPTION_ERROR, value, exc.toString());
}
private static SecureRandom sRandom = new SecureRandom();
private static final Pattern URL_VERSION_PREFIX = Pattern.compile("/v[0-9]+/(.*)");
- private static final Pattern OXM_VERSION_PREFIX = Pattern.compile(".*_v([0-9]+).*");
+ private static final Pattern OXM_VERSION_PREFIX = Pattern.compile(".{0,256}_v([0-9]{1,5})[^_]*");
private static final Pattern GIZMO_VERSION_PREFIX = Pattern.compile("[/]*services/inventory/v[0-9]+/(.*)");
private static final Pattern GIZMO_RELATIONSHIP_VERSION_PREFIX = Pattern.compile("services/inventory/relationships/v[0-9]+/(.*)");
return null;
- }
-
-
+ }
+
public static String extractRawPathWithoutVersion(String selfLinkUri) {
try {
try {
gizmoEntity = mapper.readValue(ain.getOpResult().getResult(), GizmoEntity.class);
} catch (Exception exc) {
- exc.printStackTrace();
LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR, "Failed to marshal json"
+ " response str into JsonNode with error, " + exc.getLocalizedMessage());
ain.changeState(NodeProcessingState.ERROR,
public void addQueryParams(Collection<String> params) {
- if (params != null & params.size() > 0) {
+ if (params != null && params.size() > 0) {
for (String param : params) {
addQueryParam(param);
* syncs
*/
retryLimitTracker.clear();
-
+ } catch (InterruptedException e) {
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
} catch (Exception exc) {
// TODO -> LOG, waht should be logged here?
}
package org.onap.aai.sparky.dal;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
networkTransaction.setOperationType(HttpMethod.PUT);
assertNotNull(networkTransaction.getOperationType());
networkTransaction.setTaskAgeInMs();
- assertNotNull(networkTransaction.getTaskAgeInMs());
networkTransaction.setEntityType("searchedNodeClass");
assertNotNull(networkTransaction.getEntityType());
networkTransaction.setLink("/etc/aaiEntityNodeDescriptors.json");
package org.onap.aai.sparky.search;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
public void updateValues() {
entityTypeSummaryBucket.setTotalChartHits(8);
- assertNotNull(entityTypeSummaryBucket.getTotalChartHits());
+ assertEquals(8,entityTypeSummaryBucket.getTotalChartHits());
entityTypeSummaryBucket.setBuckets(bucketList);
assertNotNull(entityTypeSummaryBucket.getBuckets());
entityTypeSummaryBucket.addBucket(bucket);
import java.util.ArrayList;
import static org.junit.Assert.*;
+import static org.junit.Assert.assertNull;
public class EcompSsoTest {
Mockito.when(portalRestCentralServiceImpl.getUserRoles(Mockito.anyString()))
.thenReturn(new ArrayList<EcompRole>());
- assertNotNull(ecompSso.validateUserAccess("ui_view"));
+ assertFalse(ecompSso.validateUserAccess("ui_view"));
}
@Test
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
Mockito.when(request.getCookies()).thenReturn(cookies);
Cookie result = EcompSso.getCookie(request, testCookieName + "1");
+ assertNotNull(result);
assertEquals(cookie1.getName(), result.getName());
assertEquals(cookie1.getValue(), result.getValue());
assertNull(EcompSso.getCookie(request, testCookieName + "3"));
@Test
public void updateValues() {
-
-
-
-
-
syncControllerConfig.setNumInternalSyncWorkers(3);
assertEquals(3,syncControllerConfig.getNumInternalSyncWorkers());
syncControllerConfig.setNumSyncElasticWorkers(5);
assertTrue(syncControllerConfig.isRunOnceSyncEnabled());
syncControllerConfig.setPeriodicSyncEnabled(true);
assertTrue(syncControllerConfig.isPeriodicSyncEnabled());
- assertNotNull(syncControllerConfig.getSyncFrequencyInMs());
+ assertEquals(259200000,syncControllerConfig.getSyncFrequencyInMs());
assertNotNull(syncControllerConfig.getTargetSyncTime());
assertNotNull(syncControllerConfig.getNextSyncTime());
syncControllerConfig.setTimeZoneOfSyncStartTimeStamp("UTC+00:00");
Thread.sleep(10000L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
System.out.println("Sync done with thread = " + Thread.currentThread().getName()
package org.onap.aai.sparky.util;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
assertNotNull(nodeUtils.buildDepthPadding(2));
- assertNotNull(nodeUtils.isNumeric("234"));
+ assertTrue(nodeUtils.isNumeric("234"));
assertNull(nodeUtils.calculateEditAttributeUri(null));
assertNotNull(nodeUtils.generateUniqueShaDigest("unique-101"));
assertNull(nodeUtils.getNodeFieldAsText(jsonNode,""));
}
+
+ @Test
+ public void extractOxmVersionFromPath() {
+ assertEquals("8",NodeUtils.extractOxmVersionFromPath("test_oxm_v8.xml"));
+ assertEquals("9",NodeUtils.extractOxmVersionFromPath("test_oxm_v9.xml"));
+ assertEquals("11",NodeUtils.extractOxmVersionFromPath("test_oxm_v11.xml"));
+ assertEquals("11",NodeUtils.extractOxmVersionFromPath("test_oxm_v11.json"));
+ assertEquals("11",NodeUtils.extractOxmVersionFromPath("test_oxm_v11other.json"));
+ assertEquals("11",NodeUtils.extractOxmVersionFromPath("/path_v10/test_oxm_v11.xml"));
+ assertEquals("11",NodeUtils.extractOxmVersionFromPath("\\pathv10\\test_oxm_v11.xml"));
+ }
}