Java Code Examples for org.alfresco.service.cmr.repository.StoreRef#getProtocol()

The following examples show how to use org.alfresco.service.cmr.repository.StoreRef#getProtocol() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiTAdminServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void bootstrapSystemTenantStore(ImporterBootstrap systemImporterBootstrap, String tenantDomain)
{
    // Bootstrap Tenant-Specific System Store
    StoreRef bootstrapStoreRef = systemImporterBootstrap.getStoreRef();
    StoreRef tenantBootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
    systemImporterBootstrap.setStoreUrl(tenantBootstrapStoreRef.toString());
    
    // override default property (workspace://SpacesStore)
    List<String> mustNotExistStoreUrls = new ArrayList<String>();
    mustNotExistStoreUrls.add(new StoreRef(PROTOCOL_STORE_WORKSPACE, tenantService.getName(STORE_BASE_ID_USER, tenantDomain)).toString());
    systemImporterBootstrap.setMustNotExistStoreUrls(mustNotExistStoreUrls);
    
    systemImporterBootstrap.bootstrap();
    
    // reset since systemImporter is singleton (hence reused)
    systemImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
    
    if (logger.isDebugEnabled())
    {
        logger.debug("Bootstrapped store: "+tenantService.getBaseName(tenantBootstrapStoreRef)+" (Tenant: "+tenantDomain+")");
    }
}
 
Example 2
Source File: MultiTServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public StoreRef getName(String username, StoreRef storeRef)
{
    if (storeRef == null)
    {
        return null;
    }

    if ((username != null) && (AuthenticationUtil.isMtEnabled()))
    {
        int idx = username.lastIndexOf(SEPARATOR);
        if ((idx > 0) && (idx < (username.length() - 1)))
        {
            String tenantDomain = username.substring(idx + 1);
            return new StoreRef(storeRef.getProtocol(), getName(storeRef.getIdentifier(), tenantDomain));
        }
    }

    return storeRef;
}
 
Example 3
Source File: StreamContent.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
ObjectReference(StoreRef ref, String id)
{
    String[] relativePath = id.split("/");

    // bug fix MNT-16380
    // for using a relative path to a node id eg. 18cc-.../folder1/.../folderN/fileA.txt
    // if only one slash we don't have a relative path
    if (relativePath.length <= 2)
    {
        if (id.indexOf('/') != -1)
        {
            id = id.substring(0, id.indexOf('/'));
        }
        this.ref = new NodeRef(ref, id);
    }
    else
    {
        String[] reference = new String[relativePath.length + 2];
        reference[0] = ref.getProtocol();
        reference[1] = ref.getIdentifier();
        System.arraycopy(relativePath, 0, reference, 2, relativePath.length);
        this.ref = repository.findNodeRef("node", reference);
    }
}
 
Example 4
Source File: NodesGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean handleNode(Node node)
{
    if (storeRef != null)
    {
        // MT - since storeRef is not null, filter by store here
        StoreRef tenantStoreRef = node.getStore().getStoreRef();
        StoreRef baseStoreRef = new StoreRef(tenantStoreRef.getProtocol(), tenantService.getBaseName(tenantStoreRef.getIdentifier(), true));
        if (storeRef.equals(baseStoreRef))
        {
            nodes.add(new NodeRecord(node, qnameDAO, tenantService));
        }
    }
    else
    {
        nodes.add(new NodeRecord(node, qnameDAO, tenantService));
    }
    
    // continue - get next node
    return true;
}
 
Example 5
Source File: RepositoryLocation.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param storeRef       the store reference (e.g. 'workspace://SpacesStore' )
 * @param path           the path (e.g. '/app:company_home/app:dictionary/app:models' )
 * @param queryLanguage  the query language (e.g. 'xpath' or 'lucence')
 */
public RepositoryLocation(StoreRef storeRef, String path, String queryLanguage)
{
    this.storeProtocol = storeRef.getProtocol();
    this.storeId = storeRef.getIdentifier();
    this.path = path;
    
    setQueryLanguage(queryLanguage);
}
 
Example 6
Source File: PlainStringifier.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String stringifyRepositoryLocation(RepositoryNodeRef repositoryNodeRef) throws ReferenceEncodingException
{
    NodeRef nodeRef = repositoryNodeRef.getNodeRef();
    StoreRef storeRef = nodeRef.getStoreRef();

    return NODE + DELIMITER + storeRef.getProtocol() + DELIMITER + storeRef.getIdentifier() + DELIMITER
                + nodeRef.getId();
}
 
