daniel_philippi
Occasional Collector

Content Transport: Install an existing server available feature

Jump to solution

Hi all.

I tried a few things that could be found in some community entries and documentations but nothing helped me.

I want to install an existing feature that is available on the FS server like I can do it in a schedule entry.

I found the featureInstallAgent but here I need to have a featureFile. But I do not want to create a new one but to use an existing one.

Please help 🙂

Greetings,
Daniel

 

This is what I have so far:

import de.espirit.firstspirit.feature.*;
import de.espirit.firstspirit.agency.*;

SpecialistsBroker broker = connection.getBroker();

BrokerAgent brokerAgent = broker.requireSpecialist(BrokerAgent.TYPE);

broker = brokerAgent.getBrokerByProjectName(context.project.getName());

FeatureInstallAgent featureAgent = broker.requireSpecialist(FeatureInstallAgent.TYPE);

context.logInfo("Project " + context.project.getName());

0 Kudos
2 Solutions

Accepted Solutions
hoebbel
Crownpeak employee

Hello Daniel,

maybe this example code will help you ("/path/to/feature/feature.zip" has to be an existing feature)

import de.espirit.firstspirit.io.FileSystemsAgent;  
import de.espirit.firstspirit.feature.FeatureInstallAgent;
import de.espirit.firstspirit.transport.LayerMapper;

fileSystemsAgent = context.requireSpecialist(FileSystemsAgent.TYPE);  
featureFile = new File("/path/to/feature/feature.zip");
  
fileInput = new FileInputStream(featureFile);
featureInstallagent = context.requireSpecialist(FeatureInstallAgent.TYPE);  
featureFile = featureInstallagent.uploadFeatureFile(fileInput);
layerMapper = de.espirit.firstspirit.transport.LayerMapper.CREATE_NEW_DEFAULT_LAYER_MAPPER;
sah = featureInstallagent.installFeature(featureFile, layerMapper);
result = sah.getResult();
context.logInfo("Feature installed. Updated elements: " + result.getUpdatedElements());

 

Best regards
Holger

View solution in original post

0 Kudos
daniel_philippi
Occasional Collector

I figured out a workaround.

As the features are stored in the filesystem of the firstspirit server (we mounted another filesystem to that folder so we can access it with multiple FS servers (d, q and p)) the only option I need to put into the script Holger mentioned is the path to the features folder.

To get the latest feature zip file I had to search for it inside the folder and then I was able to install it with the script. Not as I expected it, but it is solving my problem perfectly!
Now I can offer now various action templates that install different feature ZIPs into various projects and I can control the feature to be installed in one place inside the server manager! Perfect!

View solution in original post

0 Kudos
5 Replies
hoebbel
Crownpeak employee

Hello Daniel,

maybe this example code will help you ("/path/to/feature/feature.zip" has to be an existing feature)

import de.espirit.firstspirit.io.FileSystemsAgent;  
import de.espirit.firstspirit.feature.FeatureInstallAgent;
import de.espirit.firstspirit.transport.LayerMapper;

fileSystemsAgent = context.requireSpecialist(FileSystemsAgent.TYPE);  
featureFile = new File("/path/to/feature/feature.zip");
  
fileInput = new FileInputStream(featureFile);
featureInstallagent = context.requireSpecialist(FeatureInstallAgent.TYPE);  
featureFile = featureInstallagent.uploadFeatureFile(fileInput);
layerMapper = de.espirit.firstspirit.transport.LayerMapper.CREATE_NEW_DEFAULT_LAYER_MAPPER;
sah = featureInstallagent.installFeature(featureFile, layerMapper);
result = sah.getResult();
context.logInfo("Feature installed. Updated elements: " + result.getUpdatedElements());

 

Best regards
Holger

0 Kudos
daniel_philippi
Occasional Collector

No

I would like to use an existing feature zip that is available in the server storage.

I know the name and I would like to have access like it is possible with FeatureAgent.getFeatureFiles().

I want to do the same as I can do in a schedule task: content transport --> storage

0 Kudos
hoebbel
Crownpeak employee

As the feature storages are not part of the API as far as I know, this is unfortunately not possible.
If this access is desired, please create a corresponding idea.

0 Kudos
daniel_philippi
Occasional Collector

Too bad. That would have beed just nice to have and would make my life a bit easier. But ok, I will go another way.

Thanks!

0 Kudos
daniel_philippi
Occasional Collector

I figured out a workaround.

As the features are stored in the filesystem of the firstspirit server (we mounted another filesystem to that folder so we can access it with multiple FS servers (d, q and p)) the only option I need to put into the script Holger mentioned is the path to the features folder.

To get the latest feature zip file I had to search for it inside the folder and then I was able to install it with the script. Not as I expected it, but it is solving my problem perfectly!
Now I can offer now various action templates that install different feature ZIPs into various projects and I can control the feature to be installed in one place inside the server manager! Perfect!

0 Kudos