if(Validator.isNotNull(uuid) && Validator.isNotNull(nameFile))
{
String version = request.getParameter("version");
HttpMethod method = null;
PostMethod post = null;
String urlVersion;
if(Validator.isNotNull(version)){
urlVersion = AlfrescoUtil.getUrlAccesoVersionDocumento();
}else{
urlVersion = AlfrescoUtil.getUrlAccesoDocumento();
}
String name7 = nameFile;
String name8 = "";
String encoding = "ISO-8859-1";
name8 = URLEncoder.encode(name7, encoding);
urlVersion = urlVersion + uuid + "/" + name8;
urlVersion = urlVersion.replaceAll(" ", "_x0020_");
try {
//_log.error("inicio - webDav");
HttpClient client = new HttpClient();
method = new GetMethod(urlVersion);
client.executeMethod(method);
// Se comprueba si se ha devuelto el formulario de login
boolean esFormularioLogin = false;
Header header = method.getResponseHeader("Content-Type");
if (header.getValue().indexOf("text/html") != -1) {
InputStream is = method.getResponseBodyAsStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String linea = br.readLine();
while (linea != null) {
if (linea.indexOf("action=\""+AlfrescoUtil.getUrlAccesoLoginAlfrescoDescargaDocumentos()+"\"")!=-1) {
esFormularioLogin = true;
break;
}
linea = br.readLine();
}
}
//_log.error("fin - webDav");
// Se env�a la autenticaci�n y se vuelve a intentar descargar
if (esFormularioLogin) {
//_log.error("inicio - primera vez que abro fichero");
// Se env�a el login
method.releaseConnection();
post = new PostMethod(AlfrescoUtil.getUrlAccesoLoginAlfresco());
//Se obtiene usuario y contrase�a.
/*
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
String usuario = themeDisplay.getUserId();
UserIdMapper usuarioPwd = UserIdMapperLocalServiceUtil.getUserIdMapper(themeDisplay.getUser().getUserId(), "password");
String passwordUsuario = Encryptor.decrypt(themeDisplay.getCompany().getKeyObj(), usuarioPwd.getExternalUserId());
*/
NameValuePair name = new NameValuePair("loginForm:user-name", AlfrescoUtil.getAdministradorUser());
NameValuePair password = new NameValuePair("loginForm:user-password", AlfrescoUtil.getAdministradorPassword());
NameValuePair language = new NameValuePair("loginForm:language", "es_ES");
NameValuePair boton = new NameValuePair("loginForm:submit", "Entrar");
NameValuePair SUBMIT = new NameValuePair("loginForm_SUBMIT", "1");
NameValuePair link = new NameValuePair("loginForm:_link_hidden_", "");
post.setRequestBody(
new NameValuePair[] {name, password, language, boton,
SUBMIT, link});
client.executeMethod(post);
post.releaseConnection();
// Se vuelve a intentar
method = new GetMethod(urlVersion);
client.executeMethod(method);
//_log.error("fin - primera vez que abro fichero");
}
//_log.error("inicio - sendFile");
ServletResponseUtil.sendFile(response, name7, method.getResponseBodyAsStream(), mimeType);
//_log.error("fin - sendFile - inicio - release");
method.releaseConnection();
//_log.error("fin - release");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
} finally {
// Release the connection.
if (method != null)
method.releaseConnection();
}
}
<input id="loginForm:user-name" name="loginForm:user-name" type="text" value="admin" onkeyup="updateButtonState();" style="width:150px" onchange="updateButtonState();" />
</td>
</tr>
<tr><td>Contraseña:</td>
<td>
<input type="password" id="loginForm:user-password" name="loginForm:user-password" style="width:150px" />
</td>
</tr>
<tr>
<td>
Idioma:
</td>
<td>
<select id="loginForm:language" name="loginForm:language" size="1" style="width:150px" onchange="document.forms['loginForm'].submit(); return true;"> <option value="en_US" selected="selected">English</option> <option value="de_DE">German</option> <option value="es_ES">Spanish</option> <option value="fr_FR">French</option> <option value="it_IT">Italian</option> <option value="ja_JP">Japanese</option></select>
</td>
</tr>
<tr>
<td colspan=2 align=right>
<input id="loginForm:submit" name="loginForm:submit" type="submit" value="Iniciar sesión" onclick="if(typeof window.clearFormHiddenParams_loginForm!='undefined'){clearFormHiddenParams_loginForm('loginForm');}" />
</td>
</tr>
NameValuePair name = new NameValuePair("loginForm:user-name", AlfrescoUtil.getAdministradorUser());
NameValuePair password = new NameValuePair("loginForm:user-password", AlfrescoUtil.getAdministradorPassword());
NameValuePair language = new NameValuePair("loginForm:language", "en_US");
NameValuePair boton = new NameValuePair("loginForm:submit","Iniciar Sesión");
NameValuePair SUBMIT = new NameValuePair("loginForm_SUBMIT", "1");
NameValuePair link = new NameValuePair("loginForm:_link_hidden_", "");
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.