本文整理汇总了Java中org.wso2.carbon.utils.multitenancy.MultitenantUtils.getAxis2RepositoryPath方法的典型用法代码示例。如果您正苦于以下问题:Java MultitenantUtils.getAxis2RepositoryPath方法的具体用法?Java MultitenantUtils.getAxis2RepositoryPath怎么用?Java MultitenantUtils.getAxis2RepositoryPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.utils.multitenancy.MultitenantUtils
的用法示例。
在下文中一共展示了MultitenantUtils.getAxis2RepositoryPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newCarbonRepositorySynchronizer
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
* Create and initialize a new DeploymentSynchronizer for the Carbon repository of the
* specified tenant. This method first attempts to load the synchronizer configuration
* from the registry. If a configuration does not exist in the registry, it will get the
* configuration from the global ServerConfiguration of Carbon. Note that this method
* does not start the created synchronizers. It only creates and initializes them using
* the available configuration settings.
*
* @param tenantId ID of the tenant
* @return a DeploymentSynchronizer instance or null if the synchronizer is disabled
* @throws org.wso2.carbon.deployment.synchronizer.DeploymentSynchronizerException If an error occurs while initializing the synchronizer
*/
public static DeploymentSynchronizer newCarbonRepositorySynchronizer(int tenantId)
throws DeploymentSynchronizerException {
DeploymentSynchronizerConfiguration config = getActiveSynchronizerConfiguration(tenantId);
if (config.isEnabled()) {
String filePath = MultitenantUtils.getAxis2RepositoryPath(tenantId);
ArtifactRepository artifactRepository = createArtifactRepository(
config.getRepositoryType());
artifactRepository.init(tenantId);
DeploymentSynchronizer synchronizer = DeploymentSynchronizationManager.getInstance().
createSynchronizer(tenantId, artifactRepository, filePath);
synchronizer.setAutoCommit(config.isAutoCommit());
synchronizer.setAutoCheckout(config.isAutoCheckout());
synchronizer.setPeriod(config.getPeriod());
synchronizer.setUseEventing(config.isUseEventing());
if (log.isDebugEnabled()) {
log.debug("Registered file path:" + filePath + " for tenant: " + tenantId);
}
return synchronizer;
}
return null;
}
示例2: notifyUpdate
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
public void notifyUpdate(OMElement element) {
if (log.isDebugEnabled()) {
log.debug("Received new event: " + element);
}
OMElement timestampElement = element.getFirstChildWithName(TIMESTAMP);
if (timestampElement == null) {
log.warn("Timestamp element not available in the event");
return;
}
OMElement detailElement = element.getFirstChildWithName(DETAILS);
OMElement sessionElement = detailElement.getFirstChildWithName(SESSION);
OMElement tenantElement = sessionElement.getFirstChildWithName(TENANT);
if (tenantElement == null) {
log.warn("Tenant ID not available in the event");
return;
}
String timestamp = timestampElement.getText();
int tenantId = Integer.parseInt(tenantElement.getText());
DeploymentSynchronizationManager syncManager = DeploymentSynchronizationManager.getInstance();
// TODO: Implement an alternative way to get the file path
String filePath = MultitenantUtils.getAxis2RepositoryPath(tenantId);
DeploymentSynchronizer synchronizer = syncManager.getSynchronizer(filePath);
if (synchronizer == null || !synchronizer.isAutoCheckout()) {
log.warn("Unable to find the synchronizer for the file path: " + filePath);
return;
}
try {
Date date = DATE_FORMAT.parse(timestamp);
synchronizer.requestCheckout(date.getTime());
} catch (ParseException e) {
log.error("Error while parsing the registry event time stamp: " + timestamp, e);
}
}
示例3: deleteSynchronizer
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
public DeploymentSynchronizer deleteSynchronizer(int tenantId) {
String filePath = MultitenantUtils.getAxis2RepositoryPath(tenantId);
synchronized (filePath.intern()) {
return synchronizers.remove(filePath);
}
}
示例4: resolveChecksum
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
* Resolves the checksum inconsistency in svn client when commit and update.
*
* @param errorMessage Error message which is captured by the SVNNotifyListener logError
* method.
*/
public static void resolveChecksum(String errorMessage) {
if(errorMessage.contains("Base checksum mismatch")) {
int exIndex = errorMessage.indexOf("expected:");
int acIndex = errorMessage.indexOf("actual:");
int beginFile = errorMessage.indexOf("'", 0);
int endFile = errorMessage.indexOf("'", beginFile +1);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String axis2RepoPath = MultitenantUtils.getAxis2RepositoryPath(tenantId);
// Append file separator at the end if not present. Usually tenant mode its not present.
if((axis2RepoPath.length() -1) != axis2RepoPath.lastIndexOf(File.separator)) {
axis2RepoPath = axis2RepoPath.concat(File.separator);
}
/*
Expected and actual checksum values are interchanged in the exception trace
in svn client side.
*/
String expectedChecksum = errorMessage.substring(acIndex+7, errorMessage.length()-1);
String actualChecksum = errorMessage.substring(exIndex+9, acIndex);
String filePath = errorMessage.substring(beginFile+1, endFile);
String svnFile = SVN_FOLDER + File.separator + CHECKSUM_FILENAME;
String newSvnFile = SVN_FOLDER + File.separator + CHECKSUM_TEMP_FILENAME;
int fileNameStartIndex = filePath.lastIndexOf(File.separatorChar) + 1;
String svnPath = filePath.substring(0, fileNameStartIndex);
String fullSvnFilePath = axis2RepoPath + svnPath + svnFile;
String fulltmpFilePath = axis2RepoPath + svnPath + newSvnFile;
File errorFile = new File(fullSvnFilePath);
File tmpFile = new File(fulltmpFilePath);
log.debug("Trying to correct the checksum mismatch for SVN file:" +fullSvnFilePath+ "." +
"Expected:" +expectedChecksum.trim()+ " but it is:" +actualChecksum.trim());
try (Reader fis = new FileReader(errorFile);
BufferedReader bis = new BufferedReader(new InputStreamReader(new FileInputStream(errorFile)));
BufferedWriter bw = new BufferedWriter(new FileWriter(tmpFile));) {
String line;
while((line = bis.readLine()) != null){
String plainLine = line.trim();
if(plainLine.contains(actualChecksum.trim())) {
log.debug("Found checksum:"+actualChecksum.trim()+". Will be replaced " +
"with:"+expectedChecksum.trim());
bw.write(expectedChecksum.trim());
}else {
bw.write(line);
}
bw.newLine();
}
} catch(Exception e){
log.error(e.getMessage());
}
// Rename the tmp file and remove old file.
if(errorFile.delete()){
log.debug("SVN file:" +fullSvnFilePath+ " modifying.");
if(tmpFile.renameTo(errorFile)){
log.debug("SVN file:" +fullSvnFilePath+ " update successful.");
}else {
log.error("SVN file:" +fulltmpFilePath+ " update failed. Please check file permissions and allow for modification.");
}
}else {
log.error("SVN file:" +fullSvnFilePath+ " unable to modify. Please check file permissions and allow for modification.");
log.error("Unable to resolve checksum mismatch");
}
}
}
示例5: getCarbonRepositoryFilePath
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
* Returns the Carbon/Axis2 repository path for the given ConfigurationContext
*
* @param cfgCtx A ConfigurationContext instance owned by super tenant or some other tenant
* @return Axis2 repository path from which the configuration is read
*/
public static String getCarbonRepositoryFilePath(ConfigurationContext cfgCtx) {
int tenantId = MultitenantUtils.getTenantId(cfgCtx);
return MultitenantUtils.getAxis2RepositoryPath(tenantId);
}