use of org.alfresco.repo.usage.UserUsageTrackingComponent in project alfresco-repository by Alfresco.
the class FTPServerTest method testFtpQuotaAndFtp.
/**
* Test a quota failue exception over FTP.
* A file should not exist after a create and quota exception.
*/
public void testFtpQuotaAndFtp() throws Exception {
// Enable usages
ContentUsageImpl contentUsage = (ContentUsageImpl) applicationContext.getBean("contentUsageImpl");
contentUsage.setEnabled(true);
contentUsage.init();
UserUsageTrackingComponent userUsageTrackingComponent = (UserUsageTrackingComponent) applicationContext.getBean("userUsageTrackingComponent");
userUsageTrackingComponent.setEnabled(true);
userUsageTrackingComponent.bootstrapInternal();
final String TEST_DIR = "/Alfresco/User Homes/" + USER_THREE;
FTPClient ftpOne = connectClient();
try {
int reply = ftpOne.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
fail("FTP server refused connection.");
}
boolean login = ftpOne.login(USER_THREE, PASSWORD_THREE);
assertTrue("user three login not successful", login);
boolean success = ftpOne.changeWorkingDirectory("Alfresco");
assertTrue("user three unable to cd to Alfreco", success);
success = ftpOne.changeWorkingDirectory("User*Homes");
assertTrue("user one unable to cd to User*Homes", success);
success = ftpOne.changeWorkingDirectory(USER_THREE);
assertTrue("user one unable to cd to " + USER_THREE, success);
/**
* Create a file as user three which is bigger than the quota
*/
String FILE3_CONTENT_3 = "test file 3 content that needs to be greater than 100 bytes to result in a quota exception being thrown";
String FILE1_NAME = "test.docx";
// Should not be success
success = ftpOne.appendFile(FILE1_NAME, new ByteArrayInputStream(FILE3_CONTENT_3.getBytes("UTF-8")));
assertFalse("user one can ignore quota", success);
boolean deleted = ftpOne.deleteFile(FILE1_NAME);
assertFalse("quota exception expected", deleted);
logger.debug("test done");
} finally {
// Disable usages
contentUsage.setEnabled(false);
contentUsage.init();
userUsageTrackingComponent.setEnabled(false);
userUsageTrackingComponent.bootstrapInternal();
ftpOne.dele(TEST_DIR);
if (ftpOne != null) {
ftpOne.disconnect();
}
}
}
use of org.alfresco.repo.usage.UserUsageTrackingComponent in project alfresco-repository by Alfresco.
the class MultiTAdminServiceImpl method bootstrapSpacesTenantStore.
private void bootstrapSpacesTenantStore(ImporterBootstrap spacesImporterBootstrap, String tenantDomain) {
// Bootstrap Tenant-Specific Spaces Store
StoreRef bootstrapStoreRef = spacesImporterBootstrap.getStoreRef();
StoreRef tenantBootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
spacesImporterBootstrap.setStoreUrl(tenantBootstrapStoreRef.toString());
// override admin username property
Properties props = spacesImporterBootstrap.getConfiguration();
props.put("alfresco_user_store.adminusername", getTenantAdminUser(tenantDomain));
// override guest username property
props.put("alfresco_user_store.guestusername", getTenantGuestUser(tenantDomain));
spacesImporterBootstrap.bootstrap();
// reset since spacesImporterBootstrap is singleton (hence reused)
spacesImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
// calculate any missing usages
UserUsageTrackingComponent userUsageTrackingComponent = (UserUsageTrackingComponent) ctx.getBean("userUsageTrackingComponent");
userUsageTrackingComponent.bootstrapInternal();
if (logger.isDebugEnabled()) {
logger.debug("Bootstrapped store: " + tenantService.getBaseName(tenantBootstrapStoreRef) + " (Tenant: " + tenantDomain + ")");
}
}
Aggregations