use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class SearchEngineDAOFactory method getSearcher.
@Override
public ISearcherDAO getSearcher(String subDir) throws ApsSystemException {
ISearcherDAO searcherDao = null;
try {
Class searcherClass = Class.forName(this.getSearcherClassName());
searcherDao = (ISearcherDAO) searcherClass.newInstance();
searcherDao.init(this.getDirectory(subDir));
} catch (Throwable t) {
_logger.error("Error creating new searcher", t);
throw new ApsSystemException("Error creating new searcher", t);
}
return searcherDao;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class SearchEngineDAOFactory method getIndexer.
@Override
public IIndexerDAO getIndexer(String subDir) throws ApsSystemException {
IIndexerDAO indexerDao = null;
try {
Class indexerClass = Class.forName(this.getIndexerClassName());
indexerDao = (IIndexerDAO) indexerClass.newInstance();
indexerDao.setLangManager(this.getLangManager());
indexerDao.init(this.getDirectory(subDir));
} catch (Throwable t) {
_logger.error("Error getting indexer", t);
throw new ApsSystemException("Error creating new indexer", t);
}
return indexerDao;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class SearchEngineDAOFactory method getDirectory.
private File getDirectory(String subDirectory) throws ApsSystemException {
String dirName = this.getIndexDiskRootFolder();
if (!dirName.endsWith("/")) {
dirName += "/";
}
dirName += "cmscontents/" + subDirectory;
_logger.debug("Index Directory: {}", dirName);
File dir = new File(dirName);
if (!dir.exists() || !dir.isDirectory()) {
dir.mkdirs();
_logger.debug("Index Directory created");
}
if (!dir.canRead() || !dir.canWrite()) {
throw new ApsSystemException(dirName + " does not have r/w rights");
}
return dir;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class AuthEndpointServlet method validateClient.
private boolean validateClient(final OAuthAuthzRequest oauthRequest, HttpServletRequest request, HttpServletResponse response) throws OAuthProblemException {
final IOAuthConsumerManager consumerManager = (IOAuthConsumerManager) ApsWebApplicationUtils.getBean(SystemConstants.OAUTH_CONSUMER_MANAGER, request);
final String clientId = oauthRequest.getClientId();
try {
final ConsumerRecordVO clientDetail = consumerManager.getConsumerRecord(clientId);
if (clientDetail != null) {
if (!clientDetail.getKey().equals(oauthRequest.getClientId())) {
throw OAuthUtils.handleOAuthProblemException("Invalid clientId");
} else if (clientDetail.getExpirationDate().getTime() < System.currentTimeMillis()) {
throw OAuthUtils.handleOAuthProblemException("ClientId is expired");
} else if (!clientDetail.getCallbackUrl().equals(oauthRequest.getRedirectURI())) {
throw OAuthUtils.handleOAuthProblemException("Invalid redirectUri");
}
return true;
}
} catch (ApsSystemException e) {
logger.error("ApsSystemException {}", e.getMessage());
try {
response.sendError(500);
} catch (IOException e1) {
logger.error("IOException {}", e1);
}
return false;
}
return false;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiEntityTypeInterface method addEntityType.
public StringApiResponse addEntityType(JAXBEntityType jaxbEntityType) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
IEntityManager manager = this.getEntityManager();
String typeCode = jaxbEntityType.getTypeCode();
IApsEntity masterEntityType = manager.getEntityPrototype(typeCode);
if (null != masterEntityType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' already exists");
}
if (typeCode == null || typeCode.length() != 3) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Invalid type code - '" + typeCode + "'");
}
Map<String, AttributeInterface> attributes = manager.getEntityAttributePrototypes();
IApsEntity newEntityType = jaxbEntityType.buildEntityType(manager.getEntityClass(), attributes);
this.checkNewEntityType(jaxbEntityType, newEntityType, response);
((IEntityTypesConfigurer) manager).addEntityPrototype(newEntityType);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error extracting entity type", t);
// ApsSystemUtils.logThrowable(t, this, "getEntityType");
throw new ApsSystemException("Error extracting entity type", t);
}
return response;
}
Aggregations