Example 7
Source File: NodeProtocol.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Reference propagateNodeRefMutations(NodeRef mutatedNodeRef, Reference reference)
{
    StoreRef storeRef = mutatedNodeRef.getStoreRef();
    String storeId = storeRef.getIdentifier();
    String protocol = storeRef.getProtocol();

    if (Version2Model.STORE_ID.equals(storeId) || VersionModel.STORE_ID.equals(storeId)
                || VersionBaseModel.STORE_PROTOCOL.equals(protocol))
    {
        Resource resource = reference.getResource();
        if (resource instanceof RepositoryResource)
        {
            RepositoryResource repositoryResource = (RepositoryResource) resource;
            RepositoryLocation location = repositoryResource.getLocation();
            if (location instanceof RepositoryNodeRef)
            {
                RepositoryNodeRef repositoryNodeRef = (RepositoryNodeRef) location;
                NodeRef nodeRef = repositoryNodeRef.getNodeRef();
                NodeRef nodeRefPropagation = new NodeRef(mutatedNodeRef.getStoreRef(),
                                                         nodeRef.getId());
                Resource resourcePropagation = new RepositoryResource(new RepositoryNodeRef(nodeRefPropagation));

                return new Reference(reference.getEncoding(),
                                     reference.getProtocol(),
                                     resourcePropagation,
                                     reference.getParameters());
            }
        }
    }

    // default branch

    return reference;
}
 
Example 8
Source File: MultiTAdminServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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+")");
    }
}
 
Example 9
Source File: MultiTServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public StoreRef getName(StoreRef storeRef)
{
    if (storeRef == null)
    {
        return null;
    }

    return new StoreRef(storeRef.getProtocol(), getName(storeRef.getIdentifier()));
}
 
Example 10
Source File: MultiTServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public StoreRef getBaseName(StoreRef storeRef)
{
    if (storeRef == null)
    {
        return null;
    }

    return new StoreRef(storeRef.getProtocol(), getBaseName(storeRef.getIdentifier()));
}
 
Example 11
Source File: StreamContent.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
ObjectReference(StoreRef ref, String[] path)
{
    String[] reference = new String[path.length + 2];
    reference[0] = ref.getProtocol();
    reference[1] = ref.getIdentifier();
    System.arraycopy(path, 0, reference, 2, path.length);
    this.ref = repository.findNodeRef("path", reference);
}
 
Example 12
Source File: MultiTenantShareMapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Create a tenant domain specific share
 */
private final DiskSharedDevice createTenantShare(String tenantDomain)
{
    logger.debug("create tenant share for domain " + tenantDomain);
       StoreRef storeRef = new StoreRef(getStoreName());
       NodeRef rootNodeRef = new NodeRef(storeRef.getProtocol(), storeRef.getIdentifier(), "dummy"); 
       
       // Root nodeRef is required for storeRef part
       
       rootNodeRef = m_alfrescoConfig.getTenantService().getRootNode(
               m_alfrescoConfig.getNodeService(), 
               m_alfrescoConfig.getSearchService(),
       		m_alfrescoConfig.getNamespaceService(), 
       		getRootPath(), 
       		rootNodeRef);

       //  Create the disk driver and context

       DiskInterface diskDrv = getRepoDiskInterface();
       ContentContext diskCtx = new ContentContext(m_tenantShareName, getStoreName(), getRootPath(), rootNodeRef);
       
       // Set a quota manager for the share, if enabled
       
       if ( m_quotaManager != null)
       {
       	diskCtx.setQuotaManager( m_quotaManager);
       }
       
       if(m_config instanceof ServerConfigurationBean)
       {
           ServerConfigurationBean config = (ServerConfigurationBean)m_config;
           
           config.initialiseRuntimeContext("cifs.tenant." + tenantDomain, diskCtx);
       }
       else
       {
           throw new AlfrescoRuntimeException("configuration error, unknown configuration bean");
       }
       
       //  Default the filesystem to look like an 80Gb sized disk with 90% free space

       diskCtx.setDiskInformation(new SrvDiskInfo(2560, 64, 512, 2304));

       //  Create a temporary shared device for the user to access the tenant company home directory

       return new DiskSharedDevice(m_tenantShareName, diskDrv, diskCtx);
}