但安装好GitLab之后面临一个问题,如何将服务器上的git项目直接导入到GitLab,之前的Git服务器是由是git+apache搭建的(详见在Linux上用Apache搭建Git服务器)。
在网上发现了这篇文档——Import bare repositories into your GitLab instance,并按之进行了 *** 作。
1)设置存放代码库的主目录
vi /etc/gitlab/gitlab.rb
比如这里设置为:git_data_dir "/gitlab/repos"
2)访问刚搭建的GitLab站点,创建一个group,比如cnblogs。
这时会在 /gitlab/repos 下创建 /gitlab/repos/repositories/cnblogs 文件夹。
然后在/gitlab/repos/repositories/创建一个文件夹,比如cnblogs
3)将现有的所有git项目文件复制到这个文件夹
cp -r /data/git/* /gitlab/repos/repositories/cnblogs
4)修改一下复制过来的文件夹的所有者:
chown -R git:git /gitlab/repos/repositories/cnblogs
5)运行GitLab导入命令
cd /var/opt/gitlab
gitlab-rake gitlab:import:repos
等了一段时间之后,显示done,却一个项目也没导入进来。
经研究发现,在导入时,GitLab只认文件夹名以.git结尾的项目。于是,将要导入的项目文件夹名称加上.git后缀,再次进行导入。
结果显示导入成功,比如:
Processing cnblogs/CNBlogsJob.git
* Created CNBlogsJob (cnblogs/CNBlogsJob.git)
Done!
可以是GitLab站点上却看不到已导入的项目。多次努力,也没能解决这个问题。
后来,实在没办法,改为手动导入,导入方法如下:
1)在GitLab站点上创建与要导入的项目同名的项目。
2)进入刚创建的项目文件夹
cd /gitlab/repos/repositories/cnblogs/项目名称.git
3)删除该文件下的所有文件
rm -rf *
4)将要导入的项目文件夹下的所有文件复制过来
cp -r /data/git/CNBlogsJob/* /gitlab/repos/repositories/cnblogs/CNBlogsJob.git
就这样将项目一个一个地导入进来。
5)导入完成后,修改一下导入的所有项目的文件所有者
chown -R git:git /gitlab/repos/repositories/cnblogs
如果不修改所有者,客户端无法进行git push。
就这样手动地完成了现有Git项目的导入。
备注: *** 作系统是CentOS 6.2,GitLab版本是7.8.4。
一、内容概述
Tetracorder是美国地质调查局(USGS)的Clark等人开发的一个高光谱矿物填图软件,主要用来处理AVIRIS数据,但也可以处理其他高光谱数据。该软件的开发较早,从1990年开始,经过十来年的修改完善,现已经很成熟。
Tetracorder包含400种以上的矿物、植被、雪地和人造物体的标准光谱库,而且还在不断补充当中。该软件最大的特色是融入了“专家系统”的概念,即在专家知识的基础上,利用专家系统决策支持工具(即各种算法),来识别光谱所含矿物信息,并生成矿物分布图。该软件集成了多种常用的光谱数据处理与分析算法,能针对特定问题选择不同的算法,然后对结果进行评估,并利用专家系统的决策功能,实现矿物光谱自动化识别与填图。
Tetracorder专家系统通过一种或多种可诊断的吸收特征来识别地表物体,就算是对吸收特征比较接近的矿物,也能取得良好的识别效果(Dalton et al.,2004)。Tetracorder采用的算法中有两种是最基本的(Clark et al.,1990,2003;Clark and Swayze,1995):一是连续去除光谱法,旨在提取出吸收特征;二是最小二乘法,旨在计算出遥感光谱与库参照光谱之间的拟合程度。
Tetracorder程序源代码现在已经在USGS光谱实验室的网站上公开,它是用RatFOR语言编写的,但可以转换成C语言或FORTRUN语言。
二、应用范围及应用实例
Tetracorder软件可应用于对地表矿物进行识别和填图,检测酸性岩质排泄物的来源,或对植被类型、冰、融雪、水及水污染进行填图。矿物填图结果可运用于地质填图、检测断层,并且对风化、矿化、热液蚀变及其他地质过程提供更好的认识。场地环境评估,例如酸性矿山废水源区填图,可帮助加快场地治理,节省治理所需时间和成本。除了地球表面以外,成像光谱和Tetracorder软件还被用于探测火星、月球表面的大气、海洋与陆地。
(一)地质应用
以内华达州Cuprite矿床为例,先将AVIRIS数据转换成表观反射率,以清除大气吸收与散射以及太阳响应的影响。然后用Tetracorder自带的算法,对这些反射率数据进行分析,一共搜索了254种光谱类型,得出了拟合、深度与拟合、深度3种类型图像(762幅)。根据像元的空间分组情况,按照拟合值大于临界阀值的标准,识别出了大约70种光谱类型。这些类型中有些是植被,有些是矿物,约有45种最清楚(图1)。Cuprite地区发育两套不同时代的热液系统,显示出蚀变分带相叠加的特征。根据矿物分布图,不仅可进一步研究该地区遭受的热液活动,还可以发现新的隐伏断层。
图1 Cuprite矿区AVIRIS数据的Tetracorder分析结果
(据Clark,2002)
(据USGS于1995年获得的内华达州Cuprite矿区的AVIRIS数据,图件由Tetracorder 3.3生成)
(二)环境应用
位于科罗拉多州中部的莱德维尔(Leadville)矿区是一个开采了100多年的废弃矿山,已对环境造成了严重污染。矿山开采留下的废石与尾矿中,含有黄铁矿和其他硫化物、硫酸盐等,覆盖面积达30km2(包含莱德维尔市)。
首先采集了莱德维尔地区的AVIRIS数据,并利用Tetracorder系统进行了矿物填图。经过野外检查,其结果比较准确。矿物分布图(图2)显示了蚀变区所在,那里是酸性岩排泄物的源区,因而引导人们将治理工作集中到这些污染物的源区。黄铁矿风化后变成黄钾铁矾,使水质变酸,从岩石和土壤中过滤出了重金属。这样,黄铁矿与黄钾铁矾的分布图就表示酸性水的来源区。其他尾矿堆积中不含与酸性岩石有关的排泄物,提示调查人员不需要对这些地方进行清理。根据这项研究结果,美国环保局估计成像矿物填图技术为环境修复治理节省了至少200万美元,并且减少了清理时间至少约2.5年。
图2 莱德维尔地区的Tetracorder分析矿物图(与正射影像图相叠加)
(据Clark,2002)
三、资料来源
Clark R N,Swayze G A,Gallagher A J et al.1993.The U S Geological Survey,Digital Spectral Library:Version 1:0.2 to 3.0 microns.US Geological Survey Open File Report,93~592
Clark R N,Swayze G A,Livo K E et al.2003.Imaging spectroscopy:Earth and planetary remote sensing with the USGS Tetracorder and expert systems,J.Geophys.Res.,108(E12),5131,doi:10.1029/2002 JE001847,pages 5~1 to 5~44(http://speclab.cr.usgs.gov/PAPERS/tetracorde)
Dalton J B,Bove D J,Mladinich C S et al.2004.Identification of spectrally similar materials using the USGS Tetracorde ralgorithm:the calcite⁃epidote⁃chlorite problem.Remote Sensing of Environment,89,455~466
以下两个类可以很方便的完成字符串的加密和解密
加密 CryptHelper encrypt(password)
解密 CrypHelper decrypt(password)
代码如下
CryptUtils java
[java]
package gdie lab crypt
import java io IOException
import javax crypto Cipher
import javax crypto KeyGenerator
import javax crypto SecretKey
import apache xerces internal impl dv util Base
public class CryptUtils {
private static String Algorithm = DES
private static byte[] DEFAULT_KEY=new byte[] { }
private static String VALUE_ENCODING= UTF
/**
* 生成密钥
*
* @return byte[] 返回生成的密钥
* @throws exception
* 扔出异常
*/
public static byte[] getSecretKey() throws Exception {
KeyGenerator keygen = KeyGenerator getInstance(Algorithm)
SecretKey deskey = keygen generateKey()
// if (debug ) System out println ( 生成密钥 +byte hex (deskey getEncoded
// ()))
return deskey getEncoded()
}
/**
* 将指定的数据根据提供的密钥进行加密
*
* @param input
* 需要加密的数据
* @param key
* 密钥
* @return byte[] 加密后的数据
* @throws Exception
*/
public static byte[] encryptData(byte[] input byte[] key) throws Exception {
SecretKey deskey = new javax crypto spec SecretKeySpec(key Algorithm)
// if (debug )
// {
// System out println ( 加密前的二进串 +byte hex (input ))
// System out println ( 加密前的字符串 +new String (input ))
//
// }
Cipher c = Cipher getInstance(Algorithm)
c init(Cipher ENCRYPT_MODE deskey)
byte[] cipherByte = c doFinal(input)
// if (debug ) System out println ( 加密后的二进串 +byte hex (cipherByte ))
return cipherByte
}
public static byte[] encryptData(byte[] input) throws Exception {
return encryptData(input DEFAULT_KEY)
}
/**
* 将给定的已加密的数据通过指定的密钥进行解密
*
* @param input
* 待解密的数据
* @param key
* 密钥
* @return byte[] 解密后的数据
* @throws Exception
*/
public static byte[] decryptData(byte[] input byte[] key) throws Exception {
SecretKey deskey = new javax crypto spec SecretKeySpec(key Algorithm)
// if (debug ) System out println ( 解密前的信息 +byte hex (input ))
Cipher c = Cipher getInstance(Algorithm)
c init(Cipher DECRYPT_MODE deskey)
byte[] clearByte = c doFinal(input)
// if (debug )
// {
// System out println ( 解密后的二进串 +byte hex (clearByte ))
// System out println ( 解密后的字符串 +(new String (clearByte )))
//
// }
return clearByte
}
public static byte[] decryptData(byte[] input) throws Exception {
return decryptData(input DEFAULT_KEY)
}
/**
* 字节码转换成 进制字符串
*
* @param byte[] b 输入要转换的字节码
* @return String 返回转换后的 进制字符串
*/
public static String byte hex(byte[] bytes) {
StringBuilder hs = new StringBuilder()
for(byte b : bytes)
hs append(String format( % $ X b))
return hs toString()
}
public static byte[] hex byte(String content) {
int l=content length()》
byte[] result=new byte[l]
for(int i= i<li++) {
int j=i《
String s=content substring(j j+ )
result[i]=Integer valueOf(s ) byteValue()
}
return result
}
/**
* 将字节数组转换为base 编码字符串
* @param buffer
* @return
*/
public static String bytesToBase (byte[] buffer) {
//BASE Encoder en=new BASE Encoder()
return Base encode(buffer)
// return encoder encode(buffer)
}
/**
* 将base 编码的字符串解码为字节数组
* @param value
* @return
* @throws IOException
*/
public static byte[] base ToBytes(String value) throws IOException {
//return Base decodeToByteArray(value)
// System out println(decoder decodeBuffer(value))
// return decoder decodeBuffer(value)
return Base decode(value)
}
/**
* 加密给定的字符串
* @param value
* @return 加密后的base 字符串
*/
public static String encryptString(String value) {
return encryptString(value DEFAULT_KEY)
}
/**
* 根据给定的密钥加密字符串
* @param value 待加密的字符串
* @param key 以BASE 形式存在的密钥
* @return 加密后的base 字符串
* @throws IOException
*/
public static String encryptString(String value String key) throws IOException {
return encryptString(value base ToBytes(key))
}
/**
* 根据给定的密钥加密字符串
* @param value 待加密的字符串
* @param key 字节数组形式的密钥
* @return 加密后的base 字符串
*/
public static String encryptString(String value byte[] key) {
try {
byte[] data=value getBytes(VALUE_ENCODING)
data=CryptUtils encryptData(data key)
return bytesToBase (data)
} catch (Exception e) {
// TODO Auto generated catch block
e printStackTrace()
return null
}
}
/**
* 解密字符串
* @param value base 形式存在的密文
* @return 明文
*/
public static String decryptString(String value) {
return decryptString(value DEFAULT_KEY)
}
/**
* 解密字符串
* @param value base 形式存在的密文
* @param key base 形式存在的密钥
* @return 明文
* @throws IOException
*/
public static String decryptString(String value String key) throws IOException {
String s=decryptString(value base ToBytes(key))
return s
}
/**
* 解密字符串
* @param value base 形式存在的密文
* @param key 字节数据形式存在的密钥
* @return 明文
*/
public static String decryptString(String value byte[] key) {
try {
byte[] data=base ToBytes(value)
data=CryptUtils decryptData(data key)
return new String(data VALUE_ENCODING)
}catch(Exception e) {
e printStackTrace()
return null
}
}
}
package gdie lab crypt
import java io IOException
import javax crypto Cipher
import javax crypto KeyGenerator
import javax crypto SecretKey
import apache xerces internal impl dv util Base
public class CryptUtils {
private static String Algorithm = DES
private static byte[] DEFAULT_KEY=new byte[] { }
private static String VALUE_ENCODING= UTF
/**
* 生成密钥
*
* @return byte[] 返回生成的密钥
* @throws exception
* 扔出异常
*/
public static byte[] getSecretKey() throws Exception {
KeyGenerator keygen = KeyGenerator getInstance(Algorithm)
SecretKey deskey = keygen generateKey()
// if (debug ) System out println ( 生成密钥 +byte hex (deskey getEncoded
// ()))
return deskey getEncoded()
}
/**
* 将指定的数据根据提供的密钥进行加密
*
* @param input
* 需要加密的数据
* @param key
* 密钥
* @return byte[] 加密后的数据
* @throws Exception
*/
public static byte[] encryptData(byte[] input byte[] key) throws Exception {
SecretKey deskey = new javax crypto spec SecretKeySpec(key Algorithm)
// if (debug )
// {
// System out println ( 加密前的二进串 +byte hex (input ))
// System out println ( 加密前的字符串 +new String (input ))
//
// }
Cipher c = Cipher getInstance(Algorithm)
c init(Cipher ENCRYPT_MODE deskey)
byte[] cipherByte = c doFinal(input)
// if (debug ) System out println ( 加密后的二进串 +byte hex (cipherByte ))
return cipherByte
}
public static byte[] encryptData(byte[] input) throws Exception {
return encryptData(input DEFAULT_KEY)
}
/**
* 将给定的已加密的数据通过指定的密钥进行解密
*
* @param input
* 待解密的数据
* @param key
* 密钥
* @return byte[] 解密后的数据
* @throws Exception
*/
public static byte[] decryptData(byte[] input byte[] key) throws Exception {
SecretKey deskey = new javax crypto spec SecretKeySpec(key Algorithm)
// if (debug ) System out println ( 解密前的信息 +byte hex (input ))
Cipher c = Cipher getInstance(Algorithm)
c init(Cipher DECRYPT_MODE deskey)
byte[] clearByte = c doFinal(input)
// if (debug )
// {
// System out println ( 解密后的二进串 +byte hex (clearByte ))
// System out println ( 解密后的字符串 +(new String (clearByte )))
//
// }
return clearByte
}
public static byte[] decryptData(byte[] input) throws Exception {
return decryptData(input DEFAULT_KEY)
}
/**
* 字节码转换成 进制字符串
*
* @param byte[] b 输入要转换的字节码
* @return String 返回转换后的 进制字符串
*/
public static String byte hex(byte[] bytes) {
StringBuilder hs = new StringBuilder()
for(byte b : bytes)
hs append(String format( % $ X b))
return hs toString()
}
public static byte[] hex byte(String content) {
int l=content length()》
byte[] result=new byte[l]
for(int i= i<li++) {
int j=i《
String s=content substring(j j+ )
result[i]=Integer valueOf(s ) byteValue()
}
return result
}
/**
* 将字节数组转换为base 编码字符串
* @param buffer
* @return
*/
public static String bytesToBase (byte[] buffer) {
//BASE Encoder en=new BASE Encoder()
return Base encode(buffer)
// return encoder encode(buffer)
}
/**
* 将base 编码的字符串解码为字节数组
* @param value
* @return
* @throws IOException
*/
public static byte[] base ToBytes(String value) throws IOException {
//return Base decodeToByteArray(value)
// System out println(decoder decodeBuffer(value))
// return decoder decodeBuffer(value)
return Base decode(value)
}
/**
* 加密给定的字符串
* @param value
* @return 加密后的base 字符串
*/
public static String encryptString(String value) {
return encryptString(value DEFAULT_KEY)
}
/**
* 根据给定的密钥加密字符串
* @param value 待加密的字符串
* @param key 以BASE 形式存在的密钥
* @return 加密后的base 字符串
* @throws IOException
*/
public static String encryptString(String value String key) throws IOException {
return encryptString(value base ToBytes(key))
}
/**
* 根据给定的密钥加密字符串
* @param value 待加密的字符串
* @param key 字节数组形式的密钥
* @return 加密后的base 字符串
*/
public static String encryptString(String value byte[] key) {
try {
byte[] data=value getBytes(VALUE_ENCODING)
data=CryptUtils encryptData(data key)
return bytesToBase (data)
} catch (Exception e) {
// TODO Auto generated catch block
e printStackTrace()
return null
}
}
/**
* 解密字符串
* @param value base 形式存在的密文
* @return 明文
*/
public static String decryptString(String value) {
return decryptString(value DEFAULT_KEY)
}
/**
* 解密字符串
* @param value base 形式存在的密文
* @param key base 形式存在的密钥
* @return 明文
* @throws IOException
*/
public static String decryptString(String value String key) throws IOException {
String s=decryptString(value base ToBytes(key))
return s
}
/**
* 解密字符串
* @param value base 形式存在的密文
* @param key 字节数据形式存在的密钥
* @return 明文
*/
public static String decryptString(String value byte[] key) {
try {
byte[] data=base ToBytes(value)
data=CryptUtils decryptData(data key)
return new String(data VALUE_ENCODING)
}catch(Exception e) {
e printStackTrace()
return null
}
}
}
CryptHelper java
[java]
package gdie lab crypt
import javax crypto Cipher
import javax crypto SecretKey
import javax crypto SecretKeyFactory
import javax crypto spec DESKeySpec
import javax crypto spec IvParameterSpec
import springframework util DigestUtils
public class CryptHelper{
private static String CRYPT_KEY = zhongqian
//加密
private static Cipher ecip
//解密
private static Cipher dcip
static {
try {
String KEY = DigestUtils md DigestAsHex(CRYPT_KEY getBytes()) toUpperCase()
KEY = KEY substring( )
byte[] bytes = KEY getBytes()
DESKeySpec ks = new DESKeySpec(bytes)
SecretKeyFactory skf = SecretKeyFactory getInstance( DES )
SecretKey sk = skf generateSecret(ks)
IvParameterSpec iv = new IvParameterSpec(bytes)
ecip = Cipher getInstance( DES/CBC/PKCS Padding )
ecip init(Cipher ENCRYPT_MODE sk iv )
dcip = Cipher getInstance( DES/CBC/PKCS Padding )
dcip init(Cipher DECRYPT_MODE sk iv )
}catch(Exception ex) {
ex printStackTrace()
}
}
public static String encrypt(String content) throws Exception {
byte[] bytes = ecip doFinal(content getBytes( ascii ))
return CryptUtils byte hex(bytes)
}
public static String decrypt(String content) throws Exception {
byte[] bytes = CryptUtils hex byte(content)
bytes = dcip doFinal(bytes)
return new String(bytes ascii )
}
//test
public static void main(String[] args) throws Exception {
String password = gly
String en = encrypt(password)
System out println(en)
System out println(decrypt(en))
}
}
package gdie lab crypt
import javax crypto Cipher
import javax crypto SecretKey
import javax crypto SecretKeyFactory
import javax crypto spec DESKeySpec
import javax crypto spec IvParameterSpec
import springframework util DigestUtils
public class CryptHelper{
private static String CRYPT_KEY = zhongqian
//加密
private static Cipher ecip
//解密
private static Cipher dcip
static {
try {
String KEY = DigestUtils md DigestAsHex(CRYPT_KEY getBytes()) toUpperCase()
KEY = KEY substring( )
byte[] bytes = KEY getBytes()
DESKeySpec ks = new DESKeySpec(bytes)
SecretKeyFactory skf = SecretKeyFactory getInstance( DES )
SecretKey sk = skf generateSecret(ks)
IvParameterSpec iv = new IvParameterSpec(bytes)
ecip = Cipher getInstance( DES/CBC/PKCS Padding )
ecip init(Cipher ENCRYPT_MODE sk iv )
dcip = Cipher getInstance( DES/CBC/PKCS Padding )
dcip init(Cipher DECRYPT_MODE sk iv )
}catch(Exception ex) {
ex printStackTrace()
}
}
public static String encrypt(String content) throws Exception {
byte[] bytes = ecip doFinal(content getBytes( ascii ))
return CryptUtils byte hex(bytes)
}
public static String decrypt(String content) throws Exception {
byte[] bytes = CryptUtils hex byte(content)
bytes = dcip doFinal(bytes)
return new String(bytes ascii )
}
//test
public static void main(String[] args) throws Exception {
String password = gly
String en = encrypt(password)
System out println(en)
System out println(decrypt(en))
}
lishixinzhi/Article/program/Java/hx/201311/26449
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)