Search in sources :

Example 1 with RepositoryInstance

use of com.dexels.navajo.repository.api.RepositoryInstance in project navajo by Dexels.

the class BundleQueueComponent method checkForChangedScripts.

private void checkForChangedScripts(Event e, String folder) {
    RepositoryInstance ri = (RepositoryInstance) e.getProperty("repository");
    Set<String> changedScripts = new HashSet<>(RepositoryEventParser.filterChanged(e, folder));
    for (String changedScript : changedScripts) {
        // Replace windows backslashes with normal ones
        changedScript = changedScript.replace("\\", "/");
        try {
            File location = new File(ri.getRepositoryFolder(), changedScript);
            if (location.isFile()) {
                String stripped = changedScript.substring(folder.length());
                int dotIndex = stripped.lastIndexOf('.');
                if (dotIndex < 0) {
                    logger.info("Scripts need an extension, and {} has none. Ignoring update.", stripped);
                    continue;
                }
                String scriptName = stripped.substring(0, dotIndex);
                String extension = stripped.substring(dotIndex, stripped.length());
                if (!SUPPORTED_EXTENSIONS.contains(extension)) {
                    logger.info("Ignoring file update {} due to non-matching extension: {} ", scriptName, extension);
                    continue;
                }
                if (scriptName.endsWith("entitymapping")) {
                    continue;
                }
                enqueueScript(scriptName, changedScript);
            }
        } catch (IllegalArgumentException e1) {
            logger.warn("Error in handling changed script {}: {}", changedScript, e1);
        }
    }
}
Also used : RepositoryInstance(com.dexels.navajo.repository.api.RepositoryInstance) File(java.io.File) HashSet(java.util.HashSet)

Example 2 with RepositoryInstance

use of com.dexels.navajo.repository.api.RepositoryInstance in project navajo by Dexels.

the class TestHttpResource method setUp.

@Before
public void setUp() throws Exception {
    this.access = new Access();
    access.setTenant("MYTENANT");
    factory = new HttpResourceFactory();
    component = new ResourceComponent();
    RepositoryInstance instance = createStubInstance("test");
    component.setRepositoryInstance(instance);
    Map<String, Object> settings = new HashMap<String, Object>();
    String url = TestConfig.HTTP_TEST_URL.getValue();
    Assert.assertNotNull(url);
    settings.put("url", url);
    settings.put("name", "binstore");
    settings.put("authorization", TestConfig.HTTP_TEST_TOKEN.getValue());
    settings.put("secret", TestConfig.HTTP_TEST_SECRET.getValue());
    settings.put("expire", "120");
    component.activate(settings);
    factory.addHttpResource(component, settings);
    factory.activate();
}
Also used : ResourceComponent(com.dexels.navajo.resource.http.impl.ResourceComponent) HashMap(java.util.HashMap) RepositoryInstance(com.dexels.navajo.repository.api.RepositoryInstance) Access(com.dexels.navajo.script.api.Access) Before(org.junit.Before)

Aggregations

RepositoryInstance (com.dexels.navajo.repository.api.RepositoryInstance)2 ResourceComponent (com.dexels.navajo.resource.http.impl.ResourceComponent)1 Access (com.dexels.navajo.script.api.Access)1 File (java.io.File)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Before (org.junit.Before)1