本文整理汇总了Java中de.espirit.firstspirit.access.project.Project类的典型用法代码示例。如果您正苦于以下问题:Java Project类的具体用法?Java Project怎么用?Java Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Project类属于de.espirit.firstspirit.access.project包,在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activateProjectIfNecessary
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static void activateProjectIfNecessary(ProjectImportParameters projectImportParameters, Project fsProject) {
boolean projectIsActive = fsProject.isActive();
if (projectImportParameters.isFsForceProjectActivation()) {
if (!projectIsActive) {
LOGGER.warn("Project '" + projectImportParameters.getProjectName() + "' is not active! Try to activate...");
UserService userService = fsProject.getUserService();
AdminService adminService = userService.getConnection().getService(AdminService.class);
adminService.getProjectStorage().activateProject(fsProject);
}
if(!fsProject.isActive()) {
throw new ExecutionException("Project with name '"
+ projectImportParameters.getProjectName()
+ "' seems to be deactivated! To force activation, configure fsForceProjectActivation with true!");
}
}
}
示例2: performDeletion
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@SuppressWarnings("squid:S2221")
private static boolean performDeletion(Project project, ProjectStorage projectStorage) {
try {
LOGGER.debug("Deactivate project.");
projectStorage.deactivateProject(project);
LOGGER.debug("Project was locked and deactivated.");
LOGGER.debug("Remove Project.");
projectStorage.refreshProjects();
projectStorage.removeProject(project);
projectStorage.refreshProjects();
} catch (Exception e) {
LOGGER.error("Cannot delete project!", e);
return false;
}
LOGGER.info("Successfully deleted project from server!");
return true;
}
示例3: testProjectExistsOnServerReturnsTrueIfProjectExists
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
* Test that projectExistsOnServer is true if a project exists.
*/
@Test
public void testProjectExistsOnServerReturnsTrueIfProjectExists() {
// Arrange
final Project mockProject = mock(Project.class);
final ServerConnection mockConnection = mock(ServerConnection.class);
when(mockConnection.isConnected()).thenReturn(true);
when(mockConnection.getProjectByName(anyString())).thenReturn(mockProject);
final ProjectExportParameters mockProjectExportParameters = mock(ProjectExportParameters.class);
when(mockProjectExportParameters.getProjectName()).thenReturn("anyString");
// Act
final boolean projectExists = testling.projectExistsOnServer(mockConnection, mockProjectExportParameters);
// Assert
assertThat("Expected equal.", projectExists, equalTo(true));
}
示例4: testPerformExportProjectIsNotActiveAndActivationWasNotForced
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
* Test that export fails if the project is not active and will not be forced to be active.
*/
@Test
public void testPerformExportProjectIsNotActiveAndActivationWasNotForced() {
// Arrange
final Project mockProject = mock(Project.class);
when(mockProject.isActive()).thenReturn(false);
final ProjectExportParameters mockProjectExportParameters = mock(ProjectExportParameters.class);
when(mockProjectExportParameters.isFsForceProjectActivation()).thenReturn(false);
final ServerConnection mockConnection = mock(ServerConnection.class);
when(mockConnection.getProjectByName(mockProjectExportParameters.getProjectName())).thenReturn(mockProject);
// Act
final boolean exported = testling.performExport(mockConnection, mockProjectExportParameters);
// Assert
assertThat("Expect equals", exported, is(false));
}
示例5: testPerformExportProjectWhenActivationFails
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
* Test that export fails if the project could not be activated by the FirstSpirit server.
*/
@Test
public void testPerformExportProjectWhenActivationFails() {
// Arrange
final Project mockProject = mock(Project.class);
when(mockProject.isActive()).thenReturn(false);
final ProjectExportParameters mockProjectExportParameters = mock(ProjectExportParameters.class);
when(mockProjectExportParameters.isFsForceProjectActivation()).thenReturn(true);
final ServerConnection mockConnection = mock(ServerConnection.class);
when(mockConnection.getProjectByName(mockProjectExportParameters.getProjectName())).thenReturn(mockProject);
final ProjectExporter spyProjectExporter = spy(testling);
doReturn(false).when(spyProjectExporter).activateProjectByForce(mockConnection, mockProject);
// Act
final boolean exported = spyProjectExporter.performExport(mockConnection, mockProjectExportParameters);
// Assert
assertThat("Expect equals", exported, is(false));
}
示例6: testActivateProjectByForceCallsAdminService
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
* Test that the AdminService tries to activate the project.
*/
@Test
public void testActivateProjectByForceCallsAdminService() {
// Arrange
final Project mockProject = mock(Project.class);
final ProjectStorage mockProjectStorage = mock(ProjectStorage.class);
final AdminService mockAdminService = mock(AdminService.class);
when(mockAdminService.getProjectStorage()).thenReturn(mockProjectStorage);
final ServerConnection mockConnection = mock(ServerConnection.class);
when(mockConnection.getService(AdminService.class)).thenReturn(mockAdminService);
// Act
testling.activateProjectByForce(mockConnection, mockProject);
// Assert
verify(mockProjectStorage).activateProject(mockProject);
}
示例7: installWebAppAndActivateWebServer
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean installWebAppAndActivateWebServer(final WebScope webScope, final long projectId,
final Connection connection, final WebAppId webAppId) {
final Project project = connection.getProjectById(projectId);
try {
ModuleAdminAgent moduleAdminAgent = connection.getBroker().requireSpecialist(ModuleAdminAgent.TYPE);
boolean successfullyDeployed = moduleAdminAgent.deployWebApp(webAppId);
if (!setActiveWebServerForProject(webScope, project) || !successfullyDeployed){
return false;
}
} catch (IllegalStateException ise) {
LOGGER.error("Cannot deploy war file!", ise);
return false;
}
return true;
}
示例8: requireProjectSpecificBroker
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private void requireProjectSpecificBroker() {
LOGGER.debug("Require project specific specialist broker for project '{}'...", clientConfig.getProject());
String name;
try {
final Project project = getProject();
name = project != null ? project.getName() : null;
} catch (Exception e) { //NOSONAR
throw new IllegalStateException(
"Project '" + clientConfig.getProject() + "' not found on server. Correct project name or omit --dont-create-project option.", e);
}
if (StringUtils.isNotBlank(name)) {
final SpecialistsBroker broker = connection.getBroker();
final BrokerAgent brokerAgent = broker.requireSpecialist(BrokerAgent.TYPE);
projectBroker = brokerAgent.getBrokerByProjectName(name);
}
if (projectBroker == null) {
throw new IllegalStateException("ProjectBroker cannot be retrieved for project " + name + ". Wrong project name?");
}
}
示例9: getProject
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@Override
public Project getProject() {
final String projectName = clientConfig.getProject();
if (StringUtils.isBlank(projectName)) {
return null;
}
Project project = connection.getProjectByName(projectName);
if (project == null && clientConfig.isCreatingProjectIfMissing()) {
project = createProject(projectName);
}
LOGGER.debug("activate project if deactivated: " + clientConfig.isActivateProjectIfDeactivated(), projectName);
if (clientConfig.isActivateProjectIfDeactivated()) {
activateProject(projectName, project);
}
LOGGER.info("project is '{}'", project);
return project;
}
示例10: execute
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@Override
public ContentCreatorAddressResult execute(ContentCreatorAddressParameters parameters) {
final Connection connection = parameters.getConnection();
final Project project = connection.getProjectByName(parameters.getProjectName());
final long projectId = project.getId();
final Locale locale = Optional.ofNullable(parameters.getLocale()).orElse(project.getMasterLanguage().getLocale());
final String language = locale.getLanguage();
final String contentCreatorUrl =
connection.getServerConfiguration().getUrl() + "fs5webedit_" + projectId + "/?locale=" + language + "&project=" + projectId;
return new ContentCreatorAddressResult(contentCreatorUrl);
}
示例11: performImport
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean performImport(Connection connection, ProjectImportParameters projectImportParameters) {
ProjectStorage projectStorage = connection.getService(AdminService.class).getProjectStorage();
try {
removeExportFileFromServerIfExists(projectImportParameters, projectStorage);
ExportFile exportFile;
try (FileInputStream fileInputStream = new FileInputStream(projectImportParameters.getProjectFile())) {
exportFile = projectStorage.uploadExportFile(projectImportParameters.getProjectFile().getName(), fileInputStream);
}
ProjectInfo info = projectStorage.getProjectInfo(exportFile);
HashMap<String, String> layerMapping = getLayerMappingDefinition(projectImportParameters, info);
ImportParameters importParameters = new ImportParameters(exportFile, info,
projectImportParameters.getProjectName(), projectImportParameters.getProjectDescription(), layerMapping,
new HashMap<>());
importParameters.getLayerMapping();
ServerActionHandle<ImportProgress, Boolean> importHandle = projectStorage.startImport(importParameters);
waitUntilImportFinished(importHandle);
refreshProjects(connection);
Project fsProject = connection.getProjectByName(projectImportParameters.getProjectName());
boolean projectIsPresent = fsProject != null;
if (projectIsPresent) {
activateProjectIfNecessary(projectImportParameters, fsProject);
}
return projectIsPresent;
} catch (ExecutionException | IOException e) {
LOGGER.error("Not able to perform import!", e);
return false;
}
}
示例12: projectExistsOnServer
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean projectExistsOnServer(Connection connection, ProjectImportParameters projectImportParameters) {
Project[] projects = connection.getProjects();
if (projects == null || projects.length < 1) {
LOGGER.debug("Could not find any projects on the server.");
return false;
}
for (Project project: connection.getProjects()) {
LOGGER.debug("Found project: "+project.getName());
if (project.getName().equals(projectImportParameters.getProjectName())) {
return true;
}
}
LOGGER.debug("Could not find project "+ projectImportParameters.getProjectName());
return false;
}
示例13: deleteProject
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
* This methods deletes a FirstSpirit project from a server
* @param connection to the FirstSpirit server
* @param projectName of the project you want to delete
* @return true if the project was deleted successfully, false otherwise.
* @throws ExecutionException If a project with the given name does not exist on the server or it does exists, but cannot be locked.
*/
public boolean deleteProject(Connection connection, String projectName) {
LOGGER.info("Start deleting project: '{}'", projectName);
if (connection == null) {
LOGGER.error("Connection is not set!");
throw new IllegalArgumentException("Connection is null.");
}
Project project = connection.getProjectByName(projectName);
if (project == null) {
LOGGER.error("Cannot find project!");
throw new ExecutionException(EXCEPTIONSTRING + projectName + " does not exist on server.");
}
LOGGER.debug("Lock project");
try {
project.lock();
LOGGER.debug("Project is locked.");
} catch (LockException e) {
LOGGER.error("Cannot lock project. ", e);
throw new ExecutionException(EXCEPTIONSTRING + projectName + " could not be locked.");
}
ProjectStorage projectStorage = returnProjectStorage(connection, project);
if (projectStorage == null) {
LOGGER.error("Cannot process deletion. Preparation failed.");
throw new ExecutionException(EXCEPTIONSTRING + "ProjectStorage is missing.");
}
return performDeletion(project, projectStorage);
}
示例14: returnProjectStorage
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@VisibleForTesting
ProjectStorage returnProjectStorage (Connection connection, Project project) {
if (connection == null || !canAccessProject(connection, project)) {
LOGGER.info("Cannot access project.");
return null;
}
ProjectStorage projectStorage = connection.getBroker().requireSpecialist(ServicesBroker.TYPE).getService(AdminService.class).getProjectStorage();
if (projectStorage == null) {
LOGGER.info("Cannot access project storage.");
}
return projectStorage;
}
示例15: canAccessProject
import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean canAccessProject(Connection connection, Project project) {
if (connection.getProjects().length < 1 || project == null) {
LOGGER.info("Cannot find project on server.");
return false;
}
return true;
}