void put(final URI uri, ArtifactData data) throws Exception { reporter.trace("put %s %s", uri, data); File tmp = createTempFile(repoDir, "mtp", ".whatever"); tmp.deleteOnExit(); try { copy(uri.toURL(), tmp); byte[] sha = SHA1.digest(tmp).digest(); reporter.trace("SHA %s %s", uri, Hex.toHexString(sha)); ArtifactData existing = get(sha); if (existing != null) { reporter.trace("existing"); xcopy(existing, data); return; } File meta = new File(repoDir, Hex.toHexString(sha) + ".json"); File file = new File(repoDir, Hex.toHexString(sha)); rename(tmp, file); reporter.trace("file %s", file); data.file = file.getAbsolutePath(); data.sha = sha; data.busy = false; CommandData cmddata = parseCommandData(data); if (cmddata.bsn != null) { data.name = cmddata.bsn + "-" + cmddata.version; } else data.name = Strings.display(cmddata.title, cmddata.bsn, cmddata.name, uri); codec.enc().to(meta).put(data); reporter.trace("TD = " + data); } finally { tmp.delete(); reporter.trace("puted %s %s", uri, data); } }
/** * Turn the shas into a readable form * * @param dependencies * @return * @throws Exception */ public List<?> toString(List<byte[]> dependencies) throws Exception { List<String> out = new ArrayList<String>(); for (byte[] dependency : dependencies) { ArtifactData data = get(dependency); if (data == null) out.add(Hex.toHexString(dependency)); else { out.add(Strings.display(data.name, Hex.toHexString(dependency))); } } return out; }
/** * 날자 형식의 String에 구분자를 넣어준다. (yyyy-MM-dd) Carendar를 사용하지 않기 위한 편법. * * @param 8자리 yyyyMMdd형식의 String */ public static String toDate(String yyyyMMdd, String seperator) { if (Strings.isEmpty(yyyyMMdd)) return ""; if (yyyyMMdd.length() == 8) return yyyyMMdd.substring(0, 4) + seperator + yyyyMMdd.substring(4, 6) + seperator + yyyyMMdd.substring(6, 8); else if (yyyyMMdd.length() == 6) return yyyyMMdd.substring(0, 4) + seperator + yyyyMMdd.substring(4, 6); else return yyyyMMdd; }
public String getColumnName(int c) { return labelAsHeader ? getMetaProperty(c).getLabel(locale) : Strings.change(getMetaProperty(c).getQualifiedName(), ".", "_"); }
/** reflection된 10자리 사업자등록번호를 '-'를 삽입하여 반환한다. */ public static String toBid(Object obj, String name) { String money = (String) Clazz.getObject(obj, name); ; return toBid(Strings.nvl(money)); }
/** * 패턴에 따라 String을 리턴해줌 * * @return ex) toFormat("123456",*.FORMAT_INT) => "123,456" */ public String get(String str) { return format.format(Strings.getDoubleValue(str)); }
public Object parse(HttpServletRequest request, String string) throws Exception { if (Is.emptyString(string)) return null; string = Strings.change(string, " ", ""); // In order to work with Polish return new BigDecimal(getFormat().parse(string).toString()).setScale(2); }