public void setState(ManagedIndexState state){ if(state == null){ throw new IllegalArgumentException("The parsed ManagedIndexState MUST NOT be NULL!"); } setProperty(STATE, state.name()); if(state != ManagedIndexState.ERROR){ remove(STACK_TRACE); } } /**
public ManagedIndexState getState(){ String state = getProperty(STATE); if(state == null){ log.warn("No ManagedIndexState (key: '"+STATE+"') present in the" + "IndexMetadata for '"+getIndexReference()+"'! -> return null"); return null; } else { try { return ManagedIndexState.valueOf(state); } catch (IllegalArgumentException e) { log.error("Unable to parse ManagedIndexState from value '"+ state+"'! -> return null",e); return null; } } } /**
private ManagedIndexMetadata(String serverName, String pid,ComponentContext context){ this.serverName = serverName; this.pid = pid; //this.context = context; //init the Maps for manageing Indexes with the different states for(ManagedIndexState state : ManagedIndexState.values()){ managed.put(state, new HashMap<String,IndexMetadata>()); } File dir = null; if(context != null){ dir = context.getBundleContext().getDataFile(DEFAULT_INDEX_CONFIG_DIR+'/'+pid); //dir might be null if the OSGI environment is missing file system support } if (dir == null) { //outside OSGI or OSGI has no file system support // use config directory relative to the the Managed Solr Directory dir = new File(DEFAULT_INDEX_CONFIG_DIR,pid).getAbsoluteFile(); } log.info("SolrYard Config Directory: "+dir); this.configDir = dir; } /**
public void setState(ManagedIndexState state){ if(state == null){ throw new IllegalArgumentException("The parsed ManagedIndexState MUST NOT be NULL!"); } setProperty(STATE, state.name()); if(state != ManagedIndexState.ERROR){ remove(STACK_TRACE); } } /**
private ManagedIndexMetadata(String serverName, String pid,ComponentContext context){ this.serverName = serverName; this.pid = pid; //this.context = context; //init the Maps for manageing Indexes with the different states for(ManagedIndexState state : ManagedIndexState.values()){ managed.put(state, new HashMap<String,IndexMetadata>()); } File dir = null; if(context != null){ dir = context.getBundleContext().getDataFile(DEFAULT_INDEX_CONFIG_DIR+'/'+pid); //dir might be null if the OSGI environment is missing file system support } if (dir == null) { //outside OSGI or OSGI has no file system support // use config directory relative to the the Managed Solr Directory dir = new File(DEFAULT_INDEX_CONFIG_DIR,pid).getAbsoluteFile(); } log.info("SolrYard Config Directory: "+dir); this.configDir = dir; } /**
public ManagedIndexState getState(){ String state = getProperty(STATE); if(state == null){ log.warn("No ManagedIndexState (key: '"+STATE+"') present in the" + "IndexMetadata for '"+getIndexReference()+"'! -> return null"); return null; } else { try { return ManagedIndexState.valueOf(state); } catch (IllegalArgumentException e) { log.error("Unable to parse ManagedIndexState from value '"+ state+"'! -> return null",e); return null; } } } /**
desiredState.name(), metadata.getArchive()}); switch (desiredState) { case ACTIVE:
/** * validates the values of the IndexProperties * @throws IOException */ private void validate(boolean store) throws IOException { if(isSynchronized() && getIndexArchives().isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Synchronized=true and no Index-Archives are defined!"); } ManagedIndexState state = getState(); if(state == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexMetadata without the required key '"+STATE+ "' set to one of the values '"+ Arrays.toString(ManagedIndexState.values())+"'!"); } if(isActive()){ if(getDirectory() == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Active=true and no Directory is defined!"); } } String name = getIndexName(); if(name == null || name.isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where the required key '"+ INDEX_NAME+"' is not defined or empty!"); } }
desiredState.name(), metadata.getArchive()}); switch (desiredState) { case ACTIVE:
/** * validates the values of the IndexProperties * @throws IOException */ private void validate(boolean store) throws IOException { if(isSynchronized() && getIndexArchives().isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Synchronized=true and no Index-Archives are defined!"); } ManagedIndexState state = getState(); if(state == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexMetadata without the required key '"+STATE+ "' set to one of the values '"+ Arrays.toString(ManagedIndexState.values())+"'!"); } if(isActive()){ if(getDirectory() == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Active=true and no Directory is defined!"); } } String name = getIndexName(); if(name == null || name.isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where the required key '"+ INDEX_NAME+"' is not defined or empty!"); } }