List of usage examples for java.lang Byte valueOf
public static Byte valueOf(String s) throws NumberFormatException
From source file:com.datatorrent.lib.appdata.gpo.GPOUtils.java
public static Map<String, Object> getDestringedData(FieldsDescriptor fd, Map<String, String> stringMap) { Map<String, Object> fieldToData = Maps.newHashMap(); Map<String, Type> fieldToType = fd.getFieldToType(); for (Map.Entry<String, String> entry : stringMap.entrySet()) { Object objValue;/*from w w w. j a va 2 s. co m*/ String valueString = entry.getValue(); Type valueType = fieldToType.get(entry.getKey()); switch (valueType) { case BOOLEAN: { objValue = Boolean.valueOf(valueString); break; } case BYTE: { objValue = Byte.valueOf(valueString); break; } case SHORT: { objValue = Short.valueOf(valueString); break; } case INTEGER: { objValue = Integer.valueOf(valueString); break; } case LONG: { objValue = Long.valueOf(valueString); break; } case FLOAT: { objValue = Float.valueOf(valueString); break; } case DOUBLE: { objValue = Double.valueOf(valueString); break; } case STRING: { objValue = valueString; break; } case OBJECT: throw new UnsupportedOperationException("The given type " + entry.getValue() + " is unsupported."); default: throw new UnsupportedOperationException("The given type " + entry.getValue() + " is unsupported."); } fieldToData.put(entry.getKey(), objValue); } return fieldToData; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.AbstractDataset.java
private Number fromDoubleToNumber(double x) { switch (getDtype()) { case BOOL:/*w w w . ja v a 2 s .c om*/ case INT32: return Integer.valueOf((int) x); case INT8: return Byte.valueOf((byte) x); case INT16: return Short.valueOf((short) x); case INT64: return Long.valueOf((long) x); case FLOAT32: return Float.valueOf((float) x); case FLOAT64: return Double.valueOf(x); } return null; }
From source file:com.ah.be.admin.restoredb.RestoreAdmin.java
/** * Get all information from mail_notification table * * @return List<MailNotification> all MailNotification BO * @throws AhRestoreColNotExistException * - if mail_notification.xml is not exist. * @throws AhRestoreException// ww w . java 2 s . c om * - if error in parsing mail_notification.xml. */ public static List<MailNotification> getAllEmailNotficationSettings() throws Exception { AhRestoreGetXML xmlParser = new AhRestoreGetXML(); /** * Check validation of schedule_backup.xml */ boolean restoreRet = xmlParser.readXMLFile("mail_notification"); if (!restoreRet) { return null; } /** * No one row data stored in local_user table is allowed */ int rowCount = xmlParser.getRowCount(); List<MailNotification> notifications = new ArrayList<MailNotification>(); boolean isColPresent; String colName; MailNotification notification; for (int i = 0; i < rowCount; i++) { notification = new MailNotification(); /** * Set servername */ colName = "servername"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String serverName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; notification.setServerName(serverName); /** * Set mailfrom */ colName = "mailfrom"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String mailFrom = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; notification.setMailFrom(mailFrom); /** * Set mailto */ colName = "mailto"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String mailTo = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; notification.setMailTo(mailTo); /** * idp comment: add this field in 3.4r2 */ colName = "inNetIdp"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { boolean inNetIdp = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setInNetIdp(inNetIdp); } /** * vpn comment: add this field in 3.4 */ colName = "vpn"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { boolean vpn = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setVpn(vpn); } else { fromPreTo3dot4 = true; } /** * airscreen comment: add this field in 3.4 */ colName = "airScreen"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { boolean airScreen = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setAirScreen(airScreen); } /** * Set hdCpu */ colName = "hdcpu"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { if (fromPreTo3dot4) { int hdCpu = AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)); notification.setHdCpu(hdCpu > 0); } else { boolean hdCpu = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setHdCpu(hdCpu); } } /** * Set hdMemory */ colName = "hdmemory"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { if (fromPreTo3dot4) { int hdMemory = AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)); notification.setHdMemory(hdMemory > 0); } else { boolean hdMemory = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setHdMemory(hdMemory); } } /** * Set auth */ colName = "auth"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { if (fromPreTo3dot4) { int auth = AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)); notification.setAuth(auth > 0); } else { boolean auth = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setAuth(auth); } } /** * Set interfaceValue */ colName = "interfacevalue"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { if (fromPreTo3dot4) { int interfaceValue = AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)); notification.setInterfaceValue(interfaceValue > 0); } else { boolean interfaceValue = AhRestoreCommons .convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setInterfaceValue(interfaceValue); } } /** * Set clientMonitor */ colName = "clientMonitor"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { boolean clientMonitor = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setClientMonitor(clientMonitor); } /** * Set clientRegister */ colName = "clientRegister"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { boolean clientRegister = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setClientRegister(clientRegister); } /** * Set l2Dos */ colName = "l2dos"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { if (fromPreTo3dot4) { int l2DOS = AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)); notification.setL2Dos(l2DOS > 0); } else { boolean l2DOS = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setL2Dos(l2DOS); } } /** * Set screen */ colName = "screen"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { if (fromPreTo3dot4) { int screen = AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)); notification.setScreen(screen > 0); } else { boolean screen = AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setScreen(screen); } } /** * Set hdRadio */ colName = "hdradio"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String hdRadio = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "16"; notification.setHdRadio(Byte.valueOf(hdRadio)); /** * Set capWap */ colName = "capwap"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String capWap = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "29"; notification.setCapWap(Byte.valueOf(capWap)); /** * Set ad */ colName = "ad"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String ad = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "9"; notification.setAd(Byte.valueOf(ad)); /** * Set tca */ colName = "tca"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String tca = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "17"; notification.setTca(Byte.valueOf(tca)); /** * Set security */ colName = "security"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String security = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "8"; notification.setSecurity(Byte.valueOf(security)); /** * Set config */ colName = "config"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String config = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "8"; notification.setConfig(Byte.valueOf(config)); /** * Set System */ colName = "system"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String system = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "9"; notification.setSystem(Byte.valueOf(system)); /** * Set timeBomb */ colName = "timeBomb"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String timeBomb = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "28"; notification.setTimeBomb(Byte.valueOf(timeBomb)); /** * Set client */ colName = "client"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String client = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "5"; notification.setClient(Byte.valueOf(client)); /** * Set sendMailFlag */ colName = "sendmailflag"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); boolean sendMailFlag = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setSendMailFlag(sendMailFlag); /** * Set supportSSL */ colName = "supportSSL"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); boolean supportSSL = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setSupportSSL(supportSSL); /** * Set supportTLS */ colName = "supportTLS"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); boolean supportTLS = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setSupportTLS(supportTLS); /** * Set port */ colName = "port"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); if (isColPresent) { notification.setPort(AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName))); } else { if (supportSSL) { notification.setPort(465); } } /** * Set supportPwdAuth */ colName = "supportPwdAuth"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); boolean supportPwdAuth = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); notification.setSupportPwdAuth(supportPwdAuth); /** * Set emailUserName */ colName = "emailUserName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String emailUserName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; notification.setEmailUserName(emailUserName); /** * Set emailPassword */ colName = "emailPassword"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); String emailPassword = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; notification.setEmailPassword(emailPassword); /** * Set owner */ colName = "owner"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, "mail_notification", colName); long ownerId = isColPresent ? AhRestoreCommons.convertLong(xmlParser.getColVal(i, colName)) : 1; if (null == AhRestoreNewMapTools.getHmDomain(ownerId)) { BeLogTools.debug(HmLogConst.M_RESTORE, "Restore table 'mail_notification' data be lost, cause: 'owner' column is not available."); continue; } notification.setOwner(AhRestoreNewMapTools.getHmDomain(ownerId)); if (null == notification.getOwner()) continue; notifications.add(notification); } return !notifications.isEmpty() ? notifications : null; }
From source file:org.openbaton.clients.interfaces.client.openstack.OpenstackClient.java
private static String translateToNAT(String floatingIp) throws UnknownHostException { Properties natRules = new Properties(); try {// w ww . j av a 2 s . c om File file = new File("/etc/openbaton/plugin/openstack/nat-translation-rules.properties"); if (file.exists()) { natRules.load(new FileInputStream(file)); } else { natRules.load(OpenstackClient.class.getResourceAsStream("/nat-translation-rules.properties")); } } catch (IOException e) { log.warn("no translation rules!"); return floatingIp; } for (Map.Entry<Object, Object> entry : natRules.entrySet()) { String fromCidr = (String) entry.getKey(); String toCidr = (String) entry.getValue(); log.debug("cidr is: " + fromCidr); SubnetUtils utilsFrom = new SubnetUtils(fromCidr); SubnetUtils utilsTo = new SubnetUtils(toCidr); SubnetUtils.SubnetInfo subnetInfoFrom = utilsFrom.getInfo(); SubnetUtils.SubnetInfo subnetInfoTo = utilsTo.getInfo(); InetAddress floatingIpNetAddr = InetAddress.getByName(floatingIp); if (subnetInfoFrom.isInRange(floatingIp)) { //translation! log.debug("From networkMask " + subnetInfoFrom.getNetmask()); log.debug("To networkMask " + subnetInfoTo.getNetmask()); if (!subnetInfoFrom.getNetmask().equals(subnetInfoTo.getNetmask())) { log.error("Not translation possible, netmasks are different"); return floatingIp; } byte[] host = new byte[4]; for (int i = 0; i < floatingIpNetAddr.getAddress().length; i++) { byte value = (byte) (floatingIpNetAddr.getAddress()[i] | InetAddress.getByName(subnetInfoFrom.getNetmask()).getAddress()[i]); if (value == -1) { host[i] = 0; } else { host[i] = value; } } byte[] netaddress = InetAddress.getByName(subnetInfoTo.getNetworkAddress()).getAddress(); String[] result = new String[4]; for (int i = 0; i < netaddress.length; i++) { int intValue = new Byte((byte) (netaddress[i] | Byte.valueOf(host[i]))).intValue(); if (intValue < 0) { intValue = intValue & 0xFF; } result[i] = String.valueOf(intValue); } return StringUtils.join(result, "."); } } return floatingIp; }
From source file:org.apache.sysml.lops.compile.Dag.java
/** * Method to generate MapReduce job instructions from a given set of nodes. * //from www . ja v a 2 s . c o m * @param execNodes list of exec nodes * @param inst list of instructions * @param writeinst list of write instructions * @param deleteinst list of delete instructions * @param rmvarinst list of rmvar instructions * @param jt job type * @throws LopsException if LopsException occurs * @throws DMLRuntimeException if DMLRuntimeException occurs */ private void generateMapReduceInstructions(ArrayList<Lop> execNodes, ArrayList<Instruction> inst, ArrayList<Instruction> writeinst, ArrayList<Instruction> deleteinst, ArrayList<Instruction> rmvarinst, JobType jt) throws LopsException, DMLRuntimeException { ArrayList<Byte> resultIndices = new ArrayList<Byte>(); ArrayList<String> inputs = new ArrayList<String>(); ArrayList<String> outputs = new ArrayList<String>(); ArrayList<InputInfo> inputInfos = new ArrayList<InputInfo>(); ArrayList<OutputInfo> outputInfos = new ArrayList<OutputInfo>(); ArrayList<Long> numRows = new ArrayList<Long>(); ArrayList<Long> numCols = new ArrayList<Long>(); ArrayList<Long> numRowsPerBlock = new ArrayList<Long>(); ArrayList<Long> numColsPerBlock = new ArrayList<Long>(); ArrayList<String> mapperInstructions = new ArrayList<String>(); ArrayList<String> randInstructions = new ArrayList<String>(); ArrayList<String> recordReaderInstructions = new ArrayList<String>(); int numReducers = 0; int replication = 1; ArrayList<String> inputLabels = new ArrayList<String>(); ArrayList<String> outputLabels = new ArrayList<String>(); ArrayList<Instruction> renameInstructions = new ArrayList<Instruction>(); ArrayList<Instruction> variableInstructions = new ArrayList<Instruction>(); ArrayList<Instruction> postInstructions = new ArrayList<Instruction>(); ArrayList<Integer> MRJobLineNumbers = null; if (DMLScript.ENABLE_DEBUG_MODE) { MRJobLineNumbers = new ArrayList<Integer>(); } ArrayList<Lop> inputLops = new ArrayList<Lop>(); boolean cellModeOverride = false; /* Find the nodes that produce an output */ ArrayList<Lop> rootNodes = new ArrayList<Lop>(); getOutputNodes(execNodes, rootNodes, jt); if (LOG.isTraceEnabled()) LOG.trace("# of root nodes = " + rootNodes.size()); /* Remove transient writes that are simple copy of transient reads */ if (jt == JobType.GMR || jt == JobType.GMRCELL) { ArrayList<Lop> markedNodes = new ArrayList<Lop>(); // only keep data nodes that are results of some computation. for (Lop rnode : rootNodes) { if (rnode.getExecLocation() == ExecLocation.Data && ((Data) rnode).isTransient() && ((Data) rnode).getOperationType() == OperationTypes.WRITE && ((Data) rnode).getDataType() == DataType.MATRIX) { // no computation, just a copy if (rnode.getInputs().get(0).getExecLocation() == ExecLocation.Data && ((Data) rnode.getInputs().get(0)).isTransient() && rnode.getOutputParameters() .getLabel().equals(rnode.getInputs().get(0).getOutputParameters().getLabel())) { markedNodes.add(rnode); } } } // delete marked nodes rootNodes.removeAll(markedNodes); markedNodes.clear(); if (rootNodes.isEmpty()) return; } // structure that maps node to their indices that will be used in the instructions HashMap<Lop, Integer> nodeIndexMapping = new HashMap<Lop, Integer>(); /* Determine all input data files */ for (Lop rnode : rootNodes) { getInputPathsAndParameters(rnode, execNodes, inputs, inputInfos, numRows, numCols, numRowsPerBlock, numColsPerBlock, nodeIndexMapping, inputLabels, inputLops, MRJobLineNumbers); } // In case of RAND job, instructions are defined in the input file if (jt == JobType.DATAGEN) randInstructions = inputs; int[] start_index = new int[1]; start_index[0] = inputs.size(); /* Get RecordReader Instructions */ // currently, recordreader instructions are allowed only in GMR jobs if (jt == JobType.GMR || jt == JobType.GMRCELL) { for (Lop rnode : rootNodes) { getRecordReaderInstructions(rnode, execNodes, inputs, recordReaderInstructions, nodeIndexMapping, start_index, inputLabels, inputLops, MRJobLineNumbers); if (recordReaderInstructions.size() > 1) throw new LopsException("MapReduce job can only have a single recordreader instruction: " + recordReaderInstructions.toString()); } } /* * Handle cases when job's output is FORCED to be cell format. * - If there exist a cell input, then output can not be blocked. * Only exception is when jobType = REBLOCK/CSVREBLOCK (for obvisous reason) * or when jobType = RAND since RandJob takes a special input file, * whose format should not be used to dictate the output format. * - If there exists a recordReader instruction * - If jobtype = GroupedAgg. This job can only run in cell mode. */ // if (jt != JobType.REBLOCK && jt != JobType.CSV_REBLOCK && jt != JobType.DATAGEN && jt != JobType.TRANSFORM) { for (int i = 0; i < inputInfos.size(); i++) if (inputInfos.get(i) == InputInfo.BinaryCellInputInfo || inputInfos.get(i) == InputInfo.TextCellInputInfo) cellModeOverride = true; } if (!recordReaderInstructions.isEmpty() || jt == JobType.GROUPED_AGG) cellModeOverride = true; /* Get Mapper Instructions */ for (int i = 0; i < rootNodes.size(); i++) { getMapperInstructions(rootNodes.get(i), execNodes, inputs, mapperInstructions, nodeIndexMapping, start_index, inputLabels, inputLops, MRJobLineNumbers); } if (LOG.isTraceEnabled()) { LOG.trace(" Input strings: " + inputs.toString()); if (jt == JobType.DATAGEN) LOG.trace(" Rand instructions: " + getCSVString(randInstructions)); if (jt == JobType.GMR) LOG.trace(" RecordReader instructions: " + getCSVString(recordReaderInstructions)); LOG.trace(" Mapper instructions: " + getCSVString(mapperInstructions)); } /* Get Shuffle and Reducer Instructions */ ArrayList<String> shuffleInstructions = new ArrayList<String>(); ArrayList<String> aggInstructionsReducer = new ArrayList<String>(); ArrayList<String> otherInstructionsReducer = new ArrayList<String>(); for (Lop rn : rootNodes) { int resultIndex = getAggAndOtherInstructions(rn, execNodes, shuffleInstructions, aggInstructionsReducer, otherInstructionsReducer, nodeIndexMapping, start_index, inputLabels, inputLops, MRJobLineNumbers); if (resultIndex == -1) throw new LopsException("Unexpected error in piggybacking!"); if (rn.getExecLocation() == ExecLocation.Data && ((Data) rn).getOperationType() == Data.OperationTypes.WRITE && ((Data) rn).isTransient() && rootNodes.contains(rn.getInputs().get(0))) { // Both rn (a transient write) and its input are root nodes. // Instead of creating two copies of the data, simply generate a cpvar instruction NodeOutput out = setupNodeOutputs(rn, ExecType.MR, cellModeOverride, true); writeinst.addAll(out.getLastInstructions()); } else { resultIndices.add(Byte.valueOf((byte) resultIndex)); // setup output filenames and outputInfos and generate related instructions NodeOutput out = setupNodeOutputs(rn, ExecType.MR, cellModeOverride, false); outputLabels.add(out.getVarName()); outputs.add(out.getFileName()); outputInfos.add(out.getOutInfo()); if (LOG.isTraceEnabled()) { LOG.trace(" Output Info: " + out.getFileName() + ";" + OutputInfo.outputInfoToString(out.getOutInfo()) + ";" + out.getVarName()); } renameInstructions.addAll(out.getLastInstructions()); variableInstructions.addAll(out.getPreInstructions()); postInstructions.addAll(out.getPostInstructions()); } } /* Determine if the output dimensions are known */ byte[] resultIndicesByte = new byte[resultIndices.size()]; for (int i = 0; i < resultIndicesByte.length; i++) { resultIndicesByte[i] = resultIndices.get(i).byteValue(); } if (LOG.isTraceEnabled()) { LOG.trace(" Shuffle Instructions: " + getCSVString(shuffleInstructions)); LOG.trace(" Aggregate Instructions: " + getCSVString(aggInstructionsReducer)); LOG.trace(" Other instructions =" + getCSVString(otherInstructionsReducer)); LOG.trace(" Output strings: " + outputs.toString()); LOG.trace(" ResultIndices = " + resultIndices.toString()); } /* Prepare the MapReduce job instruction */ MRJobInstruction mr = new MRJobInstruction(jt); // check if this is a map-only job. If not, set the number of reducers if (!shuffleInstructions.isEmpty() || !aggInstructionsReducer.isEmpty() || !otherInstructionsReducer.isEmpty()) numReducers = total_reducers; // set inputs, outputs, and other other properties for the job mr.setInputOutputLabels(inputLabels.toArray(new String[0]), outputLabels.toArray(new String[0])); mr.setOutputs(resultIndicesByte); mr.setDimsUnknownFilePrefix(getFilePath()); mr.setNumberOfReducers(numReducers); mr.setReplication(replication); // set instructions for recordReader and mapper mr.setRecordReaderInstructions(getCSVString(recordReaderInstructions)); mr.setMapperInstructions(getCSVString(mapperInstructions)); //compute and set mapper memory requirements (for consistency of runtime piggybacking) if (jt == JobType.GMR) { double mem = 0; for (Lop n : execNodes) mem += computeFootprintInMapper(n); mr.setMemoryRequirements(mem); } if (jt == JobType.DATAGEN) mr.setRandInstructions(getCSVString(randInstructions)); // set shuffle instructions mr.setShuffleInstructions(getCSVString(shuffleInstructions)); // set reducer instruction mr.setAggregateInstructionsInReducer(getCSVString(aggInstructionsReducer)); mr.setOtherInstructionsInReducer(getCSVString(otherInstructionsReducer)); if (DMLScript.ENABLE_DEBUG_MODE) { // set line number information for each MR instruction mr.setMRJobInstructionsLineNumbers(MRJobLineNumbers); } /* Add the prepared instructions to output set */ inst.addAll(variableInstructions); inst.add(mr); inst.addAll(postInstructions); deleteinst.addAll(renameInstructions); for (Lop l : inputLops) { if (DMLScript.ENABLE_DEBUG_MODE) { processConsumers(l, rmvarinst, deleteinst, l); } else { processConsumers(l, rmvarinst, deleteinst, null); } } }
From source file:com.mimp.controllers.personal.java
@RequestMapping(value = "/PersonalCrearSesion", method = RequestMethod.GET) public ModelAndView PersonalCrearSesion_GET(ModelMap map, HttpSession session) { Personal usuario = (Personal) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); }/*from w ww . ja va 2s . c o m*/ String numSesion = (String) session.getAttribute("numSesion"); String fecha = (String) session.getAttribute("fecha"); String hora = (String) session.getAttribute("hora"); String duracion = (String) session.getAttribute("duracion"); String direccion = (String) session.getAttribute("direccion"); String capacitador = (String) session.getAttribute("capacitador"); String ua = (String) session.getAttribute("ua"); Sesion tempSesion = new Sesion(); tempSesion.setNSesion(numSesion); Date tempfecha = tempSesion.getFecha(); if (fecha != null) { if (fecha.contains("ene") || fecha.contains("feb") || fecha.contains("mar") || fecha.contains("abr") || fecha.contains("may") || fecha.contains("jun") || fecha.contains("jul") || fecha.contains("ago") || fecha.contains("set") || fecha.contains("oct") || fecha.contains("nov") || fecha.contains("dic")) { tempSesion.setFecha(tempfecha); } else { if (!fecha.equals("")) { tempSesion.setFecha(format.stringToDate(fecha)); } else { tempSesion.setFecha(null); } } } else { tempSesion.setFecha(null); } tempSesion.setHora(hora); tempSesion.setUnidad(ua); short habilitado = Byte.valueOf("1"); short inscritos = Byte.valueOf("0"); tempSesion.setDuracion(duracion); tempSesion.setHabilitado(habilitado); tempSesion.setDireccion(direccion); tempSesion.setFacilitador(capacitador); tempSesion.setAsistencia(inscritos); ServicioPersonal.PersonalCrearSesion(tempSesion); map.put("listaSesiones", ServicioPersonal.listaSesiones(usuario.getUnidad().getDepartamento())); map.put("listaTalleres", ServicioPersonal.listaTalleres(usuario.getUnidad().getDepartamento())); map.put("formato", format); String mensaje_log = "El usuario: " + usuario.getNombre() + " " + usuario.getApellidoP() + " con ID: " + usuario.getIdpersonal() + ". Creo una nueva Sesin informativa con nmero: " + numSesion; String Tipo_registro = "Sesin"; try { String Numero_registro = String.valueOf(numSesion); ServicioPersonal.InsertLog(usuario, Tipo_registro, Numero_registro, mensaje_log); } catch (Exception ex) { } session.removeAttribute("numSesion"); session.removeAttribute("fecha"); session.removeAttribute("hora"); session.removeAttribute("duracion"); session.removeAttribute("direccion"); session.removeAttribute("capacitador"); session.removeAttribute("ua"); return new ModelAndView("/Personal/Informativa/lista_charlas", map); }
From source file:com.ibm.bi.dml.lops.compile.Dag.java
/** * Method to generate MapReduce job instructions from a given set of nodes. * //from w w w. j a v a2 s .c o m * @param execNodes * @param inst * @param deleteinst * @param jobType * @throws LopsException * @throws DMLUnsupportedOperationException * @throws DMLRuntimeException */ @SuppressWarnings("unchecked") public void generateMapReduceInstructions(ArrayList<N> execNodes, ArrayList<Instruction> inst, ArrayList<Instruction> writeinst, ArrayList<Instruction> deleteinst, ArrayList<Instruction> rmvarinst, JobType jt) throws LopsException, DMLUnsupportedOperationException, DMLRuntimeException { ArrayList<Byte> resultIndices = new ArrayList<Byte>(); ArrayList<String> inputs = new ArrayList<String>(); ArrayList<String> outputs = new ArrayList<String>(); ArrayList<InputInfo> inputInfos = new ArrayList<InputInfo>(); ArrayList<OutputInfo> outputInfos = new ArrayList<OutputInfo>(); ArrayList<Long> numRows = new ArrayList<Long>(); ArrayList<Long> numCols = new ArrayList<Long>(); ArrayList<Long> numRowsPerBlock = new ArrayList<Long>(); ArrayList<Long> numColsPerBlock = new ArrayList<Long>(); ArrayList<String> mapperInstructions = new ArrayList<String>(); ArrayList<String> randInstructions = new ArrayList<String>(); ArrayList<String> recordReaderInstructions = new ArrayList<String>(); int numReducers = 0; int replication = 1; ArrayList<String> inputLabels = new ArrayList<String>(); ArrayList<String> outputLabels = new ArrayList<String>(); ArrayList<Instruction> renameInstructions = new ArrayList<Instruction>(); ArrayList<Instruction> variableInstructions = new ArrayList<Instruction>(); ArrayList<Instruction> postInstructions = new ArrayList<Instruction>(); ArrayList<Integer> MRJobLineNumbers = null; if (DMLScript.ENABLE_DEBUG_MODE) { MRJobLineNumbers = new ArrayList<Integer>(); } ArrayList<Lop> inputLops = new ArrayList<Lop>(); boolean cellModeOverride = false; /* Find the nodes that produce an output */ ArrayList<N> rootNodes = new ArrayList<N>(); getOutputNodes(execNodes, rootNodes, jt); if (LOG.isTraceEnabled()) LOG.trace("# of root nodes = " + rootNodes.size()); /* Remove transient writes that are simple copy of transient reads */ if (jt == JobType.GMR || jt == JobType.GMRCELL) { ArrayList<N> markedNodes = new ArrayList<N>(); // only keep data nodes that are results of some computation. for (int i = 0; i < rootNodes.size(); i++) { N node = rootNodes.get(i); if (node.getExecLocation() == ExecLocation.Data && ((Data) node).isTransient() && ((Data) node).getOperationType() == OperationTypes.WRITE && ((Data) node).getDataType() == DataType.MATRIX) { // no computation, just a copy if (node.getInputs().get(0).getExecLocation() == ExecLocation.Data && ((Data) node.getInputs().get(0)).isTransient() && node.getOutputParameters().getLabel() .compareTo(node.getInputs().get(0).getOutputParameters().getLabel()) == 0) { markedNodes.add(node); } } } // delete marked nodes rootNodes.removeAll(markedNodes); markedNodes.clear(); if (rootNodes.isEmpty()) return; } // structure that maps node to their indices that will be used in the instructions HashMap<N, Integer> nodeIndexMapping = new HashMap<N, Integer>(); /* Determine all input data files */ for (int i = 0; i < rootNodes.size(); i++) { getInputPathsAndParameters(rootNodes.get(i), execNodes, inputs, inputInfos, numRows, numCols, numRowsPerBlock, numColsPerBlock, nodeIndexMapping, inputLabels, inputLops, MRJobLineNumbers); } // In case of RAND job, instructions are defined in the input file if (jt == JobType.DATAGEN) randInstructions = inputs; int[] start_index = new int[1]; start_index[0] = inputs.size(); /* Get RecordReader Instructions */ // currently, recordreader instructions are allowed only in GMR jobs if (jt == JobType.GMR || jt == JobType.GMRCELL) { for (int i = 0; i < rootNodes.size(); i++) { getRecordReaderInstructions(rootNodes.get(i), execNodes, inputs, recordReaderInstructions, nodeIndexMapping, start_index, inputLabels, inputLops, MRJobLineNumbers); if (recordReaderInstructions.size() > 1) throw new LopsException("MapReduce job can only have a single recordreader instruction: " + recordReaderInstructions.toString()); } } /* * Handle cases when job's output is FORCED to be cell format. * - If there exist a cell input, then output can not be blocked. * Only exception is when jobType = REBLOCK/CSVREBLOCK (for obvisous reason) * or when jobType = RAND since RandJob takes a special input file, * whose format should not be used to dictate the output format. * - If there exists a recordReader instruction * - If jobtype = GroupedAgg. This job can only run in cell mode. */ // if (jt != JobType.REBLOCK && jt != JobType.CSV_REBLOCK && jt != JobType.DATAGEN && jt != JobType.TRANSFORM) { for (int i = 0; i < inputInfos.size(); i++) if (inputInfos.get(i) == InputInfo.BinaryCellInputInfo || inputInfos.get(i) == InputInfo.TextCellInputInfo) cellModeOverride = true; } if (!recordReaderInstructions.isEmpty() || jt == JobType.GROUPED_AGG) cellModeOverride = true; /* Get Mapper Instructions */ for (int i = 0; i < rootNodes.size(); i++) { getMapperInstructions(rootNodes.get(i), execNodes, inputs, mapperInstructions, nodeIndexMapping, start_index, inputLabels, inputLops, MRJobLineNumbers); } if (LOG.isTraceEnabled()) { LOG.trace(" Input strings: " + inputs.toString()); if (jt == JobType.DATAGEN) LOG.trace(" Rand instructions: " + getCSVString(randInstructions)); if (jt == JobType.GMR) LOG.trace(" RecordReader instructions: " + getCSVString(recordReaderInstructions)); LOG.trace(" Mapper instructions: " + getCSVString(mapperInstructions)); } /* Get Shuffle and Reducer Instructions */ ArrayList<String> shuffleInstructions = new ArrayList<String>(); ArrayList<String> aggInstructionsReducer = new ArrayList<String>(); ArrayList<String> otherInstructionsReducer = new ArrayList<String>(); for (int i = 0; i < rootNodes.size(); i++) { N rn = rootNodes.get(i); int resultIndex = getAggAndOtherInstructions(rn, execNodes, shuffleInstructions, aggInstructionsReducer, otherInstructionsReducer, nodeIndexMapping, start_index, inputLabels, inputLops, MRJobLineNumbers); if (resultIndex == -1) throw new LopsException("Unexpected error in piggybacking!"); if (rn.getExecLocation() == ExecLocation.Data && ((Data) rn).getOperationType() == Data.OperationTypes.WRITE && ((Data) rn).isTransient() && rootNodes.contains(rn.getInputs().get(0))) { // Both rn (a transient write) and its input are root nodes. // Instead of creating two copies of the data, simply generate a cpvar instruction NodeOutput out = setupNodeOutputs(rootNodes.get(i), ExecType.MR, cellModeOverride, true); writeinst.addAll(out.getLastInstructions()); } else { resultIndices.add(Byte.valueOf((byte) resultIndex)); // setup output filenames and outputInfos and generate related instructions NodeOutput out = setupNodeOutputs(rootNodes.get(i), ExecType.MR, cellModeOverride, false); outputLabels.add(out.getVarName()); outputs.add(out.getFileName()); outputInfos.add(out.getOutInfo()); if (LOG.isTraceEnabled()) { LOG.trace(" Output Info: " + out.getFileName() + ";" + OutputInfo.outputInfoToString(out.getOutInfo()) + ";" + out.getVarName()); } renameInstructions.addAll(out.getLastInstructions()); variableInstructions.addAll(out.getPreInstructions()); postInstructions.addAll(out.getPostInstructions()); } } /* Determine if the output dimensions are known */ byte[] resultIndicesByte = new byte[resultIndices.size()]; for (int i = 0; i < resultIndicesByte.length; i++) { resultIndicesByte[i] = resultIndices.get(i).byteValue(); } if (LOG.isTraceEnabled()) { LOG.trace(" Shuffle Instructions: " + getCSVString(shuffleInstructions)); LOG.trace(" Aggregate Instructions: " + getCSVString(aggInstructionsReducer)); LOG.trace(" Other instructions =" + getCSVString(otherInstructionsReducer)); LOG.trace(" Output strings: " + outputs.toString()); LOG.trace(" ResultIndices = " + resultIndices.toString()); } /* Prepare the MapReduce job instruction */ MRJobInstruction mr = new MRJobInstruction(jt); // check if this is a map-only job. If not, set the number of reducers if (!shuffleInstructions.isEmpty() || !aggInstructionsReducer.isEmpty() || !otherInstructionsReducer.isEmpty()) numReducers = total_reducers; // set inputs, outputs, and other other properties for the job mr.setInputOutputLabels(getStringArray(inputLabels), getStringArray(outputLabels)); mr.setOutputs(resultIndicesByte); mr.setDimsUnknownFilePrefix(getFilePath()); mr.setNumberOfReducers(numReducers); mr.setReplication(replication); // set instructions for recordReader and mapper mr.setRecordReaderInstructions(getCSVString(recordReaderInstructions)); mr.setMapperInstructions(getCSVString(mapperInstructions)); //compute and set mapper memory requirements (for consistency of runtime piggybacking) if (jt == JobType.GMR) { double mem = 0; for (N n : execNodes) mem += computeFootprintInMapper(n); mr.setMemoryRequirements(mem); } if (jt == JobType.DATAGEN) mr.setRandInstructions(getCSVString(randInstructions)); // set shuffle instructions mr.setShuffleInstructions(getCSVString(shuffleInstructions)); // set reducer instruction mr.setAggregateInstructionsInReducer(getCSVString(aggInstructionsReducer)); mr.setOtherInstructionsInReducer(getCSVString(otherInstructionsReducer)); if (DMLScript.ENABLE_DEBUG_MODE) { // set line number information for each MR instruction mr.setMRJobInstructionsLineNumbers(MRJobLineNumbers); } /* Add the prepared instructions to output set */ inst.addAll(variableInstructions); inst.add(mr); inst.addAll(postInstructions); deleteinst.addAll(renameInstructions); for (Lop l : inputLops) { if (DMLScript.ENABLE_DEBUG_MODE) { processConsumers((N) l, rmvarinst, deleteinst, (N) l); } else { processConsumers((N) l, rmvarinst, deleteinst, null); } } }
From source file:com.mimp.controllers.personal.java
@RequestMapping(value = "/PersonalHabilitarSesion", method = RequestMethod.GET) public ModelAndView PersonalHabilitarSesion_GET(ModelMap map, HttpSession session) { Personal usuario = (Personal) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); }/*from www . j av a 2 s . c o m*/ long id = Long.parseLong(session.getAttribute("idSesion").toString()); Sesion tempSesion = new Sesion(); tempSesion = ServicioPersonal.getSesion(id); short habilitado = Byte.valueOf("0"); tempSesion.setHabilitado(habilitado); ServicioPersonal.PersonalUpdateSesion(tempSesion); map.put("listaTalleres", ServicioPersonal.listaTalleres(usuario.getUnidad().getDepartamento())); map.put("listaSesiones", ServicioPersonal.listaSesiones(usuario.getUnidad().getDepartamento())); map.put("formato", format); String mensaje_log = "El usuario: " + usuario.getNombre() + " " + usuario.getApellidoP() + " con ID: " + usuario.getIdpersonal() + ". Habilit la Sesin con nmero: " + tempSesion.getNSesion(); String Tipo_registro = "Sesin"; try { String Numero_registro = String.valueOf(tempSesion.getNSesion()); ServicioPersonal.InsertLog(usuario, Tipo_registro, Numero_registro, mensaje_log); } catch (Exception ex) { } return new ModelAndView("/Personal/Informativa/lista_charlas", map); }
From source file:com.ah.be.admin.restoredb.RestoreAdmin.java
/** * Get all information from clientMonitorSettings table * * @return List<HMServicesSettings> all logsettings BO * @throws AhRestoreColNotExistException * - if hm_clientMonitorSettings.xml is not exist. * @throws AhRestoreException/*w w w . ja v a 2 s .c om*/ * - if error in parsing hm_clientMonitorSettings.xml. */ private static List<HMServicesSettings> getAllHMServicesSettings() throws Exception { AhRestoreGetXML xmlParser = new AhRestoreGetXML(); String fileName = "clientmonitorsettings"; if (!AhRestoreGetXML.checkXMLFileExist(fileName)) { fileName = "hmservicessettings"; } String tableName = fileName; /** * Check validation of clientmonitorsettings.xml */ boolean restoreRet = xmlParser.readXMLFile(fileName); if (!restoreRet) { return null; } /** * No one row data stored in schedule_backup table is allowed */ int rowCount = xmlParser.getRowCount(); List<HMServicesSettings> settings = new ArrayList<HMServicesSettings>(); boolean isColPresent; String colName; for (int i = 0; i < rowCount; i++) { HMServicesSettings bo = new HMServicesSettings(); /** * Set enableClientRefresh */ colName = "enableClientRefresh"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableClientRefresh = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setEnableClientRefresh(enableClientRefresh); /** * Set enableClientManagement */ colName = "enableClientManagement"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableClientManagement = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setEnableClientManagement(enableClientManagement); /** * Set enableCidClientEnforcement */ colName = "enableCidPolicyEnforcement"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableCidPolicyEnforcement = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setEnableCidPolicyEnforcement(enableCidPolicyEnforcement); /** * Set apiKey */ colName = "apiKey"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String apiKey = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setApiKey(apiKey); /** * Set refreshInterval */ colName = "refreshInterval"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int refreshInterval = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : 60; if (enableClientRefresh && (refreshInterval < 10 || refreshInterval > 1440)) { refreshInterval = 60; } bo.setRefreshInterval(refreshInterval); /** * Set refreshFilterName */ colName = "refreshFilterName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String refreshFilterName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setRefreshFilterName(refreshFilterName); /** * Set session expiration */ colName = "sessionExpiration"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int sessionExpiration = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : 15; bo.setSessionExpiration(sessionExpiration); /** * Set session finite */ colName = "infiniteSession"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean infiniteSession = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setInfiniteSession(infiniteSession); /** * Set snmpCommunity */ colName = "snmpCommunity"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String snmpCommunity = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setSnmpCommunity(snmpCommunity); /** * Set snmpreceiverip */ colName = "snmpreceiverip"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String ipId = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; if (!"".equals(ipId)) { Long newID = AhRestoreNewMapTools.getMapIpAdddress(Long.valueOf(ipId)); if (null != newID) { bo.setSnmpReceiverIP(AhRestoreNewTools.CreateBoWithId(IpAddress.class, newID)); } } /** * Set showNotifyInfo */ colName = "showNotifyInfo"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean showNotifyInfo = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setShowNotifyInfo(showNotifyInfo); /** * Set notifyInformationTitle */ colName = "notifyInformationTitle"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String notifyInformationTitle = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setNotifyInformationTitle(notifyInformationTitle); /** * Set notifyInformation */ colName = "notifyInformation"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String notifyInformation = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setNotifyInformation(notifyInformation); /** * Set maintenance mode flag */ colName = "hmStatus"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); short hmStatus = isColPresent ? (short) AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.HM_OLINE_STATUS_NORMAL; bo.setHmStatus(hmStatus); /** * Set virtual host name */ colName = "virtualHostName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String virtualHostName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : null; bo.setVirtualHostName(virtualHostName); /** * Set enableTeacher */ colName = "enableTeacher"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableTeacher = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setEnableTeacher(enableTeacher); /** * Set presenceEnable */ colName = "presenceEnable"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean presenceEnable = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setPresenceEnable(presenceEnable); /** * Set apSlaType */ colName = "apSlaType"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int apSlaType = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.AP_SLA_STATS_ALL; bo.setApSlaType(apSlaType); /** * Set clientSlaType */ colName = "clientSlaType"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int clientSlaType = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.CLIENT_SLA_STATS_ALL; bo.setClientSlaType(clientSlaType); /** * Set enableProxy */ colName = "enableProxy"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableProxy = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setEnableProxy(enableProxy); /** * Set proxyServer */ colName = "proxyServer"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String proxyServer = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setProxyServer(proxyServer); /** * Set proxyPort */ colName = "proxyPort"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int proxyPort = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : 0; bo.setProxyPort(proxyPort); /** * Set proxyUserName */ colName = "proxyUserName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String proxyUserName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setProxyUserName(proxyUserName); /** * Set proxyPassword */ colName = "proxyPassword"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String proxyPassword = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setProxyPassword(proxyPassword); /** * Set snpMaximum */ colName = "snpMaximum"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int snpMaximum = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : 20; bo.setSnpMaximum(snpMaximum); /** * Set maxUpdateNum */ colName = "maxUpdateNum"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int maxUpdateNum = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.MAX_HIVEOS_SOFTVER_UPDATE_NUM; bo.setMaxUpdateNum(maxUpdateNum); /** * Set concurrentConfigGenNum */ colName = "concurrentConfigGenNum"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String concurrentConfigGenNum = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "3"; bo.setConcurrentConfigGenNum(Byte.valueOf(concurrentConfigGenNum)); /** * Set concurrentConfigGenNum */ colName = "concurrentSearchUserNum"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String concurrentSearchUserNum = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : "1"; bo.setConcurrentSearchUserNum(Byte.valueOf(concurrentSearchUserNum)); /** * Set tvProxyIP */ colName = "tvProxyIP"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String tvProxyIP = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setTvProxyIP(tvProxyIP); /** * Set tvProxyIP */ colName = "tvProxyPort"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int tvProxyPort = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : 0; bo.setTvProxyPort(tvProxyPort); /** * Set tvAutoProxyFile */ colName = "tvAutoProxyFile"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String tvAutoProxyFile = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setTvAutoProxyFile(tvAutoProxyFile); /** * Set enableTVProxy */ colName = "enableTVProxy"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableTVProxy = isColPresent && AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)); bo.setEnableTVProxy(enableTVProxy); /** * Set enableCaseSensitive */ colName = "enableCaseSensitive"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int enableCaseSensitive = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : 1; bo.setEnableCaseSensitive((short) enableCaseSensitive); /** * Set owner */ colName = "owner"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); long ownerId = isColPresent ? AhRestoreCommons.convertLong(xmlParser.getColVal(i, colName)) : 1; if (null == AhRestoreNewMapTools.getHmDomain(ownerId)) { BeLogTools.debug(HmLogConst.M_RESTORE, "Restore table 'clientmonitorsettings' data be lost, cause: 'owner' column is not available."); continue; } bo.setOwner(AhRestoreNewMapTools.getHmDomain(ownerId)); if (null == bo.getOwner()) continue; // web security // Barracuda /** * Set authorizationKey */ colName = "authorizationKey"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String authorizationKey = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setAuthorizationKey(authorizationKey); /** * Set serviceHost */ colName = "serviceHost"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String serviceHost = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setServiceHost(serviceHost); /** * Set servicePort */ colName = "servicePort"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int servicePort = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.SERVICEPROT_DEFAULT_VALUE; bo.setServicePort(servicePort); /** * Set windowsDomain */ colName = "windowsDomain"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String windowsDomain = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setWindowsDomain(windowsDomain); /** * Set barracudaDefaultUserName */ colName = "barracudaDefaultUserName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String barracudaDefaultUserName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setBarracudaDefaultUserName(barracudaDefaultUserName); /** * Set enableBarracuda */ colName = "enableBarracuda"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableBarracuda = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableBarracuda(enableBarracuda); // WebSense /** * Set accountID */ colName = "accountID"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String accountID = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setAccountID(accountID); /** * Set securityKey */ colName = "securityKey"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String securityKey = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setSecurityKey(securityKey); /** * Set webSenseServiceHost */ colName = "webSenseServiceHost"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String webSenseServiceHost = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : NmsUtil.getText("resources.hmResources", "admin.management.webSecurity.websense.serviceHost.hosted"); bo.setWebSenseServiceHost(webSenseServiceHost); /** * Set port */ colName = "port"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int port = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.PORT_DEFAULT_VALUE; bo.setPort(port); /** * Set wensenseMode */ colName = "wensenseMode"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); int wensenseMode = isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.WEBSENSEMODE_HOSTED; bo.setWensenseMode((short) wensenseMode); /** * Set defaultDomain */ colName = "defaultDomain"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String defaultDomain = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setDefaultDomain(defaultDomain); /** * Set websense default user name */ colName = "webSenseDefaultUserName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String webSenseDefaultUserName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setWebSenseDefaultUserName(webSenseDefaultUserName); /** * Set enableWebsense */ colName = "enableWebsense"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableWebsense = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableWebsense(enableWebsense); /** * set BARRACUDAWHITELIST_ID */ colName = "BARRACUDAWHITELIST_ID"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String barracudawhitelist_id = isColPresent ? xmlParser.getColVal(i, colName) : null; if (barracudawhitelist_id != null && !(barracudawhitelist_id.trim().equals("")) && !(barracudawhitelist_id.trim().equalsIgnoreCase("null"))) { DomainObject domainObj = AhRestoreNewMapTools .getMapDomainObject(AhRestoreCommons.convertLong(barracudawhitelist_id)); if (domainObj != null) { try { domainObj = QueryUtil.findBoById(DomainObject.class, domainObj.getId(), new DomainObjectAction()); if (domainObj.getObjType() != DomainObject.WEB_SECURITY) { domainObj.setId(null); domainObj.setObjType(DomainObject.WEB_SECURITY); if (domainObj.getItems() != null) { List<DomainNameItem> items = new ArrayList<DomainNameItem>(); items.addAll(domainObj.getItems()); domainObj.setItems(items); } QueryUtil.createBo(domainObj); } //QueryUtil.updateBo(domainObj); } catch (Exception e) { e.printStackTrace(); } } bo.setBarracudaWhitelist(domainObj); if (null == domainObj) { AhRestoreDBTools.logRestoreMsg("Cound not find BARRACUDAWHITELIST_ID:" + barracudawhitelist_id); } } /** * set WEBSENSEWHITELIST_ID */ colName = "WEBSENSEWHITELIST_ID"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String websenseWhitelist_id = isColPresent ? xmlParser.getColVal(i, colName) : null; if (websenseWhitelist_id != null && !(websenseWhitelist_id.trim().equals("")) && !(websenseWhitelist_id.trim().equalsIgnoreCase("null"))) { DomainObject domainObj = AhRestoreNewMapTools .getMapDomainObject(AhRestoreCommons.convertLong(websenseWhitelist_id)); if (domainObj != null) { try { domainObj = QueryUtil.findBoById(DomainObject.class, domainObj.getId(), new DomainObjectAction()); if (domainObj.getObjType() != DomainObject.WEB_SECURITY) { domainObj.setId(null); domainObj.setObjType(DomainObject.WEB_SECURITY); if (domainObj.getItems() != null) { List<DomainNameItem> items = new ArrayList<DomainNameItem>(); items.addAll(domainObj.getItems()); domainObj.setItems(items); } QueryUtil.createBo(domainObj); } } catch (Exception e) { e.printStackTrace(); } } bo.setWebsenseWhitelist(domainObj); if (null == domainObj) { AhRestoreDBTools.logRestoreMsg("Cound not find WEBSENSEWHITELIST_ID:" + websenseWhitelist_id); } } /** * Set enableDistributedUpgrade */ colName = "enableDistributedUpgrade"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); if (isColPresent) { boolean enableDistributedUpgrade = AhRestoreCommons .convertStringToBoolean(xmlParser.getColVal(i, colName)); if (enableDistributedUpgrade) { // update to HiveApUpdateSettings bo HiveApUpdateSettings updateSetting = QueryUtil.findBoByAttribute(HiveApUpdateSettings.class, "owner", AhRestoreNewMapTools.getHmDomain(ownerId)); if (updateSetting != null) { updateSetting.setDistributedUpgrades(true); QueryUtil.updateBo(updateSetting); } } } /** * Set enabledBetaIDM */ colName = "enabledBetaIDM"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enabledBetaIDM = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnabledBetaIDM(enabledBetaIDM); /** * Set enableRadarDetection */ colName = "enableRadarDetection"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableRadarDetection = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableRadarDetection(enableRadarDetection); /** * Set enableCollectAppData */ colName = "enableCollectAppData"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableCollectAppData = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableCollectAppData(enableCollectAppData); /** * Set classifier tag setting */ colName = "classifiertag"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String classifiertag = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setClassifierTag(classifiertag); /** * set date format */ colName = "timeType"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); short timeType = (short) (isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.TIME_TYPE_1); bo.setTimeType(timeType); colName = "dateFormat"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); short dateFormat = (short) (isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.DATE_FORMAT_TYPE_1); bo.setDateFormat(dateFormat); colName = "timeFormat"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); short timeFormat = (short) (isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.TIME_FORMAT_TYPE_1); bo.setTimeFormat(timeFormat); colName = "dateSeparator"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); short dateSeparator = (short) (isColPresent ? AhRestoreCommons.convertInt(xmlParser.getColVal(i, colName)) : HMServicesSettings.DATE_SEPARATOR_TYPE_1); bo.setDateSeparator(dateSeparator); colName = "apiUserName"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String apiUserName = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setApiUserName(apiUserName); colName = "apiPassword"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String apiPassword = isColPresent ? AhRestoreCommons.convertString(xmlParser.getColVal(i, colName)) : ""; bo.setApiPassword(apiPassword); colName = "enableApiAccess"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableApiAccess = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableApiAccess(enableApiAccess); //For OpenDNS Feature /** * Set enableOpenDNS */ colName = "enableOpenDNS"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableOpenDNS = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableOpenDNS(enableOpenDNS); /** * Set openDNSAccount */ colName = "opendns_account_id"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); String opendns_account_id = isColPresent ? xmlParser.getColVal(i, colName) : ""; if (NmsUtil.isNotBlankId(opendns_account_id)) { Long newOpendnsAccountId = AhRestoreNewMapTools .getMapOpenDNSAccount(Long.parseLong(opendns_account_id.trim())); OpenDNSAccount openDNSAccount = AhRestoreNewTools.CreateBoWithId(OpenDNSAccount.class, newOpendnsAccountId); bo.setOpenDNSAccount(openDNSAccount); } /** * Set enableSupplementalCLI */ colName = "enableSupplementalCLI"; isColPresent = AhRestoreCommons.isColumnPresent(xmlParser, tableName, colName); boolean enableSupplementalCLI = isColPresent ? AhRestoreCommons.convertStringToBoolean(xmlParser.getColVal(i, colName)) : false; bo.setEnableSupplementalCLI(enableSupplementalCLI); settings.add(bo); } return !settings.isEmpty() ? settings : null; }
From source file:pl.betoncraft.betonquest.config.ConfigUpdater.java
private void updateTo1_4() { Debug.broadcast("Started converting configuration files from v1.3 to v1.4!"); instance.getConfig().set("autoupdate", "false"); Debug.broadcast("Added AutoUpdate option to config. It's DISABLED by default!"); Debug.broadcast("Moving conversation to separate files..."); ConfigAccessor convOld = ch.getConfigs().get("conversations"); Set<String> keys = convOld.getConfig().getKeys(false); File folder = new File(instance.getDataFolder(), "conversations"); if (folder.exists() && folder.isDirectory()) for (File file : folder.listFiles()) { file.delete();//from ww w. ja v a 2s . c o m } for (String convID : keys) { File convFile = new File(folder, convID + ".yml"); Map<String, Object> convSection = convOld.getConfig().getConfigurationSection(convID).getValues(true); YamlConfiguration convNew = YamlConfiguration.loadConfiguration(convFile); for (String key : convSection.keySet()) { convNew.set(key, convSection.get(key)); } try { convNew.save(convFile); Debug.broadcast("Conversation " + convID + " moved to it's own file!"); } catch (IOException e) { e.printStackTrace(); } } Debug.broadcast("All conversations moved, deleting old file."); new File(instance.getDataFolder(), "conversations.yml").delete(); // updating items Debug.broadcast("Starting conversion of items..."); // this map will contain all QuestItem objects extracted from // configs HashMap<String, QuestItem> items = new HashMap<>(); // this is counter for a number in item names (in items.yml) int number = 0; // check every event for (String key : ch.getConfigs().get("events").getConfig().getKeys(false)) { String instructions = ch.getString("events." + key); String[] parts = instructions.split(" "); String type = parts[0]; // if this event has items in it do the thing if (type.equals("give") || type.equals("take")) { // define all required variables String amount = ""; String conditions = ""; String material = null; int data = 0; Map<String, Integer> enchants = null; List<String> lore = null; String name = null; // for each part of the instruction string check if it // contains some data and if so pu it in variables for (String part : parts) { if (part.contains("type:")) { material = part.substring(5); } else if (part.contains("data:")) { data = Byte.valueOf(part.substring(5)); } else if (part.contains("enchants:")) { enchants = new HashMap<>(); for (String enchant : part.substring(9).split(",")) { enchants.put(enchant.split(":")[0], Integer.decode(enchant.split(":")[1])); } } else if (part.contains("lore:")) { lore = new ArrayList<>(); for (String loreLine : part.substring(5).split(";")) { lore.add(loreLine.replaceAll("_", " ")); } } else if (part.contains("name:")) { name = part.substring(5).replaceAll("_", " "); } else if (part.contains("amount:")) { amount = part; } else if (part.contains("conditions:")) { conditions = part; } } // create an item String newItemID = null; @SuppressWarnings("deprecation") QuestItem item = new QuestItem(material, data, enchants, name, lore); boolean contains = false; for (String itemKey : items.keySet()) { if (items.get(itemKey).equals(item)) { contains = true; break; } } if (!contains) { // generate new name for an item newItemID = "item" + number; number++; items.put(newItemID, item); } else { for (String itemName : items.keySet()) { if (items.get(itemName).equals(item)) { newItemID = itemName; } } } ch.getConfigs().get("events").getConfig().set(key, (type + " " + newItemID + " " + amount + " " + conditions).trim()); // replace event with updated version Debug.broadcast("Extracted " + newItemID + " from " + key + " event!"); } } // check every condition (it's almost the same code, I didn't know how // to do // it better for (String key : ch.getConfigs().get("conditions").getConfig().getKeys(false)) { String instructions = ch.getString("conditions." + key); String[] parts = instructions.split(" "); String type = parts[0]; // if this condition has items do the thing if (type.equals("hand") || type.equals("item")) { // define all variables String amount = ""; String material = null; int data = 0; Map<String, Integer> enchants = new HashMap<>(); List<String> lore = new ArrayList<>(); String name = null; String inverted = ""; // for every part check if it has some data and place it in // variables for (String part : parts) { if (part.contains("type:")) { material = part.substring(5); } else if (part.contains("data:")) { data = Byte.valueOf(part.substring(5)); } else if (part.contains("enchants:")) { for (String enchant : part.substring(9).split(",")) { enchants.put(enchant.split(":")[0], Integer.decode(enchant.split(":")[1])); } } else if (part.contains("lore:")) { for (String loreLine : part.substring(5).split(";")) { lore.add(loreLine.replaceAll("_", " ")); } } else if (part.contains("name:")) { name = part.substring(5).replaceAll("_", " "); } else if (part.contains("amount:")) { amount = part; } else if (part.equalsIgnoreCase("--inverted")) { inverted = part; } } // create an item String newItemID = null; @SuppressWarnings("deprecation") QuestItem item = new QuestItem(material, data, enchants, name, lore); boolean contains = false; for (String itemKey : items.keySet()) { if (items.get(itemKey).equals(item)) { contains = true; break; } } if (!contains) { // generate new name for an item newItemID = "item" + number; number++; items.put(newItemID, item); } else { for (String itemName : items.keySet()) { if (items.get(itemName).equals(item)) { newItemID = itemName; } } } ch.getConfigs().get("conditions").getConfig().set(key, (type + " item:" + newItemID + " " + amount + " " + inverted).trim()); Debug.broadcast("Extracted " + newItemID + " from " + key + " condition!"); } } // generated all items, now place them in items.yml for (String key : items.keySet()) { QuestItem item = items.get(key); String instruction = item.getMaterial() + " data:" + item.getData(); if (item.getName() != null) { instruction = instruction + " name:" + item.getName().replace(" ", "_"); } if (item.getLore() != null && !item.getLore().isEmpty()) { StringBuilder lore = new StringBuilder(); for (String line : item.getLore()) { lore.append(line + ";"); } instruction = instruction + " lore:" + (lore.substring(0, lore.length() - 1).replace(" ", "_")); } if (item.getEnchants() != null && !item.getEnchants().isEmpty()) { StringBuilder enchants = new StringBuilder(); for (Enchantment enchant : item.getEnchants().keySet()) { enchants.append(enchant.toString() + ":" + item.getEnchants().get(enchant) + ","); } instruction = instruction + " enchants:" + enchants.substring(0, enchants.length() - 1); } ch.getConfigs().get("items").getConfig().set(key, instruction); } ch.getConfigs().get("items").saveConfig(); ch.getConfigs().get("events").saveConfig(); ch.getConfigs().get("conditions").saveConfig(); Debug.broadcast("All extracted items has been successfully saved to items.yml!"); // end of updating to 1.4 instance.getConfig().set("version", "1.4"); Debug.broadcast("Conversion to v1.4 finished."); updateTo1_4_1(); }